summaryrefslogtreecommitdiff
path: root/selftest
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2010-09-22 11:30:34 -0700
committerJelmer Vernooij <jelmer@samba.org>2010-09-22 17:48:23 -0700
commit31d5ac05402ed9ac8158d143283c7f8b2d7bb7b4 (patch)
tree072359171a72ba718c0298232e83e45157b25809 /selftest
parent54f0da368f35ce7d7fd4b093b865ffea284d826b (diff)
downloadsamba-31d5ac05402ed9ac8158d143283c7f8b2d7bb7b4.tar.gz
samba-31d5ac05402ed9ac8158d143283c7f8b2d7bb7b4.tar.bz2
samba-31d5ac05402ed9ac8158d143283c7f8b2d7bb7b4.zip
selftest: Let tests add prefix to tests by themselve.
Diffstat (limited to 'selftest')
-rw-r--r--selftest/Subunit.pm33
-rwxr-xr-xselftest/selftest.pl35
-rw-r--r--selftest/subunithelper.py2
3 files changed, 13 insertions, 57 deletions
diff --git a/selftest/Subunit.pm b/selftest/Subunit.pm
index a94eecd7e4..1cc0e72169 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 a21ecbabe4..3bad138f5c 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 4a649c3b5f..75ede2820a 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