4 echo "$0 <directory> <all | quick> [-t <smbtorture4>] [-s <shrdir>] " \
10 ## Setup the required args
16 ## Parse oprtional args
18 while getopts s
:c
:t
: f
21 t
) SMBTORTURE4
=$OPTARG;;
22 s
) ALT_SHRDIR_ARG
=$OPTARG;;
23 c
) CUSTOM_CONF_ARG
=$OPTARG;;
27 echo "Running selftest with the following"
28 echo "Selftest Directory: $DIRECTORY"
29 echo "Subtests to Run: $SUBTESTS"
30 echo "smbtorture4 Path: $SMBTORTURE4"
31 echo "Alternative Share Dir: $ALT_SHRDIR_ARG"
32 echo "Custom Configuration: $CUSTOM_CONF_ARG"
34 if [ $CUSTOM_CONF_ARG ]; then
35 INCLUDE_CUSTOM_CONF
="include = $CUSTOM_CONF_ARG"
39 ## create the test directory
41 PREFIX
=`echo $DIRECTORY | sed s+//+/+`
42 mkdir
-p $PREFIX ||
exit $?
48 if [ -z "$TORTURE_MAXTIME" ]; then
51 export TORTURE_MAXTIME
54 ## setup the various environment variables we need
60 USERNAME
=`PATH=/usr/ucb:$PATH whoami`
61 USERID
=`PATH=/usr/ucb:$PATH id | cut -d ' ' -f1 | sed -e 's/uid=\([0-9]*\).*/\1/g'`
62 GROUPID
=`PATH=/usr/ucb:$PATH id | cut -d ' ' -f2 | sed -e 's/gid=\([0-9]*\).*/\1/g'`
65 SRCDIR
="`dirname $0`/../.."
67 SCRIPTDIR
=$SRCDIR/script
/tests
68 LIBDIR
=$PREFIX_ABS/lib
69 PIDDIR
=$PREFIX_ABS/pid
70 CONFFILE
=$LIBDIR/client.conf
71 SAMBA4CONFFILE
=$LIBDIR/samba4client.conf
72 SERVERCONFFILE
=$LIBDIR/server.conf
73 COMMONCONFFILE
=$LIBDIR/common.conf
74 PRIVATEDIR
=$PREFIX_ABS/private
75 LOCKDIR
=$PREFIX_ABS/lockdir
76 LOGDIR
=$PREFIX_ABS/logs
77 SOCKET_WRAPPER_DIR
=$PREFIX/sw
78 CONFIGURATION
="--configfile $CONFFILE"
79 SAMBA4CONFIGURATION
="-s $SAMBA4CONFFILE"
80 NSS_WRAPPER_PASSWD
="$PRIVATEDIR/passwd"
81 NSS_WRAPPER_GROUP
="$PRIVATEDIR/group"
82 WINBINDD_SOCKET_DIR
=$PREFIX_ABS/winbindd
83 WINBINDD_PRIV_PIPE_DIR
=$LOCKDIR/winbindd_privileged
85 export PREFIX PREFIX_ABS
86 export CONFIGURATION CONFFILE SAMBA4CONFIGURATION SAMBA4CONFFILE
87 export PATH SOCKET_WRAPPER_DIR DOMAIN
88 export PRIVATEDIR LIBDIR PIDDIR LOCKDIR LOGDIR SERVERCONFFILE
89 export SRCDIR SCRIPTDIR BINDIR
90 export USERNAME PASSWORD
91 export WORKGROUP SERVER SERVER_IP
92 export NSS_WRAPPER_PASSWD NSS_WRAPPER_GROUP
93 export WINBINDD_SOCKET_DIR WINBINDD_PRIV_PIPE_DIR
98 if [ $SMBTORTURE4 ]; then
99 SAMBA4BINDIR
=`dirname $SMBTORTURE4`
102 SAMBA4SHAREDDIR
="$SAMBA4BINDIR/shared"
104 export SAMBA4SHAREDDIR
107 if test x
"$LD_LIBRARY_PATH" != x
""; then
108 LD_LIBRARY_PATH
="$BINDIR:$SAMBA4SHAREDDIR:$LD_LIBRARY_PATH"
110 LD_LIBRARY_PATH
="$BINDIR:$SAMBA4SHAREDDIR"
112 echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH"
113 export LD_LIBRARY_PATH
116 ## verify that we were built with --enable-socket-wrapper
119 if test "x`smbd -b | grep SOCKET_WRAPPER`" = "x"; then
121 echo "*** You must include --enable-socket-wrapper when compiling Samba"
122 echo "*** in order to execute 'make test'. Exiting...."
127 if test "x`smbd -b | grep NSS_WRAPPER`" = "x"; then
129 echo "*** You must include --enable-nss-wrapper when compiling Samba"
130 echo "*** in order to execute 'make test'. Exiting...."
137 ## create the test directory layout
139 printf "%s" "CREATE TEST ENVIRONMENT IN '$PREFIX'"...
140 /bin
/rm -rf $PREFIX/*
141 mkdir
-p $PRIVATEDIR $LIBDIR $PIDDIR $LOCKDIR $LOGDIR
142 mkdir
-p $SOCKET_WRAPPER_DIR
143 mkdir
-p $WINBINDD_SOCKET_DIR
144 chmod 755 $WINBINDD_SOCKET_DIR
147 ## Create an alternate shrdir if one was specified.
149 if [ $ALT_SHRDIR_ARG ]; then
150 ALT_SHRDIR
=`echo $ALT_SHRDIR_ARG | sed s+//+/+`
151 mkdir
-p $ALT_SHRDIR ||
exit $?
153 cd $ALT_SHRDIR ||
exit $?
156 /bin
/rm -rf $SHRDIR/*
158 SHRDIR
=$PREFIX_ABS/tmp
164 ## Create the common config include file with the basic settings
167 cat >$COMMONCONFFILE<<EOF
168 workgroup = $WORKGROUP
170 private dir = $PRIVATEDIR
171 pid directory = $PIDDIR
172 lock directory = $LOCKDIR
173 log file = $LOGDIR/log.%m
176 name resolve order = bcast
179 TORTURE_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'
183 netbios name = TORTURE_6
184 interfaces = $TORTURE_INTERFACES
185 panic action = $SCRIPTDIR/gdb_backtrace %d %\$(MAKE_TEST_BINARY)
186 include = $COMMONCONFFILE
188 passdb backend = tdbsam
191 cat >$SAMBA4CONFFILE<<EOF
193 netbios name = TORTURE_6
194 interfaces = $TORTURE_INTERFACES
195 panic action = $SCRIPTDIR/gdb_backtrace %PID% %PROG%
196 include = $COMMONCONFFILE
197 modules dir = $SRCDIR/bin/modules
200 cat >$SERVERCONFFILE<<EOF
202 netbios name = $SERVER
203 interfaces = $SERVER_IP/8
204 bind interfaces only = yes
205 panic action = $SCRIPTDIR/gdb_backtrace %d %\$(MAKE_TEST_BINARY)
206 include = $COMMONCONFFILE
208 state directory = $LOCKDIR
209 cache directory = $LOCKDIR
211 passdb backend = tdbsam
217 add user script = $PERL $SRCDIR/../lib/nss_wrapper/nss_wrapper.pl --path $NSS_WRAPPER_PASSWD --type passwd --action add --name %u
218 add machine script = $PERL $SRCDIR/../lib/nss_wrapper/nss_wrapper.pl --path $NSS_WRAPPER_PASSWD --type passwd --action add --name %u
219 delete user script = $PERL $SRCDIR/../lib/nss_wrapper/nss_wrapper.pl --path $NSS_WRAPPER_PASSWD --type passwd --action delete --name %u
222 kernel change notify = no
226 printcap name = /dev/null
228 winbindd:socket dir = $WINBINDD_SOCKET_DIR
229 idmap uid = 100000-200000
230 idmap gid = 100000-200000
232 # min receivefile size = 4000
235 smbd:sharedelay = 100000
236 smbd:writetimeupdatedelay = 500000
240 vfs objects = $BINDIR/xattr_tdb.so $BINDIR/streams_depot.so
242 #Include user defined custom parameters if set
249 hide unreadable = yes
252 hide unwriteable files = yes
266 ## create a test account
269 cat >$NSS_WRAPPER_PASSWD<<EOF
270 nobody:x:65534:65533:nobody gecos:$PREFIX_ABS:/bin/false
271 $USERNAME:x:$USERID:$GROUPID:$USERNAME gecos:$PREFIX_ABS:/bin/false
274 cat >$NSS_WRAPPER_GROUP<<EOF
276 nogroup:x:65534:nobody
277 $USERNAME-group:x:$GROUPID:
280 MAKE_TEST_BINARY
="bin/smbpasswd"
281 export MAKE_TEST_BINARY
283 (echo $PASSWORD; echo $PASSWORD) | \
284 bin
/smbpasswd
-c $CONFFILE -L -s -a $USERNAME >/dev
/null ||
exit 1
290 SERVER_TEST_FIFO
="$PREFIX/server_test.fifo"
291 export SERVER_TEST_FIFO
292 NMBD_TEST_LOG
="$PREFIX/nmbd_test.log"
294 WINBINDD_TEST_LOG
="$PREFIX/winbindd_test.log"
295 export WINBINDD_TEST_LOG
296 SMBD_TEST_LOG
="$PREFIX/smbd_test.log"
299 # start off with 0 failures
303 .
$SCRIPTDIR/test_functions.sh
305 SOCKET_WRAPPER_DEFAULT_IFACE
=2
306 export SOCKET_WRAPPER_DEFAULT_IFACE
307 samba3_check_or_start
310 # ensure any one smbtorture call doesn't run too long
311 # and smbtorture will use 127.0.0.6 as source address by default
312 SOCKET_WRAPPER_DEFAULT_IFACE
=6
313 export SOCKET_WRAPPER_DEFAULT_IFACE
314 TORTURE4_OPTIONS
="$SAMBA4CONFIGURATION"
315 TORTURE4_OPTIONS
="$TORTURE4_OPTIONS --maximum-runtime=$TORTURE_MAXTIME"
316 TORTURE4_OPTIONS
="$TORTURE4_OPTIONS --target=samba3"
317 TORTURE4_OPTIONS
="$TORTURE4_OPTIONS --option=torture:localdir=$SHRDIR"
318 export TORTURE4_OPTIONS
320 if [ x
"$RUN_FROM_BUILD_FARM" = x
"yes" ];then
321 TORTURE4_OPTIONS
="$TORTURE4_OPTIONS --option=torture:progress=no"
326 ## ready to go...now loop through the tests
331 # give time for nbt server to register its names
332 echo "delaying for nbt name registration"
334 # This will return quickly when things are up, but be slow if we need to wait for (eg) SSL init
335 MAKE_TEST_BINARY
="bin/nmblookup"
336 bin
/nmblookup
$CONFIGURATION -U $SERVER_IP __SAMBA__
337 bin
/nmblookup
$CONFIGURATION __SAMBA__
338 bin
/nmblookup
$CONFIGURATION -U 127.255.255.255 __SAMBA__
339 bin
/nmblookup
$CONFIGURATION -U $SERVER_IP $SERVER
340 bin
/nmblookup
$CONFIGURATION $SERVER
341 # make sure smbd is also up set
343 MAKE_TEST_BINARY
="bin/smbclient"
344 bin
/smbclient
$CONFIGURATION -L $SERVER_IP -U% -p 139 |
head -2
345 bin
/smbclient
$CONFIGURATION -L $SERVER_IP -U% -p 139 |
head -2
350 .
$SCRIPTDIR/tests_
$SUBTESTS.sh
358 echo "START: $START ($0)";
359 echo "END: $END ($0)";
361 # if there were any valgrind failures, show them
362 count
=`find $PREFIX -name 'valgrind.log*' | wc -l`
363 if [ "$count" != 0 ]; then
364 for f
in $PREFIX/valgrind.log
*; do
366 echo "VALGRIND FAILURE";
367 failed
=`expr $failed + 1`
376 teststatus
$0 $failed