summaryrefslogtreecommitdiff
path: root/source4/selftest
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
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')
-rw-r--r--source4/selftest/output/buildfarm.pm7
-rw-r--r--source4/selftest/output/html.pm130
-rw-r--r--source4/selftest/output/plain.pm7
-rwxr-xr-xsource4/selftest/selftest.pl27
4 files changed, 162 insertions, 9 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;
diff --git a/source4/selftest/selftest.pl b/source4/selftest/selftest.pl
index 72fad8f2d0..1dbb494edb 100755
--- a/source4/selftest/selftest.pl
+++ b/source4/selftest/selftest.pl
@@ -136,6 +136,7 @@ my $opt_analyse_cmd = undef;
my $opt_resetup_env = undef;
my $opt_bindir = undef;
my $opt_no_lazy_setup = undef;
+my $opt_format = "plain";
my $srcdir = ".";
my $builddir = ".";
@@ -239,7 +240,6 @@ sub parse_subunit_results($$$$)
$msg_ops->end_test($msg_state, $2, $1, 0);
$expected_ret = 0;
} else {
- print "n:$msg_state->{NAME}/$2\n";
$statistics->{TESTS_UNEXPECTED_FAIL}++;
$msg_ops->end_test($msg_state, $2, $1, 1);
}
@@ -285,7 +285,7 @@ sub run_test($$$$$$)
my $ret = close(RESULT);
- cleanup_pcap($msg_state, $expected_ret, $ret);
+ cleanup_pcap($msg_state, $expected_ret, $ret);
$msg_ops->end_testsuite($msg_state, $expected_ret, $ret,
getlog_env($msg_state->{ENVNAME}));
@@ -366,6 +366,7 @@ my $result = GetOptions (
'no-lazy-setup' => \$opt_no_lazy_setup,
'resetup-environment' => \$opt_resetup_env,
'bindir:s' => \$opt_bindir,
+ 'format=s' => \$opt_format,
);
exit(1) if (not $result);
@@ -418,8 +419,10 @@ $ENV{SRCDIR} = $srcdir;
$ENV{SRCDIR_ABS} = $srcdir_abs;
my $tls_enabled = not $opt_quick;
-my $from_build_farm = (defined($ENV{RUN_FROM_BUILD_FARM}) and
- ($ENV{RUN_FROM_BUILD_FARM} eq "yes"));
+if (defined($ENV{RUN_FROM_BUILD_FARM}) and
+ ($ENV{RUN_FROM_BUILD_FARM} eq "yes")) {
+ $opt_format = "buildfarm";
+}
$ENV{TLS_ENABLED} = ($tls_enabled?"yes":"no");
$ENV{LD_LDB_MODULE_PATH} = "$old_pwd/bin/modules/ldb";
@@ -551,7 +554,7 @@ push (@torture_options, "--configfile=$conffile");
# ensure any one smbtorture call doesn't run too long
push (@torture_options, "--maximum-runtime=$torture_maxtime");
push (@torture_options, "--target=$opt_target");
-push (@torture_options, "--option=torture:progress=no") if ($from_build_farm);
+push (@torture_options, "--option=torture:progress=no") if ($opt_format eq "buildfarm");
push (@torture_options, "--format=subunit");
push (@torture_options, "--option=torture:quick=yes") if ($opt_quick);
@@ -692,12 +695,18 @@ sub teardown_env($)
}
my $msg_ops;
-if ($from_build_farm) {
+if ($opt_format eq "buildfarm") {
require output::buildfarm;
$msg_ops = new output::buildfarm();
-} else {
+} elsif ($opt_format eq "plain") {
require output::plain;
$msg_ops = new output::plain($opt_verbose, $opt_immediate, $statistics);
+} elsif ($opt_format eq "html") {
+ require output::html;
+ mkdir "test-results";
+ $msg_ops = new output::html("test-results", $statistics);
+} else {
+ die("Invalid output format '$opt_format'");
}
if ($opt_no_lazy_setup) {
@@ -737,7 +746,7 @@ $envvarstr
my $envname = $$_[1];
if (skip($name)) {
- print "SKIPPED: $name\n";
+ $msg_ops->skip_testsuite($name);
$statistics->{SUITES_SKIPPED}++;
next;
}
@@ -791,7 +800,7 @@ foreach (<$prefix/valgrind.log*>) {
}
}
-if ($from_build_farm) {
+if ($opt_format eq "buildfarm") {
print "TEST STATUS: $numfailed\n";
}