source: trunk-3.0/source/script/tests/selftest.sh@ 101

Last change on this file since 101 was 1, checked in by Paul Smedley, 18 years ago

Initial code import

File size: 5.4 KB
Line 
1#!/bin/sh
2
3if [ $# != 3 ]; then
4 echo "$0 <directory> <all | quick> <smbtorture4>"
5 exit 1
6fi
7
8SMBTORTURE4=$3
9TESTS=$2
10
11##
12## create the test directory
13##
14PREFIX=`echo $1 | sed s+//+/+`
15mkdir -p $PREFIX || exit $?
16OLD_PWD=`pwd`
17cd $PREFIX || exit $?
18PREFIX_ABS=`pwd`
19cd $OLD_PWD
20
21if [ -z "$TORTURE_MAXTIME" ]; then
22 TORTURE_MAXTIME=300
23fi
24export TORTURE_MAXTIME
25
26##
27## setup the various environment variables we need
28##
29
30SERVER=localhost2
31SERVER_IP=127.0.0.2
32USERNAME=`PATH=/usr/ucb:$PATH whoami`
33PASSWORD=test
34
35SRCDIR="`dirname $0`/../.."
36BINDIR="`pwd`/bin"
37SCRIPTDIR=$SRCDIR/script/tests
38SHRDIR=$PREFIX_ABS/tmp
39LIBDIR=$PREFIX_ABS/lib
40PIDDIR=$PREFIX_ABS/pid
41CONFFILE=$LIBDIR/client.conf
42SAMBA4CONFFILE=$LIBDIR/samba4client.conf
43SERVERCONFFILE=$LIBDIR/server.conf
44COMMONCONFFILE=$LIBDIR/common.conf
45PRIVATEDIR=$PREFIX_ABS/private
46LOCKDIR=$PREFIX_ABS/lockdir
47LOGDIR=$PREFIX_ABS/logs
48SOCKET_WRAPPER_DIR=$PREFIX/sw
49CONFIGURATION="-s $CONFFILE"
50SAMBA4CONFIGURATION="-s $SAMBA4CONFFILE"
51
52export PREFIX PREFIX_ABS
53export CONFIGURATION CONFFILE SAMBA4CONFIGURATION SAMBA4CONFFILE
54export PATH SOCKET_WRAPPER_DIR DOMAIN
55export PRIVATEDIR LIBDIR PIDDIR LOCKDIR LOGDIR SERVERCONFFILE
56export SRCDIR SCRIPTDIR BINDIR
57export USERNAME PASSWORD
58export SMBTORTURE4
59export SERVER SERVER_IP
60
61PATH=bin:$PATH
62export PATH
63
64##
65## verify that we were built with --enable-socket-wrapper
66##
67
68if test "x`smbd -b | grep SOCKET_WRAPPER`" = "x"; then
69 echo "***"
70 echo "*** You must include --enable-socket-wrapper when compiling Samba"
71 echo "*** in order to execute 'make test'. Exiting...."
72 echo "***"
73 exit 1
74fi
75
76##
77## create the test directory layout
78##
79echo -n "CREATE TEST ENVIRONMENT IN '$PREFIX'"...
80/bin/rm -rf $PREFIX/*
81mkdir -p $PRIVATEDIR $LIBDIR $PIDDIR $LOCKDIR $LOGDIR $SOCKET_WRAPPER_DIR
82mkdir -p $PREFIX_ABS/tmp
83chmod 777 $PREFIX_ABS/tmp
84
85##
86## Create the common config include file with the basic settings
87##
88
89cat >$COMMONCONFFILE<<EOF
90 workgroup = SAMBA-TEST
91
92 private dir = $PRIVATEDIR
93 pid directory = $PIDDIR
94 lock directory = $LOCKDIR
95 log file = $LOGDIR/log.%m
96 log level = 0
97
98 passdb backend = tdbsam
99
100 name resolve order = bcast
101EOF
102
103TORTURE_INTERFACES='127.0.0.6/8,127.0.0.7/8,127.0.0.8/8,127.0.0.9/8,127.0.0.10/8,127.0.0.11/8'
104
105cat >$CONFFILE<<EOF
106[global]
107 netbios name = TORTURE_6
108 interfaces = $TORTURE_INTERFACES
109 panic action = $SCRIPTDIR/gdb_backtrace %d %\$(MAKE_TEST_BINARY)
110 include = $COMMONCONFFILE
111EOF
112
113cat >$SAMBA4CONFFILE<<EOF
114[global]
115 netbios name = TORTURE_6
116 interfaces = $TORTURE_INTERFACES
117 panic action = $SCRIPTDIR/gdb_backtrace %PID% %PROG%
118 include = $COMMONCONFFILE
119EOF
120
121cat >$SERVERCONFFILE<<EOF
122[global]
123 netbios name = $SERVER
124 interfaces = $SERVER_IP/8
125 bind interfaces only = yes
126 panic action = $SCRIPTDIR/gdb_backtrace %d %\$(MAKE_TEST_BINARY)
127 include = $COMMONCONFFILE
128
129 ; Necessary to add the build farm hacks
130 add user script = /bin/false
131 add machine script = /bin/false
132
133 kernel oplocks = no
134
135 syslog = no
136 printing = bsd
137 printcap name = /dev/null
138
139[tmp]
140 path = $PREFIX_ABS/tmp
141 read only = no
142 smbd:sharedelay = 100000
143 map hidden = yes
144 map system = yes
145 create mask = 755
146[hideunread]
147 copy = tmp
148 hide unreadable = yes
149[hideunwrite]
150 copy = tmp
151 hide unwriteable files = yes
152[print1]
153 copy = tmp
154 printable = yes
155 printing = test
156[print2]
157 copy = print1
158[print3]
159 copy = print1
160[print4]
161 copy = print1
162EOF
163
164##
165## create a test account
166##
167
168(echo $PASSWORD; echo $PASSWORD) | \
169 smbpasswd -c $CONFFILE -L -s -a $USERNAME >/dev/null || exit 1
170
171echo "DONE";
172
173SERVER_TEST_FIFO="$PREFIX/server_test.fifo"
174export SERVER_TEST_FIFO
175NMBD_TEST_LOG="$PREFIX/nmbd_test.log"
176export NMBD_TEST_LOG
177SMBD_TEST_LOG="$PREFIX/smbd_test.log"
178export SMBD_TEST_LOG
179
180MAKE_TEST_BINARY=""
181export MAKE_TEST_BINARY
182
183# start off with 0 failures
184failed=0
185export failed
186
187. $SCRIPTDIR/test_functions.sh
188
189SOCKET_WRAPPER_DEFAULT_IFACE=2
190export SOCKET_WRAPPER_DEFAULT_IFACE
191samba3_check_or_start
192
193# ensure any one smbtorture call doesn't run too long
194# and smbtorture will use 127.0.0.6 as source address by default
195SOCKET_WRAPPER_DEFAULT_IFACE=6
196export SOCKET_WRAPPER_DEFAULT_IFACE
197TORTURE4_OPTIONS="$SAMBA4CONFIGURATION"
198TORTURE4_OPTIONS="$TORTURE4_OPTIONS --maximum-runtime=$TORTURE_MAXTIME"
199TORTURE4_OPTIONS="$TORTURE4_OPTIONS --target=samba3"
200export TORTURE4_OPTIONS
201
202if [ x"$RUN_FROM_BUILD_FARM" = x"yes" ];then
203 TORTURE4_OPTIONS="$TORTURE4_OPTIONS --option=torture:progress=no"
204fi
205
206
207##
208## ready to go...now loop through the tests
209##
210
211START=`date`
212(
213 # give time for nbt server to register its names
214 echo "delaying for nbt name registration"
215 sleep 4
216 # This will return quickly when things are up, but be slow if we need to wait for (eg) SSL init
217 bin/nmblookup $CONFIGURATION -U $SERVER_IP __SAMBA__
218 bin/nmblookup $CONFIGURATION __SAMBA__
219 bin/nmblookup $CONFIGURATION -U 127.255.255.255 __SAMBA__
220 bin/nmblookup $CONFIGURATION -U $SERVER_IP $SERVER
221 bin/nmblookup $CONFIGURATION $SERVER
222 # make sure smbd is also up set
223 echo "wait for smbd"
224 bin/smbclient $CONFIGURATION -L $SERVER_IP -U% -p 139 | head -2
225 bin/smbclient $CONFIGURATION -L $SERVER_IP -U% -p 139 | head -2
226
227 failed=0
228
229 . $SCRIPTDIR/tests_$TESTS.sh
230 exit $failed
231)
232failed=$?
233
234samba3_stop_sig_term
235
236END=`date`
237echo "START: $START ($0)";
238echo "END: $END ($0)";
239
240# if there were any valgrind failures, show them
241count=`find $PREFIX -name 'valgrind.log*' | wc -l`
242if [ "$count" != 0 ]; then
243 for f in $PREFIX/valgrind.log*; do
244 if [ -s $f ]; then
245 echo "VALGRIND FAILURE";
246 failed=`expr $failed + 1`
247 cat $f
248 fi
249 done
250fi
251
252sleep 2
253samba3_stop_sig_kill
254
255teststatus $0 $failed
Note: See TracBrowser for help on using the repository browser.