r8525: added two more test targets:
[samba.git] / source / script / tests / selftest.sh
1 #!/bin/sh
2 DOMAIN=SAMBADOMAIN
3 USERNAME=administrator
4 REALM=$DOMAIN
5 PASSWORD=penguin
6 SRCDIR=`pwd`
7 ROOT=$USER
8 if test -z "$ROOT"; then
9     ROOT=`whoami`
10 fi
11
12 if [ $# -lt 1 ]
13 then
14         echo "$0 PREFIX"
15         exit
16 fi
17
18
19 PREFIX=$1
20 PREFIX=`echo $PREFIX | sed s+//+/+`
21 export PREFIX
22
23 # allow selection of the test lists
24 TESTS=$2
25
26 if [ $TESTS = "all" ]; then
27     TLS_ENABLED="yes"
28 else
29     TLS_ENABLED="no"
30 fi
31
32 mkdir -p $PREFIX || exit $?
33 OLD_PWD=`pwd`
34 cd $PREFIX || exit $?
35 PREFIX_ABS=`pwd`
36 export PREFIX_ABS
37 cd $OLD_PWD
38
39 TMPDIR=$PREFIX_ABS/tmp
40 LIBDIR=$PREFIX_ABS/lib
41 PIDDIR=$PREFIX_ABS/pid
42 CONFFILE=$LIBDIR/smb.conf
43 PRIVATEDIR=$PREFIX_ABS/private
44 NCALRPCDIR=$PREFIX_ABS/ncalrpc
45 LOCKDIR=$PREFIX_ABS/lockdir
46 TLSDIR=$PRIVATEDIR/tls
47 CONFIGURATION="--configfile=$CONFFILE"
48 export CONFIGURATION
49 export CONFFILE
50
51 SMBD_TEST_FIFO="$PREFIX/smbd_test.fifo"
52 export SMBD_TEST_FIFO
53 SMBD_TEST_LOG="$PREFIX/smbd_test.log"
54 export SMBD_TEST_LOG
55
56 DO_SOCKET_WRAPPER=$3
57 if [ x"$DO_SOCKET_WRAPPER" = x"SOCKET_WRAPPER" ];then
58         SOCKET_WRAPPER_DIR="$PREFIX/socket_wrapper_dir"
59         export SOCKET_WRAPPER_DIR
60         echo "SOCKET_WRAPPER_DIR=$SOCKET_WRAPPER_DIR"
61 fi
62
63 # start off with 0 failures
64 failed=0
65 export failed
66
67 incdir=`dirname $0`
68 . $incdir/test_functions.sh
69
70 PATH=bin:$PATH
71 export PATH
72
73 rm -rf $PREFIX/*
74 mkdir -p $PRIVATEDIR $LIBDIR $PIDDIR $NCALRPCDIR $LOCKDIR $TMPDIR $TLSDIR
75
76 cat >$CONFFILE<<EOF
77 [global]
78         netbios name = LOCALHOST
79         workgroup = $DOMAIN
80         realm = $REALM
81         private dir = $PRIVATEDIR
82         pid directory = $PIDDIR
83         ncalrpc dir = $NCALRPCDIR
84         lock dir = $LOCKDIR
85         setup directory = $SRCDIR/setup
86         js include = $SRCDIR/scripting/libjs
87         name resolve order = bcast
88         interfaces = lo*
89         tls enabled = $TLS_ENABLED
90
91 [tmp]
92         path = $TMPDIR
93         read only = no
94         ntvfs handler = posix
95         posix:sharedelay = 100000
96         posix:eadb = $LOCKDIR/eadb.tdb
97
98 [cifs]
99         read only = no
100         ntvfs handler = cifs
101         cifs:server = localhost
102         cifs:user = $USERNAME
103         cifs:password = $PASSWORD
104         cifs:domain = $DOMAIN
105         cifs:share = tmp
106 EOF
107
108 ./setup/provision $CONFIGURATION --quiet --domain $DOMAIN --realm $REALM \
109     --adminpass $PASSWORD --root=$ROOT || exit 1
110
111 if [ x"$RUN_FROM_BUILD_FARM" = x"yes" ];then
112         CONFIGURATION="$CONFIGURATION --option=\"torture:progress=no\""
113 fi
114
115 smbd_check_or_start
116
117 # ensure any one smbtorture call doesn't run too long
118 TORTURE_OPTIONS="--maximum-runtime=300 $CONFIGURATION"
119 export TORTURE_OPTIONS
120
121
122 START=`date`
123 (
124  # give time for nbt server to register its names
125  echo delaying for nbt name registration
126  sleep 4
127  bin/nmblookup -U localhost localhost 
128
129  failed=0
130
131  . script/tests/tests_$TESTS.sh
132  exit $failed
133 ) 9>$SMBD_TEST_FIFO
134 failed=$?
135
136 END=`date`
137 echo "START: $START ($0)";
138 echo "END:   $END ($0)";
139
140 teststatus $0 $failed