629b518edbf10d60ad4e8e45b95a8214f12a2c6d
[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
84 (
85         shift $#
86         testitprefix="local_s3."
87         testitenv="none"
88         . $SCRIPTDIR/test_local_s3.sh
89 )
90
91 (
92         shift $#
93         testitprefix="smbtorture_s3.plain."
94         testitenv="dc"
95 #FIXME: shell sourcing with ARGS is just supported by bash but bash isn't everywhere.
96         . $SCRIPTDIR/test_smbtorture_s3.sh //\$SERVER_IP/tmp \$USERNAME \$PASSWORD "" "" "-l \$LOCAL_PATH"
97 )
98
99 (
100         shift $#
101         testitprefix="smbtorture_s3.crypt."
102         testitenv="dc"
103 #FIXME: shell sourcing with ARGS is just supported by bash but bash isn't everywhere.
104         . $SCRIPTDIR/test_smbtorture_s3.sh //\$SERVER_IP/tmp \$USERNAME \$PASSWORD "" "-e" "-l \$LOCAL_PATH"
105 )
106
107 (
108         shift $#
109         testitprefix="wbinfo_s3."
110         testitenv="dc:local"
111 #FIXME: shell sourcing with ARGS is just supported by bash but bash isn't everywhere.
112         . $SCRIPTDIR/test_wbinfo_s3.sh \$DOMAIN \$SERVER \$USERNAME \$PASSWORD
113 )
114
115 (
116         shift $#
117         testitprefix="wbinfo_s3."
118         testitenv="dc:local"
119 #FIXME: shell sourcing with ARGS is just supported by bash but bash isn't everywhere.
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 #FIXME: shell sourcing with ARGS is just supported by bash but bash isn't everywhere.
128         . $SCRIPTDIR/test_wbinfo_s3.sh \$DOMAIN \$SERVER \$DOMAIN\\\\\$USERNAME \$PASSWORD
129 )
130
131 (
132         shift $#
133         testitprefix="ntlm_auth_s3."
134         testitenv="dc:local"
135         . $SCRIPTDIR/test_ntlm_auth_s3.sh
136 )
137
138 # plain
139 plantest "blackbox.smbclient_s3.plain" dc BINDIR="$BINDIR" script/tests/test_smbclient_s3.sh \$SERVER \$SERVER_IP \$USERNAME \$PASSWORD \$USERID \$LOCAL_PATH
140 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
141 #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
142
143 # sign, only the member server allows signing
144 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"
145 #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"
146
147 # encrypted
148 plantest "blackbox.smbclient_s3.crypt" dc BINDIR="$BINDIR" script/tests/test_smbclient_s3.sh \$SERVER \$SERVER_IP \$USERNAME \$PASSWORD \$USERID \$LOCAL_PATH "-e"
149
150 # these don't work yet
151 #plantest "blackbox.smbclient_s3.crypt member creds" member BINDIR="$BINDIR" script/tests/test_smbclient_s3.sh \$SERVER \$SERVER_IP \$SERVER\\\\\$USERNAME \$PASSWORD "-e"
152 #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"
153
154 plantest "blackbox.net_s3_misc" dc:local BINDIR="$BINDIR" SCRIPTDIR="$SCRIPTDIR" SERVERCONFFILE="\$SMB_CONF_PATH" script/tests/test_net_misc.sh
155 plantest "blackbox.net_s3_registry" dc:local BINDIR="$BINDIR" SCRIPTDIR="$SCRIPTDIR" SERVERCONFFILE="\$SMB_CONF_PATH" script/tests/test_net_registry.sh
156 plantest "blackbox.net_s3_registry_rpc" dc:local BINDIR="$BINDIR" SCRIPTDIR="$SCRIPTDIR" SERVERCONFFILE="\$SMB_CONF_PATH" script/tests/test_net_registry.sh rpc
157 plantest "blackbox.testparm_s3" dc:local LOCAL_PATH="$LOCAL_PATH" BINDIR="$BINDIR" SCRIPTDIR="$SCRIPTDIR" SERVERCONFFILE="\$SMB_CONF_PATH" script/tests/test_testparm_s3.sh
158
159 (
160         shift $#
161         testitprefix="posix_s3."
162         testitenv="dc"
163
164         SMBTORTURE4BINARY=$SMBTORTURE4
165         TORTURE4_OPTIONS=""
166         TORTURE4_OPTIONS="$TORTURE4_OPTIONS --configfile=\$SMB_CONF_PATH"
167         TORTURE4_OPTIONS="$TORTURE4_OPTIONS --maximum-runtime=$SELFTEST_MAXTIME"
168         TORTURE4_OPTIONS="$TORTURE4_OPTIONS --target=$SELFTEST_TARGET"
169         TORTURE4_OPTIONS="$TORTURE4_OPTIONS --basedir=$SELFTEST_PREFIX"
170         TORTURE4_OPTIONS="$TORTURE4_OPTIONS --option=\"torture:winbindd_netbios_name=\$SERVER\""
171         TORTURE4_OPTIONS="$TORTURE4_OPTIONS --option=\"torture:winbindd_netbios_domain=\$DOMAIN\""
172         if [ -n "$SELFTEST_VERBOSE" ]; then
173                 TORTURE4_OPTIONS="$TORTURE4_OPTIONS --option=torture:progress=no"
174         fi
175         TORTURE_OPTIONS="$TORTURE4_OPTIONS --format=subunit"
176         if [ -n "$SELFTEST_QUICK" ]; then
177                 TORTURE4_OPTIONS="$TORTURE4_OPTIONS --option=torture:quick=yes"
178         fi
179
180         # This is an ugly hack...
181         TORTURE4_OPTIONS="$TORTURE4_OPTIONS --option=torture:localdir=$SELFTEST_PREFIX/dc/share"
182
183         if [ -x "$SMBTORTURE4" ]; then
184                 LIB_PATH_VAR_VAR="\$`echo $LIB_PATH_VAR`"
185                 S4_LIB_PREFIX=`eval echo "$LIB_PATH_VAR=\"$SAMBA4SHAREDDIR:$LIB_PATH_VAR_VAR\""`
186                 SMBTORTURE4="$S4_LIB_PREFIX $SMBTORTURE4"
187                 SMBTORTURE4VERSION=`eval $SMBTORTURE4 --version`
188         fi
189         if [ -n "$SMBTORTURE4" -a -n "$SMBTORTURE4VERSION" ];then
190                 echo "Using SMBTORTURE4: $SMBTORTURE4BINARY"
191                 echo "Version: $SMBTORTURE4VERSION"
192 #FIXME: shell sourcing with ARGS is just supported by bash but bash isn't everywhere.
193                 . $SCRIPTDIR/test_posix_s3.sh //\$SERVER_IP/tmp \$USERNAME \$PASSWORD "" ""
194         else
195                 echo "Skip Tests with Samba4's smbtorture"
196                 echo "Try to compile with --with-smbtorture4-path=PATH to enable"
197         fi
198
199 )
200