diff options
author | Stefan Metzmacher <metze@samba.org> | 2005-06-10 15:32:16 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:17:55 -0500 |
commit | 67c606b86314ada34b7f266cb6314858e23a134d (patch) | |
tree | 2650d7923b9037dde05d46d21da5f2eefc020a77 /source4/script/tests/test_functions.sh | |
parent | 46b829513a47dbb74fb0ea07ed85494da1480919 (diff) | |
download | samba-67c606b86314ada34b7f266cb6314858e23a134d.tar.gz samba-67c606b86314ada34b7f266cb6314858e23a134d.tar.bz2 samba-67c606b86314ada34b7f266cb6314858e23a134d.zip |
r7463: - move some more stuff into functions
- try to kill all jobs return by jobs -p
metze
(This used to be commit e4f5e52a8454fc2e6d5536e2cc9eb918c6c0e174)
Diffstat (limited to 'source4/script/tests/test_functions.sh')
-rw-r--r-- | source4/script/tests/test_functions.sh | 113 |
1 files changed, 101 insertions, 12 deletions
diff --git a/source4/script/tests/test_functions.sh b/source4/script/tests/test_functions.sh index e493a74ec6..467670435f 100644 --- a/source4/script/tests/test_functions.sh +++ b/source4/script/tests/test_functions.sh @@ -1,15 +1,66 @@ -testit() { - name=$1 - shift 1 - trap "rm -f test.$$" EXIT - cmdline="$*" +smbd_check_or_start() { + if [ -n "$SMBD_TEST_FIFO" ];then + if [ -p "$SMBD_TEST_FIFO" ];then + return 0; + fi + + if [ -n "$SOCKET_WRAPPER_DIR" ];then + if [ -d "$SOCKET_WRAPPER_DIR" ]; then + rm -f $SOCKET_WRAPPER_DIR/* + else + mkdir -p $SOCKET_WRAPPER_DIR + fi + fi + + rm -f $SMBD_TEST_FIFO + mkfifo $SMBD_TEST_FIFO + rm -f $SMBD_TEST_LOG + + echo -n "STARTING SMBD..." + (( + $SRCDIR/bin/smbd -d1 -s $CONFFILE -M single -i < $SMBD_TEST_FIFO > $SMBD_TEST_LOG 2>&1; + ret=$?; + rm -f $SMBD_TEST_FIFO; + if [ -n "$SOCKET_WRAPPER_DIR" -a -d "$SOCKET_WRAPPER_DIR" ]; then + rm -f $SOCKET_WRAPPER_DIR/* + fi + echo "smbd exists with status $ret"; + echo "smbd exists with status $ret" >>$SMBD_TEST_LOG; + exit $ret; + ) || exit $? &) 2>/dev/null || exit $? + sleep 2 + echo "DONE" + fi + return 0; +} + +smbd_check_only() { if [ -n "$SMBD_TEST_FIFO" ];then - if [ ! -p "$SMBD_TEST_FIFO" ];then - echo "TEST SKIPPED: $name (reason: smbd is down)"; + if [ -p "$SMBD_TEST_FIFO" ];then + return 0; + fi + return 1; + fi + return 0; +} + +smbd_have_test_log() { + if [ -n "$SMBD_TEST_LOG" ];then + if [ -r "$SMBD_TEST_LOG" ];then return 0; fi fi + return 1; +} + +testit() { + name=$1 + shift 1 + SMBD_IS_UP="no" + TEST_LOG="$PREFIX/test_log.$$" + trap "rm -f $TEST_LOG" EXIT + cmdline="$*" if [ x"$RUN_FROM_BUILD_FARM" = x"yes" ];then echo "--==--==--==--==--==--==--==--==--==--==--" @@ -20,11 +71,29 @@ testit() { else echo "Testing $name" fi - ( $cmdline > test.$$ 2>&1 ) + + smbd_check_only && SMBD_IS_UP="yes" + if [ x"$SMBD_IS_UP" = x"no" ];then + if [ x"$RUN_FROM_BUILD_FARM" = x"yes" ];then + echo "==========================================" + echo "TEST SKIPPED: $name (reason SMBD is down)" + echo "==========================================" + else + echo "TEST SKIPPED: $name (reason SMBD is down)" + fi + return 1 + fi + + smbd_have_test_log && echo "" >$SMBD_TEST_LOG + + ( $cmdline > $TEST_LOG 2>&1 ) status=$? if [ x"$status" != x"0" ]; then - cat test.$$; - rm -f test.$$; + echo "TEST OUTPUT:" + cat $TEST_LOG; + smbd_have_test_log && echo "SMBD OUTPUT:"; + smbd_have_test_log && cat $SMBD_TEST_LOG; + rm -f $TEST_LOG; if [ x"$RUN_FROM_BUILD_FARM" = x"yes" ];then echo "==========================================" echo "TEST FAILED: $name (status $status)" @@ -34,7 +103,7 @@ testit() { fi return 1; fi - rm -f test.$$; + rm -f $TEST_LOG; if [ x"$RUN_FROM_BUILD_FARM" = x"yes" ];then echo "ALL OK: $cmdline" echo "==========================================" @@ -47,10 +116,20 @@ testit() { testok() { name=`basename $1` failed=$2 + + JOBS=`jobs -p` + for J in $JOBS;do + kill $J >/dev/null 2>&1; + done + JOBS=`jobs -p` + for J in $JOBS;do + kill -s 9 $J >/dev/null 2>&1; + done + if [ x"$failed" = x"0" ];then : else - echo "$failed TESTS FAILED ($name)"; + echo "$failed TESTS FAILED or SKIPPED ($name)"; fi exit $failed } @@ -58,6 +137,16 @@ testok() { teststatus() { name=`basename $1` failed=$2 + + JOBS=`jobs -p` + for J in $JOBS;do + kill $J >/dev/null 2>&1; + done + JOBS=`jobs -p` + for J in $JOBS;do + kill -s 9 $J >/dev/null 2>&1; + done + if [ x"$failed" = x"0" ];then echo "TEST STATUS: $failed"; else |