r9562: successfully get the samba 3 smbtorture working (as a test case for infrastructre)
authorGerald Carter <jerry@samba.org>
Wed, 24 Aug 2005 03:09:49 +0000 (03:09 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 16:01:13 +0000 (11:01 -0500)
source/script/tests/functions
source/script/tests/runtests.sh
source/script/tests/t_001.sh
source/script/tests/t_002.sh [new file with mode: 0644]

index 4cc8d4a2c0865f02f9ca464c2fd9b9178e9c0d96..40e185e153f76bbaab89ccc5caa812d0df97c16d 100644 (file)
@@ -40,3 +40,43 @@ stop_smbd()
        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
+}
+
index e8594f5199ef36e7c4f0903fc1caacd55cfa7ec5..b814ad91e79c1c38b4433465259dc6eb8a8310cd 100644 (file)
@@ -5,6 +5,10 @@ if [ "x$1" == "x" ]; then
        exit 1
 fi
 
+if [ $# == 2 ]; then
+       testnum=$2
+fi
+
 ##
 ## create the test directory
 ##
@@ -19,6 +23,9 @@ cd $OLD_PWD
 ## setup the various environment variables we need
 ##
 
+USERNAME=`whoami`
+PASSWORD=test
+
 SRCDIR=`pwd`
 SCRIPTDIR=$SRCDIR/script/tests
 TMPDIR=$PREFIX_ABS/tmp
@@ -35,6 +42,7 @@ PATH=`pwd`/bin:$PATH
 export PREFIX_ABS CONFIGURATION CONFFILE PATH SOCKET_WRAPPER_DIR DOMAIN
 export PRIVATEDIR LIBDIR PIDDIR LOCKDIR TMPDIR LOGDIR
 export SRCDIR SCRIPTDIR
+export USERNAME PASSWORD
 
 ## 
 ## create the test directory layout
@@ -42,6 +50,7 @@ export SRCDIR SCRIPTDIR
 
 /bin/rm -rf $PREFIX/*
 mkdir -p $PRIVATEDIR $LIBDIR $PIDDIR $LOCKDIR $TMPDIR $LOGDIR $SOCKET_WRAPPER_DIR
+chmod 1777 $TMPDIR
 
 ##
 ## Create the common config include file with the basic settings
@@ -57,17 +66,46 @@ cat >$LIBDIR/common.conf<<EOF
        log file = $LOGDIR/log.%m
        log level = 0
 
+       passdb backend = tdbsam
+
        interfaces = lo
        bind interfaces only = yes
 
-       panic action = $PREFIX_ABS/script/tests/gdb_backtrace /proc/%d/exe %d
+       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
index f9f530c9744cca777982ace40039dcc9ccbf9d32..77b023c4c498fd00e34943c847b1afe4bde639e3 100644 (file)
@@ -18,5 +18,8 @@ EOF
 start_smbd || exit $?
 
 smbclient $CONFIGURATION -L localhost -N -p 139
+ret=$?
 
 stop_smbd
+
+exit $ret
diff --git a/source/script/tests/t_002.sh b/source/script/tests/t_002.sh
new file mode 100644 (file)
index 0000000..4898726
--- /dev/null
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+. $SCRIPTDIR/functions
+
+cat >$CONFFILE<<EOF
+[global]
+       include = $LIBDIR/common.conf
+
+[test]
+       path = $TMPDIR
+       read only = no
+EOF
+
+##
+## Test code 
+##
+
+start_smbd || exit $?
+
+smbtorture //localhost/test -U${USERNAME}%${PASSWORD} FDPASS
+ret=$?
+
+stop_smbd
+
+exit $ret