summaryrefslogtreecommitdiff
path: root/selftest/output
diff options
context:
space:
mode:
authorbubulle <bubulle@alioth.debian.org>2010-04-06 18:12:47 +0000
committerbubulle <bubulle@alioth.debian.org>2010-04-06 18:12:47 +0000
commitc038a4e9c09ba4ac77d885ac0afee418f41b8891 (patch)
treef5b2444727ff995f46dabbbf94863e9926501444 /selftest/output
parent9e2f5a6ab663f7a111832217c527508c75ddae8a (diff)
downloadsamba-c038a4e9c09ba4ac77d885ac0afee418f41b8891.tar.gz
Revert to 3.4.7...for now?
git-svn-id: svn://svn.debian.org/svn/pkg-samba/trunk/samba@3416 fc4039ab-9d04-0410-8cac-899223bdd6b0
Diffstat (limited to 'selftest/output')
-rw-r--r--selftest/output/buildfarm.pm120
-rw-r--r--selftest/output/html.pm76
-rw-r--r--selftest/output/plain.pm98
3 files changed, 187 insertions, 107 deletions
diff --git a/selftest/output/buildfarm.pm b/selftest/output/buildfarm.pm
new file mode 100644
index 0000000000..cee6c1e63a
--- /dev/null
+++ b/selftest/output/buildfarm.pm
@@ -0,0 +1,120 @@
+#!/usr/bin/perl
+
+package output::buildfarm;
+
+use Exporter;
+@ISA = qw(Exporter);
+
+use FindBin qw($RealBin);
+use lib "$RealBin/..";
+
+use Subunit qw(parse_results);
+
+use strict;
+
+sub new($$$) {
+ my ($class) = @_;
+ my $self = {
+ test_output => {},
+ start_time => time()
+ };
+ bless($self, $class);
+}
+
+sub start_testsuite($$)
+{
+ my ($self, $name) = @_;
+ my $out = "";
+
+ $self->{NAME} = $name;
+ $self->{START_TIME} = time();
+
+ my $duration = $self->{START_TIME} - $self->{start_time};
+ $out .= "--==--==--==--==--==--==--==--==--==--==--\n";
+ $out .= "Running test $name (level 0 stdout)\n";
+ $out .= "--==--==--==--==--==--==--==--==--==--==--\n";
+ $out .= scalar(localtime())."\n";
+ $out .= "SELFTEST RUNTIME: " . $duration . "s\n";
+ $out .= "NAME: $name\n";
+
+ $self->{test_output}->{$name} = "";
+
+ print $out;
+}
+
+sub output_msg($$)
+{
+ my ($self, $output) = @_;
+
+ $self->{test_output}->{$self->{NAME}} .= $output;
+}
+
+sub control_msg($$)
+{
+ my ($self, $output) = @_;
+
+ $self->{test_output}->{$self->{NAME}} .= $output;
+}
+
+sub end_testsuite($$$$$$)
+{
+ my ($self, $name, $result, $unexpected, $reason) = @_;
+ my $out = "";
+
+ $out .= "TEST RUNTIME: " . (time() - $self->{START_TIME}) . "s\n";
+
+ if (not $unexpected) {
+ $out .= "ALL OK\n";
+ } else {
+ $out .= "ERROR: $reason\n";
+ $out .= $self->{test_output}->{$name};
+ }
+
+ $out .= "==========================================\n";
+ if (not $unexpected) {
+ $out .= "TEST PASSED: $name\n";
+ } else {
+ $out .= "TEST FAILED: $name (status $reason)\n";
+ }
+ $out .= "==========================================\n";
+
+ print $out;
+}
+
+sub start_test($$$)
+{
+ my ($self, $parents, $testname) = @_;
+
+ if ($#$parents == -1) {
+ $self->start_testsuite($testname);
+ }
+}
+
+sub end_test($$$$$)
+{
+ my ($self, $parents, $testname, $result, $unexpected, $reason) = @_;
+
+ if ($unexpected) {
+ $self->{test_output}->{$self->{NAME}} .= "UNEXPECTED($result): $testname\n";
+ }
+
+ if ($#$parents == -1) {
+ $self->end_testsuite($testname, $result, $unexpected, $reason);
+ }
+}
+
+sub summary($)
+{
+ my ($self) = @_;
+
+ print "DURATION: " . (time() - $self->{start_time}) . " seconds\n";
+}
+
+sub skip_testsuite($$$$)
+{
+ my ($self, $name, $reason) = @_;
+
+ print "SKIPPED: $name\n";
+}
+
+1;
diff --git a/selftest/output/html.pm b/selftest/output/html.pm
index 8e42b65649..1049527129 100644
--- a/selftest/output/html.pm
+++ b/selftest/output/html.pm
@@ -1,19 +1,5 @@
#!/usr/bin/perl
-# HTML output for selftest
-# Copyright (C) 2008 Jelmer Vernooij <jelmer@samba.org>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
package output::html;
use Exporter;
@ISA = qw(Exporter);
@@ -24,6 +10,8 @@ use warnings;
use FindBin qw($RealBin);
use lib "$RealBin/..";
+use Subunit qw(parse_results);
+
sub new($$$) {
my ($class, $dirname, $statistics) = @_;
my $self = {
@@ -61,10 +49,6 @@ sub new($$$) {
return $self;
}
-sub testsuite_count($$)
-{
-}
-
sub print_html_header($$$)
{
my ($self, $title, $fh) = @_;
@@ -96,8 +80,6 @@ sub start_testsuite($$)
{
my ($self, $name) = @_;
- $self->{START_TIME} = $self->{last_time};
-
$self->{local_statistics} = {
success => 0,
skip => 0,
@@ -122,7 +104,6 @@ sub control_msg($$)
{
my ($self, $output) = @_;
- # Perhaps the CSS should hide this by default?
$self->{msg} .= "<span class=\"control\">$output<br/></span>\n";
}
@@ -131,21 +112,19 @@ sub output_msg($$)
my ($self, $output) = @_;
unless (defined($self->{active_test})) {
- if (defined($self->{NAME})) {
- print TEST "$output<br/>";
- }
+ print TEST "$output<br/>";
} else {
$self->{msg} .= "$output<br/>";
}
}
-sub end_testsuite($$$)
+sub end_testsuite($$$$)
{
- my ($self, $name, $result, $reason) = @_;
+ my ($self, $name, $result, $unexpected, $reason) = @_;
print TEST "</table>\n";
- print TEST "<div class=\"duration\">Duration: " . ($self->{last_time} - $self->{START_TIME}) . "s</div>\n";
+ print TEST "<div class=\"duration\">Duration: " . (time() - $self->{START_TIME}) . "s</div>\n";
$self->print_html_footer(*TEST);
@@ -155,10 +134,12 @@ sub end_testsuite($$$)
print INDEX " <td class=\"testSuite\"><a href=\"$self->{HTMLFILE}\">$name</a></td>\n";
my $st = $self->{local_statistics};
- if ($result eq "xfail") {
- print INDEX " <td class=\"resultExpectedFailure\">";
- } elsif ($result eq "success") {
- print INDEX " <td class=\"resultOk\">";
+ if (not $unexpected) {
+ if ($result eq "failure") {
+ print INDEX " <td class=\"resultExpectedFailure\">";
+ } else {
+ print INDEX " <td class=\"resultOk\">";
+ }
} else {
print INDEX " <td class=\"resultFailure\">";
}
@@ -185,33 +166,40 @@ sub end_testsuite($$$)
}
if ($l == 0) {
- print INDEX uc($result);
+ if (not $unexpected) {
+ print INDEX "OK";
+ } else {
+ print INDEX "FAIL";
+ }
}
print INDEX "</td>";
print INDEX "</tr>\n";
-
- $self->{NAME} = undef;
-}
-
-sub report_time($$)
-{
- my ($self, $time) = @_;
- $self->{last_time} = $time;
}
sub start_test($$)
{
- my ($self, $testname) = @_;
+ my ($self, $parents, $testname) = @_;
+
+ if ($#$parents == -1) {
+ $self->{START_TIME} = time();
+ $self->start_testsuite($testname);
+ return;
+ }
$self->{active_test} = $testname;
$self->{msg} = "";
}
-sub end_test($$$$)
+sub end_test($$$$$$)
{
- my ($self, $testname, $result, $unexpected, $reason) = @_;
+ my ($self, $parents, $testname, $result, $unexpected, $reason) = @_;
+
+ if ($#$parents == -1) {
+ $self->end_testsuite($testname, $result, $unexpected, $reason);
+ return;
+ }
print TEST "<tr>";
diff --git a/selftest/output/plain.pm b/selftest/output/plain.pm
index 5e75ce9511..82a73ab932 100644
--- a/selftest/output/plain.pm
+++ b/selftest/output/plain.pm
@@ -1,19 +1,5 @@
#!/usr/bin/perl
-# Plain text output for selftest
-# Copyright (C) 2008-2009 Jelmer Vernooij <jelmer@samba.org>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
package output::plain;
use Exporter;
@ISA = qw(Exporter);
@@ -29,7 +15,7 @@ sub new($$$$$$$) {
verbose => $verbose,
immediate => $immediate,
statistics => $statistics,
- start_time => undef,
+ start_time => time(),
test_output => {},
suitesfailed => [],
suites_ok => 0,
@@ -41,21 +27,6 @@ sub new($$$$$$$) {
bless($self, $class);
}
-sub testsuite_count($$)
-{
- my ($self, $count) = @_;
- $self->{totalsuites} = $count;
-}
-
-sub report_time($$)
-{
- my ($self, $time) = @_;
- unless ($self->{start_time}) {
- $self->{start_time} = $time;
- }
- $self->{last_time} = $time;
-}
-
sub output_msg($$);
sub start_testsuite($$)
@@ -64,18 +35,14 @@ sub start_testsuite($$)
$self->{index}++;
$self->{NAME} = $name;
- $self->{START_TIME} = $self->{last_time};
+ $self->{START_TIME} = time();
my $duration = $self->{START_TIME} - $self->{start_time};
$self->{test_output}->{$name} = "" unless($self->{verbose});
my $out = "";
- $out .= "[$self->{index}";
- if ($self->{totalsuites}) {
- $out .= "/$self->{totalsuites}";
- }
- $out.= " in ".$duration."s";
+ $out .= "[$self->{index}/$self->{totalsuites} in ".$duration."s";
$out .= sprintf(", %d errors", ($#{$self->{suitesfailed}}+1)) if ($#{$self->{suitesfailed}} > -1);
$out .= "] $name";
if ($self->{immediate}) {
@@ -93,10 +60,8 @@ sub output_msg($$)
require FileHandle;
print $output;
STDOUT->flush();
- } elsif (defined($self->{NAME})) {
- $self->{test_output}->{$self->{NAME}} .= $output;
} else {
- print $output;
+ $self->{test_output}->{$self->{NAME}} .= $output;
}
}
@@ -104,28 +69,30 @@ sub control_msg($$)
{
my ($self, $output) = @_;
- #$self->output_msg($output);
+ $self->output_msg($output);
}
-sub end_testsuite($$$$)
+sub end_testsuite($$$$$)
{
- my ($self, $name, $result, $reason) = @_;
+ my ($self, $name, $result, $unexpected, $reason) = @_;
my $out = "";
- my $unexpected = 0;
- if ($result eq "success" or $result eq "xfail") {
- $self->{suites_ok}++;
- } else {
+ if ($unexpected) {
+ if ($result eq "success" and not defined($reason)) {
+ $reason = "Expected negative exit code, got positive exit code";
+ }
$self->output_msg("ERROR: $reason\n");
push (@{$self->{suitesfailed}}, $name);
- if ($self->{immediate} and not $self->{verbose}) {
- $out .= $self->{test_output}->{$name};
- }
- $unexpected = 1;
+ } else {
+ $self->{suites_ok}++;
+ }
+
+ if ($unexpected and $self->{immediate} and not $self->{verbose}) {
+ $out .= $self->{test_output}->{$name};
}
if (not $self->{immediate}) {
- unless($unexpected) {
+ if (not $unexpected) {
$out .= " ok\n";
} else {
$out .= " " . uc($result) . "\n";
@@ -137,20 +104,28 @@ sub end_testsuite($$$$)
sub start_test($$$)
{
- my ($self, $testname) = @_;
+ my ($self, $parents, $testname) = @_;
+
+ if ($#$parents == -1) {
+ $self->start_testsuite($testname);
+ }
}
sub end_test($$$$$)
{
- my ($self, $testname, $result, $unexpected, $reason) = @_;
+ my ($self, $parents, $testname, $result, $unexpected, $reason) = @_;
+ if ($#$parents == -1) {
+ $self->end_testsuite($testname, $result, $unexpected, $reason);
+ return;
+ }
+
my $append = "";
unless ($unexpected) {
$self->{test_output}->{$self->{NAME}} = "";
if (not $self->{immediate}) {
if ($result eq "failure") { print "f"; }
- elsif ($result eq "xfail") { print "X"; }
elsif ($result eq "skip") { print "s"; }
elsif ($result eq "success") { print "."; }
else { print "?($result)"; }
@@ -158,7 +133,9 @@ sub end_test($$$$$)
return;
}
- $append = "UNEXPECTED($result): $testname\n";
+ my $fullname = join(".", @$parents).".$testname";
+
+ $append = "UNEXPECTED($result): $testname ($fullname)\n";
$self->{test_output}->{$self->{NAME}} .= $append;
@@ -223,18 +200,13 @@ sub summary($)
}
-sub skip_testsuite($$$)
+sub skip_testsuite($$)
{
my ($self, $name, $reason) = @_;
- unless (defined($reason)) {
- $reason = "UNKNOWN";
- }
push (@{$self->{skips}->{$reason}}, $name);
- if ($self->{totalsuites}) {
- $self->{totalsuites}--;
- }
+ $self->{totalsuites}--;
}
1;