summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source4/build/smb_build/makefile.pm2
-rwxr-xr-xsource4/script/tests/selftest.sh29
-rw-r--r--source4/script/tests/test_functions.sh113
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<<EOF
path = $TMPDIR
read only = no
ntvfs handler = posix
- posix:sharedelay = 5000
+ posix:sharedelay = 100000
EOF
ADDARG="-s $CONFFILE"
@@ -49,20 +62,8 @@ if [ x"$RUN_FROM_BUILD_FARM" = x"yes" ];then
ADDARG="$ADDARG --option=\"torture:progress=no\""
fi
-SMBD_TEST_FIFO="$PREFIX/smbd_test.fifo"
-export SMBD_TEST_FIFO
-
-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 $? &
+smbd_check_or_start
-sleep 2
START=`date`
(
failed=0
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