summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2006-03-21 22:16:44 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:15:40 -0500
commited9ad1827bcead21483ce59464b5e3da7a509d29 (patch)
tree280fdd17338e6988e4f3016e8651251449d7a810
parent4ba096740ff8773d7108ca24c6af9a47d085fa00 (diff)
downloadsamba-ed9ad1827bcead21483ce59464b5e3da7a509d29.tar.gz
samba-ed9ad1827bcead21483ce59464b5e3da7a509d29.tar.bz2
samba-ed9ad1827bcead21483ce59464b5e3da7a509d29.zip
r14632: add basic 'make test' using samba4's smbtorture
I'll try to add some tests using samba3's smbtorture and smbclient later. can someone check if this would be save to run on the build-farm without leaking child processes... metze (This used to be commit 899fd6808ebd04d039caf7199c60d34a4987b43a)
-rw-r--r--source3/Makefile.in6
-rw-r--r--source3/script/tests/functions82
-rw-r--r--source3/script/tests/runtests.sh129
-rwxr-xr-xsource3/script/tests/selftest.sh194
-rw-r--r--source3/script/tests/t_001.sh30
-rw-r--r--source3/script/tests/t_002.sh30
-rw-r--r--source3/script/tests/test_functions.sh221
-rwxr-xr-xsource3/script/tests/test_posix_s3.sh52
-rwxr-xr-xsource3/script/tests/tests_all.sh8
9 files changed, 478 insertions, 274 deletions
diff --git a/source3/Makefile.in b/source3/Makefile.in
index edf9548d5e..40d59e7cec 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -846,9 +846,9 @@ pch: proto_exists
##
## Targets for 'make test'
##
-test: all torture
- @echo Running Samba 3 Test suite
- @sh ./script/tests/runtests.sh t_dir
+test: all torture bin/timelimit
+ @echo Running Test suite
+ @sh ./script/tests/selftest.sh ${selftest_prefix}/st all "${smbtorture4_path}"
# Check for PAM module problems. Specifically, check that every module we
# built can actually be loaded by a minimal PAM-aware application.
diff --git a/source3/script/tests/functions b/source3/script/tests/functions
deleted file mode 100644
index 8cb8f0b155..0000000000
--- a/source3/script/tests/functions
+++ /dev/null
@@ -1,82 +0,0 @@
-##
-## library file for test functions
-##
-
-##
-## start/stop smbd daemon
-##
-check_smbd_running()
-{
- ## the smbcontrol ping will return a 0 on success
- smbcontrol $CONFIGURATION smbd ping 2>&1 > /dev/null
-}
-
-start_smbd()
-{
- echo "Starting smbd...."
-
- smbd $CONFIGURATION || return $?
-
- sleep 1
-
- smbcontrol $CONFIGURATION `cat $PIDDIR/smbd.pid` ping 2>&1 > /dev/null || return $?
-}
-
-stop_smbd()
-{
- smbd_pid=`cat $PIDDIR/smbd.pid`
- echo "Shutting down smbd (pid $smbd_pid)..."
-
- ## belt and braces; first kill and then send a shutdown message
-
- kill -TERM $smbd_pid
- smbcontrol $CONFIGURATION smbd shutdown
-
- ## check to see if smbd is already running
- check_smbd_running
- if test $? = 0; then
- echo "Unable to stop smbd!"
- exit 2
- fi
-}
-
-
-##
-## start/stop smbd daemon
-##
-check_nmbd_running()
-{
- ## the smbcontrol ping will return a 0 on success
- smbcontrol $CONFIGURATION nmbd ping 2>&1 > /dev/null
-}
-
-start_nmbd()
-{
- echo "Starting nmbd...."
-
- nmbd $CONFIGURATION || return $?
-
- sleep 1
-
- # smbcontrol $CONFIGURATION `cat $PIDDIR/nmbd.pid` ping 2>&1 > /dev/null || return $?
- kill -0 `cat $PIDDIR/nmbd.pid`
-}
-
-stop_nmbd()
-{
- nmbd_pid=`cat $PIDDIR/nmbd.pid`
- echo "Shutting down nmbd (pid $nmbd_pid)..."
-
- ## belt and braces; first kill and then send a shutdown message
-
- kill -TERM $nmbd_pid 2> /dev/null
- sleep 1
-
- ## check to see if smbd is already running
- kill -0 $nmbd_pid 2> /dev/null
- if test $? = 0; then
- echo "Unable to stop nmbd!"
- exit 2
- fi
-}
-
diff --git a/source3/script/tests/runtests.sh b/source3/script/tests/runtests.sh
deleted file mode 100644
index ddaf94e8ac..0000000000
--- a/source3/script/tests/runtests.sh
+++ /dev/null
@@ -1,129 +0,0 @@
-#!/bin/sh
-
-if [ "x$1" = "x" ]; then
- echo "$0 <directory>"
- exit 1
-fi
-
-if [ $# = 2 ]; then
- testnum=$2
-fi
-
-##
-## create the test directory
-##
-PREFIX=`echo $1 | sed s+//+/+`
-mkdir -p $PREFIX || exit $?
-OLD_PWD=`pwd`
-cd $PREFIX || exit $?
-export PREFIX_ABS=`pwd`
-cd $OLD_PWD
-
-##
-## setup the various environment variables we need
-##
-
-USERNAME=`whoami`
-PASSWORD=test
-
-SRCDIR=`pwd`
-SCRIPTDIR=$SRCDIR/script/tests
-SHRDIR=$PREFIX_ABS/tmp
-LIBDIR=$PREFIX_ABS/lib
-PIDDIR=$PREFIX_ABS/pid
-CONFFILE=$LIBDIR/smb.conf
-PRIVATEDIR=$PREFIX_ABS/private
-LOCKDIR=$PREFIX_ABS/lockdir
-LOGDIR=$PREFIX_ABS/logs
-SOCKET_WRAPPER_DIR=$PREFIX_ABS/sockwrap
-CONFIGURATION="-s $CONFFILE"
-PATH=`pwd`/bin:$PATH
-
-export PREFIX_ABS CONFIGURATION CONFFILE PATH SOCKET_WRAPPER_DIR DOMAIN
-export PRIVATEDIR LIBDIR PIDDIR LOCKDIR LOGDIR
-export SRCDIR SCRIPTDIR
-export USERNAME PASSWORD
-
-
-##
-## verify that we were built with --enable-socket-wrapper
-##
-
-if test "x`smbd -b | grep SOCKET_WRAPPER`" = "x"; then
- echo "***"
- echo "*** You must include --enable-socket-wrapper when compiling Samba"
- echo "*** in order to execute 'make test'. Exiting...."
- echo "***"
- exit 1
-fi
-
-##
-## create the test directory layout
-##
-
-/bin/rm -rf $PREFIX/*
-mkdir -p $PRIVATEDIR $LIBDIR $PIDDIR $LOCKDIR $LOGDIR $SOCKET_WRAPPER_DIR
-
-##
-## Create the common config include file with the basic settings
-##
-
-cat >$LIBDIR/common.conf<<EOF
- netbios name = LOCALHOST
- workgroup = SAMBA-TEST
-
- private dir = $PRIVATEDIR
- pid directory = $PIDDIR
- lock directory = $LOCKDIR
- log file = $LOGDIR/log.%m
- log level = 0
-
- passdb backend = tdbsam
-
- interfaces = lo
- bind interfaces only = yes
-
- panic action = $SCRIPTDIR/gdb_backtrace %d
-EOF
-
-cat >$LIBDIR/smb.conf<<EOF
-[global]
- include = $LIBDIR/common.conf
-EOF
-
-
-##
-## create a test account
-##
-
-(echo $PASSWORD; echo $PASSWORD) | smbpasswd -c $LIBDIR/smb.conf -L -s -a $USERNAME
-
-
-##
-## ready to go...now loop through the tests
-##
-
-if [ -f $SCRIPTDIR/t_$testnum.sh ]; then
- testfile=$SCRIPTDIR/t_$testnum.sh
- echo ">>>>>> Starting test driver `basename $testfile` <<<<<"
- sh $testfile
- if [ $? = 0 ]; then
- echo ">>>>> test ok <<<<<"
- else
- echo ">>>>> test failed <<<<<"
- fi
-
- exit 0
-fi
-
-for testfile in `ls $SCRIPTDIR/t_*sh | sort`; do
- echo " "
- echo ">>>>>> Starting test driver `basename $testfile` <<<<<"
- sh $testfile
- if [ $? = 0 ]; then
- echo ">>>>> test ok <<<<<"
- else
- echo ">>>>> test failed <<<<<"
- fi
-done
-
diff --git a/source3/script/tests/selftest.sh b/source3/script/tests/selftest.sh
new file mode 100755
index 0000000000..caaf1e1df1
--- /dev/null
+++ b/source3/script/tests/selftest.sh
@@ -0,0 +1,194 @@
+#!/bin/sh
+
+if [ $# != 3 ]; then
+ echo "$0 <directory> <all | quick> <smbtorture4>"
+ exit 1
+fi
+
+SMBTORTURE4=$3
+TESTS=$2
+
+##
+## create the test directory
+##
+PREFIX=`echo $1 | sed s+//+/+`
+mkdir -p $PREFIX || exit $?
+OLD_PWD=`pwd`
+cd $PREFIX || exit $?
+export PREFIX_ABS=`pwd`
+cd $OLD_PWD
+
+if [ -z "$TORTURE_MAXTIME" ]; then
+ TORTURE_MAXTIME=300
+fi
+
+##
+## setup the various environment variables we need
+##
+
+SERVER=localhost
+USERNAME=`whoami`
+PASSWORD=test
+
+SRCDIR=`pwd`
+SCRIPTDIR=$SRCDIR/script/tests
+SHRDIR=$PREFIX_ABS/tmp
+LIBDIR=$PREFIX_ABS/lib
+PIDDIR=$PREFIX_ABS/pid
+CONFFILE=$LIBDIR/smb.conf
+COMMONCONFFILE=$LIBDIR/common.conf
+PRIVATEDIR=$PREFIX_ABS/private
+LOCKDIR=$PREFIX_ABS/lockdir
+LOGDIR=$PREFIX_ABS/logs
+SOCKET_WRAPPER_DIR=$PREFIX/sw
+CONFIGURATION="-s $CONFFILE"
+
+export PREFIX_ABS CONFIGURATION CONFFILE PATH SOCKET_WRAPPER_DIR DOMAIN
+export PRIVATEDIR LIBDIR PIDDIR LOCKDIR LOGDIR
+export SRCDIR SCRIPTDIR
+export USERNAME PASSWORD
+export SMBTORTURE4
+
+PATH=bin:$PATH
+export PATH
+
+##
+## verify that we were built with --enable-socket-wrapper
+##
+
+if test "x`smbd -b | grep SOCKET_WRAPPER`" = "x"; then
+ echo "***"
+ echo "*** You must include --enable-socket-wrapper when compiling Samba"
+ echo "*** in order to execute 'make test'. Exiting...."
+ echo "***"
+ exit 1
+fi
+
+##
+## create the test directory layout
+##
+echo -n "CREATE TEST ENVIRONMENT IN '$PREFIX'"...
+/bin/rm -rf $PREFIX/*
+mkdir -p $PRIVATEDIR $LIBDIR $PIDDIR $LOCKDIR $LOGDIR $SOCKET_WRAPPER_DIR
+mkdir -p $PREFIX_ABS/tmp
+chmod 777 $PREFIX_ABS/tmp
+
+##
+## Create the common config include file with the basic settings
+##
+
+cat >$COMMONCONFFILE<<EOF
+ netbios name = LOCALHOST
+ workgroup = SAMBA-TEST
+
+ private dir = $PRIVATEDIR
+ pid directory = $PIDDIR
+ lock directory = $LOCKDIR
+ log file = $LOGDIR/log.%m
+ log level = 0
+
+ passdb backend = tdbsam
+
+ name resolve order = bcast
+
+ interfaces = 127.0.0.1/8
+ bind interfaces only = yes
+
+ panic action = $SCRIPTDIR/gdb_backtrace %d
+EOF
+
+cat >$CONFFILE<<EOF
+[global]
+ include = $COMMONCONFFILE
+
+[tmp]
+ path = $PREFIX_ABS/tmp
+ read only = no
+EOF
+
+
+##
+## create a test account
+##
+
+(echo $PASSWORD; echo $PASSWORD) | \
+ smbpasswd -c $CONFFILE -L -s -a $USERNAME >/dev/null || exit 1
+
+echo "DONE";
+
+if [ x"$RUN_FROM_BUILD_FARM" = x"yes" ];then
+ CONFIGURATION="$CONFIGURATION --option=\"torture:progress=no\""
+fi
+
+SERVER_TEST_FIFO="$PREFIX/server_test.fifo"
+export SERVER_TEST_FIFO
+NMBD_TEST_LOG="$PREFIX/nmbd_test.log"
+export NMBD_TEST_LOG
+SMBD_TEST_LOG="$PREFIX/smbd_test.log"
+export SMBD_TEST_LOG
+
+# start off with 0 failures
+failed=0
+export failed
+
+. $SCRIPTDIR/test_functions.sh
+
+SOCKET_WRAPPER_DEFAULT_IFACE=1
+export SOCKET_WRAPPER_DEFAULT_IFACE
+samba3_check_or_start
+
+# ensure any one smbtorture call doesn't run too long
+# and smbtorture will use 127.0.0.26 as source address by default
+SOCKET_WRAPPER_DEFAULT_IFACE=26
+export SOCKET_WRAPPER_DEFAULT_IFACE
+TORTURE4_INTERFACES='127.0.0.26/8,127.0.0.27/8,127.0.0.28/8,127.0.0.29/8,127.0.0.30/8,127.0.0.31/8'
+TORTURE4_OPTIONS="--maximum-runtime=$TORTURE_MAXTIME --option=interfaces=$TORTURE4_INTERFACES $CONFIGURATION"
+export TORTURE4_OPTIONS
+
+if [ x"$RUN_FROM_BUILD_FARM" = x"yes" ];then
+ TORTURE4_OPTIONS="$TORTURE4_OPTIONS --option=\"torture:progress=no\""
+fi
+
+##
+## ready to go...now loop through the tests
+##
+
+START=`date`
+(
+ # give time for nbt server to register its names
+ echo delaying for nbt name registration
+ sleep 4
+ # This will return quickly when things are up, but be slow if we need to wait for (eg) SSL init
+ bin/nmblookup $CONFIGURATION -U $SERVER $SERVER
+ bin/nmblookup $CONFIGURATION -U $SERVER $SERVER
+ bin/nmblookup $CONFIGURATION -U $SERVER $SERVER
+
+ failed=0
+
+ . $SCRIPTDIR/tests_$TESTS.sh
+ exit $failed
+)
+failed=$?
+
+samba3_stop_sig_term
+
+END=`date`
+echo "START: $START ($0)";
+echo "END: $END ($0)";
+
+# if there were any valgrind failures, show them
+count=`find $PREFIX -name 'valgrind.log*' | wc -l`
+if [ "$count" != 0 ]; then
+ for f in $PREFIX/valgrind.log*; do
+ if [ -s $f ]; then
+ echo "VALGRIND FAILURE";
+ failed=`expr $failed + 1`
+ cat $f
+ fi
+ done
+fi
+
+sleep 2
+samba3_stop_sig_kill
+
+teststatus $0 $failed
diff --git a/source3/script/tests/t_001.sh b/source3/script/tests/t_001.sh
deleted file mode 100644
index 6d54d0e489..0000000000
--- a/source3/script/tests/t_001.sh
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/bin/sh
-
-. $SCRIPTDIR/functions
-
-cat >$CONFFILE<<EOF
-[global]
- include = $LIBDIR/common.conf
- smb ports = 139
-
-[test]
- path = $PREFIX_ABS/tmp
- read only = no
-EOF
-
-##
-## Test code
-##
-
-/bin/rm -rf $PREFIX_ABS/tmp
-mkdir $PREFIX_ABS/tmp
-chmod 1777 $PREFIX_ABS/tmp
-
-start_smbd || exit $?
-
-smbclient $CONFIGURATION -L localhost -N -p 139
-ret=$?
-
-stop_smbd
-
-exit $ret
diff --git a/source3/script/tests/t_002.sh b/source3/script/tests/t_002.sh
deleted file mode 100644
index 42070bed80..0000000000
--- a/source3/script/tests/t_002.sh
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/bin/sh
-
-. $SCRIPTDIR/functions
-
-cat >$CONFFILE<<EOF
-[global]
- include = $LIBDIR/common.conf
-
-[test]
- path = $PREFIX_ABS/tmp
- read only = no
-EOF
-
-##
-## Test code
-##
-
-/bin/rm -rf $PREFIX_ABS/tmp
-mkdir $PREFIX_ABS/tmp
-chmod 1777 $PREFIX_ABS/tmp
-
-
-start_smbd || exit $?
-
-smbtorture //localhost/test -U${USERNAME}%${PASSWORD} FDPASS
-ret=$?
-
-stop_smbd
-
-exit $ret
diff --git a/source3/script/tests/test_functions.sh b/source3/script/tests/test_functions.sh
new file mode 100644
index 0000000000..265385d0b1
--- /dev/null
+++ b/source3/script/tests/test_functions.sh
@@ -0,0 +1,221 @@
+
+samba3_stop_sig_term() {
+ RET=0
+ kill -USR1 `cat $PIDDIR/timelimit.nmbd.pid` >/dev/null 2>&1 || \
+ kill -ALRM `cat $PIDDIR/timelimit.nmbd.pid` || RET=$?
+
+ kill -USR1 `cat $PIDDIR/timelimit.smbd.pid` >/dev/null 2>&1 || \
+ kill -ALRM `cat $PIDDIR/timelimit.smbd.pid` || RET=$?
+
+ return $RET;
+}
+
+samba3_stop_sig_kill() {
+ kill -ALRM `cat $PIDDIR/timelimit.nmbd.pid` >/dev/null 2>&1
+ kill -ALRM `cat $PIDDIR/timelimit.smbd.pid` >/dev/null 2>&1
+ return 0;
+}
+
+samba3_check_or_start() {
+ if [ -n "$SERVER_TEST_FIFO" ];then
+
+ trap samba3_stop_sig_kill SIGINT SIGQUIT
+ trap samba3_stop_sig_kill SIGTERM
+
+ if [ -p "$SERVER_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 $SERVER_TEST_FIFO
+ mkfifo $SERVER_TEST_FIFO
+
+ rm -f $NMBD_TEST_LOG
+ echo -n "STARTING NMBD..."
+ ((
+ if [ -z "$NMBD_MAXTIME" ]; then
+ NMBD_MAXTIME=2700
+ fi
+ timelimit $NMBD_MAXTIME $SMBD_VALGRIND $SRCDIR/bin/nmbd -F -S --no-process-group -d1 -s $CONFFILE > $NMBD_TEST_LOG 2>&1 &
+ TIMELIMIT_NMBD_PID=$!
+ echo $TIMELIMIT_NMBD_PID > $PIDDIR/timelimit.nmbd.pid
+ wait $TIMELIMIT_NMBD_PID
+ ret=$?;
+ rm -f $SERVER_TEST_FIFO
+ if [ -n "$SOCKET_WRAPPER_DIR" -a -d "$SOCKET_WRAPPER_DIR" ]; then
+ rm -f $SOCKET_WRAPPER_DIR/*
+ fi
+ if [ x"$ret" = x"0" ];then
+ echo "nmbd exits with status $ret";
+ echo "nmbd exits with status $ret" >>$NMBD_TEST_LOG;
+ elif [ x"$ret" = x"137" ];then
+ echo "nmbd got SIGXCPU and exits with status $ret!"
+ echo "nmbd got SIGXCPU and exits with status $ret!">>$NMBD_TEST_LOG;
+ else
+ echo "nmbd failed with status $ret!"
+ echo "nmbd failed with status $ret!">>$NMBD_TEST_LOG;
+ fi
+ exit $ret;
+ ) || exit $? &) 2>/dev/null || exit $?
+ echo "DONE"
+
+ rm -f $SMBD_TEST_LOG
+ echo -n "STARTING SMBD..."
+ ((
+ if [ -z "$SMBD_MAXTIME" ]; then
+ SMBD_MAXTIME=2700
+ fi
+ timelimit $SMBD_MAXTIME $SMBD_VALGRIND $SRCDIR/bin/smbd -F -S --no-process-group -d1 -s $CONFFILE > $SMBD_TEST_LOG 2>&1 &
+ TIMELIMIT_SMBD_PID=$!
+ echo $TIMELIMIT_SMBD_PID > $PIDDIR/timelimit.smbd.pid
+ wait $TIMELIMIT_SMBD_PID
+ ret=$?;
+ rm -f $SERVER_TEST_FIFO
+ if [ -n "$SOCKET_WRAPPER_DIR" -a -d "$SOCKET_WRAPPER_DIR" ]; then
+ rm -f $SOCKET_WRAPPER_DIR/*
+ fi
+ if [ x"$ret" = x"0" ];then
+ echo "smbd exits with status $ret";
+ echo "smbd exits with status $ret" >>$SMBD_TEST_LOG;
+ elif [ x"$ret" = x"137" ];then
+ echo "smbd got SIGXCPU and exits with status $ret!"
+ echo "smbd got SIGXCPU and exits with status $ret!">>$SMBD_TEST_LOG;
+ else
+ echo "smbd failed with status $ret!"
+ echo "smbd failed with status $ret!">>$SMBD_TEST_LOG;
+ fi
+ exit $ret;
+ ) || exit $? &) 2>/dev/null || exit $?
+ echo "DONE"
+ fi
+ return 0;
+}
+
+samba3_nmbd_test_log() {
+ if [ -n "$NMBD_TEST_LOG" ];then
+ if [ -r "$NMBD_TEST_LOG" ];then
+ return 0;
+ fi
+ fi
+ return 1;
+}
+
+samba3_smbd_test_log() {
+ if [ -n "$SMBD_TEST_LOG" ];then
+ if [ -r "$SMBD_TEST_LOG" ];then
+ return 0;
+ fi
+ fi
+ return 1;
+}
+
+samba3_check_only() {
+ if [ -n "$SERVER_TEST_FIFO" ];then
+ if [ -p "$SERVER_TEST_FIFO" ];then
+ return 0;
+ fi
+ return 1;
+ fi
+ return 0;
+}
+
+testit() {
+ if [ -z "$PREFIX" ]; then
+ PREFIX=test_prefix
+ mkdir -p $PREFIX
+ fi
+ name=$1
+ shift 1
+ SERVERS_ARE_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)"
+ echo "--==--==--==--==--==--==--==--==--==--==--"
+ date
+ echo "Testing $name"
+ else
+ echo "Testing $name ($failed)"
+ fi
+
+ samba3_check_only && SERVERS_ARE_UP="yes"
+ if [ x"$SERVERS_ARE_UP" != x"yes" ];then
+ if [ x"$RUN_FROM_BUILD_FARM" = x"yes" ];then
+ echo "SERVERS are down! Skipping: $cmdline"
+ echo "=========================================="
+ echo "TEST SKIPPED: $name (reason SERVERS are down)"
+ echo "=========================================="
+ else
+ echo "TEST SKIPPED: $name (reason SERVERS are down)"
+ fi
+ return 1
+ fi
+
+ ( $cmdline > $TEST_LOG 2>&1 )
+ status=$?
+ if [ x"$status" != x"0" ]; then
+ echo "TEST OUTPUT:"
+ cat $TEST_LOG;
+ samba3_nmbd_test_log && echo "NMBD OUTPUT:";
+ samba3_nmbd_test_log && cat $NMBD_TEST_LOG;
+ samba3_smbd_test_log && echo "SMBD OUTPUT:";
+ samba3_smbd_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)"
+ echo "=========================================="
+ else
+ echo "TEST FAILED: $cmdline (status $status)"
+ fi
+ return 1;
+ fi
+ rm -f $TEST_LOG;
+ if [ x"$RUN_FROM_BUILD_FARM" = x"yes" ];then
+ echo "ALL OK: $cmdline"
+ echo "=========================================="
+ echo "TEST PASSED: $name"
+ echo "=========================================="
+ fi
+ return 0;
+}
+
+testok() {
+ name=`basename $1`
+ failed=$2
+
+ if [ x"$failed" = x"0" ];then
+ :
+ else
+ echo "$failed TESTS FAILED or SKIPPED ($name)";
+ fi
+ exit $failed
+}
+
+teststatus() {
+ name=`basename $1`
+ failed=$2
+
+ if [ x"$failed" = x"0" ];then
+ echo "TEST STATUS: $failed";
+ else
+ echo "TEST STATUS: $failed";
+ fi
+ exit $failed
+}
+
+if [ -z "$VALGRIND" ]; then
+ MALLOC_CHECK_=2
+ export MALLOC_CHECK_
+fi
+
diff --git a/source3/script/tests/test_posix_s3.sh b/source3/script/tests/test_posix_s3.sh
new file mode 100755
index 0000000000..64e984cb67
--- /dev/null
+++ b/source3/script/tests/test_posix_s3.sh
@@ -0,0 +1,52 @@
+#!/bin/sh
+
+# this runs the file serving tests that are expected to pass with samba3
+
+if [ $# -lt 3 ]; then
+cat <<EOF
+Usage: test_posix_s3.sh UNC USERNAME PASSWORD <first> <smbtorture args>
+EOF
+exit 1;
+fi
+
+unc="$1"
+username="$2"
+password="$3"
+start="$4"
+shift 4
+ADDARGS="$*"
+
+incdir=`dirname $0`
+. $incdir/test_functions.sh
+
+tests="BASE-FDPASS BASE-LOCK1 BASE-LOCK2 BASE-LOCK3 BASE-LOCK4"
+tests="$tests BASE-LOCK5 BASE-LOCK6 BASE-LOCK7 BASE-UNLINK BASE-ATTR"
+tests="$tests BASE-DIR1 BASE-DIR2 BASE-VUID"
+tests="$tests BASE-DENY1 BASE-DENY2 BASE-TCON BASE-TCONDEV BASE-RW1"
+tests="$tests BASE-DENY3 BASE-XCOPY BASE-OPEN BASE-DENYDOS"
+tests="$tests BASE-PROPERTIES BASE-MANGLE BASE-DELETE"
+tests="$tests BASE-CHKPATH BASE-SECLEAK BASE-TRANS2 BASE-NEGNOWAIT"
+tests="$tests BASE-NTDENY1 BASE-NTDENY2 BASE-RENAME BASE-OPENATTR BASE-DISCONNECT"
+tests="$tests RAW-QFSINFO RAW-QFILEINFO RAW-SFILEINFO-BUG RAW-SFILEINFO"
+tests="$tests RAW-LOCK RAW-MKDIR RAW-SEEK RAW-CONTEXT RAW-MUX RAW-OPEN RAW-WRITE"
+tests="$tests RAW-UNLINK RAW-READ RAW-CLOSE RAW-IOCTL RAW-SEARCH RAW-CHKPATH RAW-RENAME"
+tests="$tests RAW-EAS RAW-STREAMS RAW-ACLS"
+
+soon="BASE-CHARSET RAW-OPLOCK RAW-NOTIFY BASE-DELAYWRITE"
+#echo "WARNING: Skipping tests $soon"
+
+#testit "my first samba3 test" $SRCDIR/bin/smbclient $CONFIGURATION -L 127.0.0.1 -N -p 139 || failed=`expr $failed + 1`
+
+tests="BASE-FDPASS BASE-VUID BASE-UNLINK BASE-ATTR BASE-DIR2 BASE-TCON BASE-OPEN BASE-CHKPATH"
+
+failed=0
+for t in $tests; do
+ if [ ! -z "$start" -a "$start" != $t ]; then
+ continue;
+ fi
+ start=""
+ name="$t"
+ testit "$name" $VALGRIND $SMBTORTURE4 $TORTURE_OPTIONS $ADDARGS $unc -U"$username"%"$password" $t || failed=`expr $failed + 1`
+done
+
+testok $0 $failed
diff --git a/source3/script/tests/tests_all.sh b/source3/script/tests/tests_all.sh
new file mode 100755
index 0000000000..6f7a0c3d2d
--- /dev/null
+++ b/source3/script/tests/tests_all.sh
@@ -0,0 +1,8 @@
+
+if [ -n "$SMBTORTURE4" ];then
+ echo "Running Tests with Samba4's smbtorture"
+ $SMBTORTURE4 --version
+ $SCRIPTDIR/test_posix_s3.sh //$SERVER/tmp $USERNAME $PASSWORD "" || failed=`expr $failed + $?`
+else
+ echo "Skip Tests with Samba4's smbtorture"
+fi