Author: jelmer Date: 2007-12-20 15:54:02 +0000 (Thu, 20 Dec 2007) New Revision: 26547
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=26547 Log: Make testsuites less special during subunit handling. Modified: branches/SAMBA_4_0/ branches/SAMBA_4_0/source/selftest/Subunit.pm branches/SAMBA_4_0/source/selftest/output/buildfarm.pm branches/SAMBA_4_0/source/selftest/output/html.pm branches/SAMBA_4_0/source/selftest/output/plain.pm branches/SAMBA_4_0/source/selftest/selftest.pl Changeset: Property changes on: branches/SAMBA_4_0 ___________________________________________________________________ Name: bzr:revision-info ...skipped... Name: bzr:revision-id:v3-trunk0 ...skipped... Modified: branches/SAMBA_4_0/source/selftest/Subunit.pm =================================================================== --- branches/SAMBA_4_0/source/selftest/Subunit.pm 2007-12-20 15:54:00 UTC (rev 26546) +++ branches/SAMBA_4_0/source/selftest/Subunit.pm 2007-12-20 15:54:02 UTC (rev 26547) @@ -6,20 +6,20 @@ 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 @@ } 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 @@ } } - 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++; Modified: branches/SAMBA_4_0/source/selftest/output/buildfarm.pm =================================================================== --- branches/SAMBA_4_0/source/selftest/output/buildfarm.pm 2007-12-20 15:54:00 UTC (rev 26546) +++ branches/SAMBA_4_0/source/selftest/output/buildfarm.pm 2007-12-20 15:54:02 UTC (rev 26547) @@ -49,47 +49,53 @@ $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($) Modified: branches/SAMBA_4_0/source/selftest/output/html.pm =================================================================== --- branches/SAMBA_4_0/source/selftest/output/html.pm 2007-12-20 15:54:00 UTC (rev 26546) +++ branches/SAMBA_4_0/source/selftest/output/html.pm 2007-12-20 15:54:02 UTC (rev 26547) @@ -136,7 +136,7 @@ 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 @@ 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 @@ } if ($l == 0) { - if ($ret == $expected_ret) { + if (not $unexpected) { print INDEX "OK"; } else { print INDEX "FAIL"; @@ -197,16 +197,26 @@ 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>"; $self->{local_statistics}->{$result}++; Modified: branches/SAMBA_4_0/source/selftest/output/plain.pm =================================================================== --- branches/SAMBA_4_0/source/selftest/output/plain.pm 2007-12-20 15:54:00 UTC (rev 26546) +++ branches/SAMBA_4_0/source/selftest/output/plain.pm 2007-12-20 15:54:02 UTC (rev 26547) @@ -25,18 +25,18 @@ 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 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 @@ 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) { Modified: branches/SAMBA_4_0/source/selftest/selftest.pl =================================================================== --- branches/SAMBA_4_0/source/selftest/selftest.pl 2007-12-20 15:54:00 UTC (rev 26546) +++ branches/SAMBA_4_0/source/selftest/selftest.pl 2007-12-20 15:54:02 UTC (rev 26547) @@ -251,20 +251,27 @@ setup_pcap($msg_state); + $msg_ops->start_test($msg_state, [], $name); + open(RESULT, "$cmd 2>&1|"); - $msg_ops->start_testsuite($name, $msg_state); - 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; + 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"); + } + cleanup_pcap($msg_state, $expected_ret, $ret); - $msg_ops->end_testsuite($name, $msg_state, $expected_ret, $ret, - getlog_env($msg_state->{ENVNAME})); - if (not $opt_socket_wrapper_keep_pcap and defined($msg_state->{PCAP_FILE})) { $msg_ops->output_msg($msg_state,
