r8349: as we don't use standard dirs, we need to create smb.conf before we run provision
[bbaumbach/samba-autobuild/.git] / source4 / script / tests / selftest.sh
1 #!/bin/sh
2 DOMAIN=SAMBADOMAIN
3 USERNAME=administrator
4 REALM=$DOMAIN
5 PASSWORD=penguin
6 SRCDIR=`pwd`
7 ROOT=$USER
8 if test -z "$ROOT"; then
9     ROOT=`whoami`
10 fi
11
12 if [ $# -lt 1 ]
13 then
14         echo "$0 PREFIX"
15         exit
16 fi
17
18 PREFIX=$1
19 export PREFIX
20 mkdir -p $PREFIX || exit $?
21 OLD_PWD=`pwd`
22 cd $PREFIX || exit $?
23 PREFIX_ABS=`pwd`
24 export PREFIX_ABS
25 cd $OLD_PWD
26
27 TMPDIR=$PREFIX_ABS/tmp
28 LIBDIR=$PREFIX_ABS/lib
29 PIDDIR=$PREFIX_ABS/pid
30 CONFFILE=$LIBDIR/smb.conf
31 PRIVATEDIR=$PREFIX_ABS/private
32 NCALRPCDIR=$PREFIX_ABS/ncalrpc
33 LOCKDIR=$PREFIX_ABS/lockdir
34 TLSDIR=$PRIVATEDIR/tls
35 CONFIGURATION="--configfile=$CONFFILE"
36 export CONFIGURATION
37
38 SMBD_TEST_FIFO="$PREFIX/smbd_test.fifo"
39 export SMBD_TEST_FIFO
40 SMBD_TEST_LOG="$PREFIX/smbd_test.log"
41 export SMBD_TEST_LOG
42
43 DO_SOCKET_WRAPPER=$2
44 if [ x"$DO_SOCKET_WRAPPER" = x"SOCKET_WRAPPER" ];then
45         SOCKET_WRAPPER_DIR="$PREFIX/socket_wrapper_dir"
46         export SOCKET_WRAPPER_DIR
47         echo "SOCKET_WRAPPER_DIR=$SOCKET_WRAPPER_DIR"
48 fi
49
50 # start off with 0 failures
51 failed=0
52 export failed
53
54 incdir=`dirname $0`
55 . $incdir/test_functions.sh
56
57 PATH=bin:$PATH
58 export PATH
59
60 rm -rf $PREFIX/*
61 mkdir -p $PRIVATEDIR $LIBDIR $PIDDIR $NCALRPCDIR $LOCKDIR $TMPDIR $TLSDIR
62
63 cat >$CONFFILE<<EOF
64 [global]
65         netbios name = LOCALHOST
66         workgroup = $DOMAIN
67         realm = $REALM
68         private dir = $PRIVATEDIR
69         pid directory = $PIDDIR
70         ncalrpc dir = $NCALRPCDIR
71         lock dir = $LOCKDIR
72         js include = $SRCDIR/scripting/libjs
73         name resolve order = bcast
74         interfaces = lo*
75
76 [tmp]
77         path = $TMPDIR
78         read only = no
79         ntvfs handler = posix
80         posix:sharedelay = 100000
81         posix:eadb = $LOCKDIR/eadb.tdb
82
83 [cifs]
84         read only = no
85         ntvfs handler = cifs
86         cifs:server = localhost
87         cifs:user = $USERNAME
88         cifs:password = $PASSWORD
89         cifs:domain = $DOMAIN
90         cifs:share = tmp
91 EOF
92
93 ./setup/provision $CONFIGURATION --quiet --domain $DOMAIN --realm $REALM \
94     --adminpass $PASSWORD --root=$ROOT
95
96 if [ x"$RUN_FROM_BUILD_FARM" = x"yes" ];then
97         CONFIGURATION="$CONFIGURATION --option=\"torture:progress=no\""
98 fi
99
100 smbd_check_or_start
101
102 # ensure any one smbtorture call doesn't run too long
103 TORTURE_OPTIONS="--maximum-runtime=300 $CONFIGURATION"
104 export TORTURE_OPTIONS
105
106
107 START=`date`
108 (
109  # give time for nbt server to register its names
110  echo delaying for nbt name registration
111  sleep 4
112  bin/nmblookup -U localhost localhost 
113
114  failed=0
115  $SRCDIR/script/tests/test_ejs.sh localhost $USERNAME $PASSWORD || failed=`expr $failed + $?`
116  $SRCDIR/script/tests/test_ldap.sh localhost $USERNAME $PASSWORD || failed=`expr $failed + $?`
117  $SRCDIR/script/tests/test_quick.sh //localhost/cifs $USERNAME $PASSWORD "" || failed=`expr $failed + $?`
118  $SRCDIR/script/tests/test_rpc.sh localhost $USERNAME $PASSWORD $DOMAIN || failed=`expr $failed + $?`
119  $SRCDIR/script/tests/test_session_key.sh localhost $USERNAME $PASSWORD $DOMAIN || failed=`expr $failed + $?`
120  $SRCDIR/script/tests/test_binding_string.sh localhost $USERNAME $PASSWORD $DOMAIN || failed=`expr $failed + $?`
121  $SRCDIR/script/tests/test_echo.sh localhost $USERNAME $PASSWORD $DOMAIN || failed=`expr $failed + $?`
122  $SRCDIR/script/tests/test_posix.sh //localhost/tmp $USERNAME $PASSWORD "" || failed=`expr $failed + $?`
123  $SRCDIR/script/tests/test_local.sh || failed=`expr $failed + $?`
124  exit $failed
125 ) 9>$SMBD_TEST_FIFO
126 failed=$?
127
128 END=`date`
129 echo "START: $START ($0)";
130 echo "END:   $END ($0)";
131
132 teststatus $0 $failed