s4:scripting/python/modules.[ch] - explicitly say that "py_update_path" takes no...
[Samba.git] / source4 / selftest / tests.py
blob2dd91fb50d0baea2d49dc77683e9faa04d3e6baa
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.
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".
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.
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.
21 import os
22 import subprocess
24 def binpath(name):
25 return os.path.join(samba4bindir, "%s%s" % (name, os.getenv("EXEEXT", "")))
27 perl = os.getenv("PERL", "perl")
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
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
41 python = os.getenv("PYTHON", "python")
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
51 def plantestsuite(name, env, cmdline, allow_empty_output=False):
52 """Plan a test suite.
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 if "$LISTOPT" in cmdline:
67 filter_subunit_args.append("$LISTOPT")
68 print "%s 2>&1 | %s/selftest/filter-subunit %s --prefix=\"%s.\"" % (cmdline,
69 srcdir,
70 " ".join(filter_subunit_args),
71 name)
72 if allow_empty_output:
73 print "WARNING: allowing empty subunit output from %s" % name
76 def add_prefix(prefix, support_list=False):
77 if support_list:
78 listopt = "$LISTOPT "
79 else:
80 listopt = ""
81 return "%s/selftest/filter-subunit %s--fail-on-empty --prefix=\"%s.\"" % (srcdir, listopt, prefix)
84 def plantestsuite_loadlist(name, env, cmdline):
85 print "-- TEST-LOADLIST --"
86 if env == "none":
87 fullname = name
88 else:
89 fullname = "%s(%s)" % (name, env)
90 print fullname
91 print env
92 if isinstance(cmdline, list):
93 cmdline = " ".join(cmdline)
94 support_list = ("$LISTOPT" in cmdline)
95 print "%s $LOADLIST 2>&1 | %s" % (cmdline, add_prefix(name, support_list))
98 def plantestsuite_idlist(name, env, cmdline):
99 print "-- TEST-IDLIST --"
100 print name
101 print env
102 if isinstance(cmdline, list):
103 cmdline = " ".join(cmdline)
104 print cmdline
107 def skiptestsuite(name, reason):
108 """Indicate that a testsuite was skipped.
110 :param name: Test suite name
111 :param reason: Reason the test suite was skipped
113 # FIXME: Report this using subunit, but re-adjust the testsuite count somehow
114 print "skipping %s (%s)" % (name, reason)
117 def planperltestsuite(name, path):
118 """Run a perl test suite.
120 :param name: Name of the test suite
121 :param path: Path to the test runner
123 if has_perl_test_more:
124 plantestsuite(name, "none", "%s %s | %s" % (perl, path, tap2subunit))
125 else:
126 skiptestsuite(name, "Test::More not available")
129 def planpythontestsuite(env, module):
130 if has_system_subunit_run:
131 plantestsuite_idlist(module, env, [python, "-m", "subunit.run", "$LISTOPT", module])
132 else:
133 plantestsuite_idlist(module, env, "PYTHONPATH=$PYTHONPATH:%s/../lib/subunit/python:%s/../lib/testtools %s -m subunit.run $LISTOPT %s" % (samba4srcdir, samba4srcdir, python, module))
136 def plansmbtorturetestsuite(name, env, options):
137 modname = "samba4.%s" % name
138 cmdline = "%s $LISTOPT %s %s" % (valgrindify(smb4torture), options, name)
139 plantestsuite_loadlist(modname, env, cmdline)
142 srcdir = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "../.."))
143 samba4srcdir = os.path.join(srcdir, 'source4')
144 builddir = os.getenv("BUILDDIR", samba4srcdir)
145 samba4bindir = os.path.normpath(os.path.join(builddir, "bin"))
146 smb4torture = binpath("smbtorture")
147 smb4torture_testsuite_list = subprocess.Popen([smb4torture, "--list-suites"], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate("")[0].splitlines()
148 validate = os.getenv("VALIDATE", "")
149 if validate:
150 validate_list = [validate]
151 else:
152 validate_list = []
153 def smb4torture_testsuites(prefix):
154 return filter(lambda x: x.startswith(prefix), smb4torture_testsuite_list)
156 sub = subprocess.Popen("tap2subunit 2> /dev/null", stdout=subprocess.PIPE, stdin=subprocess.PIPE, shell=True)
157 sub.communicate("")
158 if sub.returncode != 0:
159 tap2subunit = "PYTHONPATH=%s/../lib/subunit/python:%s/../lib/testtools %s %s/../lib/subunit/filters/tap2subunit" % (samba4srcdir, samba4srcdir, python, samba4srcdir)
160 else:
161 cmd = "echo -ne \"1..1\nok 1 # skip doesn't seem to work yet\n\" | tap2subunit 2> /dev/null | grep skip"
162 sub = subprocess.Popen(cmd, stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
163 if sub.returncode == 0:
164 tap2subunit = "tap2subunit"
165 else:
166 tap2subunit = "PYTHONPATH=%s/../lib/subunit/python:%s/../lib/testtools %s %s/../lib/subunit/filters/tap2subunit" % (samba4srcdir, samba4srcdir, python, samba4srcdir)
168 subprocess.call([smb4torture, "-V"])
170 bbdir = os.path.join(srcdir, "testprogs/blackbox")
172 configuration = "--configfile=$SMB_CONF_PATH"
174 torture_options = [configuration, "--maximum-runtime=$SELFTEST_MAXTIME", "--target=$SELFTEST_TARGET", "--basedir=$SELFTEST_TMPDIR"]
175 if not os.getenv("SELFTEST_VERBOSE"):
176 torture_options.append("--option=torture:progress=no")
177 torture_options.append("--format=subunit")
178 if os.getenv("SELFTEST_QUICK"):
179 torture_options.append("--option=torture:quick=yes")
180 smb4torture += " " + " ".join(torture_options)
182 print "OPTIONS %s" % " ".join(torture_options)
184 # Simple tests for LDAP and CLDAP
185 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']:
186 plantestsuite("samba4.ldb.ldap with options %s(dc)" % options, "dc", "%s/test_ldb.sh ldap $SERVER %s" % (bbdir, options))
188 # see if we support ldaps
189 try:
190 config_h = os.environ["CONFIG_H"]
191 except KeyError:
192 config_h = os.path.join(samba4bindir, "default/source4/include/config.h")
193 f = open(config_h, 'r')
194 try:
195 have_tls_support = ("ENABLE_GNUTLS 1" in f.read())
196 finally:
197 f.close()
199 if have_tls_support:
200 for options in ['-U"$USERNAME%$PASSWORD"']:
201 plantestsuite("samba4.ldb.ldaps with options %s(dc)" % options, "dc",
202 "%s/test_ldb.sh ldaps $SERVER_IP %s" % (bbdir, options))
204 for options in ['-U"$USERNAME%$PASSWORD"']:
205 plantestsuite("samba4.ldb.ldapi with options %s(dc:local)" % options, "dc:local",
206 "%s/test_ldb.sh ldapi $PREFIX_ABS/dc/private/ldapi %s" % (bbdir, options))
208 for t in smb4torture_testsuites("ldap."):
209 plansmbtorturetestsuite(t, "dc", '-U"$USERNAME%$PASSWORD" //$SERVER_IP/_none_')
211 ldbdir = os.path.join(samba4srcdir, "lib/ldb")
212 # Don't run LDB tests when using system ldb, as we won't have ldbtest installed
213 if os.path.exists(os.path.join(samba4bindir, "ldbtest")):
214 plantestsuite("ldb.base", "none", "%s/tests/test-tdb.sh" % ldbdir,
215 allow_empty_output=True)
216 else:
217 skiptestsuite("ldb.base", "Using system LDB, ldbtest not available")
219 # Tests for RPC
221 # add tests to this list as they start passing, so we test
222 # that they stay passing
223 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"]
224 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"]
225 drs_rpc_tests = smb4torture_testsuites("drs.rpc")
226 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
227 slow_ncacn_np_tests = ["rpc.samlogon", "rpc.samr.users", "rpc.samr.large-dc", "rpc.samr.users.privileges", "rpc.samr.passwords", "rpc.samr.passwords.pwdlastset"]
228 slow_ncacn_ip_tcp_tests = ["rpc.samr", "rpc.cracknames"]
230 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"]
232 # Make sure all tests get run
233 rpc_tests = smb4torture_testsuites("rpc.")
234 auto_rpc_tests = filter(lambda t: t not in all_rpc_tests, rpc_tests)
236 for bindoptions in ["seal,padcheck"] + validate_list + ["bigendian"]:
237 for transport in ["ncalrpc", "ncacn_np", "ncacn_ip_tcp"]:
238 env = "dc"
239 if transport == "ncalrpc":
240 tests = ncalrpc_tests
241 env = "dc:local"
242 elif transport == "ncacn_np":
243 tests = ncacn_np_tests
244 elif transport == "ncacn_ip_tcp":
245 tests = ncacn_ip_tcp_tests
246 for t in tests:
247 plantestsuite_loadlist("samba4.%s on %s with %s" % (t, transport, bindoptions), env, [valgrindify(smb4torture), "$LISTOPT", "%s:$SERVER[%s]" % (transport, bindoptions), '-U$USERNAME%$PASSWORD', '-W', '$DOMAIN', t])
248 plantestsuite_loadlist("samba4.rpc.samba3.sharesec on %s with %s" % (transport, bindoptions), env, [valgrindify(smb4torture), "$LISTOPT", "%s:$SERVER[%s]" % (transport, bindoptions), '-U$USERNAME%$PASSWORD', '-W', '$DOMAIN', '--option=torture:share=tmp', 'rpc.samba3-sharesec'])
250 for bindoptions in [""] + validate_list + ["bigendian"]:
251 for t in auto_rpc_tests:
252 plantestsuite_loadlist("samba4.%s with %s" % (t, bindoptions), "dc", [valgrindify(smb4torture), "$LISTOPT", "$SERVER[%s]" % bindoptions, '-U$USERNAME%$PASSWORD', '-W', '$DOMAIN', t])
254 t = "rpc.countcalls"
255 plantestsuite_loadlist("samba4.%s" % t, "dc:local", [valgrindify(smb4torture), "$LISTOPT", "$SERVER[%s]" % bindoptions, '-U$USERNAME%$PASSWORD', '-W', '$DOMAIN', t])
257 for transport in ["ncacn_np", "ncacn_ip_tcp"]:
258 env = "dc"
259 if transport == "ncacn_np":
260 tests = slow_ncacn_np_tests
261 elif transport == "ncacn_ip_tcp":
262 tests = slow_ncacn_ip_tcp_tests
263 for t in tests:
264 plantestsuite_loadlist("samba4.%s on %s" % (t, transport), env, [valgrindify(smb4torture), "$LISTOPT", "%s:$SERVER" % transport, '-U$USERNAME%$PASSWORD', '-W', '$DOMAIN', t])
266 # Tests for the DFS referral calls implementation
267 for t in smb4torture_testsuites("dfs."):
268 plansmbtorturetestsuite(t, "dc", '//$SERVER/ipc\$ -U$USERNAME%$PASSWORD')
270 # Tests for the NET API (net.api.become.dc tested below against all the roles)
271 net_tests = filter(lambda x: "net.api.become.dc" not in x, smb4torture_testsuites("net."))
272 for t in net_tests:
273 plansmbtorturetestsuite(t, "dc", '$SERVER[%s] -U$USERNAME%%$PASSWORD -W $DOMAIN' % validate)
275 # Tests for session keys and encryption of RPC pipes
276 # FIXME: Integrate these into a single smbtorture test
278 transport = "ncacn_np"
279 for ntlmoptions in [
280 "-k no --option=usespnego=yes",
281 "-k no --option=usespnego=yes --option=ntlmssp_client:128bit=no",
282 "-k no --option=usespnego=yes --option=ntlmssp_client:56bit=yes",
283 "-k no --option=usespnego=yes --option=ntlmssp_client:56bit=no",
284 "-k no --option=usespnego=yes --option=ntlmssp_client:128bit=no --option=ntlmssp_client:56bit=yes",
285 "-k no --option=usespnego=yes --option=ntlmssp_client:128bit=no --option=ntlmssp_client:56bit=no",
286 "-k no --option=usespnego=yes --option=clientntlmv2auth=yes",
287 "-k no --option=usespnego=yes --option=clientntlmv2auth=yes --option=ntlmssp_client:128bit=no",
288 "-k no --option=usespnego=yes --option=clientntlmv2auth=yes --option=ntlmssp_client:128bit=no --option=ntlmssp_client:56bit=yes",
289 "-k no --option=usespnego=no --option=clientntlmv2auth=yes",
290 "-k no --option=gensec:spnego=no --option=clientntlmv2auth=yes",
291 "-k no --option=usespnego=no"]:
292 name = "rpc.lsa.secrets on %s with with %s" % (transport, ntlmoptions)
293 plantestsuite_loadlist("samba4.%s" % name, "dc", [smb4torture, "$LISTOPT", "%s:$SERVER[]" % (transport), ntlmoptions, '-U$USERNAME%$PASSWORD', '-W', '$DOMAIN', '--option=gensec:target_hostname=$NETBIOSNAME', 'rpc.lsa.secrets'])
295 transports = ["ncacn_np", "ncacn_ip_tcp"]
297 #Kerberos varies between functional levels, so it is important to check this on all of them
298 for env in ["dc", "fl2000dc", "fl2003dc", "fl2008r2dc"]:
299 transport = "ncacn_np"
300 plantestsuite_loadlist("samba4.rpc.pac on %s" % (transport,), env, [smb4torture, "$LISTOPT", "%s:$SERVER[]" % (transport, ), '-U$USERNAME%$PASSWORD', '-W', '$DOMAIN', 'rpc.pac'])
301 for transport in transports:
302 plantestsuite_loadlist("samba4.rpc.lsa.secrets on %s with Kerberos" % (transport,), env, [smb4torture, "$LISTOPT", "%s:$SERVER[]" % (transport, ), '-k', 'yes', '-U$USERNAME%$PASSWORD', '-W', '$DOMAIN', '--option=gensec:target_hostname=$NETBIOSNAME', 'rpc.lsa.secrets'])
303 plantestsuite_loadlist("samba4.rpc.lsa.secrets on %s with Kerberos - use target principal" % (transport,), env, [smb4torture, "$LISTOPT", "%s:$SERVER[]" % (transport, ), '-k', 'yes', '-U$USERNAME%$PASSWORD', '-W', '$DOMAIN', "--option=clientusespnegoprincipal=yes", '--option=gensec:target_hostname=$NETBIOSNAME', 'rpc.lsa.secrets'])
304 plantestsuite_loadlist("samba4.rpc.lsa.secrets on %s with Kerberos - use Samba3 style login" % transport, env, [smb4torture, "$LISTOPT", "%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*"])
305 plantestsuite_loadlist("samba4.rpc.lsa.secrets on %s with Kerberos - use Samba3 style login, use target principal" % transport, env, [smb4torture, "$LISTOPT", "%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*"])
306 plantestsuite_loadlist("samba4.rpc.echo on %s" % (transport, ), env, [smb4torture, "$LISTOPT", "%s:$SERVER[]" % (transport,), '-U$USERNAME%$PASSWORD', '-W', '$DOMAIN', 'rpc.echo'])
308 # Echo tests test bulk Kerberos encryption of DCE/RPC
309 for bindoptions in ["connect", "spnego", "spnego,sign", "spnego,seal"] + validate_list + ["padcheck", "bigendian", "bigendian,seal"]:
310 echooptions = "--option=socket:testnonblock=True --option=torture:quick=yes -k yes"
311 plantestsuite_loadlist("samba4.rpc.echo on %s with %s and %s" % (transport, bindoptions, echooptions), env, [smb4torture, "$LISTOPT", "%s:$SERVER[%s]" % (transport, bindoptions), echooptions, '-U$USERNAME%$PASSWORD', '-W', '$DOMAIN', 'rpc.echo'])
312 plansmbtorturetestsuite("net.api.become.dc", env, '$SERVER[%s] -U$USERNAME%%$PASSWORD -W $DOMAIN' % validate)
314 for bindoptions in ["sign", "seal"]:
315 env = "dc"
316 plantestsuite_loadlist("samba4.rpc.backupkey with %s" % (bindoptions), env, [smb4torture, "$LISTOPT", "ncacn_np:$SERVER[%s]" % ( bindoptions), '-U$USERNAME%$PASSWORD', '-W', '$DOMAIN', 'rpc.backupkey'])
318 for transport in transports:
319 for bindoptions in ["sign", "seal"]:
320 for ntlmoptions in [
321 "--option=ntlmssp_client:ntlm2=yes --option=torture:quick=yes",
322 "--option=ntlmssp_client:ntlm2=no --option=torture:quick=yes",
323 "--option=ntlmssp_client:ntlm2=yes --option=ntlmssp_client:128bit=no --option=torture:quick=yes",
324 "--option=ntlmssp_client:ntlm2=no --option=ntlmssp_client:128bit=no --option=torture:quick=yes",
325 "--option=ntlmssp_client:ntlm2=yes --option=ntlmssp_client:keyexchange=no --option=torture:quick=yes",
326 "--option=ntlmssp_client:ntlm2=no --option=ntlmssp_client:keyexchange=no --option=torture:quick=yes",
327 "--option=clientntlmv2auth=yes --option=ntlmssp_client:keyexchange=no --option=torture:quick=yes",
328 "--option=clientntlmv2auth=yes --option=ntlmssp_client:128bit=no --option=ntlmssp_client:keyexchange=yes --option=torture:quick=yes",
329 "--option=clientntlmv2auth=yes --option=ntlmssp_client:128bit=no --option=ntlmssp_client:keyexchange=no --option=torture:quick=yes"]:
330 if transport == "ncalrpc":
331 env = "dc:local"
332 else:
333 env = "dc"
334 plantestsuite_loadlist("samba4.rpc.echo on %s with %s and %s" % (transport, bindoptions, ntlmoptions), env, [smb4torture, "$LISTOPT", "%s:$SERVER[%s]" % (transport, bindoptions), ntlmoptions, '-U$USERNAME%$PASSWORD', '-W', '$DOMAIN', 'rpc.echo'])
336 plantestsuite_loadlist("samba4.rpc.echo on ncacn_np over smb2", "dc", [smb4torture, "$LISTOPT", 'ncacn_np:$SERVER[smb2]', '-U$USERNAME%$PASSWORD', '-W', '$DOMAIN', 'rpc.echo'])
338 plantestsuite_loadlist("samba4.ntp.signd", "dc:local", [smb4torture, "$LISTOPT", 'ncacn_np:$SERVER', '-U$USERNAME%$PASSWORD', '-W', '$DOMAIN', 'ntp.signd'])
340 # Tests against the NTVFS POSIX backend
341 ntvfsargs = ["--option=torture:sharedelay=10000", "--option=torture:oplocktimeout=3", "--option=torture:writetimeupdatedelay=50000"]
343 smb2 = smb4torture_testsuites("smb2.")
344 #The QFILEINFO-IPC test needs to be on ipc$
345 raw = filter(lambda x: "raw.qfileinfo.ipc" not in x, smb4torture_testsuites("raw."))
346 base = smb4torture_testsuites("base.")
348 for t in base + raw + smb2:
349 plansmbtorturetestsuite(t, "dc", '//$SERVER/tmp -U$USERNAME%$PASSWORD' + " " + " ".join(ntvfsargs))
351 plansmbtorturetestsuite("raw.qfileinfo.ipc", "dc", '//$SERVER/ipc\$ -U$USERNAME%$PASSWORD')
353 for t in smb4torture_testsuites("rap."):
354 plansmbtorturetestsuite(t, "dc", '//$SERVER/IPC\$ -U$USERNAME%$PASSWORD')
356 # Tests against the NTVFS CIFS backend
357 for t in base + raw:
358 plantestsuite_loadlist("samba4.ntvfs.cifs.%s" % t, "dc", [valgrindify(smb4torture), "$LISTOPT", '//$NETBIOSNAME/cifs', '-U$USERNAME%$PASSWORD'] + ntvfsargs + [t])
360 plansmbtorturetestsuite('echo.udp', 'dc:local', '//$SERVER/whatever')
362 # Local tests
363 for t in smb4torture_testsuites("local."):
364 plansmbtorturetestsuite(t, "none", "ncalrpc:")
366 tdbtorture4 = binpath("tdbtorture")
367 if os.path.exists(tdbtorture4):
368 plantestsuite("tdb.stress", "none", valgrindify(tdbtorture4))
369 else:
370 skiptestsuite("tdb.stress", "Using system TDB, tdbtorture not available")
372 plansmbtorturetestsuite("drs.unit", "none", "ncalrpc:")
374 # Pidl tests
375 for f in sorted(os.listdir(os.path.join(samba4srcdir, "../pidl/tests"))):
376 if f.endswith(".pl"):
377 planperltestsuite("pidl.%s" % f[:-3], os.path.normpath(os.path.join(samba4srcdir, "../pidl/tests", f)))
378 planperltestsuite("selftest.samba4", os.path.normpath(os.path.join(samba4srcdir, "../selftest/test_samba4.pl")))
380 # Blackbox Tests:
381 # tests that interact directly with the command-line tools rather than using
382 # the API. These mainly test that the various command-line options of commands
383 # work correctly.
385 planpythontestsuite("none", "samba.tests.blackbox.ndrdump")
386 plantestsuite("samba4.blackbox.samba_tool(dc:local)", "dc:local", [os.path.join(samba4srcdir, "utils/tests/test_samba_tool.sh"), '$SERVER', "$USERNAME", "$PASSWORD", "$DOMAIN"])
387 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])
388 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])
389 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])
390 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])
391 plantestsuite("samba4.blackbox.ktpass(dc)", "dc", [os.path.join(bbdir, "test_ktpass.sh"), '$PREFIX'])
392 plantestsuite("samba4.blackbox.passwords(dc:local)", "dc:local", [os.path.join(bbdir, "test_passwords.sh"), '$SERVER', '$USERNAME', '$PASSWORD', '$REALM', '$DOMAIN', "$PREFIX"])
393 plantestsuite("samba4.blackbox.export.keytab(dc:local)", "dc:local", [os.path.join(bbdir, "test_export_keytab.sh"), '$SERVER', '$USERNAME', '$REALM', '$DOMAIN', "$PREFIX"])
394 plantestsuite("samba4.blackbox.cifsdd(dc)", "dc", [os.path.join(samba4srcdir, "client/tests/test_cifsdd.sh"), '$SERVER', '$USERNAME', '$PASSWORD', "$DOMAIN"])
395 plantestsuite("samba4.blackbox.nmblookup(dc)", "dc", [os.path.join(samba4srcdir, "utils/tests/test_nmblookup.sh"), '$NETBIOSNAME', '$NETBIOSALIAS', '$SERVER', '$SERVER_IP'])
396 plantestsuite("samba4.blackbox.nmblookup(member)", "member", [os.path.join(samba4srcdir, "utils/tests/test_nmblookup.sh"), '$NETBIOSNAME', '$NETBIOSALIAS', '$SERVER', '$SERVER_IP'])
397 plantestsuite("samba4.blackbox.locktest(dc)", "dc", [os.path.join(samba4srcdir, "torture/tests/test_locktest.sh"), '$SERVER', '$USERNAME', '$PASSWORD', '$DOMAIN', '$PREFIX'])
398 plantestsuite("samba4.blackbox.masktest", "dc", [os.path.join(samba4srcdir, "torture/tests/test_masktest.sh"), '$SERVER', '$USERNAME', '$PASSWORD', '$DOMAIN', '$PREFIX'])
399 plantestsuite("samba4.blackbox.gentest(dc)", "dc", [os.path.join(samba4srcdir, "torture/tests/test_gentest.sh"), '$SERVER', '$USERNAME', '$PASSWORD', '$DOMAIN', "$PREFIX"])
400 plantestsuite("samba4.blackbox.wbinfo(dc:local)", "dc:local", [os.path.join(samba4srcdir, "../nsswitch/tests/test_wbinfo.sh"), '$DOMAIN', '$USERNAME', '$PASSWORD', "dc"])
401 plantestsuite("samba4.blackbox.wbinfo(member:local)", "member:local", [os.path.join(samba4srcdir, "../nsswitch/tests/test_wbinfo.sh"), '$DOMAIN', '$DC_USERNAME', '$DC_PASSWORD', "member"])
402 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'])
404 # Tests using the "Simple" NTVFS backend
405 for t in ["base.rw1"]:
406 plantestsuite_loadlist("samba4.ntvfs.simple.%s" % t, "dc", [valgrindify(smb4torture), "$LISTOPT", "//$SERVER/simple", '-U$USERNAME%$PASSWORD', t])
408 # Domain Member Tests
409 plantestsuite_loadlist("samba4.rpc.echo against member server with local creds", "member", [valgrindify(smb4torture), "$LISTOPT", 'ncacn_np:$NETBIOSNAME', '-U$NETBIOSNAME/$USERNAME%$PASSWORD', 'rpc.echo'])
410 plantestsuite_loadlist("samba4.rpc.echo against member server with domain creds", "member", [valgrindify(smb4torture), "$LISTOPT", 'ncacn_np:$NETBIOSNAME', '-U$DOMAIN/$DC_USERNAME%$DC_PASSWORD', 'rpc.echo'])
411 plantestsuite_loadlist("samba4.rpc.samr against member server with local creds", "member", [valgrindify(smb4torture), "$LISTOPT", 'ncacn_np:$NETBIOSNAME', '-U$NETBIOSNAME/$USERNAME%$PASSWORD', "rpc.samr"])
412 plantestsuite_loadlist("samba4.rpc.samr.users against member server with local creds", "member", [valgrindify(smb4torture), "$LISTOPT", 'ncacn_np:$NETBIOSNAME', '-U$NETBIOSNAME/$USERNAME%$PASSWORD', "rpc.samr.users"])
413 plantestsuite_loadlist("samba4.rpc.samr.passwords against member server with local creds", "member", [valgrindify(smb4torture), "$LISTOPT", 'ncacn_np:$NETBIOSNAME', '-U$NETBIOSNAME/$USERNAME%$PASSWORD', "rpc.samr.passwords"])
414 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'])
416 # RPC Proxy
417 plantestsuite_loadlist("samba4.rpc.echo against rpc proxy with domain creds", "rpc_proxy", [valgrindify(smb4torture), "$LISTOPT", 'ncacn_ip_tcp:$NETBIOSNAME', '-U$DOMAIN/$DC_USERNAME%$DC_PASSWORD', "rpc.echo"])
419 # Tests SMB signing
420 for mech in [
421 "-k no",
422 "-k no --option=usespnego=no",
423 "-k no --option=gensec:spengo=no",
424 "-k yes",
425 "-k yes --option=gensec:fake_gssapi_krb5=yes --option=gensec:gssapi_krb5=no"]:
426 for signing in ["--signing=on", "--signing=required"]:
427 signoptions = "%s %s" % (mech, signing)
428 name = "smb.signing on with %s" % signoptions
429 plantestsuite_loadlist("samba4.%s" % name, "dc", [valgrindify(smb4torture), "$LISTOPT", '//$NETBIOSNAME/tmp', signoptions, '-U$USERNAME%$PASSWORD', 'base.xcopy'])
431 for mech in [
432 "-k no",
433 "-k no --option=usespnego=no",
434 "-k no --option=gensec:spengo=no",
435 "-k yes",
436 "-k yes --option=gensec:fake_gssapi_krb5=yes --option=gensec:gssapi_krb5=no"]:
437 signoptions = "%s --signing=off" % mech
438 name = "smb.signing on with %s" % signoptions
439 plantestsuite_loadlist("samba4.%s domain-creds" % name, "member", [valgrindify(smb4torture), "$LISTOPT", '//$NETBIOSNAME/tmp', signoptions, '-U$DC_USERNAME%$DC_PASSWORD', 'base.xcopy'])
441 for mech in [
442 "-k no",
443 "-k no --option=usespnego=no",
444 "-k no --option=gensec:spengo=no"]:
445 signoptions = "%s --signing=off" % mech
446 name = "smb.signing on with %s" % signoptions
447 plantestsuite_loadlist("samba4.%s local-creds" % name, "member", [valgrindify(smb4torture), "$LISTOPT", '//$NETBIOSNAME/tmp', signoptions, '-U$NETBIOSNAME/$USERNAME%$PASSWORD', 'base.xcopy'])
448 plantestsuite_loadlist("samba4.smb.signing --signing=yes anon", "dc", [valgrindify(smb4torture), "$LISTOPT", '//$NETBIOSNAME/tmp', '-k', 'no', '--signing=yes', '-U%', 'base.xcopy'])
449 plantestsuite_loadlist("samba4.smb.signing --signing=required anon", "dc", [valgrindify(smb4torture), "$LISTOPT", '//$NETBIOSNAME/tmp', '-k', 'no', '--signing=required', '-U%', 'base.xcopy'])
450 plantestsuite_loadlist("samba4.smb.signing --signing=no anon", "member", [valgrindify(smb4torture), "$LISTOPT", '//$NETBIOSNAME/tmp', '-k', 'no', '--signing=no', '-U%', 'base.xcopy'])
452 nbt_tests = smb4torture_testsuites("nbt.")
453 for t in nbt_tests:
454 plansmbtorturetestsuite(t, "dc", "//$SERVER/_none_ -U\"$USERNAME%$PASSWORD\"")
456 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\""]
458 winbind_struct_tests = smb4torture_testsuites("winbind.struct")
459 winbind_ndr_tests = smb4torture_testsuites("winbind.ndr")
460 for env in ["dc", "member"]:
461 for t in winbind_struct_tests:
462 plansmbtorturetestsuite(t, env, "%s //_none_/_none_" % " ".join(wb_opts))
464 for t in winbind_ndr_tests:
465 plansmbtorturetestsuite(t, env, "%s //_none_/_none_" % " ".join(wb_opts))
467 nsstest4 = binpath("nsstest")
468 if os.path.exists(nsstest4):
469 plantestsuite("samba4.nss.test using winbind(member)", "member", [valgrindify(nsstest4), os.path.join(samba4bindir, "shared/libnss_winbind.so")])
470 else:
471 skiptestsuite("samba4.nss.test using winbind(member)", "nsstest not available")
473 subunitrun = valgrindify(python) + " " + os.path.join(samba4srcdir, "scripting/bin/subunitrun")
474 def plansambapythontestsuite(name, env, path, module, environ={}, extra_args=[]):
475 environ = dict(environ)
476 environ["PYTHONPATH"] = "$PYTHONPATH:" + path
477 args = ["%s=%s" % item for item in environ.iteritems()]
478 args += [subunitrun, "$LISTOPT", module]
479 args += extra_args
480 plantestsuite(name, env, args)
483 plansambapythontestsuite("ldb.python", "none", "%s/lib/ldb/tests/python/" % samba4srcdir, 'api')
484 planpythontestsuite("none", "samba.tests.credentials")
485 plantestsuite_idlist("samba.tests.gensec", "dc:local", [subunitrun, "$LISTOPT", '-U"$USERNAME%$PASSWORD"', "samba.tests.gensec"])
486 planpythontestsuite("none", "samba.tests.registry")
487 plansambapythontestsuite("tdb.python", "none", "%s/lib/tdb/python/tests" % srcdir, 'simple')
488 planpythontestsuite("none", "samba.tests.auth")
489 planpythontestsuite("none", "samba.tests.security")
490 planpythontestsuite("none", "samba.tests.dcerpc.misc")
491 planpythontestsuite("none", "samba.tests.param")
492 planpythontestsuite("none", "samba.tests.upgrade")
493 planpythontestsuite("none", "samba.tests.core")
494 planpythontestsuite("none", "samba.tests.provision")
495 planpythontestsuite("none", "samba.tests.samba3")
496 planpythontestsuite("dc:local", "samba.tests.dcerpc.sam")
497 planpythontestsuite("dc:local", "samba.tests.dsdb")
498 planpythontestsuite("none", "samba.tests.netcmd")
499 planpythontestsuite("dc:local", "samba.tests.dcerpc.bare")
500 planpythontestsuite("dc:local", "samba.tests.dcerpc.unix")
501 planpythontestsuite("none", "samba.tests.dcerpc.rpc_talloc")
502 planpythontestsuite("none", "samba.tests.samdb")
503 planpythontestsuite("none", "samba.tests.hostconfig")
504 planpythontestsuite("none", "samba.tests.messaging")
505 planpythontestsuite("none", "samba.tests.samba3sam")
506 planpythontestsuite("none", "subunit")
507 planpythontestsuite("dc:local", "samba.tests.dcerpc.rpcecho")
508 plantestsuite_idlist("samba.tests.dcerpc.registry", "dc:local", [subunitrun, "$LISTOPT", '-U"$USERNAME%$PASSWORD"', "samba.tests.dcerpc.registry"])
509 plantestsuite("samba4.ldap.python(dc)", "dc", [python, os.path.join(samba4srcdir, "dsdb/tests/python/ldap.py"), '$SERVER', '-U"$USERNAME%$PASSWORD"', '-W', '$DOMAIN'])
510 plantestsuite("samba4.tokengroups.python(dc)", "dc:local", [python, os.path.join(samba4srcdir, "dsdb/tests/python/token_group.py"), '$SERVER', '-U"$USERNAME%$PASSWORD"', '-W', '$DOMAIN'])
511 plantestsuite("samba4.sam.python(dc)", "dc", [python, os.path.join(samba4srcdir, "dsdb/tests/python/sam.py"), '$SERVER', '-U"$USERNAME%$PASSWORD"', '-W', '$DOMAIN'])
512 plansambapythontestsuite("samba4.schemaInfo.python(dc)", "dc", os.path.join(samba4srcdir, 'dsdb/tests/python'), 'dsdb_schema_info', extra_args=['-U"$DOMAIN/$DC_USERNAME%$DC_PASSWORD"'])
513 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)
514 for env in ["dc", "fl2000dc", "fl2003dc", "fl2008r2dc"]:
515 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'])
516 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"])
517 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'])
518 plantestsuite("samba4.ldap.acl.python(%s)" % env, env, [python, os.path.join(samba4srcdir, "dsdb/tests/python/acl.py"), '$SERVER', '-U"$USERNAME%$PASSWORD"', '-W', '$DOMAIN'])
519 if env != "fl2000dc":
520 # This test makes excessively use of the "userPassword" attribute which
521 # isn't available on DCs with Windows 2000 domain function level -
522 # therefore skip it in that configuration
523 plantestsuite("samba4.ldap.passwords.python(%s)" % env, env, [python, os.path.join(samba4srcdir, "dsdb/tests/python/passwords.py"), "$SERVER", '-U"$USERNAME%$PASSWORD"', "-W", "$DOMAIN"])
524 planpythontestsuite("dc:local", "samba.tests.upgradeprovisionneeddc")
525 planpythontestsuite("none", "samba.tests.upgradeprovision")
526 planpythontestsuite("none", "samba.tests.xattr")
527 planpythontestsuite("none", "samba.tests.ntacls")
528 plantestsuite("samba4.deletetest.python(dc)", "dc", ['PYTHONPATH="$PYTHONPATH:%s/lib/subunit/python:%s/lib/testtools"' % (srcdir, srcdir),
529 python, os.path.join(samba4srcdir, "dsdb/tests/python/deletetest.py"),
530 '$SERVER', '-U"$USERNAME%$PASSWORD"', '-W', '$DOMAIN'])
531 plansambapythontestsuite("samba4.policy.python", "none", "%s/lib/policy/tests/python" % samba4srcdir, 'bindings')
532 plantestsuite("samba4.blackbox.samba3dump", "none", [python, os.path.join(samba4srcdir, "scripting/bin/samba3dump"), os.path.join(samba4srcdir, "../testdata/samba3")], allow_empty_output=True)
533 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)
534 plantestsuite("samba4.blackbox.provision.py", "none", ["PYTHON=%s" % python, os.path.join(samba4srcdir, "setup/tests/blackbox_provision.sh"), '$PREFIX/provision'])
535 plantestsuite("samba4.blackbox.upgradeprovision.py", "none", ["PYTHON=%s" % python, os.path.join(samba4srcdir, "setup/tests/blackbox_upgradeprovision.sh"), '$PREFIX/provision'])
536 plantestsuite("samba4.blackbox.setpassword.py", "none", ["PYTHON=%s" % python, os.path.join(samba4srcdir, "setup/tests/blackbox_setpassword.sh"), '$PREFIX/provision'])
537 plantestsuite("samba4.blackbox.newuser.py", "none", ["PYTHON=%s" % python, os.path.join(samba4srcdir, "setup/tests/blackbox_newuser.sh"), '$PREFIX/provision'])
538 plantestsuite("samba4.blackbox.group.py", "none", ["PYTHON=%s" % python, os.path.join(samba4srcdir, "setup/tests/blackbox_group.sh"), '$PREFIX/provision'])
539 plantestsuite("samba4.blackbox.spn.py(dc:local)", "dc:local", ["PYTHON=%s" % python, os.path.join(samba4srcdir, "setup/tests/blackbox_spn.sh"), '$PREFIX/dc'])
540 plantestsuite("samba4.ldap.bind(dc)", "dc", [python, os.path.join(samba4srcdir, "auth/credentials/tests/bind.py"), '$SERVER', '-U"$USERNAME%$PASSWORD"'])
542 # DRS python tests
543 plansambapythontestsuite("samba4.blackbox.samba-tool.drs(vampire_dc)", "vampire_dc", os.path.join(samba4srcdir, 'scripting/python'), "samba.tests.blackbox.samba_tool_drs", environ={'DC1': '$DC_SERVER', 'DC2': '$VAMPIRE_DC_SERVER'}, extra_args=['-U$DOMAIN/$DC_USERNAME%$DC_PASSWORD'])
544 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'])
545 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'])
546 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'])
548 # This makes sure we test the rid allocation code
549 t = "rpc.samr.large-dc"
550 plantestsuite_loadlist("samba4.%s.one" % t, "vampire_dc", [valgrindify(smb4torture), "$LISTOPT", '$SERVER', '-U$USERNAME%$PASSWORD', '-W', '$DOMAIN', t])
551 plantestsuite_loadlist("samba4.%s.two" % t, "vampire_dc", [valgrindify(smb4torture), "$LISTOPT", '$SERVER', '-U$USERNAME%$PASSWORD', '-W', '$DOMAIN', t])
553 # some RODC testing
554 plantestsuite_loadlist("samba4.rpc.echo", "rodc", [smb4torture, "$LISTOPT", 'ncacn_np:$SERVER', "-k", "yes", '-U$USERNAME%$PASSWORD', '-W' '$DOMAIN', 'rpc.echo'])
555 plantestsuite("samba4.blackbox.provision-backend.py", "none", ["PYTHON=%s" % python, os.path.join(samba4srcdir, "setup/tests/blackbox_provision-backend.sh"), '$PREFIX/provision'])