s4-smbtorture: Make test names lowercase and dot-separated.
[metze/samba/wip.git] / source4 / selftest / tests.py
1 #!/usr/bin/python
2 # This script generates a list of testsuites that should be run as part of
3 # the Samba 4 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 4, 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/knownfail. This makes it
12 # very easy to see what functionality is still missing in Samba 4 and makes
13 # it possible to run the testsuite against other servers, such as Samba 3 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 import os
22 import subprocess
23
24 def binpath(name):
25     return os.path.join(samba4bindir, "%s%s" % (name, os.getenv("EXEEXT", "")))
26
27 perl = os.getenv("PERL", "perl")
28
29 if subprocess.call([perl, "-e", "eval require Test::More;"]) == 0:
30     has_perl_test_more = True
31 else:
32     has_perl_test_more = False
33
34 try:
35     from subunit.run import TestProgram
36 except ImportError:
37     has_system_subunit_run = False
38 else:
39     has_system_subunit_run = True
40
41 python = os.getenv("PYTHON", "python")
42
43 def valgrindify(cmdline):
44     """Run a command under valgrind, if $VALGRIND was set."""
45     valgrind = os.getenv("VALGRIND")
46     if valgrind is None:
47         return cmdline
48     return valgrind + " " + cmdline
49
50
51 def plantestsuite(name, env, cmdline, allow_empty_output=False):
52     """Plan a test suite.
53
54     :param name: Testsuite name
55     :param env: Environment to run the testsuite in
56     :param cmdline: Command line to run
57     """
58     print "-- TEST --"
59     print name
60     print env
61     if isinstance(cmdline, list):
62         cmdline = " ".join(cmdline)
63     filter_subunit_args = []
64     if not allow_empty_output:
65         filter_subunit_args.append("--fail-on-empty")
66     print "%s 2>&1 | ../selftest/filter-subunit %s --prefix=\"%s.\"" % (cmdline, " ".join(filter_subunit_args), name)
67     if allow_empty_output:
68         print "WARNING: allowing empty subunit output from %s" % name
69
70
71 def plantestsuite_loadlist(name, env, cmdline):
72     print "-- TEST-LOADLIST --"
73     if env == "none":
74         fullname = name
75     else:
76         fullname = "%s(%s)" % (name, env)
77     print fullname
78     print env
79     if isinstance(cmdline, list):
80         cmdline = " ".join(cmdline)
81     print "%s $LOADLIST 2>&1 | ../selftest/filter-subunit --fail-on-empty --prefix=\"%s.\"" % (cmdline, fullname)
82
83
84 def plantestsuite_idlist(name, env, cmdline):
85     print "-- TEST-IDLIST --"
86     print name
87     print env
88     if isinstance(cmdline, list):
89         cmdline = " ".join(cmdline)
90     print cmdline
91
92
93 def skiptestsuite(name, reason):
94     """Indicate that a testsuite was skipped.
95
96     :param name: Test suite name
97     :param reason: Reason the test suite was skipped
98     """
99     # FIXME: Report this using subunit, but re-adjust the testsuite count somehow
100     print "skipping %s (%s)" % (name, reason)
101
102
103 def planperltestsuite(name, path):
104     """Run a perl test suite.
105
106     :param name: Name of the test suite
107     :param path: Path to the test runner
108     """
109     if has_perl_test_more:
110         plantestsuite(name, "none", "%s %s | %s" % (perl, path, tap2subunit))
111     else:
112         skiptestsuite(name, "Test::More not available")
113
114
115 def planpythontestsuite(env, module):
116     if has_system_subunit_run:
117         plantestsuite_idlist(module, env, [python, "-m", "subunit.run", "$LISTOPT", module])
118     else:
119         plantestsuite_idlist(module, env, "PYTHONPATH=$PYTHONPATH:%s/../lib/subunit/python:%s/../lib/testtools %s -m subunit.run $LISTOPT %s" % (samba4srcdir, samba4srcdir, python, module))
120
121
122 def plansmbtorturetestsuite(name, env, options):
123     modname = "samba4.%s" % name
124     cmdline = "%s %s %s" % (valgrindify(smb4torture), options, name)
125     plantestsuite_loadlist(modname, env, cmdline)
126
127
128 samba4srcdir = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), ".."))
129 builddir = os.getenv("BUILDDIR", samba4srcdir)
130 samba4bindir = os.path.normpath(os.path.join(builddir, "bin"))
131 smb4torture = binpath("smbtorture")
132 smb4torture_testsuite_list = subprocess.Popen([smb4torture, "--list-suites"], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate("")[0].splitlines()
133 validate = os.getenv("VALIDATE", "")
134 if validate:
135     validate_list = [validate]
136 else:
137     validate_list = []
138 def smb4torture_testsuites(prefix):
139     return filter(lambda x: x.startswith(prefix), smb4torture_testsuite_list)
140
141 sub = subprocess.Popen("tap2subunit 2> /dev/null", stdout=subprocess.PIPE, stdin=subprocess.PIPE, shell=True)
142 sub.communicate("")
143 if sub.returncode != 0:
144     tap2subunit = "PYTHONPATH=%s/../lib/subunit/python:%s/../lib/testtools %s %s/../lib/subunit/filters/tap2subunit" % (samba4srcdir, samba4srcdir, python, samba4srcdir)
145 else:
146     cmd = "echo -ne \"1..1\nok 1 # skip doesn't seem to work yet\n\" | tap2subunit 2> /dev/null | grep skip"
147     sub = subprocess.Popen(cmd, stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
148     if sub.returncode == 0:
149         tap2subunit = "tap2subunit"
150     else:
151         tap2subunit = "PYTHONPATH=%s/../lib/subunit/python:%s/../lib/testtools %s %s/../lib/subunit/filters/tap2subunit" % (samba4srcdir, samba4srcdir, python, samba4srcdir)
152
153 subprocess.call([smb4torture, "-V"])
154
155 bbdir = "../testprogs/blackbox"
156
157 configuration = "--configfile=$SMB_CONF_PATH"
158
159 torture_options = [configuration, "--maximum-runtime=$SELFTEST_MAXTIME", "--target=$SELFTEST_TARGET", "--basedir=$SELFTEST_TMPDIR"]
160 if not os.getenv("SELFTEST_VERBOSE"):
161     torture_options.append("--option=torture:progress=no")
162 torture_options.append("--format=subunit")
163 if os.getenv("SELFTEST_QUICK"):
164     torture_options.append("--option=torture:quick=yes")
165 smb4torture += " " + " ".join(torture_options)
166
167 print "OPTIONS %s" % " ".join(torture_options)
168
169 # Simple tests for LDAP and CLDAP
170 for options in ['-U"$USERNAME%$PASSWORD" --option=socket:testnonblock=true', '-U"$USERNAME%$PASSWORD"', '-U"$USERNAME%$PASSWORD" -k yes', '-U"$USERNAME%$PASSWORD" -k no', '-U"$USERNAME%$PASSWORD" -k no --sign', '-U"$USERNAME%$PASSWORD" -k no --encrypt', '-U"$USERNAME%$PASSWORD" -k yes --encrypt', '-U"$USERNAME%$PASSWORD" -k yes --sign']:
171     plantestsuite("samba4.ldb.ldap with options %s(dc)" % options, "dc", "%s/test_ldb.sh ldap $SERVER %s" % (bbdir, options))
172
173 # see if we support ldaps
174 try:
175     config_h = os.environ["CONFIG_H"]
176 except KeyError:
177     config_h = os.path.join(samba4bindir, "default/source4/include/config.h")
178 f = open(config_h, 'r')
179 try:
180     have_tls_support = ("ENABLE_GNUTLS 1" in f.read())
181 finally:
182     f.close()
183
184 if have_tls_support:
185     for options in ['-U"$USERNAME%$PASSWORD"']:
186         plantestsuite("samba4.ldb.ldaps with options %s(dc)" % options, "dc",
187                 "%s/test_ldb.sh ldaps $SERVER_IP %s" % (bbdir, options))
188
189 for options in ['-U"$USERNAME%$PASSWORD"']:
190     plantestsuite("samba4.ldb.ldapi with options %s(dc:local)" % options, "dc:local",
191             "%s/test_ldb.sh ldapi $PREFIX_ABS/dc/private/ldapi %s" % (bbdir, options))
192
193 for t in smb4torture_testsuites("ldap."):
194     plansmbtorturetestsuite(t, "dc", '-U"$USERNAME%$PASSWORD" //$SERVER_IP/_none_')
195
196 ldbdir = os.path.join(samba4srcdir, "lib/ldb")
197 # Don't run LDB tests when using system ldb, as we won't have ldbtest installed
198 if os.path.exists(os.path.join(samba4bindir, "ldbtest")):
199     plantestsuite("ldb.base", "none",
200         "TEST_DATA_PREFIX=$PREFIX %s/tests/test-tdb.sh" % ldbdir,
201         allow_empty_output=True)
202 else:
203     skiptestsuite("ldb.base", "Using system LDB, ldbtest not available")
204
205 # Tests for RPC
206
207 # add tests to this list as they start passing, so we test
208 # that they stay passing
209 ncacn_np_tests = ["rpc.schannel", "rpc.join", "rpc.lsa", "rpc.dssetup", "rpc.altercontext", "rpc.multibind", "rpc.netlogon", "rpc.handles", "rpc.samsync", "rpc.samba3-sessionkey", "rpc.samba3-getusername", "rpc.samba3-lsa", "rpc.samba3-bind", "rpc.samba3-netlogon", "rpc.asyncbind", "rpc.lsalookup", "rpc.lsa-getuser", "rpc.schannel2", "rpc.authcontext"]
210 ncalrpc_tests = ["rpc.schannel", "rpc.join", "rpc.lsa", "rpc.dssetup", "rpc.altercontext", "rpc.multibind", "rpc.netlogon", "rpc.drsuapi", "rpc.asyncbind", "rpc.lsalookup", "rpc.lsa-getuser", "rpc.schannel2", "rpc.authcontext"]
211 drs_rpc_tests = smb4torture_testsuites("drs.rpc")
212 ncacn_ip_tcp_tests = ["rpc.schannel", "rpc.join", "rpc.lsa", "rpc.dssetup", "rpc.altercontext", "rpc.multibind", "rpc.netlogon", "rpc.handles", "rpc.asyncbind", "rpc.lsalookup", "rpc.lsa-getuser", "rpc.schannel2", "rpc.authcontext", "rpc.objectuuid"] + drs_rpc_tests
213 slow_ncacn_np_tests = ["rpc.samlogon", "rpc.samr.users", "rpc.samr.large-dc", "rpc.samr.users.privileges", "rpc.samr.passwords", "rpc.samr.passwords.pwdlastset"]
214 slow_ncacn_ip_tcp_tests = ["rpc.samr", "rpc.cracknames"]
215
216 all_rpc_tests = ncalrpc_tests + ncacn_np_tests + ncacn_ip_tcp_tests + slow_ncacn_np_tests + slow_ncacn_ip_tcp_tests + ["rpc.lsa.secrets", "rpc.pac", "rpc.samba3-sharesec", "rpc.countcalls"]
217
218 # Make sure all tests get run
219 rpc_tests = smb4torture_testsuites("rpc.")
220 auto_rpc_tests = filter(lambda t: t not in all_rpc_tests, rpc_tests)
221
222 for bindoptions in ["seal,padcheck"] + validate_list + ["bigendian"]:
223     for transport in ["ncalrpc", "ncacn_np", "ncacn_ip_tcp"]:
224         env = "dc"
225         if transport == "ncalrpc":
226             tests = ncalrpc_tests
227             env = "dc:local"
228         elif transport == "ncacn_np":
229             tests = ncacn_np_tests
230         elif transport == "ncacn_ip_tcp":
231             tests = ncacn_ip_tcp_tests
232         for t in tests:
233             plantestsuite_loadlist("samba4.%s on %s with %s" % (t, transport, bindoptions), env, [valgrindify(smb4torture), "%s:$SERVER[%s]" % (transport, bindoptions), '-U$USERNAME%$PASSWORD', '-W', '$DOMAIN', t])
234         plantestsuite_loadlist("samba4.rpc.samba3.sharesec on %s with %s" % (transport, bindoptions), env, [valgrindify(smb4torture), "%s:$SERVER[%s]" % (transport, bindoptions), '-U$USERNAME%$PASSWORD', '-W', '$DOMAIN', '--option=torture:share=tmp', 'rpc.samba3-sharesec'])
235
236 for bindoptions in [""] + validate_list + ["bigendian"]:
237     for t in auto_rpc_tests:
238         plantestsuite_loadlist("samba4.%s with %s" % (t, bindoptions), "dc", [valgrindify(smb4torture), "$SERVER[%s]" % bindoptions, '-U$USERNAME%$PASSWORD', '-W', '$DOMAIN', t])
239
240 t = "rpc.countcalls"
241 plantestsuite_loadlist("samba4.%s" % t, "dc:local", [valgrindify(smb4torture), "$SERVER[%s]" % bindoptions, '-U$USERNAME%$PASSWORD', '-W', '$DOMAIN', t])
242
243 for transport in ["ncacn_np", "ncacn_ip_tcp"]:
244     env = "dc"
245     if transport == "ncacn_np":
246         tests = slow_ncacn_np_tests
247     elif transport == "ncacn_ip_tcp":
248         tests = slow_ncacn_ip_tcp_tests
249     for t in tests:
250         plantestsuite_loadlist("samba4.%s on %s" % (t, transport), env, [valgrindify(smb4torture), "%s:$SERVER" % transport, '-U$USERNAME%$PASSWORD', '-W', '$DOMAIN', t])
251
252 # Tests for the DFS referral calls implementation
253 for t in smb4torture_testsuites("dfs."):
254     plansmbtorturetestsuite(t, "dc", '//$SERVER/ipc\$ -U$USERNAME%$PASSWORD')
255
256 # Tests for the NET API (net.api.become.dc tested below against all the roles)
257 net_tests = filter(lambda x: "net.api.become.dc" not in x, smb4torture_testsuites("net."))
258 for t in net_tests:
259     plansmbtorturetestsuite(t, "dc", '$SERVER[%s] -U$USERNAME%%$PASSWORD -W $DOMAIN' % validate)
260
261 # Tests for session keys and encryption of RPC pipes
262 # FIXME: Integrate these into a single smbtorture test
263
264 transport = "ncacn_np"
265 for ntlmoptions in [
266     "-k no --option=usespnego=yes",
267     "-k no --option=usespnego=yes --option=ntlmssp_client:128bit=no",
268     "-k no --option=usespnego=yes --option=ntlmssp_client:56bit=yes",
269     "-k no --option=usespnego=yes --option=ntlmssp_client:56bit=no",
270     "-k no --option=usespnego=yes --option=ntlmssp_client:128bit=no --option=ntlmssp_client:56bit=yes",
271     "-k no --option=usespnego=yes --option=ntlmssp_client:128bit=no --option=ntlmssp_client:56bit=no",
272     "-k no --option=usespnego=yes --option=clientntlmv2auth=yes",
273     "-k no --option=usespnego=yes --option=clientntlmv2auth=yes --option=ntlmssp_client:128bit=no",
274     "-k no --option=usespnego=yes --option=clientntlmv2auth=yes --option=ntlmssp_client:128bit=no --option=ntlmssp_client:56bit=yes",
275     "-k no --option=usespnego=no --option=clientntlmv2auth=yes",
276     "-k no --option=gensec:spnego=no --option=clientntlmv2auth=yes",
277     "-k no --option=usespnego=no"]:
278     name = "rpc.lsa.secrets on %s with with %s" % (transport, ntlmoptions)
279     plantestsuite_loadlist("samba4.%s" % name, "dc", [smb4torture, "%s:$SERVER[]" % (transport), ntlmoptions, '-U$USERNAME%$PASSWORD', '-W', '$DOMAIN', '--option=gensec:target_hostname=$NETBIOSNAME', 'rpc.lsa.secrets'])
280
281 transports = ["ncacn_np", "ncacn_ip_tcp"]
282
283 #Kerberos varies between functional levels, so it is important to check this on all of them
284 for env in ["dc", "fl2000dc", "fl2003dc", "fl2008r2dc"]:
285     transport = "ncacn_np"
286     plantestsuite_loadlist("samba4.rpc.pac on %s" % (transport,), env, [smb4torture, "%s:$SERVER[]" % (transport, ), '-U$USERNAME%$PASSWORD', '-W', '$DOMAIN', 'rpc.pac'])
287     for transport in transports:
288         plantestsuite_loadlist("samba4.rpc.lsa.secrets on %s with Kerberos" % (transport,), env, [smb4torture, "%s:$SERVER[]" % (transport, ), '-k', 'yes', '-U$USERNAME%$PASSWORD', '-W', '$DOMAIN', '--option=gensec:target_hostname=$NETBIOSNAME', 'rpc.lsa.secrets'])
289         plantestsuite_loadlist("samba4.rpc.lsa.secrets on %s with Kerberos - use target principal" % (transport,), env, [smb4torture, "%s:$SERVER[]" % (transport, ), '-k', 'yes', '-U$USERNAME%$PASSWORD', '-W', '$DOMAIN', "--option=clientusespnegoprincipal=yes", '--option=gensec:target_hostname=$NETBIOSNAME', 'rpc.lsa.secrets'])
290         plantestsuite_loadlist("samba4.rpc.lsa.secrets on %s with Kerberos - use Samba3 style login" % transport, env, [smb4torture, "%s:$SERVER" % transport, '-k', 'yes', '-U$USERNAME%$PASSWORD', '-W', '$DOMAIN', "--option=gensec:fake_gssapi_krb5=yes", '--option=gensec:gssapi_krb5=no', '--option=gensec:target_hostname=$NETBIOSNAME', "rpc.lsa.secrets.none*"])
291         plantestsuite_loadlist("samba4.rpc.lsa.secrets on %s with Kerberos - use Samba3 style login, use target principal" % transport, env, [smb4torture, "%s:$SERVER" % transport, '-k', 'yes', '-U$USERNAME%$PASSWORD', '-W', '$DOMAIN', "--option=clientusespnegoprincipal=yes", '--option=gensec:fake_gssapi_krb5=yes', '--option=gensec:gssapi_krb5=no', '--option=gensec:target_hostname=$NETBIOSNAME', "rpc.lsa.secrets.none*"])
292         plantestsuite_loadlist("samba4.rpc.echo on %s" % (transport, ), env, [smb4torture, "%s:$SERVER[]" % (transport,), '-U$USERNAME%$PASSWORD', '-W', '$DOMAIN', 'rpc.echo'])
293
294         # Echo tests test bulk Kerberos encryption of DCE/RPC
295         for bindoptions in ["connect", "spnego", "spnego,sign", "spnego,seal"] + validate_list + ["padcheck", "bigendian", "bigendian,seal"]:
296             echooptions = "--option=socket:testnonblock=True --option=torture:quick=yes -k yes"
297             plantestsuite_loadlist("samba4.rpc.echo on %s with %s and %s" % (transport, bindoptions, echooptions), env, [smb4torture, "%s:$SERVER[%s]" % (transport, bindoptions), echooptions, '-U$USERNAME%$PASSWORD', '-W', '$DOMAIN', 'rpc.echo'])
298     plansmbtorturetestsuite("net.api.become.dc", env, '$SERVER[%s] -U$USERNAME%%$PASSWORD -W $DOMAIN' % validate)
299
300 for transport in transports:
301     for bindoptions in ["sign", "seal"]:
302         for ntlmoptions in [
303         "--option=ntlmssp_client:ntlm2=yes --option=torture:quick=yes",
304         "--option=ntlmssp_client:ntlm2=no --option=torture:quick=yes",
305         "--option=ntlmssp_client:ntlm2=yes --option=ntlmssp_client:128bit=no --option=torture:quick=yes",
306         "--option=ntlmssp_client:ntlm2=no --option=ntlmssp_client:128bit=no --option=torture:quick=yes",
307         "--option=ntlmssp_client:ntlm2=yes --option=ntlmssp_client:keyexchange=no --option=torture:quick=yes",
308         "--option=ntlmssp_client:ntlm2=no --option=ntlmssp_client:keyexchange=no --option=torture:quick=yes",
309         "--option=clientntlmv2auth=yes --option=ntlmssp_client:keyexchange=no --option=torture:quick=yes",
310         "--option=clientntlmv2auth=yes --option=ntlmssp_client:128bit=no --option=ntlmssp_client:keyexchange=yes --option=torture:quick=yes",
311         "--option=clientntlmv2auth=yes --option=ntlmssp_client:128bit=no --option=ntlmssp_client:keyexchange=no --option=torture:quick=yes"]:
312             if transport == "ncalrpc":
313                 env = "dc:local"
314             else:
315                 env = "dc"
316             plantestsuite_loadlist("samba4.rpc.echo on %s with %s and %s" % (transport, bindoptions, ntlmoptions), env, [smb4torture, "%s:$SERVER[%s]" % (transport, bindoptions), ntlmoptions, '-U$USERNAME%$PASSWORD', '-W', '$DOMAIN', 'rpc.echo'])
317
318 plantestsuite_loadlist("samba4.rpc.echo on ncacn_np over smb2", "dc", [smb4torture, 'ncacn_np:$SERVER[smb2]', '-U$USERNAME%$PASSWORD', '-W', '$DOMAIN', 'rpc.echo'])
319
320 plantestsuite_loadlist("samba4.ntp.signd", "dc:local", [smb4torture, 'ncacn_np:$SERVER', '-U$USERNAME%$PASSWORD', '-W', '$DOMAIN', 'ntp.signd'])
321
322 # Tests against the NTVFS POSIX backend
323 ntvfsargs = ["--option=torture:sharedelay=10000", "--option=torture:oplocktimeout=3", "--option=torture:writetimeupdatedelay=50000"]
324
325 smb2 = smb4torture_testsuites("smb2.")
326 #The QFILEINFO-IPC test needs to be on ipc$
327 raw = filter(lambda x: "raw.qfileinfo.ipc" not in x, smb4torture_testsuites("raw."))
328 base = smb4torture_testsuites("base.")
329
330 for t in base + raw + smb2:
331     plansmbtorturetestsuite(t, "dc", '//$SERVER/tmp -U$USERNAME%$PASSWORD' + " " + " ".join(ntvfsargs))
332
333 plansmbtorturetestsuite("raw.qfileinfo.ipc", "dc", '//$SERVER/ipc\$ -U$USERNAME%$PASSWORD')
334
335 for t in smb4torture_testsuites("rap."):
336     plansmbtorturetestsuite(t, "dc", '//$SERVER/IPC\$ -U$USERNAME%$PASSWORD')
337
338 # Tests against the NTVFS CIFS backend
339 for t in base + raw:
340     plantestsuite_loadlist("samba4.ntvfs.cifs.%s" % t, "dc", [valgrindify(smb4torture), '//$NETBIOSNAME/cifs', '-U$USERNAME%$PASSWORD'] + ntvfsargs + [t])
341
342 plansmbtorturetestsuite('ECHO-UDP', 'dc:local', '//$SERVER/whatever')
343
344 # Local tests
345 for t in smb4torture_testsuites("local."):
346     plansmbtorturetestsuite(t, "none", "ncalrpc:")
347
348 tdbtorture4 = binpath("tdbtorture")
349 if os.path.exists(tdbtorture4):
350     plantestsuite("tdb.stress", "none", valgrindify(tdbtorture4))
351 else:
352     skiptestsuite("tdb.stress", "Using system TDB, tdbtorture not available")
353
354 plansmbtorturetestsuite("drs.unit", "none", "ncalrpc:")
355
356 # Pidl tests
357 for f in sorted(os.listdir(os.path.join(samba4srcdir, "../pidl/tests"))):
358     if f.endswith(".pl"):
359         planperltestsuite("pidl.%s" % f[:-3], os.path.normpath(os.path.join(samba4srcdir, "../pidl/tests", f)))
360 planperltestsuite("selftest.samba4", os.path.normpath(os.path.join(samba4srcdir, "../selftest/test_samba4.pl")))
361
362 # Blackbox Tests:
363 # tests that interact directly with the command-line tools rather than using
364 # the API. These mainly test that the various command-line options of commands
365 # work correctly.
366
367 planpythontestsuite("none", "samba.tests.blackbox.ndrdump")
368 plantestsuite("samba4.blackbox.samba_tool(dc:local)", "dc:local", [os.path.join(samba4srcdir, "utils/tests/test_samba_tool.sh"),  '$SERVER', "$USERNAME", "$PASSWORD", "$DOMAIN"])
369 plantestsuite("samba4.blackbox.pkinit(dc:local)", "dc:local", [os.path.join(bbdir, "test_pkinit.sh"), '$SERVER', '$USERNAME', '$PASSWORD', '$REALM', '$DOMAIN', '$PREFIX', "aes256-cts-hmac-sha1-96", configuration])
370 plantestsuite("samba4.blackbox.kinit(dc:local)", "dc:local", [os.path.join(bbdir, "test_kinit.sh"), '$SERVER', '$USERNAME', '$PASSWORD', '$REALM', '$DOMAIN', '$PREFIX', "aes256-cts-hmac-sha1-96", configuration])
371 plantestsuite("samba4.blackbox.kinit(fl2000dc:local)", "fl2000dc:local", [os.path.join(bbdir, "test_kinit.sh"), '$SERVER', '$USERNAME', '$PASSWORD', '$REALM', '$DOMAIN', '$PREFIX', "arcfour-hmac-md5", configuration])
372 plantestsuite("samba4.blackbox.kinit(fl2008r2dc:local)", "fl2008r2dc:local", [os.path.join(bbdir, "test_kinit.sh"), '$SERVER', '$USERNAME', '$PASSWORD', '$REALM', '$DOMAIN', '$PREFIX', "aes256-cts-hmac-sha1-96", configuration])
373 plantestsuite("samba4.blackbox.ktpass(dc)", "dc", [os.path.join(bbdir, "test_ktpass.sh"), '$PREFIX'])
374 plantestsuite("samba4.blackbox.passwords(dc:local)", "dc:local", [os.path.join(bbdir, "test_passwords.sh"), '$SERVER', '$USERNAME', '$PASSWORD', '$REALM', '$DOMAIN', "$PREFIX"])
375 plantestsuite("samba4.blackbox.export.keytab(dc:local)", "dc:local", [os.path.join(bbdir, "test_export_keytab.sh"), '$SERVER', '$USERNAME', '$REALM', '$DOMAIN', "$PREFIX"])
376 plantestsuite("samba4.blackbox.cifsdd(dc)", "dc", [os.path.join(samba4srcdir, "client/tests/test_cifsdd.sh"), '$SERVER', '$USERNAME', '$PASSWORD', "$DOMAIN"])
377 plantestsuite("samba4.blackbox.nmblookup(dc)", "dc", [os.path.join(samba4srcdir, "utils/tests/test_nmblookup.sh"), '$NETBIOSNAME', '$NETBIOSALIAS', '$SERVER', '$SERVER_IP'])
378 plantestsuite("samba4.blackbox.nmblookup(member)", "member", [os.path.join(samba4srcdir, "utils/tests/test_nmblookup.sh"), '$NETBIOSNAME', '$NETBIOSALIAS', '$SERVER', '$SERVER_IP'])
379 plantestsuite("samba4.blackbox.locktest(dc)", "dc", [os.path.join(samba4srcdir, "torture/tests/test_locktest.sh"), '$SERVER', '$USERNAME', '$PASSWORD', '$DOMAIN', '$PREFIX'])
380 plantestsuite("samba4.blackbox.masktest", "dc", [os.path.join(samba4srcdir, "torture/tests/test_masktest.sh"), '$SERVER', '$USERNAME', '$PASSWORD', '$DOMAIN', '$PREFIX'])
381 plantestsuite("samba4.blackbox.gentest(dc)", "dc", [os.path.join(samba4srcdir, "torture/tests/test_gentest.sh"), '$SERVER', '$USERNAME', '$PASSWORD', '$DOMAIN', "$PREFIX"])
382 plantestsuite("samba4.blackbox.wbinfo(dc:local)", "dc:local", [os.path.join(samba4srcdir, "../nsswitch/tests/test_wbinfo.sh"), '$DOMAIN', '$USERNAME', '$PASSWORD', "dc"])
383 plantestsuite("samba4.blackbox.wbinfo(member:local)", "member:local", [os.path.join(samba4srcdir, "../nsswitch/tests/test_wbinfo.sh"), '$DOMAIN', '$DC_USERNAME', '$DC_PASSWORD', "member"])
384 plantestsuite("samba4.blackbox.chgdcpass(dc)", "dc", [os.path.join(bbdir, "test_chgdcpass.sh"), '$SERVER', "LOCALDC\$", '$REALM', '$DOMAIN', '$PREFIX', "aes256-cts-hmac-sha1-96", '$SELFTEST_PREFIX/dc'])
385
386 # Tests using the "Simple" NTVFS backend
387 for t in ["base.rw1"]:
388     plantestsuite_loadlist("samba4.ntvfs.simple.%s" % t, "dc", [valgrindify(smb4torture), "//$SERVER/simple", '-U$USERNAME%$PASSWORD', t])
389
390 # Domain Member Tests
391 plantestsuite_loadlist("samba4.rpc.echo against member server with local creds", "member", [valgrindify(smb4torture), 'ncacn_np:$NETBIOSNAME', '-U$NETBIOSNAME/$USERNAME%$PASSWORD', 'rpc.echo'])
392 plantestsuite_loadlist("samba4.rpc.echo against member server with domain creds", "member", [valgrindify(smb4torture), 'ncacn_np:$NETBIOSNAME', '-U$DOMAIN/$DC_USERNAME%$DC_PASSWORD', 'rpc.echo'])
393 plantestsuite_loadlist("samba4.rpc.samr against member server with local creds", "member", [valgrindify(smb4torture), 'ncacn_np:$NETBIOSNAME', '-U$NETBIOSNAME/$USERNAME%$PASSWORD', "rpc.samr"])
394 plantestsuite_loadlist("samba4.rpc.samr.users against member server with local creds", "member", [valgrindify(smb4torture), 'ncacn_np:$NETBIOSNAME', '-U$NETBIOSNAME/$USERNAME%$PASSWORD', "rpc.samr.users"])
395 plantestsuite_loadlist("samba4.rpc.samr.passwords against member server with local creds", "member", [valgrindify(smb4torture), 'ncacn_np:$NETBIOSNAME', '-U$NETBIOSNAME/$USERNAME%$PASSWORD', "rpc.samr.passwords"])
396 plantestsuite("samba4.blackbox.smbclient against member server with local creds", "member", [os.path.join(samba4srcdir, "client/tests/test_smbclient.sh"), '$NETBIOSNAME', '$USERNAME', '$PASSWORD', '$NETBIOSNAME', '$PREFIX'])
397
398 # RPC Proxy
399 plantestsuite_loadlist("samba4.rpc.echo against rpc proxy with domain creds", "rpc_proxy", [valgrindify(smb4torture), 'ncacn_ip_tcp:$NETBIOSNAME', '-U$DOMAIN/$DC_USERNAME%$DC_PASSWORD', "rpc.echo"])
400
401 # Tests SMB signing
402 for mech in [
403     "-k no",
404     "-k no --option=usespnego=no",
405     "-k no --option=gensec:spengo=no",
406     "-k yes",
407     "-k yes --option=gensec:fake_gssapi_krb5=yes --option=gensec:gssapi_krb5=no"]:
408     for signing in ["--signing=on", "--signing=required"]:
409         signoptions = "%s %s" % (mech, signing)
410         name = "smb.signing on with %s" % signoptions
411         plantestsuite_loadlist("samba4.%s" % name, "dc", [valgrindify(smb4torture), '//$NETBIOSNAME/tmp', signoptions, '-U$USERNAME%$PASSWORD', 'base.xcopy'])
412
413 for mech in [
414     "-k no",
415     "-k no --option=usespnego=no",
416     "-k no --option=gensec:spengo=no",
417     "-k yes",
418     "-k yes --option=gensec:fake_gssapi_krb5=yes --option=gensec:gssapi_krb5=no"]:
419     signoptions = "%s --signing=off" % mech
420     name = "smb.signing on with %s" % signoptions
421     plantestsuite_loadlist("samba4.%s domain-creds" % name, "member", [valgrindify(smb4torture), '//$NETBIOSNAME/tmp', signoptions, '-U$DC_USERNAME%$DC_PASSWORD', 'base.xcopy'])
422
423 for mech in [
424     "-k no",
425     "-k no --option=usespnego=no",
426     "-k no --option=gensec:spengo=no"]:
427     signoptions = "%s --signing=off" % mech
428     name = "smb.signing on with %s" % signoptions
429     plantestsuite_loadlist("samba4.%s local-creds" % name, "member", [valgrindify(smb4torture), '//$NETBIOSNAME/tmp', signoptions, '-U$NETBIOSNAME/$USERNAME%$PASSWORD', 'base.xcopy'])
430 plantestsuite_loadlist("samba4.smb.signing --signing=yes anon", "dc", [valgrindify(smb4torture), '//$NETBIOSNAME/tmp', '-k', 'no', '--signing=yes', '-U%', 'base.xcopy'])
431 plantestsuite_loadlist("samba4.smb.signing --signing=required anon", "dc", [valgrindify(smb4torture), '//$NETBIOSNAME/tmp', '-k', 'no', '--signing=required', '-U%', 'base.xcopy'])
432 plantestsuite_loadlist("samba4.smb.signing --signing=no anon", "member",  [valgrindify(smb4torture), '//$NETBIOSNAME/tmp', '-k', 'no', '--signing=no', '-U%', 'base.xcopy'])
433
434 nbt_tests = smb4torture_testsuites("nbt.")
435 for t in nbt_tests:
436     plansmbtorturetestsuite(t, "dc", "//$SERVER/_none_ -U\"$USERNAME%$PASSWORD\"")
437
438 wb_opts = ["--option=\"torture:strict mode=no\"", "--option=\"torture:timelimit=1\"", "--option=\"torture:winbindd_separator=/\"", "--option=\"torture:winbindd_netbios_name=$SERVER\"", "--option=\"torture:winbindd_netbios_domain=$DOMAIN\""]
439
440 winbind_struct_tests = smb4torture_testsuites("winbind.struct")
441 winbind_ndr_tests = smb4torture_testsuites("winbind.ndr")
442 for env in ["dc", "member"]:
443     for t in winbind_struct_tests:
444         plansmbtorturetestsuite(t, env, "%s //_none_/_none_" % " ".join(wb_opts))
445
446     for t in winbind_ndr_tests:
447         plansmbtorturetestsuite(t, env, "%s //_none_/_none_" % " ".join(wb_opts))
448
449 nsstest4 = binpath("nsstest")
450 if os.path.exists(nsstest4):
451     plantestsuite("samba4.nss.test using winbind(member)", "member", [valgrindify(nsstest4), os.path.join(samba4bindir, "shared/libnss_winbind.so")])
452 else:
453     skiptestsuite("samba4.nss.test using winbind(member)", "nsstest not available")
454
455 subunitrun = valgrindify(python) + " " + os.path.join(samba4srcdir, "scripting/bin/subunitrun")
456 def plansambapythontestsuite(name, env, path, module, environ={}, extra_args=[]):
457     environ = dict(environ)
458     environ["PYTHONPATH"] = "$PYTHONPATH:" + path
459     args = ["%s=%s" % item for item in environ.iteritems()]
460     args += [subunitrun, "$LISTOPT", module]
461     args += extra_args
462     plantestsuite(name, env, args)
463
464
465 plansambapythontestsuite("ldb.python", "none", "./lib/ldb/tests/python/", 'api')
466 planpythontestsuite("none", "samba.tests.credentials")
467 planpythontestsuite("none", "samba.tests.gensec")
468 planpythontestsuite("none", "samba.tests.registry")
469 plansambapythontestsuite("tdb.python", "none", "../lib/tdb/python/tests", 'simple')
470 planpythontestsuite("none", "samba.tests.auth")
471 planpythontestsuite("none", "samba.tests.security")
472 planpythontestsuite("none", "samba.tests.dcerpc.misc")
473 planpythontestsuite("none", "samba.tests.param")
474 planpythontestsuite("none", "samba.tests.upgrade")
475 planpythontestsuite("none", "samba.tests.core")
476 planpythontestsuite("none", "samba.tests.provision")
477 planpythontestsuite("none", "samba.tests.samba3")
478 planpythontestsuite("dc:local", "samba.tests.dcerpc.sam")
479 planpythontestsuite("dc:local", "samba.tests.dsdb")
480 planpythontestsuite("none", "samba.tests.netcmd")
481 planpythontestsuite("dc:local", "samba.tests.dcerpc.bare")
482 planpythontestsuite("dc:local", "samba.tests.dcerpc.unix")
483 planpythontestsuite("none", "samba.tests.dcerpc.rpc_talloc")
484 planpythontestsuite("none", "samba.tests.samdb")
485 planpythontestsuite("none", "samba.tests.hostconfig")
486 planpythontestsuite("none", "samba.tests.messaging")
487 planpythontestsuite("none", "samba.tests.samba3sam")
488 planpythontestsuite("none", "subunit")
489 planpythontestsuite("dc:local", "samba.tests.dcerpc.rpcecho")
490 plantestsuite_idlist("samba.tests.dcerpc.registry", "dc:local", [subunitrun, "$LISTOPT", '-U"$USERNAME%$PASSWORD"', "samba.tests.dcerpc.registry"])
491 plantestsuite("samba4.ldap.python(dc)", "dc", [python, os.path.join(samba4srcdir, "dsdb/tests/python/ldap.py"), '$SERVER', '-U"$USERNAME%$PASSWORD"', '-W', '$DOMAIN'])
492 plantestsuite("samba4.sam.python(dc)", "dc", [python, os.path.join(samba4srcdir, "dsdb/tests/python/sam.py"), '$SERVER', '-U"$USERNAME%$PASSWORD"', '-W', '$DOMAIN'])
493 plansambapythontestsuite("samba4.schemaInfo.python(dc)", "dc", os.path.join(samba4srcdir, 'dsdb/tests/python'), 'dsdb_schema_info', extra_args=['-U"$DOMAIN/$DC_USERNAME%$DC_PASSWORD"'])
494 plantestsuite("samba4.urgent_replication.python(dc)", "dc", [python, os.path.join(samba4srcdir, "dsdb/tests/python/urgent_replication.py"), '$PREFIX_ABS/dc/private/sam.ldb'], allow_empty_output=True)
495 for env in ["dc", "fl2000dc", "fl2003dc", "fl2008r2dc"]:
496     plantestsuite("samba4.ldap_schema.python(%s)" % env, env, [python, os.path.join(samba4srcdir, "dsdb/tests/python/ldap_schema.py"), '$SERVER', '-U"$USERNAME%$PASSWORD"', '-W', '$DOMAIN'])
497     plantestsuite("samba4.ldap.possibleInferiors.python(%s)" % env, env, [python, os.path.join(samba4srcdir, "dsdb/samdb/ldb_modules/tests/possibleinferiors.py"), "ldap://$SERVER", '-U"$USERNAME%$PASSWORD"', "-W", "$DOMAIN"])
498     plantestsuite("samba4.ldap.secdesc.python(%s)" % env, env, [python, os.path.join(samba4srcdir, "dsdb/tests/python/sec_descriptor.py"), '$SERVER', '-U"$USERNAME%$PASSWORD"', '-W', '$DOMAIN'])
499     plantestsuite("samba4.ldap.acl.python(%s)" % env, env, [python, os.path.join(samba4srcdir, "dsdb/tests/python/acl.py"), '$SERVER', '-U"$USERNAME%$PASSWORD"', '-W', '$DOMAIN'])
500     if env != "fl2000dc":
501         # This test makes excessively use of the "userPassword" attribute which
502         # isn't available on DCs with Windows 2000 domain function level -
503         # therefore skip it in that configuration
504         plantestsuite("samba4.ldap.passwords.python(%s)" % env, env, [python, os.path.join(samba4srcdir, "dsdb/tests/python/passwords.py"), "$SERVER", '-U"$USERNAME%$PASSWORD"', "-W", "$DOMAIN"])
505 planpythontestsuite("dc:local", "samba.tests.upgradeprovisionneeddc")
506 planpythontestsuite("none", "samba.tests.upgradeprovision")
507 planpythontestsuite("none", "samba.tests.xattr")
508 planpythontestsuite("none", "samba.tests.ntacls")
509 plantestsuite("samba4.deletetest.python(dc)", "dc", ['PYTHONPATH="$PYTHONPATH:../lib/subunit/python:../lib/testtools"', python, os.path.join(samba4srcdir, "dsdb/tests/python/deletetest.py"), '$SERVER', '-U"$USERNAME%$PASSWORD"', '-W', '$DOMAIN'])
510 plansambapythontestsuite("samba4.policy.python", "none", "lib/policy/tests/python", 'bindings')
511 plantestsuite("samba4.blackbox.samba3dump", "none", [python, os.path.join(samba4srcdir, "scripting/bin/samba3dump"), os.path.join(samba4srcdir, "../testdata/samba3")], allow_empty_output=True)
512 plantestsuite("samba4.blackbox.upgrade", "none", ["rm -rf $PREFIX/upgrade;", python, os.path.join(samba4srcdir, "setup/upgrade_from_s3"), "--targetdir=$PREFIX/upgrade", os.path.normpath(os.path.join(samba4srcdir, "../testdata/samba3")), os.path.normpath(os.path.join(samba4srcdir, "../testdata/samba3/smb.conf"))], allow_empty_output=True)
513 plantestsuite("samba4.blackbox.provision.py", "none", ["PYTHON=%s" % python, os.path.join(samba4srcdir, "setup/tests/blackbox_provision.sh"), '$PREFIX/provision'])
514 plantestsuite("samba4.blackbox.upgradeprovision.py", "none", ["PYTHON=%s" % python, os.path.join(samba4srcdir, "setup/tests/blackbox_upgradeprovision.sh"), '$PREFIX/provision'])
515 plantestsuite("samba4.blackbox.setpassword.py", "none", ["PYTHON=%s" % python, os.path.join(samba4srcdir, "setup/tests/blackbox_setpassword.sh"), '$PREFIX/provision'])
516 plantestsuite("samba4.blackbox.newuser.py", "none", ["PYTHON=%s" % python, os.path.join(samba4srcdir, "setup/tests/blackbox_newuser.sh"), '$PREFIX/provision'])
517 plantestsuite("samba4.blackbox.group.py", "none", ["PYTHON=%s" % python, os.path.join(samba4srcdir, "setup/tests/blackbox_group.sh"), '$PREFIX/provision'])
518 plantestsuite("samba4.blackbox.spn.py(dc:local)", "dc:local", ["PYTHON=%s" % python, os.path.join(samba4srcdir, "setup/tests/blackbox_spn.sh"), '$PREFIX/dc'])
519 plantestsuite("samba4.ldap.bind(dc)", "dc", [python, os.path.join(samba4srcdir, "auth/credentials/tests/bind.py"), '$SERVER', '-U"$USERNAME%$PASSWORD"'])
520
521 # DRS python tests
522 plansambapythontestsuite("samba4.drs.delete_object.python(vampire_dc)", "vampire_dc", os.path.join(samba4srcdir, 'torture/drs/python'), "delete_object", environ={'DC1': '$DC_SERVER', 'DC2': '$VAMPIRE_DC_SERVER'}, extra_args=['-U$DOMAIN/$DC_USERNAME%$DC_PASSWORD'])
523 plansambapythontestsuite("samba4.drs.fsmo.python(vampire_dc)", "vampire_dc", os.path.join(samba4srcdir, 'torture/drs/python'), "fsmo", environ={'DC1': "$DC_SERVER", 'DC2': "$VAMPIRE_DC_SERVER"}, extra_args=['-U$DOMAIN/$DC_USERNAME%$DC_PASSWORD'])
524 plansambapythontestsuite("samba4.drs.repl_schema.python(vampire_dc)", "vampire_dc", os.path.join(samba4srcdir, 'torture/drs/python'), "repl_schema", environ={'DC1': "$DC_SERVER", 'DC2': '$VAMPIRE_DC_SERVER'}, extra_args=['-U$DOMAIN/$DC_USERNAME%$DC_PASSWORD'])
525
526 # This makes sure we test the rid allocation code
527 t = "rpc.samr.large-dc"
528 plantestsuite_loadlist("samba4.%s.one" % t, "vampire_dc", [valgrindify(smb4torture), '$SERVER', '-U$USERNAME%$PASSWORD', '-W', '$DOMAIN', t])
529 plantestsuite_loadlist("samba4.%s.two" % t, "vampire_dc", [valgrindify(smb4torture), '$SERVER', '-U$USERNAME%$PASSWORD', '-W', '$DOMAIN', t])
530
531 # some RODC testing
532 plantestsuite_loadlist("samba4.rpc.echo", "rodc", [smb4torture, 'ncacn_np:$SERVER', "-k", "yes", '-U$USERNAME%$PASSWORD', '-W' '$DOMAIN', 'rpc.echo'])
533 plantestsuite("samba4.blackbox.provision-backend.py", "none", ["PYTHON=%s" % python, os.path.join(samba4srcdir, "setup/tests/blackbox_provision-backend.sh"), '$PREFIX/provision'])