2d223046a954849587252783c35c0b94e38f3620
[samba.git] / 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 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, 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 and makes
13 # it possible to run the testsuite against other servers, such as
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 from selftesthelpers import bindir, srcdir, python
23 from selftesthelpers import planpythontestsuite, samba4srcdir
24 from selftesthelpers import plantestsuite, bbdir
25 from selftesthelpers import configuration, valgrindify
26 from selftesthelpers import skiptestsuite
27
28 try:
29     config_h = os.environ["CONFIG_H"]
30 except KeyError:
31     samba4bindir = bindir()
32     config_h = os.path.join(samba4bindir, "default/include/config.h")
33
34 # check available features
35 config_hash = dict()
36 f = open(config_h, 'r')
37 try:
38     lines = f.readlines()
39     config_hash = dict((x[0], ' '.join(x[1:]))
40                        for x in map(lambda line: line.strip().split(' ')[1:],
41                                     list(filter(lambda line: (line[0:7] == '#define') and (len(line.split(' ')) > 2), lines))))
42 finally:
43     f.close()
44
45 have_man_pages_support = ("XSLTPROC_MANPAGES" in config_hash)
46 with_pam = ("WITH_PAM" in config_hash)
47 pam_wrapper_so_path = config_hash["LIBPAM_WRAPPER_SO_PATH"]
48 pam_set_items_so_path = config_hash["PAM_SET_ITEMS_SO_PATH"]
49
50 planpythontestsuite("none", "samba.tests.source", py3_compatible=True)
51 if have_man_pages_support:
52     planpythontestsuite("none", "samba.tests.docs", py3_compatible=True)
53
54 try:
55     import testscenarios
56 except ImportError:
57     skiptestsuite("subunit", "testscenarios not available")
58 else:
59     planpythontestsuite("none", "subunit.tests.test_suite")
60 planpythontestsuite("none", "samba.tests.blackbox.ndrdump", py3_compatible=True)
61 planpythontestsuite("none", "samba.tests.blackbox.check_output", py3_compatible=True)
62 planpythontestsuite("none", "api", name="ldb.python", extra_path=['lib/ldb/tests/python'], py3_compatible=True)
63 planpythontestsuite("none", "samba.tests.credentials", py3_compatible=True)
64 planpythontestsuite("none", "samba.tests.registry", py3_compatible=True)
65 planpythontestsuite("ad_dc_ntvfs:local", "samba.tests.auth", py3_compatible=True)
66 planpythontestsuite("none", "samba.tests.get_opt", py3_compatible=True)
67 planpythontestsuite("none", "samba.tests.security", py3_compatible=True)
68 planpythontestsuite("none", "samba.tests.dcerpc.misc", py3_compatible=True)
69 planpythontestsuite("none", "samba.tests.dcerpc.integer")
70 planpythontestsuite("none", "samba.tests.param", py3_compatible=True)
71 planpythontestsuite("none", "samba.tests.upgrade", py3_compatible=True)
72 planpythontestsuite("none", "samba.tests.core", py3_compatible=True)
73 planpythontestsuite("none", "samba.tests.common", py3_compatible=True)
74 planpythontestsuite("none", "samba.tests.provision", py3_compatible=True)
75 planpythontestsuite("none", "samba.tests.password_quality", py3_compatible=True)
76 planpythontestsuite("none", "samba.tests.strings")
77 planpythontestsuite("none", "samba.tests.netcmd")
78 planpythontestsuite("none", "samba.tests.dcerpc.rpc_talloc", py3_compatible=True)
79 planpythontestsuite("none", "samba.tests.dcerpc.array", py3_compatible=True)
80 planpythontestsuite("none", "samba.tests.dcerpc.string_tests", py3_compatible=True)
81 planpythontestsuite("none", "samba.tests.hostconfig", py3_compatible=True)
82 planpythontestsuite("ad_dc_ntvfs:local", "samba.tests.messaging",
83                     py3_compatible=True)
84 planpythontestsuite("none", "samba.tests.s3param", py3_compatible=True)
85 planpythontestsuite("none", "samba.tests.s3passdb", py3_compatible=True)
86 planpythontestsuite("none", "samba.tests.s3registry", py3_compatible=True)
87 planpythontestsuite("none", "samba.tests.s3windb", py3_compatible=True)
88 planpythontestsuite("none", "samba.tests.s3idmapdb", py3_compatible=True)
89 planpythontestsuite("none", "samba.tests.samba3sam")
90 planpythontestsuite(
91     "none", "wafsamba.tests.test_suite",
92     extra_path=[os.path.join(samba4srcdir, "..", "buildtools"),
93                 os.path.join(samba4srcdir, "..", "third_party", "waf")])
94
95
96 def cmdline(script, *args):
97     """
98     Prefix PYTHON env var and append --configurefile option to abs script path.
99
100     script.sh arg1 arg2
101     -->
102     PYTHON=python /path/to/bbdir/script.sh arg1 arg2 \
103     --configurefile $SMB_CONF_FILE
104     """
105     return [
106         "PYTHON=%s" % python,
107         os.path.join(bbdir, script),
108     ] + list(args) + [configuration]
109
110
111 plantestsuite(
112     "samba4.blackbox.demote-saveddb", "none",
113     cmdline('demote-saveddb.sh', '$PREFIX_ABS/demote'))
114
115 plantestsuite(
116     "samba4.blackbox.dbcheck.alpha13", "none",
117     cmdline('dbcheck-oldrelease.sh', '$PREFIX_ABS/provision',
118             'alpha13'))
119
120 plantestsuite(
121     "samba4.blackbox.dbcheck.release-4-0-0", "none",
122     cmdline('dbcheck-oldrelease.sh', '$PREFIX_ABS/provision',
123             'release-4-0-0'))
124
125 plantestsuite(
126     "samba4.blackbox.dbcheck.release-4-1-0rc3", "none",
127     cmdline('dbcheck-oldrelease.sh', '$PREFIX_ABS/provision',
128             'release-4-1-0rc3'))
129
130 plantestsuite(
131     "samba4.blackbox.dbcheck.release-4-1-6-partial-object", "none",
132     cmdline('dbcheck-oldrelease.sh', '$PREFIX_ABS/provision',
133             'release-4-1-6-partial-object'))
134
135 plantestsuite(
136     "samba4.blackbox.dbcheck.release-4-5-0-pre1", "none",
137     cmdline('dbcheck-oldrelease.sh', '$PREFIX_ABS/provision',
138             'release-4-5-0-pre1'))
139
140 plantestsuite(
141     "samba4.blackbox.upgradeprovision.alpha13", "none",
142     cmdline('upgradeprovision-oldrelease.sh', '$PREFIX_ABS/provision',
143             'alpha13'))
144
145 plantestsuite(
146     "samba4.blackbox.upgradeprovision.release-4-0-0", "none",
147     cmdline('upgradeprovision-oldrelease.sh', '$PREFIX_ABS/provision',
148             'release-4-0-0'))
149
150 plantestsuite(
151     "samba4.blackbox.tombstones-expunge.release-4-5-0-pre1", "none",
152     cmdline('tombstones-expunge.sh', '$PREFIX_ABS/provision',
153             'release-4-5-0-pre1'))
154
155 plantestsuite(
156     "samba4.blackbox.dbcheck-links.release-4-5-0-pre1", "none",
157     cmdline('dbcheck-links.sh', '$PREFIX_ABS/provision',
158             'release-4-5-0-pre1'))
159
160 plantestsuite(
161     "samba4.blackbox.runtime-links.release-4-5-0-pre1", "none",
162     cmdline('runtime-links.sh', '$PREFIX_ABS/provision',
163             'release-4-5-0-pre1'))
164
165 plantestsuite(
166     "samba4.blackbox.schemaupgrade", "none",
167     cmdline('schemaupgrade.sh', '$PREFIX_ABS/provision'))
168
169 plantestsuite(
170     "samba4.blackbox.functionalprep", "none",
171     cmdline('functionalprep.sh', '$PREFIX_ABS/provision'))
172
173 planpythontestsuite("none", "samba.tests.upgradeprovision", py3_compatible=True)
174 planpythontestsuite("none", "samba.tests.xattr", py3_compatible=True)
175 planpythontestsuite("none", "samba.tests.ntacls", py3_compatible=True)
176 planpythontestsuite("none", "samba.tests.policy", py3_compatible=True)
177 planpythontestsuite("none", "samba.tests.kcc.graph", py3_compatible=True)
178 planpythontestsuite("none", "samba.tests.kcc.graph_utils", py3_compatible=True)
179 planpythontestsuite("none", "samba.tests.kcc.ldif_import_export")
180 planpythontestsuite("none", "samba.tests.graph", py3_compatible=True)
181 plantestsuite("wafsamba.duplicate_symbols", "none", [os.path.join(srcdir(), "buildtools/wafsamba/test_duplicate_symbol.sh")])
182 planpythontestsuite("none", "samba.tests.glue", py3_compatible=True)
183 planpythontestsuite("none", "samba.tests.tdb_util", py3_compatible=True)
184 planpythontestsuite("none", "samba.tests.samdb_api", py3_compatible=True)
185
186 if with_pam:
187     plantestsuite("samba.tests.pam_winbind(local)", "ad_member",
188                   [os.path.join(srcdir(), "python/samba/tests/test_pam_winbind.sh"),
189                    valgrindify(python), pam_wrapper_so_path,
190                    "$SERVER", "$USERNAME", "$PASSWORD"])
191     plantestsuite("samba.tests.pam_winbind(domain)", "ad_member",
192                   [os.path.join(srcdir(), "python/samba/tests/test_pam_winbind.sh"),
193                    valgrindify(python), pam_wrapper_so_path,
194                    "$DOMAIN", "$DC_USERNAME", "$DC_PASSWORD"])
195
196     for pam_options in ["''", "use_authtok", "try_authtok"]:
197         plantestsuite("samba.tests.pam_winbind_chauthtok with options %s" % pam_options, "ad_member",
198                       [os.path.join(srcdir(), "python/samba/tests/test_pam_winbind_chauthtok.sh"),
199                        valgrindify(python), pam_wrapper_so_path, pam_set_items_so_path,
200                        "$DOMAIN", "TestPamOptionsUser", "oldp@ssword0", "newp@ssword0",
201                        pam_options, 'yes',
202                        "$DC_SERVER", "$DC_USERNAME", "$DC_PASSWORD"])
203
204     plantestsuite("samba.tests.pam_winbind_warn_pwd_expire(domain)", "ad_member",
205                   [os.path.join(srcdir(), "python/samba/tests/test_pam_winbind_warn_pwd_expire.sh"),
206                    valgrindify(python), pam_wrapper_so_path,
207                    "$DOMAIN", "alice", "Secret007"])
208
209
210 plantestsuite("samba.unittests.krb5samba", "none",
211               [os.path.join(bindir(), "default/testsuite/unittests/test_krb5samba")])
212 plantestsuite("samba.unittests.sambafs_srv_pipe", "none",
213               [os.path.join(bindir(), "default/testsuite/unittests/test_sambafs_srv_pipe")])
214 plantestsuite("samba.unittests.lib_util_modules", "none",
215               [os.path.join(bindir(), "default/testsuite/unittests/test_lib_util_modules")])
216
217 plantestsuite("samba.unittests.smb1cli_session", "none",
218               [os.path.join(bindir(), "default/libcli/smb/test_smb1cli_session")])
219
220 plantestsuite("samba.unittests.tldap", "none",
221               [os.path.join(bindir(), "default/source3/test_tldap")])
222 plantestsuite("samba.unittests.rfc1738", "none",
223               [os.path.join(bindir(), "default/lib/util/test_rfc1738")])
224 plantestsuite("samba.unittests.kerberos", "none",
225               [os.path.join(bindir(), "test_kerberos")])
226 plantestsuite("samba.unittests.ms_fnmatch", "none",
227               [os.path.join(bindir(), "default/lib/util/test_ms_fnmatch")])
228 plantestsuite("samba.unittests.ntlm_check", "none",
229               [os.path.join(bindir(), "default/libcli/auth/test_ntlm_check")])