summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source4/selftest/Subunit.pm34
-rw-r--r--source4/selftest/output/buildfarm.pm32
-rw-r--r--source4/selftest/output/html.pm24
-rw-r--r--source4/selftest/output/plain.pm36
-rwxr-xr-xsource4/selftest/selftest.pl19
5 files changed, 88 insertions, 57 deletions
diff --git a/source4/selftest/Subunit.pm b/source4/selftest/Subunit.pm
index 27e1b9815f..ea08ef8f38 100644
--- a/source4/selftest/Subunit.pm
+++ b/source4/selftest/Subunit.pm
@@ -6,20 +6,20 @@ require Exporter;
use strict;
-sub parse_results($$$$$)
+sub parse_results($$$$$$)
{
- my ($msg_ops, $msg_state, $statistics, $fh, $expecting_failure) = @_;
+ my ($msg_ops, $msg_state, $statistics, $fh, $expecting_failure, $open_tests) = @_;
my $unexpected_ok = 0;
my $expected_fail = 0;
my $unexpected_fail = 0;
my $unexpected_err = 0;
- my $open_tests = {};
+ my $orig_open_len = $#$open_tests;
while(<$fh>) {
if (/^test: (.+)\n/) {
$msg_ops->control_msg($msg_state, $_);
- $open_tests->{$1} = 1;
- $msg_ops->start_test($msg_state, $1);
+ $msg_ops->start_test($msg_state, $open_tests, $1);
+ push (@$open_tests, $1);
} elsif (/^(success|successful|failure|skip|error): (.*?)( \[)?([ \t]*)\n/) {
$msg_ops->control_msg($msg_state, $_);
my $reason = undef;
@@ -33,34 +33,34 @@ sub parse_results($$$$$)
}
my $result = $1;
if ($1 eq "success" or $1 eq "successful") {
- delete $open_tests->{$2};
+ pop(@$open_tests); #FIXME: Check that popped value == $2
if ($expecting_failure->("$msg_state->{NAME}/$2")) {
$statistics->{TESTS_UNEXPECTED_OK}++;
- $msg_ops->end_test($msg_state, $2, $1, 1, $reason);
+ $msg_ops->end_test($msg_state, $open_tests, $2, $1, 1, $reason);
$unexpected_ok++;
} else {
$statistics->{TESTS_EXPECTED_OK}++;
- $msg_ops->end_test($msg_state, $2, $1, 0, $reason);
+ $msg_ops->end_test($msg_state, $open_tests, $2, $1, 0, $reason);
}
} elsif ($1 eq "failure") {
- delete $open_tests->{$2};
+ pop(@$open_tests); #FIXME: Check that popped value == $2
if ($expecting_failure->("$msg_state->{NAME}/$2")) {
$statistics->{TESTS_EXPECTED_FAIL}++;
- $msg_ops->end_test($msg_state, $2, $1, 0, $reason);
+ $msg_ops->end_test($msg_state, $open_tests, $2, $1, 0, $reason);
$expected_fail++;
} else {
$statistics->{TESTS_UNEXPECTED_FAIL}++;
- $msg_ops->end_test($msg_state, $2, $1, 1, $reason);
+ $msg_ops->end_test($msg_state, $open_tests, $2, $1, 1, $reason);
$unexpected_fail++;
}
} elsif ($1 eq "skip") {
$statistics->{TESTS_SKIP}++;
- delete $open_tests->{$2};
- $msg_ops->end_test($msg_state, $2, $1, 0, $reason);
+ pop(@$open_tests); #FIXME: Check that popped value == $2
+ $msg_ops->end_test($msg_state, $open_tests, $2, $1, 0, $reason);
} elsif ($1 eq "error") {
$statistics->{TESTS_ERROR}++;
- delete $open_tests->{$2};
- $msg_ops->end_test($msg_state, $2, $1, 1, $reason);
+ pop(@$open_tests); #FIXME: Check that popped value == $2
+ $msg_ops->end_test($msg_state, $open_tests, $2, $1, 1, $reason);
$unexpected_err++;
}
} else {
@@ -68,8 +68,8 @@ sub parse_results($$$$$)
}
}
- foreach (keys %$open_tests) {
- $msg_ops->end_test($msg_state, $_, "error", 1,
+ while ($#$open_tests > $orig_open_len) {
+ $msg_ops->end_test($msg_state, $open_tests, pop(@$open_tests), "error", 1,
"was started but never finished!");
$statistics->{TESTS_ERROR}++;
$unexpected_err++;
diff --git a/source4/selftest/output/buildfarm.pm b/source4/selftest/output/buildfarm.pm
index f3ad9319b4..958124259e 100644
--- a/source4/selftest/output/buildfarm.pm
+++ b/source4/selftest/output/buildfarm.pm
@@ -49,47 +49,53 @@ sub control_msg($$$)
$self->{test_output}->{$state->{NAME}} .= $output;
}
-sub end_testsuite($$$$$$)
+sub end_testsuite($$$$$$$)
{
- my ($self, $name, $state, $expected_ret, $ret, $envlog) = @_;
+ my ($self, $name, $state, $result, $unexpected, $reason) = @_;
my $out = "";
$out .= "TEST RUNTIME: " . (time() - $state->{START_TIME}) . "s\n";
- if ($ret == $expected_ret) {
+ if (not $unexpected) {
$out .= "ALL OK\n";
} else {
- $out .= "ERROR: $ret\n";
+ $out .= "ERROR: $reason\n";
$out .= $self->{test_output}->{$name};
}
$out .= "PCAP FILE: $state->{PCAP_FILE}\n" if defined($state->{PCAP_FILE});
- $out .= $envlog;
-
$out .= "==========================================\n";
- if ($ret == $expected_ret) {
+ if (not $unexpected) {
$out .= "TEST PASSED: $name\n";
} else {
- $out .= "TEST FAILED: $name (status $ret)\n";
+ $out .= "TEST FAILED: $name (status $reason)\n";
}
$out .= "==========================================\n";
print $out;
}
-sub start_test($$$)
+sub start_test($$$$)
{
- my ($self, $state, $testname) = @_;
+ my ($self, $state, $parents, $testname) = @_;
+
+ if ($#$parents == -1) {
+ $self->start_testsuite($testname, $state);
+ }
}
sub end_test($$$$$$)
{
- my ($self, $state, $testname, $result, $unexpected, $reason) = @_;
+ my ($self, $state, $parents, $testname, $result, $unexpected, $reason) = @_;
- return unless ($unexpected);
+ if ($unexpected) {
+ $self->{test_output}->{$state->{NAME}} .= "UNEXPECTED($result): $testname\n";
+ }
- $self->{test_output}->{$state->{NAME}} .= "UNEXPECTED($result): $testname\n";
+ if ($#$parents == -1) {
+ $self->end_testsuite($testname, $state, $result, $unexpected, $reason);
+ }
}
sub summary($)
diff --git a/source4/selftest/output/html.pm b/source4/selftest/output/html.pm
index fc034cc95f..7f3cfac8cd 100644
--- a/source4/selftest/output/html.pm
+++ b/source4/selftest/output/html.pm
@@ -136,7 +136,7 @@ sub output_msg($$$)
sub end_testsuite($$$$$)
{
- my ($self, $name, $state, $expected_ret, $ret, $envlog) = @_;
+ my ($self, $name, $state, $result, $unexpected, $reason) = @_;
print TEST "</table>\n";
@@ -151,8 +151,8 @@ sub end_testsuite($$$$$)
print INDEX " <td class=\"testSuite\"><a href=\"$state->{HTMLFILE}\">$name</a></td>\n";
my $st = $self->{local_statistics};
- if ($ret == $expected_ret) {
- if ($ret == 0) {
+ if (not $unexpected) {
+ if ($result eq "failure") {
print INDEX " <td class=\"resultExpectedFailure\">";
} else {
print INDEX " <td class=\"resultOk\">";
@@ -183,7 +183,7 @@ sub end_testsuite($$$$$)
}
if ($l == 0) {
- if ($ret == $expected_ret) {
+ if (not $unexpected) {
print INDEX "OK";
} else {
print INDEX "FAIL";
@@ -197,15 +197,25 @@ sub end_testsuite($$$$$)
sub start_test($$$)
{
- my ($self, $state, $testname) = @_;
+ my ($self, $state, $parents, $testname) = @_;
+
+ if ($#$parents == -1) {
+ $self->start_testsuite($testname, $state);
+ return;
+ }
$self->{active_test} = $testname;
$self->{msg} = "";
}
-sub end_test($$$$$$)
+sub end_test($$$$$$$)
{
- my ($self, $state, $testname, $result, $unexpected, $reason) = @_;
+ my ($self, $state, $parents, $testname, $result, $unexpected, $reason) = @_;
+
+ if ($#$parents == -1) {
+ $self->end_testsuite($testname, $state, $result, $unexpected, $reason);
+ return;
+ }
print TEST "<tr>";
diff --git a/source4/selftest/output/plain.pm b/source4/selftest/output/plain.pm
index 8a56d1c922..a11ada871a 100644
--- a/source4/selftest/output/plain.pm
+++ b/source4/selftest/output/plain.pm
@@ -25,18 +25,18 @@ sub output_msg($$$);
sub start_testsuite($$$)
{
my ($self, $name, $state) = @_;
- my $out = "";
my $duration = $state->{START_TIME} - $self->{statistics}->{START_TIME};
- $out .= "[$state->{INDEX}/$state->{TOTAL} in ".$duration."s";
- $out .= sprintf(", %d errors", $self->{statistics}->{SUITES_FAIL}) if ($self->{statistics}->{SUITES_FAIL} > 0);
- $out .= "] $name\n",
$self->{test_output}->{$name} = "" unless($self->{verbose});
$self->output_msg($state, "CMD: $state->{CMD}\n");
- print $out;
+ my $out = "";
+ $out .= "[$state->{INDEX}/$state->{TOTAL} in ".$duration."s";
+ $out .= sprintf(", %d errors", $self->{statistics}->{SUITES_FAIL}) if ($self->{statistics}->{SUITES_FAIL} > 0);
+ $out .= "] $name\n",
+ print "$out";
}
sub output_msg($$$)
@@ -59,16 +59,14 @@ sub control_msg($$$)
sub end_testsuite($$$$$$)
{
- my ($self, $name, $state, $expected_ret, $ret, $envlog) = @_;
+ my ($self, $name, $state, $result, $unexpected, $reason) = @_;
my $out = "";
- $self->output_msg($state, "ENVLOG: $envlog\n") if ($envlog ne "");
-
- if ($ret != $expected_ret) {
- $self->output_msg($state, "ERROR: $ret\n");
+ if ($unexpected) {
+ $self->output_msg($state, "ERROR: $reason\n");
}
- if ($ret != $expected_ret and $self->{immediate} and not $self->{verbose}) {
+ if ($unexpected and $self->{immediate} and not $self->{verbose}) {
$out .= $self->{test_output}->{$name};
push (@{$self->{suitesfailed}}, $name);
}
@@ -76,14 +74,24 @@ sub end_testsuite($$$$$$)
print $out;
}
-sub start_test($$)
+sub start_test($$$$)
{
- my ($state, $testname) = @_;
+ my ($self, $state, $parents, $testname) = @_;
+
+ if ($#$parents == -1) {
+ $self->start_testsuite($testname, $state);
+ }
}
sub end_test($$$$$$)
{
- my ($self, $state, $testname, $result, $unexpected, $reason) = @_;
+ my ($self, $state, $parents, $testname, $result, $unexpected, $reason) = @_;
+
+ if ($#$parents == -1) {
+ $self->end_testsuite($testname, $state, $result, $unexpected, $reason);
+ return;
+ }
+
my $append = "";
unless ($unexpected) {
diff --git a/source4/selftest/selftest.pl b/source4/selftest/selftest.pl
index 456b483f07..4dbdb2da62 100755
--- a/source4/selftest/selftest.pl
+++ b/source4/selftest/selftest.pl
@@ -251,19 +251,26 @@ sub run_testsuite($$$$$$$)
setup_pcap($msg_state);
- open(RESULT, "$cmd 2>&1|");
- $msg_ops->start_testsuite($name, $msg_state);
+ $msg_ops->start_test($msg_state, [], $name);
+ open(RESULT, "$cmd 2>&1|");
my $expected_ret = parse_results(
- $msg_ops, $msg_state, $statistics, *RESULT, \&expecting_failure);
+ $msg_ops, $msg_state, $statistics, *RESULT, \&expecting_failure, [$name]);
+
+ my $envlog = getlog_env($envname);
+ $msg_ops->output_msg($msg_state, "ENVLOG: $envlog\n") if ($envlog ne "");
my $ret = close(RESULT);
$ret = 0 unless $ret == 1;
- cleanup_pcap($msg_state, $expected_ret, $ret);
+ if ($ret == 1) {
+ $msg_ops->end_test($msg_state, [], $name, "success", $expected_ret != $ret, undef);
+ } else {
+ $msg_ops->end_test($msg_state, [], $name, "failure", $expected_ret != $ret,
+ "Returned $ret");
+ }
- $msg_ops->end_testsuite($name, $msg_state, $expected_ret, $ret,
- getlog_env($msg_state->{ENVNAME}));
+ cleanup_pcap($msg_state, $expected_ret, $ret);
if (not $opt_socket_wrapper_keep_pcap and
defined($msg_state->{PCAP_FILE})) {