From 31d5ac05402ed9ac8158d143283c7f8b2d7bb7b4 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 22 Sep 2010 11:30:34 -0700 Subject: selftest: Let tests add prefix to tests by themselve. --- selftest/Subunit.pm | 33 --------------------------------- selftest/selftest.pl | 35 ++++++++++++----------------------- selftest/subunithelper.py | 2 +- source4/selftest/tests.sh | 23 +++++++++++++---------- 4 files changed, 26 insertions(+), 67 deletions(-) diff --git a/selftest/Subunit.pm b/selftest/Subunit.pm index a94eecd7e4b..1cc0e721696 100644 --- a/selftest/Subunit.pm +++ b/selftest/Subunit.pm @@ -19,42 +19,9 @@ use POSIX; require Exporter; @ISA = qw(Exporter); -@EXPORT_OK = qw(filter_add_prefix); use strict; -sub filter_add_prefix($$) -{ - my ($prefix, $fh) = @_; - - while(<$fh>) { - if (/^test: (.+)\n/) { - Subunit::start_test($prefix.$1); - } elsif (/^(success|successful|failure|fail|skip|knownfail|error|xfail): (.*?)( \[)?([ \t]*)( multipart)?\n/) { - my $result = $1; - my $testname = $prefix.$2; - my $reason = undef; - if ($3) { - $reason = ""; - # reason may be specified in next lines - my $terminated = 0; - while(<$fh>) { - if ($_ eq "]\n") { $terminated = 1; last; } else { $reason .= $_; } - } - - unless ($terminated) { - print $reason; - $reason = "reason ($result) interrupted"; - $result = "error"; - } - } - Subunit::end_test($testname, $result, $reason); - } else { - print $_; - } - } -} - sub start_test($) { my ($testname) = @_; diff --git a/selftest/selftest.pl b/selftest/selftest.pl index a21ecbabe48..3bad138f5c8 100755 --- a/selftest/selftest.pl +++ b/selftest/selftest.pl @@ -238,28 +238,22 @@ sub run_testsuite($$$$$) Subunit::start_testsuite($name); Subunit::progress_push(); Subunit::report_time(time()); + system($cmd); + Subunit::report_time(time()); + Subunit::progress_pop(); - open(RESULTS, "$cmd 2>&1|"); - - Subunit::filter_add_prefix("$name\.", *RESULTS); - - my $ret = 0; - - unless (close(RESULTS)) { - if ($!) { - Subunit::progress_pop(); - Subunit::end_testsuite($name, "error", "Unable to run $cmd: $!"); - return 0; - } else { - $ret = $?; - } - } - - if ($ret & 127) { + if ($? == -1) { Subunit::progress_pop(); - Subunit::end_testsuite($name, "error", sprintf("Testsuite died with signal %d, %s coredump", ($ret & 127), ($ret & 128) ? "with": "without")); + Subunit::end_testsuite($name, "error", "Unable to run $cmd: $!"); + return 0; + } elsif ($? & 127) { + Subunit::end_testsuite($name, "error", + sprintf("%s died with signal %d, %s coredump\n", $cmd, ($? & 127), ($? & 128) ? 'with' : 'without')); return 0; } + + my $exitcode = $? >> 8; + my $envlog = getlog_env($envname); if ($envlog ne "") { print "envlog: $envlog\n"; @@ -268,10 +262,6 @@ sub run_testsuite($$$$$) print "command: $cmd\n"; printf "expanded command: %s\n", expand_environment_strings($cmd); - my $exitcode = $ret >> 8; - - Subunit::report_time(time()); - Subunit::progress_pop(); if ($exitcode == 0) { Subunit::end_testsuite($name, "success"); } else { @@ -933,7 +923,6 @@ $envvarstr foreach (@todo) { $i++; my $cmd = $$_[2]; - $cmd =~ s/([\(\)])/\\$1/g; my $name = $$_[0]; my $envname = $$_[1]; diff --git a/selftest/subunithelper.py b/selftest/subunithelper.py index 4a649c3b5fb..75ede2820ad 100644 --- a/selftest/subunithelper.py +++ b/selftest/subunithelper.py @@ -298,7 +298,6 @@ class FilterOps(testtools.testresult.TestResult): def start_testsuite(self, name): self._ops.start_testsuite(name) - self.error_added = 0 self.fail_added = 0 self.xfail_added = 0 @@ -335,6 +334,7 @@ class FilterOps(testtools.testresult.TestResult): self.expected_failures = expected_failures self.strip_ok_output = strip_ok_output self.xfail_added = 0 + self.fail_added = 0 self.total_xfail = 0 self.total_error = 0 self.total_fail = 0 diff --git a/source4/selftest/tests.sh b/source4/selftest/tests.sh index b3bb85dd347..e1b176a17a0 100755 --- a/source4/selftest/tests.sh +++ b/source4/selftest/tests.sh @@ -35,12 +35,13 @@ plantestsuite() { cmdline="$*" echo "-- TEST --" if [ "$env" = "none" ]; then - echo "samba4.$name" + fullname="samba4.$name" else - echo "samba4.$name ($env)" + fullname="samba4.$name ($env)" fi + echo $fullname echo $env - echo $cmdline + echo $cmdline "2>&1" "| ../selftest/filter-subunit --prefix \"$fullname.\"" } plantestsuite_loadlist() { @@ -50,12 +51,13 @@ plantestsuite_loadlist() { cmdline="$*" echo "-- TEST-LOADLIST --" if [ "$env" = "none" ]; then - echo "samba4.$name" + fullname="samba4.$name" else - echo "samba4.$name ($env)" + fullname="samba4.$name ($env)" fi + echo $fullname echo $env - echo $cmdline + echo $cmdline "2>&1" "| ../selftest/filter-subunit --prefix \"$fullname.\"" } plantestsuite_idlist() { @@ -65,12 +67,13 @@ plantestsuite_idlist() { cmdline="$*" echo "-- TEST-IDLIST --" if [ "$env" = "none" ]; then - echo "samba4.$name" + fullname="samba4.$name" else - echo "samba4.$name ($env)" + fullname="samba4.$name ($env)" fi + echo $fullname echo $env - echo $cmdline + echo $cmdline "2>&1" "| ../selftest/filter-subunit --prefix \"$fullname.\"" } skiptestsuite() { @@ -296,7 +299,7 @@ for env in dc fl2000dc fl2003dc fl2008r2dc; do plantestsuite_loadlist "rpc.lsa.secrets on $transport with Kerberos - use Samba3 style login, use target principal" $env $smb4torture $transport:"\$SERVER" -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*" "$*" plansmbtorturetestsuite NET-API-BECOME-DC $env "\$SERVER[$VALIDATE]" -U"\$USERNAME"%"\$PASSWORD" -W "\$DOMAIN" "$*" plantestsuite_loadlist "rpc.echo on $transport with $bindoptions and $echooptions" $env $smb4torture $transport:"\$SERVER[$bindoptions]" $ntlmoptions -U"\$USERNAME"%"\$PASSWORD" -W "\$DOMAIN" RPC-ECHO "$*" - + # Echo tests test bulk Kerberos encryption of DCE/RPC for bindoptions in connect spnego spnego,sign spnego,seal $VALIDATE padcheck bigendian bigendian,seal; do echooptions="--option=socket:testnonblock=True --option=torture:quick=yes -k yes" -- cgit v1.2.1