1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

r24669: Add CSS to the test run HTML output. See http://samba.org/~jelmer/ for an

example of the current output.
(This used to be commit 1e57394e86)
This commit is contained in:
Jelmer Vernooij 2007-08-26 16:56:41 +00:00 committed by Gerald (Jerry) Carter
parent ec180e2475
commit 3f6cf9672b
5 changed files with 154 additions and 32 deletions

View File

@ -307,6 +307,9 @@ test-noswrap: everything
quicktest: all
$(SELFTEST) --quick --socket-wrapper --immediate $(TESTS)
htmlquicktest: all
$(SELFTEST) --quick --socket-wrapper --format=html --immediate $(TESTS)
quicktestone: all
$(SELFTEST) --quick --socket-wrapper --one $(TESTS)

View File

@ -16,14 +16,27 @@ sub new($$$$) {
msg => ""
};
link("selftest/output/testresults.css", "$dirname/testresults.css");
open(INDEX, ">$dirname/index.html");
print INDEX "<html>\n";
print INDEX "<html lang=\"en\">\n";
print INDEX "<head>\n";
print INDEX " <title>Samba Testsuite Run</title>\n";
print INDEX " <link rel=\"stylesheet\" type=\"text/css\" href=\"testresults.css\"/>\n";
print INDEX "</head>\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;
print INDEX "<table width=\"100%\" border=\"0\" cellspacing=\"0\">\n";
print INDEX " <tr><td class=\"title\">Samba Testsuite Run</td></tr>\n";
print INDEX " <tr><td>\n";
print INDEX " <center>";
print INDEX " <table>\n";
print INDEX " <tr>\n";
print INDEX " <td class=\"tableHead\">Test</td>\n";
print INDEX " <td class=\"tableHead\">Environment</td>\n";
print INDEX " <td class=\"tableHead\">Result</td>\n";
print INDEX " <td class=\"tableHead\">Duration</td>\n";
print INDEX " </tr>\n";
bless($self, $class);
}
@ -35,13 +48,22 @@ sub start_testsuite($$)
my ($self, $state) = @_;
$state->{HTMLFILE} = "$state->{NAME}.html";
$state->{HTMLFILE} =~ s/[:\t\n \/]/_/g;
$state->{HTMLFILE} =~ s/[:\t\n ]/_/g;
open(TEST, ">$self->{dirname}/$state->{HTMLFILE}") or die("Unable to open $state->{HTMLFILE} for writing");
open(TEST, ">$self->{dirname}/$state->{HTMLFILE}");
my $title = "Test Results for $state->{NAME}";
print TEST "<html>\n";
print TEST "<html lang=\"en\">\n";
print TEST "<head>\n";
print TEST " <title>$title</title>\n";
print TEST " <link rel=\"stylesheet\" type=\"text/css\" href=\"testresults.css\"/>\n";
print TEST "</head>\n";
print TEST "<body>\n";
print TEST "<table width=\"100%\" border=\"0\" cellspacing=\"0\">\n";
print TEST " <tr><td class=\"title\">$title</td></tr>\n";
print TEST " <tr><td>\n";
print TEST " <table>\n";
}
sub output_msg($$$)
@ -59,20 +81,21 @@ sub end_testsuite($$$$$)
{
my ($self, $state, $expected_ret, $ret, $envlog) = @_;
print TEST "</table>\n";
print TEST "</body>\n";
print TEST "</html>\n";
close(TEST);
print INDEX "<tr><td><a href=\"$state->{HTMLFILE}\">$state->{NAME}</a></td><td>$state->{ENVNAME}</td>";
print INDEX "<tr><td class=\"testSuite\"><a href=\"$state->{HTMLFILE}\">$state->{NAME}</a></td><td class=\"environment\">$state->{ENVNAME}</td>";
if ($ret == $expected_ret) {
print INDEX "<td bgcolor=\"green\">OK</td>";
print INDEX "<td class=\"resultOk\">OK</td>";
} else {
print INDEX "<td bgcolor=\"red\">FAIL</td>";
print INDEX "<td class=\"resultFailure\">FAIL</td>";
}
print INDEX "<td>" . (time() - $state->{START_TIME}) . "</td>\n";
print INDEX "<td class=\"duration\">" . (time() - $state->{START_TIME}) . "</td>\n";
print INDEX "</tr>\n";
}
@ -81,8 +104,6 @@ sub start_test($$$)
{
my ($self, $state, $testname) = @_;
print TEST "<h3>$testname</h3>\n";
$self->{active_test} = $testname;
$self->{msg} = "";
}
@ -91,15 +112,21 @@ sub end_test($$$$$)
{
my ($self, $state, $testname, $result, $unexpected) = @_;
print TEST "<tr>";
if ($result eq "skip") {
print TEST "<div bgcolor=\"yellow\">\n";
print TEST "<td class=\"outputSkipped\">\n";
} elsif ($unexpected) {
print TEST "<div bgcolor=\"red\">\n";
print TEST "<td class=\"outputFailure\">\n";
} else {
print TEST "<td class=\"outputOk\">\n";
}
print TEST "<h3>$testname</h3>\n";
print TEST $self->{msg};
print TEST "</div>\n";
print TEST "</td></tr>\n";
$self->{active_test} = undef;
}
@ -107,12 +134,13 @@ sub end_test($$$$$)
sub summary($)
{
my ($self) = @_;
print INDEX "</table>\n";
print INDEX "FAILED ($self->{statistics}->{TESTS_UNEXPECTED_FAIL} failures and $self->{statistics}->{TESTS_ERROR} errors in $self->{statistics}->{SUITES_FAIL} testsuites)\n";
print INDEX "</table>\n";
print INDEX "</center>\n";
print INDEX "</td></tr>\n";
print INDEX "</table>\n";
print INDEX "</body>\n";
print INDEX "</html>\n";
close(INDEX);
}
@ -127,7 +155,7 @@ sub skip_testsuite($$)
{
my ($self, $name) = @_;
print INDEX "<tr><td>$name</td><td>N/A</td><td bgcolor=\"yellow\">SKIPPED</td><td>N/A</td></tr>\n";
print INDEX "<tr><td class=\"testSuite\">$name</td><td class=\"environmentSkipped\">N/A</td><td class=\"resultSkipped\">SKIPPED</td><td class=\"durationSkipped\">N/A</td></tr>\n";
}
1;

View File

@ -88,7 +88,13 @@ sub summary($)
}
}
print "FAILED ($self->{statistics}->{TESTS_UNEXPECTED_FAIL} failures and $self->{statistics}->{TESTS_ERROR} errors in $self->{statistics}->{SUITES_FAIL} testsuites)\n";
if ($self->{statistics}->{SUITES_FAIL} == 0) {
my $ok = $self->{statistics}->{TESTS_EXPECTED_OK} +
$self->{statistics}->{TESTS_EXPECTED_FAIL};
print "ALL OK ($ok tests in $self->{statistics}->{SUITES_OK} testsuites)\n";
} else {
print "FAILED ($self->{statistics}->{TESTS_UNEXPECTED_FAIL} failures and $self->{statistics}->{TESTS_ERROR} errors in $self->{statistics}->{SUITES_FAIL} testsuites)\n";
}
}
sub missing_env($$$)

View File

@ -0,0 +1,92 @@
/* Stylesheet for Samba test results.
*
* Partially based on the CSS file from lcov.
*/
/* All views: main title format */
td.title
{
text-align: center;
padding-bottom: 10px;
font-family: sans-serif;
font-size: 20pt;
font-style: italic;
font-weight: bold;
}
/* Index table headers */
td.tableHead
{
text-align: center;
color: #FFFFFF;
background-color: #6688D4;
font-family: sans-serif;
font-size: 120%;
font-weight: bold;
}
/* Testsuite names */
td.testSuite
{
text-align: left;
padding-left: 10px;
padding-right: 20px;
color: #284FA8;
background-color: #DAE7FE;
font-family: monospace;
}
/* Successful */
td.resultOk
{
text-align: right;
padding-left: 10px;
padding-right: 10px;
background-color: #A7FC9D;
font-weight: bold;
}
/* Failure */
td.resultFailure
{
text-align: right;
padding-left: 10px;
padding-right: 10px;
background-color: #FF0000;
font-weight: bold;
}
/* Skipped */
td.resultSkipped
{
text-align: right;
padding-left: 10px;
padding-right: 10px;
background-color: #FFEA20;
font-weight: bold;
}
td.duration
{
text-align: right;
}
td.durationSkipped
{
text-align: right;
}
td.outputSkipped
{
background-color: #FFEA20;
}
td.outputOk
{
background-color: #A7FC9D;
}
td.outputFailure
{
background-color: #FF0000;
}

View File

@ -777,14 +777,7 @@ $target->stop();
$statistics->{END_TIME} = time();
my $duration = ($statistics->{END_TIME}-$statistics->{START_TIME});
my $numfailed = $statistics->{SUITES_FAIL};
if ($numfailed == 0) {
my $ok = $statistics->{TESTS_EXPECTED_OK} +
$statistics->{TESTS_EXPECTED_FAIL};
print "ALL OK ($ok tests in $statistics->{SUITES_OK} testsuites)\n";
} else {
$msg_ops->summary();
}
$msg_ops->summary();
print "DURATION: $duration seconds\n";
my $failed = 0;
@ -801,7 +794,7 @@ foreach (<$prefix/valgrind.log*>) {
}
if ($opt_format eq "buildfarm") {
print "TEST STATUS: $numfailed\n";
print "TEST STATUS: $statistics->{SUITES_FAIL}\n";
}
exit $numfailed;
exit $statistics->{SUITES_FAIL};