s3-tests use $PREFIX to ensure tests don't work outside the test area
[nivanova/samba-autobuild/.git] / source3 / selftest / tests.sh
1 #!/bin/bash
2 ###   ^^^FIXME -> sh ... breaks testing on *BSD etc. ... see FIXME's below
3 # This script generates a list of testsuites that should be run as part of 
4 # the Samba 3 test suite.
5
6 # The output of this script is parsed by selftest.pl, which then decides 
7 # which of the tests to actually run. It will, for example, skip all tests 
8 # listed in selftest/skip or only run a subset during "make quicktest".
9
10 # The idea is that this script outputs all of the tests of Samba 3, not 
11 # just those that are known to pass, and list those that should be skipped 
12 # or are known to fail in selftest/skip or selftest/samba4-knownfail. This makes it 
13 # very easy to see what functionality is still missing in Samba 3 and makes 
14 # it possible to run the testsuite against other servers, such as Samba 4 or 
15 # Windows that have a different set of features.
16
17 # The syntax for a testsuite is "-- TEST --" on a single line, followed 
18 # by the name of the test, the environment it needs and the command to run, all 
19 # three separated by newlines. All other lines in the output are considered 
20 # comments.
21
22 if [ ! -n "$PERL" ]
23 then
24         PERL=perl
25 fi
26
27 plantest() {
28         name=$1
29         env=$2
30         shift 2
31         cmdline="$*"
32         echo "-- TEST --"
33         if [ "$env" = "none" ]; then
34                 fullname="samba3.$name"
35         else
36                 fullname="samba3.$name ($env)"
37         fi
38         echo $fullname
39         echo $env
40         echo $cmdline "2>&1" "| ../selftest/filter-subunit --prefix \"$fullname.\""
41 }
42
43 TEST_FUNCTIONS_SH="INCLUDED"
44 testit() {
45         name=$1
46         shift 1
47         cmdline="$*"
48
49         plantest "$testitprefix$name" $testitenv $cmdline
50         return
51 }
52
53 testok() {
54         true
55         return
56 }
57
58 BINDIR=`dirname $0`/../bin
59 export BINDIR
60
61 SCRIPTDIR=`dirname $0`/../script/tests
62 export SCRIPTDIR
63
64 CONFIGURATION="--configfile \$SMB_CONF_PATH"
65 export CONFIGURATION
66
67 CONFFILE="\$SMB_CONF_PATH"
68 export CONFFILE
69
70 SERVER="\$SERVER"
71 export SERVER
72
73 USERNAME="\$USERNAME"
74 export USERNAME
75
76 PASSWORD="\$PASSWORD"
77 export PASSWORD
78
79 LOCAL_PATH="\$LOCAL_PATH"
80 export LOCAL_PATH
81
82 plantest "blackbox.success" dc:local LOCAL_PATH="$LOCAL_PATH" BINDIR="$BINDIR" SCRIPTDIR="$SCRIPTDIR" SERVERCONFFILE="\$SMB_CONF_PATH" script/tests/test_success.sh
83 plantest "blackbox.failure" dc:local LOCAL_PATH="$LOCAL_PATH" BINDIR="$BINDIR" SCRIPTDIR="$SCRIPTDIR" SERVERCONFFILE="\$SMB_CONF_PATH" script/tests/test_failure.sh
84
85 (
86         shift $#
87         testitprefix="local_s3."
88         testitenv="none"
89         . $SCRIPTDIR/test_local_s3.sh
90 )
91
92 (
93         shift $#
94         testitprefix="smbtorture_s3.plain."
95         testitenv="dc"
96 #FIXME: shell sourcing with ARGS is just supported by bash but bash isn't everywhere.
97         . $SCRIPTDIR/test_smbtorture_s3.sh //\$SERVER_IP/tmp \$USERNAME \$PASSWORD "" "" "-l \$LOCAL_PATH"
98 )
99
100 (
101         shift $#
102         testitprefix="smbtorture_s3.crypt."
103         testitenv="dc"
104 #FIXME: shell sourcing with ARGS is just supported by bash but bash isn't everywhere.
105         . $SCRIPTDIR/test_smbtorture_s3.sh //\$SERVER_IP/tmp \$USERNAME \$PASSWORD "" "-e" "-l \$LOCAL_PATH"
106 )
107
108 (
109         shift $#
110         testitprefix="wbinfo_s3."
111         testitenv="dc:local"
112 #FIXME: shell sourcing with ARGS is just supported by bash but bash isn't everywhere.
113         . $SCRIPTDIR/test_wbinfo_s3.sh \$DOMAIN \$SERVER \$USERNAME \$PASSWORD
114 )
115
116 (
117         shift $#
118         testitprefix="wbinfo_s3."
119         testitenv="dc:local"
120 #FIXME: shell sourcing with ARGS is just supported by bash but bash isn't everywhere.
121         . $SCRIPTDIR/test_wbinfo_s3.sh \$DOMAIN \$SERVER \$DOMAIN\\\\\$USERNAME \$PASSWORD
122 )
123
124 (
125         shift $#
126         testitprefix="wbinfo_s3."
127         testitenv="member:local"
128 #FIXME: shell sourcing with ARGS is just supported by bash but bash isn't everywhere.
129         . $SCRIPTDIR/test_wbinfo_s3.sh \$DOMAIN \$SERVER \$DOMAIN\\\\\$USERNAME \$PASSWORD
130 )
131
132 (
133         shift $#
134         testitprefix="ntlm_auth_s3."
135         testitenv="dc:local"
136         . $SCRIPTDIR/test_ntlm_auth_s3.sh
137 )
138
139 # plain
140 plantest "blackbox.smbclient_auth.plain" dc BINDIR="$BINDIR" script/tests/test_smbclient_auth.sh \$SERVER \$SERVER_IP \$USERNAME \$PASSWORD \$USERID
141 plantest "blackbox.smbclient_auth.plain sec share" secshare BINDIR="$BINDIR" script/tests/test_smbclient_auth.sh \$SERVER \$SERVER_IP \$SERVER\\\\\$USERNAME \$PASSWORD \$USERID
142 plantest "blackbox.smbclient_auth.plain member creds" member BINDIR="$BINDIR" script/tests/test_smbclient_auth.sh \$SERVER \$SERVER_IP \$SERVER\\\\\$USERNAME \$PASSWORD \$USERID
143
144 plantest "blackbox.smbclient_s3.plain" dc BINDIR="$BINDIR" script/tests/test_smbclient_s3.sh \$SERVER \$SERVER_IP \$USERNAME \$PASSWORD \$USERID \$LOCAL_PATH \$PREFIX
145 plantest "blackbox.smbclient_s3.plain member creds" member BINDIR="$BINDIR" script/tests/test_smbclient_s3.sh \$SERVER \$SERVER_IP \$SERVER\\\\\$USERNAME \$PASSWORD \$USERID \$LOCAL_PATH \$PREFIX
146 #plantest "blackbox.smbclient_s3.plain domain creds" member BINDIR="$BINDIR" script/tests/test_smbclient_s3.sh \$SERVER \$SERVER_IP \$DOMAIN\\\\\$DC_USERNAME \$DC_PASSWORD \$USERID \$LOCAL_PATH \$PREFIX
147
148 # sign, only the member server allows signing
149 plantest "blackbox.smbclient_s3.sign member creds" member BINDIR="$BINDIR" script/tests/test_smbclient_s3.sh \$SERVER \$SERVER_IP \$SERVER\\\\\$USERNAME \$PASSWORD \$USERID \$LOCAL_PATH \$PREFIX "--signing=required"
150 #plantest "blackbox.smbclient_s3.sign domain creds" member BINDIR="$BINDIR" script/tests/test_smbclient_s3.sh \$SERVER \$SERVER_IP \$DOMAIN\\\\\$DC_USERNAME \$DC_PASSWORD \$USERID \$LOCAL_PATH \$PREFIX "--signing=required"
151
152 # encrypted
153 plantest "blackbox.smbclient_s3.crypt" dc BINDIR="$BINDIR" script/tests/test_smbclient_s3.sh \$SERVER \$SERVER_IP \$USERNAME \$PASSWORD \$USERID \$LOCAL_PATH \$PREFIX "-e"
154
155 # these don't work yet
156 #plantest "blackbox.smbclient_s3.crypt member creds" member BINDIR="$BINDIR" script/tests/test_smbclient_s3.sh \$SERVER \$SERVER_IP \$SERVER\\\\\$USERNAME \$PASSWORD "-e"
157 #plantest "blackbox.smbclient_s3.crypt domain creds" member BINDIR="$BINDIR" script/tests/test_smbclient_s3.sh \$SERVER \$SERVER_IP \$DOMAIN\\\\\$DC_USERNAME \$DC_PASSWORD "-e"
158
159 plantest "blackbox.net.misc" dc:local BINDIR="$BINDIR" SCRIPTDIR="$SCRIPTDIR" SERVERCONFFILE="\$SMB_CONF_PATH" script/tests/test_net_misc.sh
160 plantest "blackbox.net.local.registry" dc:local BINDIR="$BINDIR" SCRIPTDIR="$SCRIPTDIR" SERVERCONFFILE="\$SMB_CONF_PATH" script/tests/test_net_registry.sh
161 plantest "blackbox.net.rpc.registry" dc BINDIR="$BINDIR" SCRIPTDIR="$SCRIPTDIR" SERVERCONFFILE="\$SMB_CONF_PATH" script/tests/test_net_registry.sh rpc
162 plantest "blackbox.net.local.registry.roundtrip" dc:local BINDIR="$BINDIR" SCRIPTDIR="$SCRIPTDIR" SERVERCONFFILE="\$SMB_CONF_PATH" script/tests/test_net_registry_roundtrip.sh
163 plantest "blackbox.testparm" dc:local LOCAL_PATH="$LOCAL_PATH" BINDIR="$BINDIR" SCRIPTDIR="$SCRIPTDIR" SERVERCONFFILE="\$SMB_CONF_PATH" script/tests/test_testparm_s3.sh
164
165 (
166         shift $#
167         testitprefix="posix_s3."
168         testitenv="dc"
169
170         SMBTORTURE4BINARY=$SMBTORTURE4
171         TORTURE4_OPTIONS=""
172         TORTURE4_OPTIONS="$TORTURE4_OPTIONS --configfile=\$SMB_CONF_PATH"
173         TORTURE4_OPTIONS="$TORTURE4_OPTIONS --maximum-runtime=$SELFTEST_MAXTIME"
174         TORTURE4_OPTIONS="$TORTURE4_OPTIONS --target=$SELFTEST_TARGET"
175         TORTURE4_OPTIONS="$TORTURE4_OPTIONS --basedir=$SELFTEST_PREFIX"
176         TORTURE4_OPTIONS="$TORTURE4_OPTIONS --option=\"torture:winbindd_netbios_name=\$SERVER\""
177         TORTURE4_OPTIONS="$TORTURE4_OPTIONS --option=\"torture:winbindd_netbios_domain=\$DOMAIN\""
178         if [ -n "$SELFTEST_VERBOSE" ]; then
179                 TORTURE4_OPTIONS="$TORTURE4_OPTIONS --option=torture:progress=no"
180         fi
181         TORTURE4_OPTIONS="$TORTURE4_OPTIONS --format=subunit"
182         if [ -n "$SELFTEST_QUICK" ]; then
183                 TORTURE4_OPTIONS="$TORTURE4_OPTIONS --option=torture:quick=yes"
184         fi
185
186         # This is an ugly hack...
187         TORTURE4_OPTIONS="$TORTURE4_OPTIONS --option=torture:localdir=$SELFTEST_PREFIX/dc/share"
188
189         if [ -x "$SMBTORTURE4" ]; then
190                 LIB_PATH_VAR_VAR="\$`echo $LIB_PATH_VAR`"
191                 S4_LIB_PREFIX=`eval echo "$LIB_PATH_VAR=\"$SAMBA4SHAREDDIR:$LIB_PATH_VAR_VAR\""`
192                 SMBTORTURE4="$S4_LIB_PREFIX $SMBTORTURE4"
193                 SMBTORTURE4VERSION=`eval $SMBTORTURE4 --version`
194         fi
195         if [ -n "$SMBTORTURE4" -a -n "$SMBTORTURE4VERSION" ];then
196                 echo "Using SMBTORTURE4: $SMBTORTURE4BINARY"
197                 echo "Version: $SMBTORTURE4VERSION"
198 #FIXME: shell sourcing with ARGS is just supported by bash but bash isn't everywhere.
199                 . $SCRIPTDIR/test_posix_s3.sh //\$SERVER_IP/tmp \$USERNAME \$PASSWORD "" ""
200         else
201                 echo "Skip Tests with Samba4's smbtorture"
202                 echo "Try to compile with --with-smbtorture4-path=PATH to enable"
203         fi
204
205 )
206