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