s4:torture/rpc/samba3rpc.c: make use of dcerpc_binding_handle stubs
[Samba/nascimento.git] / source3 / script / tests / selftest.sh
blobe49bca863b1712784b4fcc442d116eb580ef7fff
1 #!/bin/sh
3 if [ $# -lt 2 ]; then
4 echo "$0 <directory> <all | quick> [-t <smbtorture4>] [-s <shrdir>] " \
5 "[-c <custom conf>]"
6 exit 1
7 fi
9 ##
10 ## Setup the required args
12 DIRECTORY=$1; shift;
13 SUBTESTS=$1; shift;
16 ## Parse oprtional args
18 while getopts s:c:t: f
20 case $f in
21 t) SMBTORTURE4=$OPTARG;;
22 s) ALT_SHRDIR_ARG=$OPTARG;;
23 c) CUSTOM_CONF_ARG=$OPTARG;;
24 esac
25 done
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 layout
41 PREFIX=`echo $DIRECTORY | sed s+//+/+`
42 printf "%s" "CREATE TEST ENVIRONMENT IN '$PREFIX'"...
43 /bin/rm -rf $PREFIX
44 if [ -e "$PREFIX" ]; then
45 echo "***"
46 echo "*** Failed to delete test environment $PREFIX"
47 echo "*** Was a previous run done as root ?"
48 echo "***"
49 exit 1
53 ## create the test directory
55 mkdir -p $PREFIX || exit $?
56 OLD_PWD=`pwd`
57 cd $PREFIX || exit $?
58 PREFIX_ABS=`pwd`
59 cd $OLD_PWD
61 if [ -z "$TORTURE_MAXTIME" ]; then
62 TORTURE_MAXTIME=300
64 export TORTURE_MAXTIME
67 ## setup the various environment variables we need
70 WORKGROUP=SAMBA-TEST
71 SERVER=localhost2
72 SERVER_IP=127.0.0.2
73 if [ ! "x$USER" = "x" ]; then
74 USERNAME=$USER
75 else
76 if [ ! "x$LOGNAME" = "x" ]; then
77 USERNAME=$LOGNAME
78 else
79 USERNAME=`PATH=/usr/ucb:$PATH whoami || id -un`
82 USERID=`PATH=/usr/ucb:$PATH id | cut -d ' ' -f1 | sed -e 's/uid=\([0-9]*\).*/\1/g'`
83 GROUPID=`PATH=/usr/ucb:$PATH id | cut -d ' ' -f2 | sed -e 's/gid=\([0-9]*\).*/\1/g'`
84 PASSWORD=test
86 SRCDIR="`dirname $0`/../.."
87 BINDIR="`pwd`/bin"
88 SCRIPTDIR=$SRCDIR/script/tests
89 LIBDIR=$PREFIX_ABS/lib
90 PIDDIR=$PREFIX_ABS/pid
91 CONFFILE=$LIBDIR/client.conf
92 SAMBA4CONFFILE=$LIBDIR/samba4client.conf
93 SERVERCONFFILE=$LIBDIR/server.conf
94 COMMONCONFFILE=$LIBDIR/common.conf
95 PRIVATEDIR=$PREFIX_ABS/private
96 NCALRPCDIR=$PREFIX_ABS/ncalrpc
97 LOCKDIR=$PREFIX_ABS/lockdir
98 LOGDIR=$PREFIX_ABS/logs
99 SOCKET_WRAPPER_DIR=$PREFIX_ABS/sw
100 CONFIGURATION="--configfile $CONFFILE"
101 SAMBA4CONFIGURATION="-s $SAMBA4CONFFILE"
102 NSS_WRAPPER_PASSWD="$PRIVATEDIR/passwd"
103 NSS_WRAPPER_GROUP="$PRIVATEDIR/group"
104 WINBINDD_SOCKET_DIR=$PREFIX_ABS/winbindd
105 WINBINDD_PRIV_PIPE_DIR=$LOCKDIR/winbindd_privileged
106 TEST_DIRECTORY=$DIRECTORY
108 export PREFIX PREFIX_ABS
109 export CONFIGURATION CONFFILE SAMBA4CONFIGURATION SAMBA4CONFFILE
110 export PATH SOCKET_WRAPPER_DIR DOMAIN
111 export PRIVATEDIR LIBDIR PIDDIR LOCKDIR LOGDIR SERVERCONFFILE
112 export SRCDIR SCRIPTDIR BINDIR
113 export USERNAME PASSWORD
114 export WORKGROUP SERVER SERVER_IP
115 export NSS_WRAPPER_PASSWD NSS_WRAPPER_GROUP
116 export WINBINDD_SOCKET_DIR WINBINDD_PRIV_PIPE_DIR
117 export TEST_DIRECTORY
119 PATH=bin:$PATH
120 export PATH
122 if [ $SMBTORTURE4 ]; then
123 SAMBA4BINDIR=`dirname $SMBTORTURE4`
126 SAMBA4SHAREDDIR="$SAMBA4BINDIR/shared"
128 export SAMBA4SHAREDDIR
129 export SMBTORTURE4
131 if [ -z "$LIB_PATH_VAR" ] ; then
132 echo "Warning: LIB_PATH_VAR not set. Using best guess LD_LIBRARY_PATH." >&2
133 LIB_PATH_VAR=LD_LIBRARY_PATH
134 export LIB_PATH_VAR
137 eval $LIB_PATH_VAR=$BINDIR:$SAMBA4SHAREDDIR:\$$LIB_PATH_VAR
138 export $LIB_PATH_VAR
141 ## verify that we were built with --enable-socket-wrapper
144 if test "x`smbd -b | grep SOCKET_WRAPPER`" = "x"; then
145 echo "***"
146 echo "*** You must include --enable-socket-wrapper when compiling Samba"
147 echo "*** in order to execute 'make test'. Exiting...."
148 echo "***"
149 exit 1
152 if test "x`smbd -b | grep NSS_WRAPPER`" = "x"; then
153 echo "***"
154 echo "*** You must include --enable-nss-wrapper when compiling Samba"
155 echo "*** in order to execute 'make test'. Exiting...."
156 echo "***"
157 exit 1
161 mkdir -p $PRIVATEDIR $NCALRPCDIR $LIBDIR $PIDDIR $LOCKDIR $LOGDIR
162 mkdir -p $SOCKET_WRAPPER_DIR
163 mkdir -p $WINBINDD_SOCKET_DIR
164 chmod 755 $WINBINDD_SOCKET_DIR
167 ## Create an alternate shrdir if one was specified.
169 if [ $ALT_SHRDIR_ARG ]; then
170 ALT_SHRDIR=`echo $ALT_SHRDIR_ARG | sed s+//+/+`
171 mkdir -p $ALT_SHRDIR || exit $?
172 OLD_PWD=`pwd`
173 cd $ALT_SHRDIR || exit $?
174 SHRDIR=`pwd`
175 cd $OLD_PWD
176 /bin/rm -rf $SHRDIR/*
177 else
178 SHRDIR=$PREFIX_ABS/tmp
179 mkdir -p $SHRDIR
181 chmod 777 $SHRDIR
184 ## Create a read-only directory.
186 RO_SHRDIR=`echo $SHRDIR | sed -e 's:/[^/]*$::'`
187 RO_SHRDIR=$RO_SHRDIR/root-tmp
188 mkdir -p $RO_SHRDIR
189 chmod 755 $RO_SHRDIR
190 touch $RO_SHRDIR/unreadable_file
191 chmod 600 $RO_SHRDIR/unreadable_file
194 ## Create the common config include file with the basic settings
197 cat >$COMMONCONFFILE<<EOF
198 workgroup = $WORKGROUP
200 private dir = $PRIVATEDIR
201 pid directory = $PIDDIR
202 lock directory = $LOCKDIR
203 log file = $LOGDIR/log.%m
204 log level = 0
206 name resolve order = bcast
209 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'
211 cat >$CONFFILE<<EOF
212 [global]
213 netbios name = TORTURE_6
214 interfaces = $TORTURE_INTERFACES
215 panic action = $SCRIPTDIR/gdb_backtrace %d %\$(MAKE_TEST_BINARY)
216 include = $COMMONCONFFILE
218 passdb backend = tdbsam
221 cat >$SAMBA4CONFFILE<<EOF
222 [global]
223 netbios name = TORTURE_6
224 interfaces = $TORTURE_INTERFACES
225 panic action = $SCRIPTDIR/gdb_backtrace %PID% %PROG%
226 include = $COMMONCONFFILE
227 modules dir = $SRCDIR/bin/modules
228 ncalrpc dir = $NCALRPCDIR
231 cat >$SERVERCONFFILE<<EOF
232 [global]
233 netbios name = $SERVER
234 interfaces = $SERVER_IP/8
235 bind interfaces only = yes
236 panic action = $SCRIPTDIR/gdb_backtrace %d %\$(MAKE_TEST_BINARY)
237 include = $COMMONCONFFILE
239 state directory = $LOCKDIR
240 cache directory = $LOCKDIR
242 passdb backend = tdbsam
244 domain master = yes
245 domain logons = yes
246 lanman auth = yes
247 time server = yes
249 add user script = $PERL $SRCDIR/../lib/nss_wrapper/nss_wrapper.pl --passwd_path $NSS_WRAPPER_PASSWD --type passwd --action add --name %u
250 add group script = $PERL $SRCDIR/../lib/nss_wrapper/nss_wrapper.pl --group_path $NSS_WRAPPER_GROUP --type group --action add --name %g
251 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
252 add machine script = $PERL $SRCDIR/../lib/nss_wrapper/nss_wrapper.pl --passwd_path $NSS_WRAPPER_PASSWD --type passwd --action add --name %u
253 delete user script = $PERL $SRCDIR/../lib/nss_wrapper/nss_wrapper.pl --passwd_path $NSS_WRAPPER_PASSWD --type passwd --action delete --name %u
254 delete group script = $PERL $SRCDIR/../lib/nss_wrapper/nss_wrapper.pl --group_path $NSS_WRAPPER_GROUP --type group --action delete --name %g
255 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
257 addprinter command = $PERL $SRCDIR/../source3/script/tests/printing/modprinter.pl -a -s $SERVERCONFFILE --
258 deleteprinter command = $PERL $SRCDIR/../source3/script/tests/printing/modprinter.pl -d -s $SERVERCONFFILE --
260 kernel oplocks = no
261 kernel change notify = no
263 syslog = no
264 printing = bsd
265 printcap name = /dev/null
267 winbindd:socket dir = $WINBINDD_SOCKET_DIR
268 idmap uid = 100000-200000
269 idmap gid = 100000-200000
270 winbind enum users = yes
271 winbind enum groups = yes
273 # min receivefile size = 4000
275 read only = no
276 smbd:sharedelay = 100000
277 # smbd:writetimeupdatedelay = 500000
278 map hidden = no
279 map system = no
280 map readonly = no
281 store dos attributes = yes
282 create mask = 755
283 vfs objects = $BINDIR/xattr_tdb.so $BINDIR/streams_depot.so
285 #Include user defined custom parameters if set
286 $INCLUDE_CUSTOM_CONF
288 [tmp]
289 path = $SHRDIR
290 [ro-tmp]
291 path = $RO_SHRDIR
292 guest ok = yes
293 [hideunread]
294 copy = tmp
295 hide unreadable = yes
296 [tmpcase]
297 copy = tmp
298 case sensitive = yes
299 [hideunwrite]
300 copy = tmp
301 hide unwriteable files = yes
302 [print1]
303 copy = tmp
304 printable = yes
305 printing = vlp
306 print command = $BINDIR/vlp tdbfile=$LOCKDIR/vlp.tdb print %p %s
307 lpq command = $BINDIR/vlp tdbfile=$LOCKDIR/vlp.tdb lpq %p
308 lp rm command = $BINDIR/vlp tdbfile=$LOCKDIR/vlp.tdb lprm %p %j
309 lp pause command = $BINDIR/vlp tdbfile=$LOCKDIR/vlp.tdb lppause %p %j
310 lp resume command = $BINDIR/vlp tdbfile=$LOCKDIR/vlp.tdb lpresume %p %j
311 queue pause command = $BINDIR/vlp tdbfile=$LOCKDIR/vlp.tdb queuepause %p
312 queue resume command = $BINDIR/vlp tdbfile=$LOCKDIR/vlp.tdb queueresume %p
314 [print2]
315 copy = print1
316 [print3]
317 copy = print1
318 [print4]
319 copy = print1
323 ## create a test account
326 if [ "$USERID" != 0 ]; then
327 cat >$NSS_WRAPPER_PASSWD<<EOF
328 root:x:65533:65532:root gecos:$PREFIX_ABS:/bin/false
329 nobody:x:65534:65533:nobody gecos:$PREFIX_ABS:/bin/false
330 $USERNAME:x:$USERID:$GROUPID:$USERNAME gecos:$PREFIX_ABS:/bin/false
333 cat >$NSS_WRAPPER_GROUP<<EOF
334 nobody:x:65533:
335 nogroup:x:65534:nobody
336 root:x:65532:
337 $USERNAME-group:x:$GROUPID:
339 else
341 ## Running as root...
343 cat >$NSS_WRAPPER_PASSWD<<EOF
344 $USERNAME:x:$USERID:$GROUPID:$USERNAME gecos:$PREFIX_ABS:/bin/false
345 nobody:x:65534:65533:nobody gecos:$PREFIX_ABS:/bin/false
348 cat >$NSS_WRAPPER_GROUP<<EOF
349 $USERNAME-group:x:$GROUPID:
350 nobody:x:65533:
351 nogroup:x:65534:nobody
355 MAKE_TEST_BINARY="bin/smbpasswd"
356 export MAKE_TEST_BINARY
358 (echo $PASSWORD; echo $PASSWORD) | \
359 bin/smbpasswd -c $SERVERCONFFILE -L -s -a $USERNAME >/dev/null || exit 1
361 echo "DONE";
363 MAKE_TEST_BINARY=""
365 SERVER_TEST_FIFO="$PREFIX/server_test.fifo"
366 export SERVER_TEST_FIFO
367 NMBD_TEST_LOG="$PREFIX/nmbd_test.log"
368 export NMBD_TEST_LOG
369 WINBINDD_TEST_LOG="$PREFIX/winbindd_test.log"
370 export WINBINDD_TEST_LOG
371 SMBD_TEST_LOG="$PREFIX/smbd_test.log"
372 export SMBD_TEST_LOG
374 # start off with 0 failures
375 failed=0
376 export failed
378 . $SCRIPTDIR/test_functions.sh
380 SOCKET_WRAPPER_DEFAULT_IFACE=2
381 export SOCKET_WRAPPER_DEFAULT_IFACE
382 samba3_check_or_start
385 # ensure any one smbtorture call doesn't run too long
386 # and smbtorture will use 127.0.0.6 as source address by default
387 SOCKET_WRAPPER_DEFAULT_IFACE=6
388 export SOCKET_WRAPPER_DEFAULT_IFACE
389 TORTURE4_OPTIONS="$SAMBA4CONFIGURATION"
390 TORTURE4_OPTIONS="$TORTURE4_OPTIONS --maximum-runtime=$TORTURE_MAXTIME"
391 TORTURE4_OPTIONS="$TORTURE4_OPTIONS --target=samba3"
392 TORTURE4_OPTIONS="$TORTURE4_OPTIONS --option=torture:localdir=$SHRDIR"
393 TORTURE4_OPTIONS="$TORTURE4_OPTIONS --option=torture:winbindd_netbios_name=$SERVER"
394 export TORTURE4_OPTIONS
396 if [ x"$RUN_FROM_BUILD_FARM" = x"yes" ];then
397 TORTURE4_OPTIONS="$TORTURE4_OPTIONS --option=torture:progress=no"
402 ## ready to go...now loop through the tests
405 START=`date`
407 # give time for nbt server to register its names
408 echo "delaying for nbt name registration"
409 sleep 10
410 # This will return quickly when things are up, but be slow if we need to wait for (eg) SSL init
411 MAKE_TEST_BINARY="bin/nmblookup"
412 bin/nmblookup $CONFIGURATION -U $SERVER_IP __SAMBA__
413 bin/nmblookup $CONFIGURATION __SAMBA__
414 bin/nmblookup $CONFIGURATION -U 127.255.255.255 __SAMBA__
415 bin/nmblookup $CONFIGURATION -U $SERVER_IP $SERVER
416 bin/nmblookup $CONFIGURATION $SERVER
417 # make sure smbd is also up set
418 echo "wait for smbd"
419 MAKE_TEST_BINARY="bin/smbclient"
420 bin/smbclient $CONFIGURATION -L $SERVER_IP -U% -p 139 | head -2
421 bin/smbclient $CONFIGURATION -L $SERVER_IP -U% -p 139 | head -2
422 MAKE_TEST_BINARY=""
424 failed=0
426 . $SCRIPTDIR/tests_$SUBTESTS.sh
427 exit $failed
429 failed=$?
431 samba3_stop_sig_term
433 END=`date`
434 echo "START: $START ($0)";
435 echo "END: $END ($0)";
437 # if there were any valgrind failures, show them
438 count=`find $PREFIX -name 'valgrind.log*' | wc -l`
439 if [ "$count" != 0 ]; then
440 for f in $PREFIX/valgrind.log*; do
441 if [ -s $f ]; then
442 echo "VALGRIND FAILURE";
443 failed=`expr $failed + 1`
444 cat $f
446 done
449 sleep 2
450 samba3_stop_sig_kill
452 teststatus $0 $failed