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
25 return os
.path
.normpath(os
.getenv("SRCDIR", os
.path
.join(os
.path
.dirname(os
.path
.abspath(__file__
)), "..")))
28 return os
.path
.normpath(os
.path
.join(srcdir(), "source4"))
31 return os
.path
.normpath(os
.getenv("BINDIR", "./bin"))
36 if name
in binary_mapping
:
37 name
= binary_mapping
[name
]
38 return os
.path
.join(bindir(), "%s%s" % (name
, os
.getenv("EXEEXT", "")))
40 binary_mapping_string
= os
.getenv("BINARY_MAPPING", None)
41 if binary_mapping_string
is not None:
42 for binmapping_entry
in binary_mapping_string
.split(','):
44 (from_path
, to_path
) = binmapping_entry
.split(':', 1)
47 binary_mapping
[from_path
] = to_path
49 # Split perl variable to allow $PERL to be set to e.g. "perl -W"
50 perl
= os
.getenv("PERL", "perl").split()
52 if subprocess
.call(perl
+ ["-e", "eval require Test::More;"]) == 0:
53 has_perl_test_more
= True
55 has_perl_test_more
= False
58 from subunit
.run
import TestProgram
60 has_system_subunit_run
= False
62 has_system_subunit_run
= True
64 python
= os
.getenv("PYTHON", "python")
66 #Set a default value, overridden if we find a working one on the system
67 tap2subunit
= "PYTHONPATH=%s/lib/subunit/python:%s/lib/testtools %s %s/lib/subunit/filters/tap2subunit" % (srcdir(), srcdir(), python
, srcdir())
69 sub
= subprocess
.Popen("tap2subunit 2> /dev/null", stdout
=subprocess
.PIPE
, stdin
=subprocess
.PIPE
, shell
=True)
72 if sub
.returncode
== 0:
73 cmd
= "echo -ne \"1..1\nok 1 # skip doesn't seem to work yet\n\" | tap2subunit 2> /dev/null | grep skip"
74 sub
= subprocess
.Popen(cmd
, stdout
=subprocess
.PIPE
, stdin
=subprocess
.PIPE
, stderr
=subprocess
.PIPE
, shell
=True)
75 if sub
.returncode
== 0:
76 tap2subunit
= "tap2subunit"
78 def valgrindify(cmdline
):
79 """Run a command under valgrind, if $VALGRIND was set."""
80 valgrind
= os
.getenv("VALGRIND")
83 return valgrind
+ " " + cmdline
86 def plantestsuite(name
, env
, cmdline
, allow_empty_output
=False):
89 :param name: Testsuite name
90 :param env: Environment to run the testsuite in
91 :param cmdline: Command line to run
96 if isinstance(cmdline
, list):
97 cmdline
= " ".join(cmdline
)
98 filter_subunit_args
= []
99 if not allow_empty_output
:
100 filter_subunit_args
.append("--fail-on-empty")
101 if "$LISTOPT" in cmdline
:
102 filter_subunit_args
.append("$LISTOPT")
103 print "%s 2>&1 | %s/selftest/filter-subunit %s --prefix=\"%s.\"" % (cmdline
,
105 " ".join(filter_subunit_args
),
107 if allow_empty_output
:
108 print "WARNING: allowing empty subunit output from %s" % name
111 def add_prefix(prefix
, support_list
=False):
113 listopt
= "$LISTOPT "
116 return "%s/selftest/filter-subunit %s--fail-on-empty --prefix=\"%s.\"" % (srcdir(), listopt
, prefix
)
119 def plantestsuite_loadlist(name
, env
, cmdline
):
120 print "-- TEST-LOADLIST --"
124 fullname
= "%s(%s)" % (name
, env
)
127 if isinstance(cmdline
, list):
128 cmdline
= " ".join(cmdline
)
129 support_list
= ("$LISTOPT" in cmdline
)
130 print "%s $LOADLIST 2>&1 | %s" % (cmdline
, add_prefix(name
, support_list
))
133 def plantestsuite_idlist(name
, env
, cmdline
):
134 print "-- TEST-IDLIST --"
138 fullname
= "%s(%s)" % (name
, env
)
141 if isinstance(cmdline
, list):
142 cmdline
= " ".join(cmdline
)
146 def skiptestsuite(name
, reason
):
147 """Indicate that a testsuite was skipped.
149 :param name: Test suite name
150 :param reason: Reason the test suite was skipped
152 # FIXME: Report this using subunit, but re-adjust the testsuite count somehow
153 print "skipping %s (%s)" % (name
, reason
)
156 def planperltestsuite(name
, path
):
157 """Run a perl test suite.
159 :param name: Name of the test suite
160 :param path: Path to the test runner
162 if has_perl_test_more
:
163 plantestsuite(name
, "none", "%s %s | %s" % (" ".join(perl
), path
, tap2subunit
))
165 skiptestsuite(name
, "Test::More not available")
168 def planpythontestsuite(env
, module
, name
=None, extra_path
=[]):
171 pypath
= list(extra_path
)
172 if not has_system_subunit_run
:
173 pypath
.extend(["%s/lib/subunit/python" % srcdir(),
174 "%s/lib/testtools" % srcdir()])
175 args
= [python
, "-m", "subunit.run", "$LISTOPT", module
]
177 args
.insert(0, "PYTHONPATH=%s" % ":".join(["$PYTHONPATH"] + pypath
))
178 plantestsuite_idlist(name
, env
, args
)