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 LOCKDIR=$PREFIX_ABS/lockdir
84 LOGDIR=$PREFIX_ABS/logs
85 SOCKET_WRAPPER_DIR=$PREFIX/sw
86 CONFIGURATION="--configfile $CONFFILE"
87 SAMBA4CONFIGURATION="-s $SAMBA4CONFFILE"
88 NSS_WRAPPER_PASSWD="$PRIVATEDIR/passwd"
89 NSS_WRAPPER_GROUP="$PRIVATEDIR/group"
90 WINBINDD_SOCKET_DIR=$PREFIX_ABS/winbindd
91 WINBINDD_PRIV_PIPE_DIR=$LOCKDIR/winbindd_privileged
93 export PREFIX PREFIX_ABS
94 export CONFIGURATION CONFFILE SAMBA4CONFIGURATION SAMBA4CONFFILE
95 export PATH SOCKET_WRAPPER_DIR DOMAIN
96 export PRIVATEDIR LIBDIR PIDDIR LOCKDIR LOGDIR SERVERCONFFILE
97 export SRCDIR SCRIPTDIR BINDIR
98 export USERNAME PASSWORD
99 export WORKGROUP SERVER SERVER_IP
100 export NSS_WRAPPER_PASSWD NSS_WRAPPER_GROUP
101 export WINBINDD_SOCKET_DIR WINBINDD_PRIV_PIPE_DIR
106 if [ $SMBTORTURE4 ]; then
107 SAMBA4BINDIR=`dirname $SMBTORTURE4`
110 SAMBA4SHAREDDIR="$SAMBA4BINDIR/shared"
112 export SAMBA4SHAREDDIR
115 if [ -z "$LIB_PATH_VAR" ] ; then
116 echo "Warning: LIB_PATH_VAR not set. Using best guess LD_LIBRARY_PATH." >&2
117 LIB_PATH_VAR=LD_LIBRARY_PATH
121 eval $LIB_PATH_VAR=$BINDIR:$SAMBA4SHAREDDIR:\$$LIB_PATH_VAR
125 ## verify that we were built with --enable-socket-wrapper
128 if test "x`smbd -b | grep SOCKET_WRAPPER`" = "x"; then
130 echo "*** You must include --enable-socket-wrapper when compiling Samba"
131 echo "*** in order to execute 'make test'. Exiting...."
136 if test "x`smbd -b | grep NSS_WRAPPER`" = "x"; then
138 echo "*** You must include --enable-nss-wrapper when compiling Samba"
139 echo "*** in order to execute 'make test'. Exiting...."
146 ## create the test directory layout
148 printf "%s" "CREATE TEST ENVIRONMENT IN '$PREFIX'"...
149 /bin/rm -rf $PREFIX/*
150 mkdir -p $PRIVATEDIR $LIBDIR $PIDDIR $LOCKDIR $LOGDIR
151 mkdir -p $SOCKET_WRAPPER_DIR
152 mkdir -p $WINBINDD_SOCKET_DIR
153 chmod 755 $WINBINDD_SOCKET_DIR
156 ## Create an alternate shrdir if one was specified.
158 if [ $ALT_SHRDIR_ARG ]; then
159 ALT_SHRDIR=`echo $ALT_SHRDIR_ARG | sed s+//+/+`
160 mkdir -p $ALT_SHRDIR || exit $?
162 cd $ALT_SHRDIR || exit $?
165 /bin/rm -rf $SHRDIR/*
167 SHRDIR=$PREFIX_ABS/tmp
173 ## Create the common config include file with the basic settings
176 cat >$COMMONCONFFILE<<EOF
177 workgroup = $WORKGROUP
179 private dir = $PRIVATEDIR
180 pid directory = $PIDDIR
181 lock directory = $LOCKDIR
182 log file = $LOGDIR/log.%m
185 name resolve order = bcast
188 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'
192 netbios name = TORTURE_6
193 interfaces = $TORTURE_INTERFACES
194 panic action = $SCRIPTDIR/gdb_backtrace %d %\$(MAKE_TEST_BINARY)
195 include = $COMMONCONFFILE
197 passdb backend = tdbsam
200 cat >$SAMBA4CONFFILE<<EOF
202 netbios name = TORTURE_6
203 interfaces = $TORTURE_INTERFACES
204 panic action = $SCRIPTDIR/gdb_backtrace %PID% %PROG%
205 include = $COMMONCONFFILE
206 modules dir = $SRCDIR/bin/modules
209 cat >$SERVERCONFFILE<<EOF
211 netbios name = $SERVER
212 interfaces = $SERVER_IP/8
213 bind interfaces only = yes
214 panic action = $SCRIPTDIR/gdb_backtrace %d %\$(MAKE_TEST_BINARY)
215 include = $COMMONCONFFILE
217 state directory = $LOCKDIR
218 cache directory = $LOCKDIR
220 passdb backend = tdbsam
227 add user script = $PERL $SRCDIR/../lib/nss_wrapper/nss_wrapper.pl --passwd_path $NSS_WRAPPER_PASSWD --type passwd --action add --name %u
228 add group script = $PERL $SRCDIR/../lib/nss_wrapper/nss_wrapper.pl --group_path $NSS_WRAPPER_GROUP --type group --action add --name %g
229 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
230 add machine script = $PERL $SRCDIR/../lib/nss_wrapper/nss_wrapper.pl --passwd_path $NSS_WRAPPER_PASSWD --type passwd --action add --name %u
231 delete user script = $PERL $SRCDIR/../lib/nss_wrapper/nss_wrapper.pl --passwd_path $NSS_WRAPPER_PASSWD --type passwd --action delete --name %u
232 delete group script = $PERL $SRCDIR/../lib/nss_wrapper/nss_wrapper.pl --group_path $NSS_WRAPPER_GROUP --type group --action delete --name %g
233 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
236 kernel change notify = no
240 printcap name = /dev/null
242 winbindd:socket dir = $WINBINDD_SOCKET_DIR
243 idmap uid = 100000-200000
244 idmap gid = 100000-200000
246 # min receivefile size = 4000
249 smbd:sharedelay = 100000
250 smbd:writetimeupdatedelay = 500000
254 store dos attributes = yes
256 store create time = yes
257 vfs objects = $BINDIR/xattr_tdb.so $BINDIR/streams_depot.so
259 #Include user defined custom parameters if set
266 hide unreadable = yes
269 hide unwriteable files = yes
274 print command = $BINDIR/vlp tdbfile=$LOCKDIR/vlp.tdb print %p %s
275 lpq command = $BINDIR/vlp tdbfile=$LOCKDIR/vlp.tdb lpq %p
276 lp rm command = $BINDIR/vlp tdbfile=$LOCKDIR/vlp.tdb lprm %p %j
277 lp pause command = $BINDIR/vlp tdbfile=$LOCKDIR/vlp.tdb lppause %p %j
278 lp resume command = $BINDIR/vlp tdbfile=$LOCKDIR/vlp.tdb lpresume %p %j
279 queue pause command = $BINDIR/vlp tdbfile=$LOCKDIR/vlp.tdb queuepause %p
280 queue resume command = $BINDIR/vlp tdbfile=$LOCKDIR/vlp.tdb queueresume %p
291 ## create a test account
294 cat >$NSS_WRAPPER_PASSWD<<EOF
295 root:x:65533:65532:root gecos:$PREFIX_ABS:/bin/false
296 nobody:x:65534:65533:nobody gecos:$PREFIX_ABS:/bin/false
297 $USERNAME:x:$USERID:$GROUPID:$USERNAME gecos:$PREFIX_ABS:/bin/false
300 cat >$NSS_WRAPPER_GROUP<<EOF
302 nogroup:x:65534:nobody
304 $USERNAME-group:x:$GROUPID:
307 MAKE_TEST_BINARY="bin/smbpasswd"
308 export MAKE_TEST_BINARY
310 (echo $PASSWORD; echo $PASSWORD) | \
311 bin/smbpasswd -c $SERVERCONFFILE -L -s -a $USERNAME >/dev/null || exit 1
317 SERVER_TEST_FIFO="$PREFIX/server_test.fifo"
318 export SERVER_TEST_FIFO
319 NMBD_TEST_LOG="$PREFIX/nmbd_test.log"
321 WINBINDD_TEST_LOG="$PREFIX/winbindd_test.log"
322 export WINBINDD_TEST_LOG
323 SMBD_TEST_LOG="$PREFIX/smbd_test.log"
326 # start off with 0 failures
330 . $SCRIPTDIR/test_functions.sh
332 SOCKET_WRAPPER_DEFAULT_IFACE=2
333 export SOCKET_WRAPPER_DEFAULT_IFACE
334 samba3_check_or_start
337 # ensure any one smbtorture call doesn't run too long
338 # and smbtorture will use 127.0.0.6 as source address by default
339 SOCKET_WRAPPER_DEFAULT_IFACE=6
340 export SOCKET_WRAPPER_DEFAULT_IFACE
341 TORTURE4_OPTIONS="$SAMBA4CONFIGURATION"
342 TORTURE4_OPTIONS="$TORTURE4_OPTIONS --maximum-runtime=$TORTURE_MAXTIME"
343 TORTURE4_OPTIONS="$TORTURE4_OPTIONS --target=samba3"
344 TORTURE4_OPTIONS="$TORTURE4_OPTIONS --option=torture:localdir=$SHRDIR"
345 export TORTURE4_OPTIONS
347 if [ x"$RUN_FROM_BUILD_FARM" = x"yes" ];then
348 TORTURE4_OPTIONS="$TORTURE4_OPTIONS --option=torture:progress=no"
353 ## ready to go...now loop through the tests
358 # give time for nbt server to register its names
359 echo "delaying for nbt name registration"
361 # This will return quickly when things are up, but be slow if we need to wait for (eg) SSL init
362 MAKE_TEST_BINARY="bin/nmblookup"
363 bin/nmblookup $CONFIGURATION -U $SERVER_IP __SAMBA__
364 bin/nmblookup $CONFIGURATION __SAMBA__
365 bin/nmblookup $CONFIGURATION -U 127.255.255.255 __SAMBA__
366 bin/nmblookup $CONFIGURATION -U $SERVER_IP $SERVER
367 bin/nmblookup $CONFIGURATION $SERVER
368 # make sure smbd is also up set
370 MAKE_TEST_BINARY="bin/smbclient"
371 bin/smbclient $CONFIGURATION -L $SERVER_IP -U% -p 139 | head -2
372 bin/smbclient $CONFIGURATION -L $SERVER_IP -U% -p 139 | head -2
377 . $SCRIPTDIR/tests_$SUBTESTS.sh
385 echo "START: $START ($0)";
386 echo "END: $END ($0)";
388 # if there were any valgrind failures, show them
389 count=`find $PREFIX -name 'valgrind.log*' | wc -l`
390 if [ "$count" != 0 ]; then
391 for f in $PREFIX/valgrind.log*; do
393 echo "VALGRIND FAILURE";
394 failed=`expr $failed + 1`
403 teststatus $0 $failed