svn commit: samba r24345 - in branches/SAMBA_4_0: . source
source/selftest source/selftest/output
jelmer at samba.org
jelmer at samba.org
Sun Aug 12 04:00:16 GMT 2007
Author: jelmer
Date: 2007-08-12 04:00:15 +0000 (Sun, 12 Aug 2007)
New Revision: 24345
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=24345
Log:
Add --format=html option to selftest.
Added:
branches/SAMBA_4_0/source/selftest/output/html.pm
Modified:
branches/SAMBA_4_0/
branches/SAMBA_4_0/source/main.mk
branches/SAMBA_4_0/source/samba4-knownfail
branches/SAMBA_4_0/source/selftest/output/buildfarm.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:file-ids
...skipped...
Name: bzr:revision-id:v3-trunk0
...skipped...
Modified: branches/SAMBA_4_0/source/main.mk
===================================================================
--- branches/SAMBA_4_0/source/main.mk 2007-08-12 02:30:25 UTC (rev 24344)
+++ branches/SAMBA_4_0/source/main.mk 2007-08-12 04:00:15 UTC (rev 24345)
@@ -289,6 +289,9 @@
--skip=$(srcdir)/samba4-skip \
$(TEST_OPTIONS)
+htmltest: everything
+ $(SELFTEST) $(DEFAULT_TEST_OPTIONS) --format=html $(TESTS)
+
test: everything
$(SELFTEST) $(DEFAULT_TEST_OPTIONS) --immediate $(TESTS)
Modified: branches/SAMBA_4_0/source/samba4-knownfail
===================================================================
--- branches/SAMBA_4_0/source/samba4-knownfail 2007-08-12 02:30:25 UTC (rev 24344)
+++ branches/SAMBA_4_0/source/samba4-knownfail 2007-08-12 04:00:15 UTC (rev 24345)
@@ -8,3 +8,4 @@
RPC-WINREG
RPC-WKSSVC.*NetWkstaGetInfo
RPC-WKSSVC.*NetWkstaTransportEnum
+blackbox.smbclient.*USER.*PASSWD
Modified: branches/SAMBA_4_0/source/selftest/output/buildfarm.pm
===================================================================
--- branches/SAMBA_4_0/source/selftest/output/buildfarm.pm 2007-08-12 02:30:25 UTC (rev 24344)
+++ branches/SAMBA_4_0/source/selftest/output/buildfarm.pm 2007-08-12 04:00:15 UTC (rev 24345)
@@ -92,4 +92,11 @@
print "FAIL: $name (ENV[$envname] not available!)\n";
}
+sub skip_testsuite($$)
+{
+ my ($self, $name) = @_;
+
+ print "SKIPPED: $name\n";
+}
+
1;
Added: branches/SAMBA_4_0/source/selftest/output/html.pm
===================================================================
--- branches/SAMBA_4_0/source/selftest/output/html.pm 2007-08-12 02:30:25 UTC (rev 24344)
+++ branches/SAMBA_4_0/source/selftest/output/html.pm 2007-08-12 04:00:15 UTC (rev 24345)
@@ -0,0 +1,130 @@
+#!/usr/bin/perl
+
+package output::html;
+use Exporter;
+ at 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;
Modified: branches/SAMBA_4_0/source/selftest/output/plain.pm
===================================================================
--- branches/SAMBA_4_0/source/selftest/output/plain.pm 2007-08-12 02:30:25 UTC (rev 24344)
+++ branches/SAMBA_4_0/source/selftest/output/plain.pm 2007-08-12 04:00:15 UTC (rev 24345)
@@ -98,4 +98,11 @@
print "FAIL: $name (ENV[$envname] not available!)\n";
}
+sub skip_testsuite($$)
+{
+ my ($self, $name) = @_;
+
+ print "SKIPPED: $name\n";
+}
+
1;
Modified: branches/SAMBA_4_0/source/selftest/selftest.pl
===================================================================
--- branches/SAMBA_4_0/source/selftest/selftest.pl 2007-08-12 02:30:25 UTC (rev 24344)
+++ branches/SAMBA_4_0/source/selftest/selftest.pl 2007-08-12 04:00:15 UTC (rev 24345)
@@ -136,6 +136,7 @@
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 @@
$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 @@
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 @@
'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_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 @@
# 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 @@
}
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 @@
my $envname = $$_[1];
if (skip($name)) {
- print "SKIPPED: $name\n";
+ $msg_ops->skip_testsuite($name);
$statistics->{SUITES_SKIPPED}++;
next;
}
@@ -791,7 +800,7 @@
}
}
-if ($from_build_farm) {
+if ($opt_format eq "buildfarm") {
print "TEST STATUS: $numfailed\n";
}
More information about the samba-cvs
mailing list