mirror of
https://github.com/samba-team/samba.git
synced 2025-01-08 21:18:16 +03:00
selftest: Add separate command line for listing tests, allowing us of subunit-filter (which doesn't support subunit v2).
Change-Id: Icb877214a422c63fd38ef92425c7b4fe7ee19ad5 Signed-Off-By: Jelmer Vernooij <jelmer@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
parent
c3855dae71
commit
0f408599f8
@ -574,10 +574,15 @@ sub read_testlist($)
|
|||||||
$name =~ s/\n//g;
|
$name =~ s/\n//g;
|
||||||
my $env = <IN>;
|
my $env = <IN>;
|
||||||
$env =~ s/\n//g;
|
$env =~ s/\n//g;
|
||||||
|
my $loadlist;
|
||||||
|
if ($supports_loadlist) {
|
||||||
|
$loadlist = <IN>;
|
||||||
|
$loadlist =~ s/\n//g;
|
||||||
|
}
|
||||||
my $cmdline = <IN>;
|
my $cmdline = <IN>;
|
||||||
$cmdline =~ s/\n//g;
|
$cmdline =~ s/\n//g;
|
||||||
if (should_run_test($name) == 1) {
|
if (should_run_test($name) == 1) {
|
||||||
push (@ret, [$name, $env, $cmdline, $supports_loadlist]);
|
push (@ret, [$name, $env, $cmdline, $loadlist]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
print;
|
print;
|
||||||
@ -937,11 +942,12 @@ $envvarstr
|
|||||||
teardown_env($testenv_name);
|
teardown_env($testenv_name);
|
||||||
} elsif ($opt_list) {
|
} elsif ($opt_list) {
|
||||||
foreach (@todo) {
|
foreach (@todo) {
|
||||||
my $cmd = $$_[2];
|
|
||||||
my $name = $$_[0];
|
my $name = $$_[0];
|
||||||
my $envname = $$_[1];
|
my $envname = $$_[1];
|
||||||
|
my $cmd = $$_[2];
|
||||||
|
my $listcmd = $$_[3];
|
||||||
|
|
||||||
unless($cmd =~ /\$LISTOPT/) {
|
unless (defined($listcmd)) {
|
||||||
warn("Unable to list tests in $name");
|
warn("Unable to list tests in $name");
|
||||||
# Rather than ignoring this testsuite altogether, just pretend the entire testsuite is
|
# Rather than ignoring this testsuite altogether, just pretend the entire testsuite is
|
||||||
# a single "test".
|
# a single "test".
|
||||||
@ -949,14 +955,12 @@ $envvarstr
|
|||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
$cmd =~ s/\$LISTOPT/--list/g;
|
system($listcmd);
|
||||||
|
|
||||||
system($cmd);
|
|
||||||
|
|
||||||
if ($? == -1) {
|
if ($? == -1) {
|
||||||
die("Unable to run $cmd: $!");
|
die("Unable to run $listcmd: $!");
|
||||||
} elsif ($? & 127) {
|
} elsif ($? & 127) {
|
||||||
die(sprintf("%s died with signal %d, %s coredump\n", $cmd, ($? & 127), ($? & 128) ? 'with' : 'without'));
|
die(sprintf("%s died with signal %d, %s coredump\n", $listcmd, ($? & 127), ($? & 128) ? 'with' : 'without'));
|
||||||
}
|
}
|
||||||
|
|
||||||
my $exitcode = $? >> 8;
|
my $exitcode = $? >> 8;
|
||||||
|
@ -82,6 +82,12 @@ if sub.returncode == 0:
|
|||||||
if sub.returncode == 0:
|
if sub.returncode == 0:
|
||||||
tap2subunit = "tap2subunit"
|
tap2subunit = "tap2subunit"
|
||||||
|
|
||||||
|
def to_subunit1(subunit_version):
|
||||||
|
if subunit_version == 1:
|
||||||
|
return ""
|
||||||
|
return " | " + subunit2to1
|
||||||
|
|
||||||
|
|
||||||
def valgrindify(cmdline):
|
def valgrindify(cmdline):
|
||||||
"""Run a command under valgrind, if $VALGRIND was set."""
|
"""Run a command under valgrind, if $VALGRIND was set."""
|
||||||
valgrind = os.getenv("VALGRIND")
|
valgrind = os.getenv("VALGRIND")
|
||||||
@ -90,7 +96,7 @@ def valgrindify(cmdline):
|
|||||||
return valgrind + " " + cmdline
|
return valgrind + " " + cmdline
|
||||||
|
|
||||||
|
|
||||||
def plantestsuite(name, env, cmdline):
|
def plantestsuite(name, env, cmdline, subunit_version=1):
|
||||||
"""Plan a test suite.
|
"""Plan a test suite.
|
||||||
|
|
||||||
:param name: Testsuite name
|
:param name: Testsuite name
|
||||||
@ -102,7 +108,9 @@ def plantestsuite(name, env, cmdline):
|
|||||||
print env
|
print env
|
||||||
if isinstance(cmdline, list):
|
if isinstance(cmdline, list):
|
||||||
cmdline = " ".join(cmdline)
|
cmdline = " ".join(cmdline)
|
||||||
print "%s 2>&1 | " + add_prefix(name, env, "$LISTOPT" in cmdline)
|
if "$LISTOPT" in cmdline:
|
||||||
|
raise AssertionError("test %s supports --list, but not --load-list" % name)
|
||||||
|
print cmdline + " 2>&1 " + to_subunit1(subunit_version) + " | " + add_prefix(name, env)
|
||||||
|
|
||||||
|
|
||||||
def add_prefix(prefix, env, support_list=False):
|
def add_prefix(prefix, env, support_list=False):
|
||||||
@ -113,7 +121,7 @@ def add_prefix(prefix, env, support_list=False):
|
|||||||
return "%s/selftest/filter-subunit %s--fail-on-empty --prefix=\"%s.\" --suffix=\"(%s)\"" % (srcdir(), listopt, prefix, env)
|
return "%s/selftest/filter-subunit %s--fail-on-empty --prefix=\"%s.\" --suffix=\"(%s)\"" % (srcdir(), listopt, prefix, env)
|
||||||
|
|
||||||
|
|
||||||
def plantestsuite_loadlist(name, env, cmdline):
|
def plantestsuite_loadlist(name, env, cmdline, subunit_version=1):
|
||||||
print "-- TEST-LOADLIST --"
|
print "-- TEST-LOADLIST --"
|
||||||
if env == "none":
|
if env == "none":
|
||||||
fullname = name
|
fullname = name
|
||||||
@ -124,7 +132,10 @@ def plantestsuite_loadlist(name, env, cmdline):
|
|||||||
if isinstance(cmdline, list):
|
if isinstance(cmdline, list):
|
||||||
cmdline = " ".join(cmdline)
|
cmdline = " ".join(cmdline)
|
||||||
support_list = ("$LISTOPT" in cmdline)
|
support_list = ("$LISTOPT" in cmdline)
|
||||||
print "%s $LOADLIST 2>&1 | %s" % (cmdline, add_prefix(name, env, support_list))
|
if not "$LISTOPT" in cmdline:
|
||||||
|
raise AssertionError("test %s supports --load-list, but not --list" % name)
|
||||||
|
print ("%s | %s" % (cmdline, add_prefix(name, env, support_list))).replace("$LISTOPT", "--list")
|
||||||
|
print cmdline + " $LOADLIST 2>&1 " + to_subunit1(subunit_version) + "| " + add_prefix(name, env, support_list)
|
||||||
|
|
||||||
|
|
||||||
def skiptestsuite(name, reason):
|
def skiptestsuite(name, reason):
|
||||||
|
@ -81,8 +81,12 @@ def read_testlist(inf, outf):
|
|||||||
supports_loadlist = l.startswith("-- TEST-LOADLIST")
|
supports_loadlist = l.startswith("-- TEST-LOADLIST")
|
||||||
name = inf.readline().rstrip("\n")
|
name = inf.readline().rstrip("\n")
|
||||||
env = inf.readline().rstrip("\n")
|
env = inf.readline().rstrip("\n")
|
||||||
|
if supports_loadlist:
|
||||||
|
loadlist = inf.readline().rstrip("\n")
|
||||||
|
else:
|
||||||
|
loadlist = None
|
||||||
cmdline = inf.readline().rstrip("\n")
|
cmdline = inf.readline().rstrip("\n")
|
||||||
yield (name, env, cmdline, supports_loadlist)
|
yield (name, env, cmdline, loadlist)
|
||||||
else:
|
else:
|
||||||
outf.write(l)
|
outf.write(l)
|
||||||
|
|
||||||
|
@ -67,14 +67,14 @@ class ReadTestlistTests(TestCase):
|
|||||||
def test_read_list(self):
|
def test_read_list(self):
|
||||||
inf = StringIO("-- TEST --\nfoo\nbar\nbla\n")
|
inf = StringIO("-- TEST --\nfoo\nbar\nbla\n")
|
||||||
outf = StringIO()
|
outf = StringIO()
|
||||||
self.assertEquals([('foo', 'bar', 'bla', False)],
|
self.assertEquals([('foo', 'bar', 'bla', None)],
|
||||||
list(read_testlist(inf, outf)))
|
list(read_testlist(inf, outf)))
|
||||||
self.assertEquals("", outf.getvalue())
|
self.assertEquals("", outf.getvalue())
|
||||||
|
|
||||||
def test_read_list_passes_through(self):
|
def test_read_list_passes_through(self):
|
||||||
inf = StringIO("MORENOISE\n-- TEST --\nfoo\nbar\nbla\nNOISE\n")
|
inf = StringIO("MORENOISE\n-- TEST --\nfoo\nbar\nbla\nNOISE\n")
|
||||||
outf = StringIO()
|
outf = StringIO()
|
||||||
self.assertEquals([('foo', 'bar', 'bla', False)],
|
self.assertEquals([('foo', 'bar', 'bla', None)],
|
||||||
list(read_testlist(inf, outf)))
|
list(read_testlist(inf, outf)))
|
||||||
self.assertEquals("MORENOISE\nNOISE\n", outf.getvalue())
|
self.assertEquals("MORENOISE\nNOISE\n", outf.getvalue())
|
||||||
|
|
||||||
@ -143,6 +143,6 @@ class ReadTestListFileTests(TestCase):
|
|||||||
f.close()
|
f.close()
|
||||||
outf = StringIO()
|
outf = StringIO()
|
||||||
self.assertEquals(
|
self.assertEquals(
|
||||||
[('data', 'env', 'cmd', False, False)],
|
[('data', 'env', 'cmd', None)],
|
||||||
list(read_testlist_file(p, outf)))
|
list(read_testlist_file(p, outf)))
|
||||||
self.assertEquals("noise\n", outf.getvalue())
|
self.assertEquals("noise\n", outf.getvalue())
|
||||||
|
@ -81,5 +81,7 @@ opts, args = parser.parse_args()
|
|||||||
if not getattr(opts, "listtests", False):
|
if not getattr(opts, "listtests", False):
|
||||||
lp = sambaopts.get_loadparm()
|
lp = sambaopts.get_loadparm()
|
||||||
samba.tests.cmdline_credentials = credopts.get_credentials(lp)
|
samba.tests.cmdline_credentials = credopts.get_credentials(lp)
|
||||||
|
if getattr(opts, 'load_list', None):
|
||||||
|
args.insert(0, "--load-list=%s" % opts.load_list)
|
||||||
|
|
||||||
TestProgram(module=None, args=args, opts=subunitopts)
|
TestProgram(module=None, args=args, opts=subunitopts)
|
||||||
|
@ -436,7 +436,7 @@ def planoldpythontestsuite(env, module, name=None, extra_path=[], environ={}, ex
|
|||||||
args += extra_args
|
args += extra_args
|
||||||
if name is None:
|
if name is None:
|
||||||
name = module
|
name = module
|
||||||
plantestsuite(name, env, args)
|
plantestsuite_loadlist(name, env, args)
|
||||||
|
|
||||||
planoldpythontestsuite("dc:local", "samba.tests.gensec", extra_args=['-U"$USERNAME%$PASSWORD"'])
|
planoldpythontestsuite("dc:local", "samba.tests.gensec", extra_args=['-U"$USERNAME%$PASSWORD"'])
|
||||||
planoldpythontestsuite("none", "simple", extra_path=["%s/lib/tdb/python/tests" % srcdir()], name="tdb.python")
|
planoldpythontestsuite("none", "simple", extra_path=["%s/lib/tdb/python/tests" % srcdir()], name="tdb.python")
|
||||||
|
Loading…
Reference in New Issue
Block a user