r14678: - we need to use 127.0.0.2/8 as interface for the server
[Samba/nascimento.git] / source3 / script / tests / selftest.sh
blobc61cf763801a2986027b6b9ff188be1294fff27d
1 #!/bin/sh
3 if [ $# != 3 ]; then
4 echo "$0 <directory> <all | quick> <smbtorture4>"
5 exit 1
6 fi
8 SMBTORTURE4=$3
9 TESTS=$2
12 ## create the test directory
14 PREFIX=`echo $1 | sed s+//+/+`
15 mkdir -p $PREFIX || exit $?
16 OLD_PWD=`pwd`
17 cd $PREFIX || exit $?
18 export PREFIX_ABS=`pwd`
19 cd $OLD_PWD
21 if [ -z "$TORTURE_MAXTIME" ]; then
22 TORTURE_MAXTIME=300
26 ## setup the various environment variables we need
29 SERVER=localhost2
30 SERVER_IP=127.0.0.2
31 USERNAME=`whoami`
32 PASSWORD=test
34 SRCDIR=`pwd`
35 SCRIPTDIR=$SRCDIR/script/tests
36 SHRDIR=$PREFIX_ABS/tmp
37 LIBDIR=$PREFIX_ABS/lib
38 PIDDIR=$PREFIX_ABS/pid
39 CONFFILE=$LIBDIR/client.conf
40 SERVERCONFFILE=$LIBDIR/server.conf
41 COMMONCONFFILE=$LIBDIR/common.conf
42 PRIVATEDIR=$PREFIX_ABS/private
43 LOCKDIR=$PREFIX_ABS/lockdir
44 LOGDIR=$PREFIX_ABS/logs
45 SOCKET_WRAPPER_DIR=$PREFIX/sw
46 CONFIGURATION="-s $CONFFILE"
48 export PREFIX_ABS CONFIGURATION CONFFILE PATH SOCKET_WRAPPER_DIR DOMAIN
49 export PRIVATEDIR LIBDIR PIDDIR LOCKDIR LOGDIR SERVERCONFFILE
50 export SRCDIR SCRIPTDIR
51 export USERNAME PASSWORD
52 export SMBTORTURE4
53 export SERVER SERVER_IP
55 PATH=bin:$PATH
56 export PATH
59 ## verify that we were built with --enable-socket-wrapper
62 if test "x`smbd -b | grep SOCKET_WRAPPER`" = "x"; then
63 echo "***"
64 echo "*** You must include --enable-socket-wrapper when compiling Samba"
65 echo "*** in order to execute 'make test'. Exiting...."
66 echo "***"
67 exit 1
70 ##
71 ## create the test directory layout
73 echo -n "CREATE TEST ENVIRONMENT IN '$PREFIX'"...
74 /bin/rm -rf $PREFIX/*
75 mkdir -p $PRIVATEDIR $LIBDIR $PIDDIR $LOCKDIR $LOGDIR $SOCKET_WRAPPER_DIR
76 mkdir -p $PREFIX_ABS/tmp
77 chmod 777 $PREFIX_ABS/tmp
80 ## Create the common config include file with the basic settings
83 cat >$COMMONCONFFILE<<EOF
84 workgroup = SAMBA-TEST
86 private dir = $PRIVATEDIR
87 pid directory = $PIDDIR
88 lock directory = $LOCKDIR
89 log file = $LOGDIR/log.%m
90 log level = 0
92 passdb backend = tdbsam
94 name resolve order = bcast
96 panic action = $SCRIPTDIR/gdb_backtrace %d
97 EOF
99 cat >$CONFFILE<<EOF
100 [global]
101 netbios name = TORTURE26
102 interfaces = 127.0.0.26/8
103 include = $COMMONCONFFILE
106 cat >$SERVERCONFFILE<<EOF
107 [global]
108 netbios name = $SERVER
109 interfaces = $SERVER_IP/8
110 bind interfaces only = yes
111 include = $COMMONCONFFILE
113 [tmp]
114 path = $PREFIX_ABS/tmp
115 read only = no
120 ## create a test account
123 (echo $PASSWORD; echo $PASSWORD) | \
124 smbpasswd -c $CONFFILE -L -s -a $USERNAME >/dev/null || exit 1
126 echo "DONE";
128 if [ x"$RUN_FROM_BUILD_FARM" = x"yes" ];then
129 CONFIGURATION="$CONFIGURATION --option=\"torture:progress=no\""
132 SERVER_TEST_FIFO="$PREFIX/server_test.fifo"
133 export SERVER_TEST_FIFO
134 NMBD_TEST_LOG="$PREFIX/nmbd_test.log"
135 export NMBD_TEST_LOG
136 SMBD_TEST_LOG="$PREFIX/smbd_test.log"
137 export SMBD_TEST_LOG
139 # start off with 0 failures
140 failed=0
141 export failed
143 . $SCRIPTDIR/test_functions.sh
145 SOCKET_WRAPPER_DEFAULT_IFACE=2
146 export SOCKET_WRAPPER_DEFAULT_IFACE
147 samba3_check_or_start
149 # ensure any one smbtorture call doesn't run too long
150 # and smbtorture will use 127.0.0.26 as source address by default
151 SOCKET_WRAPPER_DEFAULT_IFACE=26
152 export SOCKET_WRAPPER_DEFAULT_IFACE
153 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'
154 TORTURE4_OPTIONS="--maximum-runtime=$TORTURE_MAXTIME --option=interfaces=$TORTURE4_INTERFACES $CONFIGURATION"
155 export TORTURE4_OPTIONS
157 if [ x"$RUN_FROM_BUILD_FARM" = x"yes" ];then
158 TORTURE4_OPTIONS="$TORTURE4_OPTIONS --option=\"torture:progress=no\""
162 ## ready to go...now loop through the tests
165 START=`date`
167 # give time for nbt server to register its names
168 echo "delaying for nbt name registration"
169 sleep 4
170 # This will return quickly when things are up, but be slow if we need to wait for (eg) SSL init
171 bin/nmblookup $CONFIGURATION -U $SERVER_IP __SAMBA__
172 bin/nmblookup $CONFIGURATION __SAMBA__
173 bin/nmblookup $CONFIGURATION -U 127.255.255.255 __SAMBA__
174 bin/nmblookup $CONFIGURATION -U $SERVER_IP $SERVER
175 bin/nmblookup $CONFIGURATION $SERVER
176 # make sure smbd is also up set
177 echo "wait for smbd"
178 bin/smbclient $CONFIGURATION -L $SERVER_IP -N -p 139 | head -2
179 bin/smbclient $CONFIGURATION -L $SERVER_IP -N -p 139 | head -2
181 failed=0
183 . $SCRIPTDIR/tests_$TESTS.sh
184 exit $failed
186 failed=$?
188 samba3_stop_sig_term
190 END=`date`
191 echo "START: $START ($0)";
192 echo "END: $END ($0)";
194 # if there were any valgrind failures, show them
195 count=`find $PREFIX -name 'valgrind.log*' | wc -l`
196 if [ "$count" != 0 ]; then
197 for f in $PREFIX/valgrind.log*; do
198 if [ -s $f ]; then
199 echo "VALGRIND FAILURE";
200 failed=`expr $failed + 1`
201 cat $f
203 done
206 sleep 2
207 samba3_stop_sig_kill
209 teststatus $0 $failed