r9813: Conver testsuite for samba3sam module to EJS
[samba.git] / source / script / tests / selftest.sh
index 5e94ea13e24ccff88e1b48e585cc3bf9a7cb8aa0..82cac6459f8cad1a1102a845bad268e0103a59c9 100755 (executable)
@@ -1,10 +1,15 @@
 #!/bin/sh
+# Bootstrap Samba and run a number of tests against it.
+
 DOMAIN=SAMBADOMAIN
 USERNAME=administrator
 REALM=$DOMAIN
 PASSWORD=penguin
 SRCDIR=`pwd`
 ROOT=$USER
+if test -z "$ROOT"; then
+    ROOT=$LOGNAME
+fi
 if test -z "$ROOT"; then
     ROOT=`whoami`
 fi
@@ -15,8 +20,20 @@ then
        exit
 fi
 
+
 PREFIX=$1
+PREFIX=`echo $PREFIX | sed s+//+/+`
 export PREFIX
+
+# allow selection of the test lists
+TESTS=$2
+
+if [ $TESTS = "all" ]; then
+    TLS_ENABLED="yes"
+else
+    TLS_ENABLED="no"
+fi
+
 mkdir -p $PREFIX || exit $?
 OLD_PWD=`pwd`
 cd $PREFIX || exit $?
@@ -34,15 +51,16 @@ LOCKDIR=$PREFIX_ABS/lockdir
 TLSDIR=$PRIVATEDIR/tls
 CONFIGURATION="--configfile=$CONFFILE"
 export CONFIGURATION
+export CONFFILE
 
 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
+DO_SOCKET_WRAPPER=$3
 if [ x"$DO_SOCKET_WRAPPER" = x"SOCKET_WRAPPER" ];then
-       SOCKET_WRAPPER_DIR="$PREFIX/socket_wrapper_dir"
+       SOCKET_WRAPPER_DIR="$PREFIX/sw"
        export SOCKET_WRAPPER_DIR
        echo "SOCKET_WRAPPER_DIR=$SOCKET_WRAPPER_DIR"
 fi
@@ -54,10 +72,11 @@ export failed
 incdir=`dirname $0`
 . $incdir/test_functions.sh
 
+PATH=bin:$PATH
+export PATH
+
 rm -rf $PREFIX/*
 mkdir -p $PRIVATEDIR $LIBDIR $PIDDIR $NCALRPCDIR $LOCKDIR $TMPDIR $TLSDIR
-./setup/provision.pl --quiet --outputdir $PRIVATEDIR --domain $DOMAIN --realm $REALM \
-    --adminpass $PASSWORD --root=$ROOT
 
 cat >$CONFFILE<<EOF
 [global]
@@ -68,9 +87,15 @@ cat >$CONFFILE<<EOF
        pid directory = $PIDDIR
        ncalrpc dir = $NCALRPCDIR
        lock dir = $LOCKDIR
-       js include = $LIBDIR/js
+       setup directory = $SRCDIR/setup
+       js include = $SRCDIR/scripting/libjs
        name resolve order = bcast
        interfaces = lo*
+       tls enabled = $TLS_ENABLED
+       panic action = $SRCDIR/script/gdb_backtrace %PID% %PROG%
+       wins support = yes
+       domain master = yes
+       domain logons = yes
 
 [tmp]
        path = $TMPDIR
@@ -82,13 +107,16 @@ cat >$CONFFILE<<EOF
 [cifs]
        read only = no
        ntvfs handler = cifs
-        cifs:server = localhost
-        cifs:user = $USERNAME
-        cifs:password = $PASSWORD
-        cifs:domain = $DOMAIN
+       cifs:server = localhost
+       cifs:user = $USERNAME
+       cifs:password = $PASSWORD
+       cifs:domain = $DOMAIN
        cifs:share = tmp
 EOF
 
+./setup/provision $CONFIGURATION --quiet --domain $DOMAIN --realm $REALM \
+    --adminpass $PASSWORD --root=$ROOT || exit 1
+
 if [ x"$RUN_FROM_BUILD_FARM" = x"yes" ];then
        CONFIGURATION="$CONFIGURATION --option=\"torture:progress=no\""
 fi
@@ -108,21 +136,28 @@ START=`date`
  bin/nmblookup -U localhost localhost 
 
  failed=0
- $SRCDIR/script/tests/test_ejs.sh localhost $USERNAME $PASSWORD || failed=`expr $failed + $?`
- $SRCDIR/script/tests/test_ldap.sh localhost $USERNAME $PASSWORD || failed=`expr $failed + $?`
- $SRCDIR/script/tests/test_quick.sh //localhost/cifs $USERNAME $PASSWORD "" || failed=`expr $failed + $?`
- $SRCDIR/script/tests/test_rpc.sh localhost $USERNAME $PASSWORD $DOMAIN || failed=`expr $failed + $?`
- $SRCDIR/script/tests/test_session_key.sh localhost $USERNAME $PASSWORD $DOMAIN || failed=`expr $failed + $?`
- $SRCDIR/script/tests/test_binding_string.sh localhost $USERNAME $PASSWORD $DOMAIN || failed=`expr $failed + $?`
- $SRCDIR/script/tests/test_echo.sh localhost $USERNAME $PASSWORD $DOMAIN || failed=`expr $failed + $?`
- $SRCDIR/script/tests/test_posix.sh //localhost/tmp $USERNAME $PASSWORD "" || failed=`expr $failed + $?`
- $SRCDIR/script/tests/test_local.sh || failed=`expr $failed + $?`
+
+ . script/tests/tests_$TESTS.sh
  exit $failed
 ) 9>$SMBD_TEST_FIFO
 failed=$?
 
+kill `cat $PIDDIR/smbd.pid`
+
 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
+
 teststatus $0 $failed