Author: metze
Date: 2005-06-10 15:32:16 +0000 (Fri, 10 Jun 2005)
New Revision: 7463

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=7463

Log:
- move some more stuff into functions

- try to kill all jobs return by jobs -p

metze
Modified:
   branches/SAMBA_4_0/source/build/smb_build/makefile.pm
   branches/SAMBA_4_0/source/script/tests/selftest.sh
   branches/SAMBA_4_0/source/script/tests/test_functions.sh


Changeset:
Modified: branches/SAMBA_4_0/source/build/smb_build/makefile.pm
===================================================================
--- branches/SAMBA_4_0/source/build/smb_build/makefile.pm       2005-06-10 
13:42:01 UTC (rev 7462)
+++ branches/SAMBA_4_0/source/build/smb_build/makefile.pm       2005-06-10 
15:32:16 UTC (rev 7463)
@@ -148,7 +148,7 @@
 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

Modified: branches/SAMBA_4_0/source/script/tests/selftest.sh
===================================================================
--- branches/SAMBA_4_0/source/script/tests/selftest.sh  2005-06-10 13:42:01 UTC 
(rev 7462)
+++ branches/SAMBA_4_0/source/script/tests/selftest.sh  2005-06-10 15:32:16 UTC 
(rev 7463)
@@ -12,6 +12,7 @@
 fi
 
 PREFIX=$1
+export PREFIX
 TMPDIR=$PREFIX/tmp
 LIBDIR=$PREFIX/lib
 PIDDIR=$PREFIX/pid
@@ -20,6 +21,18 @@
 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 @@
        path = $TMPDIR
        read only = no
        ntvfs handler = posix
-       posix:sharedelay = 5000
+       posix:sharedelay = 100000
 EOF
 
 ADDARG="-s $CONFFILE"
@@ -49,20 +62,8 @@
        ADDARG="$ADDARG --option=\"torture:progress=no\""
 fi
 
-SMBD_TEST_FIFO="$PREFIX/smbd_test.fifo"
-export SMBD_TEST_FIFO
+smbd_check_or_start
 
-rm -f $SMBD_TEST_FIFO
-mkfifo $SMBD_TEST_FIFO
-
-($SRCDIR/bin/smbd -d1 -s $CONFFILE -M single -i < $SMBD_TEST_FIFO;
- ret=$?;
- rm -f $SMBD_TEST_FIFO;
- echo "smbd exists with status $ret";
- exit $ret;
-)||exit $? &
-
-sleep 2
 START=`date`
 (
  failed=0

Modified: branches/SAMBA_4_0/source/script/tests/test_functions.sh
===================================================================
--- branches/SAMBA_4_0/source/script/tests/test_functions.sh    2005-06-10 
13:42:01 UTC (rev 7462)
+++ branches/SAMBA_4_0/source/script/tests/test_functions.sh    2005-06-10 
15:32:16 UTC (rev 7463)
@@ -1,16 +1,67 @@
-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 "--==--==--==--==--==--==--==--==--==--==--"
                echo "Running test $name (level 0 stdout)"
@@ -20,11 +71,29 @@
        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 @@
                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 @@
 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 @@
 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

Reply via email to