summaryrefslogtreecommitdiff
path: root/source4/selftest/output
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2007-08-12 04:00:15 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 15:01:42 -0500
commitb5e36e528155854be1b30cfd1e08d35e3e76f7b2 (patch)
tree6356e6cfcc73ad0128c11b37689ba0f610c7d459 /source4/selftest/output
parenta83380eecefbc9d488a404d3a461670838bd11d0 (diff)
downloadsamba-b5e36e528155854be1b30cfd1e08d35e3e76f7b2.tar.gz
samba-b5e36e528155854be1b30cfd1e08d35e3e76f7b2.tar.bz2
samba-b5e36e528155854be1b30cfd1e08d35e3e76f7b2.zip
r24345: Add --format=html option to selftest.
(This used to be commit de66bced9468b338e94d430a474616016c6078a5)
Diffstat (limited to 'source4/selftest/output')
-rw-r--r--source4/selftest/output/buildfarm.pm7
-rw-r--r--source4/selftest/output/html.pm130
-rw-r--r--source4/selftest/output/plain.pm7
3 files changed, 144 insertions, 0 deletions
diff --git a/source4/selftest/output/buildfarm.pm b/source4/selftest/output/buildfarm.pm
index 11d65d7306..a605f1736c 100644
--- a/source4/selftest/output/buildfarm.pm
+++ b/source4/selftest/output/buildfarm.pm
@@ -92,4 +92,11 @@ sub missing_env($$$)
print "FAIL: $name (ENV[$envname] not available!)\n";
}
+sub skip_testsuite($$)
+{
+ my ($self, $name) = @_;
+
+ print "SKIPPED: $name\n";
+}
+
1;
diff --git a/source4/selftest/output/html.pm b/source4/selftest/output/html.pm
new file mode 100644
index 0000000000..6e83d811e8
--- /dev/null
+++ b/source4/selftest/output/html.pm
@@ -0,0 +1,130 @@
+#!/usr/bin/perl
+
+package output::html;
+use Exporter;
+@ISA = qw(Exporter);
+
+use strict;
+
+sub new($$$$) {
+ my ($class, $dirname, $statistics) = @_;
+ my $self = {
+ dirname => $dirname,
+ statistics => $statistics,
+ active_test => undef,
+ msg => ""
+ };
+
+ open(INDEX, ">$dirname/index.html");
+
+ print INDEX "<html>\n";
+ print INDEX "<body>\n";
+ print INDEX "<table>\n";
+ print INDEX "<tr><td>Test</td><td>Environment</td><td>Result</td><td>Duration</td></tr>\n";
+
+ $self->{INDEX} = *INDEX;
+
+ bless($self, $class);
+}
+
+sub output_msg($$$);
+
+sub start_testsuite($$)
+{
+ my ($self, $state) = @_;
+
+ $state->{HTMLFILE} = "$state->{NAME}.html";
+
+ $state->{HTMLFILE} =~ s/[:\t\n ]/_/g;
+
+ open(TEST, ">$self->{dirname}/$state->{HTMLFILE}");
+
+ print TEST "<html>\n";
+ print TEST "<body>\n";
+}
+
+sub output_msg($$$)
+{
+ my ($self, $state, $output) = @_;
+
+ unless (defined($self->{active_test})) {
+ print TEST "$output<br>";
+ } else {
+ $self->{msg} .= "$output<br>";
+ }
+}
+
+sub end_testsuite($$$$$)
+{
+ my ($self, $state, $expected_ret, $ret, $envlog) = @_;
+
+ print TEST "</body>\n";
+ print TEST "</html>\n";
+
+ close(TEST);
+
+ print {$self->{INDEX}} "<tr><td><a href=\"$state->{HTMLFILE}\">$state->{NAME}</a></td><td>$state->{ENVNAME}</td>";
+
+ if ($ret == $expected_ret) {
+ print {$self->{INDEX}} "<td bgcolor=\"green\">OK</td>";
+ } else {
+ print {$self->{INDEX}} "<td bgcolor=\"red\">FAIL</td>";
+ }
+
+ print {$self->{INDEX}} "<td>" . (time() - $state->{START_TIME}) . "</td>\n";
+
+ print {$self->{INDEX}} "</tr>\n";
+}
+
+sub start_test($$$)
+{
+ my ($self, $state, $testname) = @_;
+
+ print TEST "<h3>$testname</h3>\n";
+
+ $self->{active_test} = $testname;
+ $self->{msg} = "";
+}
+
+sub end_test($$$$$)
+{
+ my ($self, $state, $testname, $result, $unexpected) = @_;
+
+ if ($result eq "skip") {
+ print TEST "<div bgcolor=\"yellow\">\n";
+ } elsif ($unexpected) {
+ print TEST "<div bgcolor=\"red\">\n";
+ }
+
+ print TEST $self->{msg};
+
+ print TEST "</div>\n";
+
+ $self->{active_test} = undef;
+}
+
+sub summary($)
+{
+ my ($self) = @_;
+ print {$self->{INDEX}} "</table>\n";
+ print {$self->{INDEX}} "FAILED ($self->{statistics}->{TESTS_UNEXPECTED_FAIL} failures and $self->{statistics}->{TESTS_ERROR} errors in $self->{statistics}->{SUITES_FAIL} testsuites)\n";
+
+ print {$self->{INDEX}} "</body>\n";
+ print {$self->{INDEX}} "</html>\n";
+}
+
+sub missing_env($$$)
+{
+ my ($self, $name, $envname) = @_;
+
+ print "FAIL: $name (ENV[$envname] not available!)\n";
+}
+
+sub skip_testsuite($$)
+{
+ my ($self, $name) = @_;
+
+ print {$self->{INDEX}} "<tr><td>$name</td><td>N/A</td><td bgcolor=\"yellow\">SKIPPED</td><td>N/A</td></tr>\n";
+}
+
+1;
diff --git a/source4/selftest/output/plain.pm b/source4/selftest/output/plain.pm
index 05a8bcce18..d3ffe228a7 100644
--- a/source4/selftest/output/plain.pm
+++ b/source4/selftest/output/plain.pm
@@ -98,4 +98,11 @@ sub missing_env($$$)
print "FAIL: $name (ENV[$envname] not available!)\n";
}
+sub skip_testsuite($$)
+{
+ my ($self, $name) = @_;
+
+ print "SKIPPED: $name\n";
+}
+
1;