r13240: Make the test scripts use the new smb.conf location (in PREFIX/etc).
[Samba/ekacnet.git] / source4 / script / tests / selftest.sh
blob67797b17f42f13d75a8057d11f4c6ae61989dee7
1 #!/bin/sh
2 # Bootstrap Samba and run a number of tests against it.
4 DOMAIN=SAMBADOMAIN
5 USERNAME=administrator
6 REALM=SAMBA.EXAMPLE.COM
7 PASSWORD=penguin
8 SRCDIR=`pwd`
9 ROOT=$USER
10 SERVER=localhost
11 if test -z "$ROOT"; then
12 ROOT=$LOGNAME
14 if test -z "$ROOT"; then
15 ROOT=`whoami`
18 if [ $# -lt 1 ]
19 then
20 echo "$0 PREFIX"
21 exit
24 if [ -z "$TORTURE_MAXTIME" ]; then
25 TORTURE_MAXTIME=300
29 PREFIX=$1
30 PREFIX=`echo $PREFIX | sed s+//+/+`
31 export PREFIX
33 # allow selection of the test lists
34 TESTS=$2
36 if [ $TESTS = "all" ]; then
37 TLS_ENABLED="yes"
38 else
39 TLS_ENABLED="no"
42 mkdir -p $PREFIX || exit $?
43 OLD_PWD=`pwd`
44 cd $PREFIX || exit $?
45 PREFIX_ABS=`pwd`
46 export PREFIX_ABS
47 cd $OLD_PWD
49 TEST_DATA_PREFIX=$PREFIX_ABS
50 export TEST_DATA_PREFIX
52 TMPDIR=$PREFIX_ABS/tmp
53 LIBDIR=$PREFIX_ABS/lib
54 ETCDIR=$PREFIX_ABS/etc
55 PIDDIR=$PREFIX_ABS/pid
56 CONFFILE=$ETCDIR/smb.conf
57 KRB5_CONFIG=$ETCDIR/krb5.conf
58 PRIVATEDIR=$PREFIX_ABS/private
59 NCALRPCDIR=$PREFIX_ABS/ncalrpc
60 LOCKDIR=$PREFIX_ABS/lockdir
61 TLSDIR=$PRIVATEDIR/tls
62 CONFIGURATION="--configfile=$CONFFILE"
63 export CONFIGURATION
64 export CONFFILE
66 SMBD_TEST_FIFO="$PREFIX/smbd_test.fifo"
67 export SMBD_TEST_FIFO
68 SMBD_TEST_LOG="$PREFIX/smbd_test.log"
69 export SMBD_TEST_LOG
71 DO_SOCKET_WRAPPER=$3
72 if [ x"$DO_SOCKET_WRAPPER" = x"SOCKET_WRAPPER" ];then
73 SOCKET_WRAPPER_DIR="$PREFIX/sw"
74 export SOCKET_WRAPPER_DIR
75 echo "SOCKET_WRAPPER_DIR=$SOCKET_WRAPPER_DIR"
78 # start off with 0 failures
79 failed=0
80 export failed
82 incdir=`dirname $0`
83 . $incdir/test_functions.sh
85 PATH=bin:$PATH
86 export PATH
88 rm -rf $PREFIX/*
89 mkdir -p $PRIVATEDIR $ETCDIR $LIBDIR $PIDDIR $NCALRPCDIR $LOCKDIR $TMPDIR $TLSDIR
91 cat >$PRIVATEDIR/wins_config.ldif<<EOF
92 dn: name=TORTURE_26,CN=PARTNERS
93 objectClass: wreplPartner
94 name: TORTURE_26
95 address: 127.0.0.26
96 pullInterval: 0
97 pushChangeCount: 0
98 type: 0x3
99 EOF
101 cat >$CONFFILE<<EOF
102 [global]
103 netbios name = $SERVER
104 workgroup = $DOMAIN
105 realm = $REALM
106 private dir = $PRIVATEDIR
107 pid directory = $PIDDIR
108 ncalrpc dir = $NCALRPCDIR
109 lock dir = $LOCKDIR
110 setup directory = $SRCDIR/setup
111 js include = $SRCDIR/scripting/libjs
112 name resolve order = bcast
113 interfaces = 127.0.0.1/8
114 tls enabled = $TLS_ENABLED
115 panic action = $SRCDIR/script/gdb_backtrace %PID% %PROG%
116 wins support = yes
117 server role = pdc
119 [tmp]
120 path = $TMPDIR
121 read only = no
122 ntvfs handler = posix
123 posix:sharedelay = 100000
124 posix:eadb = $LOCKDIR/eadb.tdb
126 [cifs]
127 read only = no
128 ntvfs handler = cifs
129 cifs:server = $SERVER
130 cifs:user = $USERNAME
131 cifs:password = $PASSWORD
132 cifs:domain = $DOMAIN
133 cifs:share = tmp
136 cat >$KRB5_CONFIG<<EOF
137 [libdefaults]
138 default_realm = SAMBA.EXAMPLE.COM
139 dns_lookup_realm = false
140 dns_lookup_kdc = false
141 ticket_lifetime = 24h
142 forwardable = yes
144 [realms]
145 SAMBA.EXAMPLE.COM = {
146 kdc = 127.0.0.1
147 admin_server = 127.0.0.1
148 default_domain = samba.example.com
150 [domain_realm]
151 .samba.example.com = SAMBA.EXAMPLE.COM
154 export KRB5_CONFIG
156 echo -n "PROVISIONING..."
158 ./setup/provision $CONFIGURATION --host-name=$SERVER --host-ip=127.0.0.1 \
159 --quiet --domain $DOMAIN --realm $REALM \
160 --adminpass $PASSWORD --root=$ROOT || exit 1
162 ./bin/ldbadd -H $PRIVATEDIR/wins_config.ldb < $PRIVATEDIR/wins_config.ldif >/dev/null || exit 1
164 echo "DONE"
166 if [ x"$RUN_FROM_BUILD_FARM" = x"yes" ];then
167 CONFIGURATION="$CONFIGURATION --option=\"torture:progress=no\""
170 SOCKET_WRAPPER_DEFAULT_IFACE=1
171 export SOCKET_WRAPPER_DEFAULT_IFACE
172 smbd_check_or_start
174 # ensure any one smbtorture call doesn't run too long
175 SOCKET_WRAPPER_DEFAULT_IFACE=26
176 export SOCKET_WRAPPER_DEFAULT_IFACE
177 TORTURE_INTERFACES='127.0.0.26/8,127.0.0.27/8,127.0.0.28/8,127.0.0.29/8,127.0.0.30/8,127.0.0.31/8'
178 TORTURE_OPTIONS="--maximum-runtime=$TORTURE_MAXTIME --option=interfaces=$TORTURE_INTERFACES $CONFIGURATION"
179 export TORTURE_OPTIONS
181 START=`date`
183 # give time for nbt server to register its names
184 echo delaying for nbt name registration
185 sleep 4
186 # This will return quickly when things are up, but be slow if we need to wait for (eg) SSL init
187 bin/nmblookup $CONFIGURATION -U $SERVER $SERVER
188 bin/nmblookup $CONFIGURATION -U $SERVER $SERVER
189 bin/nmblookup $CONFIGURATION -U $SERVER $SERVER
191 failed=0
193 . script/tests/tests_$TESTS.sh
194 exit $failed
195 ) 9>$SMBD_TEST_FIFO
196 failed=$?
198 kill `cat $PIDDIR/smbd.pid`
200 END=`date`
201 echo "START: $START ($0)";
202 echo "END: $END ($0)";
204 # if there were any valgrind failures, show them
205 count=`find $PREFIX -name 'valgrind.log*' | wc -l`
206 if [ "$count" != 0 ]; then
207 for f in $PREFIX/valgrind.log*; do
208 if [ -s $f ]; then
209 echo "VALGRIND FAILURE";
210 failed=`expr $failed + 1`
211 cat $f
213 done
216 teststatus $0 $failed