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 if [ ! "x$USER" = "x" ]; then
63 if [ ! "x$LOGNAME" = "x" ]; then
66 USERNAME
=`PATH=/usr/ucb:$PATH whoami || id -un`
69 USERID
=`PATH=/usr/ucb:$PATH id | cut -d ' ' -f1 | sed -e 's/uid=\([0-9]*\).*/\1/g'`
70 GROUPID
=`PATH=/usr/ucb:$PATH id | cut -d ' ' -f2 | sed -e 's/gid=\([0-9]*\).*/\1/g'`
73 SRCDIR
="`dirname $0`/../.."
75 SCRIPTDIR
=$SRCDIR/script
/tests
76 LIBDIR
=$PREFIX_ABS/lib
77 PIDDIR
=$PREFIX_ABS/pid
78 CONFFILE
=$LIBDIR/client.conf
79 SAMBA4CONFFILE
=$LIBDIR/samba4client.conf
80 SERVERCONFFILE
=$LIBDIR/server.conf
81 COMMONCONFFILE
=$LIBDIR/common.conf
82 PRIVATEDIR
=$PREFIX_ABS/private
83 NCALRPCDIR
=$PREFIX_ABS/ncalrpc
84 LOCKDIR
=$PREFIX_ABS/lockdir
85 LOGDIR
=$PREFIX_ABS/logs
86 SOCKET_WRAPPER_DIR
=$PREFIX_ABS/sw
87 CONFIGURATION
="--configfile $CONFFILE"
88 SAMBA4CONFIGURATION
="-s $SAMBA4CONFFILE"
89 NSS_WRAPPER_PASSWD
="$PRIVATEDIR/passwd"
90 NSS_WRAPPER_GROUP
="$PRIVATEDIR/group"
91 WINBINDD_SOCKET_DIR
=$PREFIX_ABS/winbindd
92 WINBINDD_PRIV_PIPE_DIR
=$LOCKDIR/winbindd_privileged
93 TEST_DIRECTORY
=$DIRECTORY
95 export PREFIX PREFIX_ABS
96 export CONFIGURATION CONFFILE SAMBA4CONFIGURATION SAMBA4CONFFILE
97 export PATH SOCKET_WRAPPER_DIR DOMAIN
98 export PRIVATEDIR LIBDIR PIDDIR LOCKDIR LOGDIR SERVERCONFFILE
99 export SRCDIR SCRIPTDIR BINDIR
100 export USERNAME PASSWORD
101 export WORKGROUP SERVER SERVER_IP
102 export NSS_WRAPPER_PASSWD NSS_WRAPPER_GROUP
103 export WINBINDD_SOCKET_DIR WINBINDD_PRIV_PIPE_DIR
104 export TEST_DIRECTORY
109 if [ $SMBTORTURE4 ]; then
110 SAMBA4BINDIR
=`dirname $SMBTORTURE4`
113 SAMBA4SHAREDDIR
="$SAMBA4BINDIR/shared"
115 export SAMBA4SHAREDDIR
118 if [ -z "$LIB_PATH_VAR" ] ; then
119 echo "Warning: LIB_PATH_VAR not set. Using best guess LD_LIBRARY_PATH." >&2
120 LIB_PATH_VAR
=LD_LIBRARY_PATH
124 eval $LIB_PATH_VAR=$BINDIR:$SAMBA4SHAREDDIR:\$
$LIB_PATH_VAR
128 ## verify that we were built with --enable-socket-wrapper
131 if test "x`smbd -b | grep SOCKET_WRAPPER`" = "x"; then
133 echo "*** You must include --enable-socket-wrapper when compiling Samba"
134 echo "*** in order to execute 'make test'. Exiting...."
139 if test "x`smbd -b | grep NSS_WRAPPER`" = "x"; then
141 echo "*** You must include --enable-nss-wrapper when compiling Samba"
142 echo "*** in order to execute 'make test'. Exiting...."
149 ## create the test directory layout
151 printf "%s" "CREATE TEST ENVIRONMENT IN '$PREFIX'"...
152 /bin
/rm -rf $PREFIX/*
153 mkdir
-p $PRIVATEDIR $NCALRPCDIR $LIBDIR $PIDDIR $LOCKDIR $LOGDIR
154 mkdir
-p $SOCKET_WRAPPER_DIR
155 mkdir
-p $WINBINDD_SOCKET_DIR
156 chmod 755 $WINBINDD_SOCKET_DIR
159 ## Create an alternate shrdir if one was specified.
161 if [ $ALT_SHRDIR_ARG ]; then
162 ALT_SHRDIR
=`echo $ALT_SHRDIR_ARG | sed s+//+/+`
163 mkdir
-p $ALT_SHRDIR ||
exit $?
165 cd $ALT_SHRDIR ||
exit $?
168 /bin
/rm -rf $SHRDIR/*
170 SHRDIR
=$PREFIX_ABS/tmp
176 ## Create the common config include file with the basic settings
179 cat >$COMMONCONFFILE<<EOF
180 workgroup = $WORKGROUP
182 private dir = $PRIVATEDIR
183 pid directory = $PIDDIR
184 lock directory = $LOCKDIR
185 log file = $LOGDIR/log.%m
188 name resolve order = bcast
191 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'
195 netbios name = TORTURE_6
196 interfaces = $TORTURE_INTERFACES
197 panic action = $SCRIPTDIR/gdb_backtrace %d %\$(MAKE_TEST_BINARY)
198 include = $COMMONCONFFILE
200 passdb backend = tdbsam
203 cat >$SAMBA4CONFFILE<<EOF
205 netbios name = TORTURE_6
206 interfaces = $TORTURE_INTERFACES
207 panic action = $SCRIPTDIR/gdb_backtrace %PID% %PROG%
208 include = $COMMONCONFFILE
209 modules dir = $SRCDIR/bin/modules
210 ncalrpc dir = $NCALRPCDIR
213 cat >$SERVERCONFFILE<<EOF
215 netbios name = $SERVER
216 interfaces = $SERVER_IP/8
217 bind interfaces only = yes
218 panic action = $SCRIPTDIR/gdb_backtrace %d %\$(MAKE_TEST_BINARY)
219 include = $COMMONCONFFILE
221 state directory = $LOCKDIR
222 cache directory = $LOCKDIR
224 passdb backend = tdbsam
231 add user script = $PERL $SRCDIR/../lib/nss_wrapper/nss_wrapper.pl --passwd_path $NSS_WRAPPER_PASSWD --type passwd --action add --name %u
232 add group script = $PERL $SRCDIR/../lib/nss_wrapper/nss_wrapper.pl --group_path $NSS_WRAPPER_GROUP --type group --action add --name %g
233 add user to group script = $PERL $SRCDIR/../lib/nss_wrapper/nss_wrapper.pl --group_path $NSS_WRAPPER_GROUP --type member --action add --name %g --member %u --passwd_path $NSS_WRAPPER_PASSWD
234 add machine script = $PERL $SRCDIR/../lib/nss_wrapper/nss_wrapper.pl --passwd_path $NSS_WRAPPER_PASSWD --type passwd --action add --name %u
235 delete user script = $PERL $SRCDIR/../lib/nss_wrapper/nss_wrapper.pl --passwd_path $NSS_WRAPPER_PASSWD --type passwd --action delete --name %u
236 delete group script = $PERL $SRCDIR/../lib/nss_wrapper/nss_wrapper.pl --group_path $NSS_WRAPPER_GROUP --type group --action delete --name %g
237 delete user from group script = $PERL $SRCDIR/../lib/nss_wrapper/nss_wrapper.pl --group_path $NSS_WRAPPER_GROUP --type member --action delete --name %g --member %u --passwd_path $NSS_WRAPPER_PASSWD
240 kernel change notify = no
244 printcap name = /dev/null
246 winbindd:socket dir = $WINBINDD_SOCKET_DIR
247 idmap uid = 100000-200000
248 idmap gid = 100000-200000
249 winbind enum users = yes
250 winbind enum groups = yes
252 # min receivefile size = 4000
255 smbd:sharedelay = 100000
256 # smbd:writetimeupdatedelay = 500000
260 store dos attributes = yes
262 store create time = yes
263 vfs objects = $BINDIR/xattr_tdb.so $BINDIR/streams_depot.so
265 #Include user defined custom parameters if set
272 hide unreadable = yes
278 hide unwriteable files = yes
283 print command = $BINDIR/vlp tdbfile=$LOCKDIR/vlp.tdb print %p %s
284 lpq command = $BINDIR/vlp tdbfile=$LOCKDIR/vlp.tdb lpq %p
285 lp rm command = $BINDIR/vlp tdbfile=$LOCKDIR/vlp.tdb lprm %p %j
286 lp pause command = $BINDIR/vlp tdbfile=$LOCKDIR/vlp.tdb lppause %p %j
287 lp resume command = $BINDIR/vlp tdbfile=$LOCKDIR/vlp.tdb lpresume %p %j
288 queue pause command = $BINDIR/vlp tdbfile=$LOCKDIR/vlp.tdb queuepause %p
289 queue resume command = $BINDIR/vlp tdbfile=$LOCKDIR/vlp.tdb queueresume %p
300 ## create a test account
303 cat >$NSS_WRAPPER_PASSWD<<EOF
304 root:x:65533:65532:root gecos:$PREFIX_ABS:/bin/false
305 nobody:x:65534:65533:nobody gecos:$PREFIX_ABS:/bin/false
306 $USERNAME:x:$USERID:$GROUPID:$USERNAME gecos:$PREFIX_ABS:/bin/false
309 cat >$NSS_WRAPPER_GROUP<<EOF
311 nogroup:x:65534:nobody
313 $USERNAME-group:x:$GROUPID:
316 MAKE_TEST_BINARY
="bin/smbpasswd"
317 export MAKE_TEST_BINARY
319 (echo $PASSWORD; echo $PASSWORD) | \
320 bin
/smbpasswd
-c $SERVERCONFFILE -L -s -a $USERNAME >/dev
/null ||
exit 1
326 SERVER_TEST_FIFO
="$PREFIX/server_test.fifo"
327 export SERVER_TEST_FIFO
328 NMBD_TEST_LOG
="$PREFIX/nmbd_test.log"
330 WINBINDD_TEST_LOG
="$PREFIX/winbindd_test.log"
331 export WINBINDD_TEST_LOG
332 SMBD_TEST_LOG
="$PREFIX/smbd_test.log"
335 # start off with 0 failures
339 .
$SCRIPTDIR/test_functions.sh
341 SOCKET_WRAPPER_DEFAULT_IFACE
=2
342 export SOCKET_WRAPPER_DEFAULT_IFACE
343 samba3_check_or_start
346 # ensure any one smbtorture call doesn't run too long
347 # and smbtorture will use 127.0.0.6 as source address by default
348 SOCKET_WRAPPER_DEFAULT_IFACE
=6
349 export SOCKET_WRAPPER_DEFAULT_IFACE
350 TORTURE4_OPTIONS
="$SAMBA4CONFIGURATION"
351 TORTURE4_OPTIONS
="$TORTURE4_OPTIONS --maximum-runtime=$TORTURE_MAXTIME"
352 TORTURE4_OPTIONS
="$TORTURE4_OPTIONS --target=samba3"
353 TORTURE4_OPTIONS
="$TORTURE4_OPTIONS --option=torture:localdir=$SHRDIR"
354 TORTURE4_OPTIONS
="$TORTURE4_OPTIONS --option=torture:winbindd_netbios_name=$SERVER"
355 export TORTURE4_OPTIONS
357 if [ x
"$RUN_FROM_BUILD_FARM" = x
"yes" ];then
358 TORTURE4_OPTIONS
="$TORTURE4_OPTIONS --option=torture:progress=no"
363 ## ready to go...now loop through the tests
368 # give time for nbt server to register its names
369 echo "delaying for nbt name registration"
371 # This will return quickly when things are up, but be slow if we need to wait for (eg) SSL init
372 MAKE_TEST_BINARY
="bin/nmblookup"
373 bin
/nmblookup
$CONFIGURATION -U $SERVER_IP __SAMBA__
374 bin
/nmblookup
$CONFIGURATION __SAMBA__
375 bin
/nmblookup
$CONFIGURATION -U 127.255.255.255 __SAMBA__
376 bin
/nmblookup
$CONFIGURATION -U $SERVER_IP $SERVER
377 bin
/nmblookup
$CONFIGURATION $SERVER
378 # make sure smbd is also up set
380 MAKE_TEST_BINARY
="bin/smbclient"
381 bin
/smbclient
$CONFIGURATION -L $SERVER_IP -U% -p 139 |
head -2
382 bin
/smbclient
$CONFIGURATION -L $SERVER_IP -U% -p 139 |
head -2
387 .
$SCRIPTDIR/tests_
$SUBTESTS.sh
395 echo "START: $START ($0)";
396 echo "END: $END ($0)";
398 # if there were any valgrind failures, show them
399 count
=`find $PREFIX -name 'valgrind.log*' | wc -l`
400 if [ "$count" != 0 ]; then
401 for f
in $PREFIX/valgrind.log
*; do
403 echo "VALGRIND FAILURE";
404 failed
=`expr $failed + 1`
413 teststatus
$0 $failed