From 67c606b86314ada34b7f266cb6314858e23a134d Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 10 Jun 2005 15:32:16 +0000 Subject: r7463: - move some more stuff into functions - try to kill all jobs return by jobs -p metze (This used to be commit e4f5e52a8454fc2e6d5536e2cc9eb918c6c0e174) --- source4/build/smb_build/makefile.pm | 2 +- source4/script/tests/selftest.sh | 29 +++++---- source4/script/tests/test_functions.sh | 113 +++++++++++++++++++++++++++++---- 3 files changed, 117 insertions(+), 27 deletions(-) diff --git a/source4/build/smb_build/makefile.pm b/source4/build/smb_build/makefile.pm index b14991a840..97f570114d 100644 --- a/source4/build/smb_build/makefile.pm +++ b/source4/build/smb_build/makefile.pm @@ -148,7 +148,7 @@ basics: idl proto_exists test: @DEFAULT_TEST_TARGET@ test-swrap: all - SOCKET_WRAPPER_DIR=`pwd`/prefix-test ./script/tests/selftest.sh `pwd`/prefix-test + ./script/tests/selftest.sh `pwd`/prefix-test SOCKET_WRAPPER test-noswrap: all ./script/tests/selftest.sh `pwd`/prefix-test diff --git a/source4/script/tests/selftest.sh b/source4/script/tests/selftest.sh index b3198e0f46..dd6bd31fa5 100755 --- a/source4/script/tests/selftest.sh +++ b/source4/script/tests/selftest.sh @@ -12,6 +12,7 @@ then fi PREFIX=$1 +export PREFIX TMPDIR=$PREFIX/tmp LIBDIR=$PREFIX/lib PIDDIR=$PREFIX/pid @@ -20,6 +21,18 @@ PRIVATEDIR=$PREFIX/private NCALRPCDIR=$PREFIX/ncalrpc LOCKDIR=$PREFIX/lockdir +SMBD_TEST_FIFO="$PREFIX/smbd_test.fifo" +export SMBD_TEST_FIFO +SMBD_TEST_LOG="$PREFIX/smbd_test.log" +export SMBD_TEST_LOG + +DO_SOCKET_WRAPPER=$2 +if [ x"$DO_SOCKET_WRAPPER" = x"SOCKET_WRAPPER" ];then + SOCKET_WRAPPER_DIR="$PREFIX/socket_wrapper_dir" + export SOCKET_WRAPPER_DIR + echo "SOCKET_WRAPPER_DIR=$SOCKET_WRAPPER_DIR" +fi + incdir=`dirname $0` . $incdir/test_functions.sh @@ -41,7 +54,7 @@ cat >$CONFFILE< $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 -- cgit