10 use FindBin qw($RealBin);
13 my ($class, $dirname, $statistics) = @_;
16 statistics => $statistics,
18 local_statistics => {},
22 expected_success => [],
23 unexpected_success => [],
24 expected_failure => [],
25 unexpected_failure => [],
30 link("$RealBin/output/testresults.css", "$dirname/testresults.css");
32 open(INDEX, ">$dirname/index.html");
36 $self->print_html_header("Samba Testsuite Run", *INDEX);
38 print INDEX " <center>";
39 print INDEX " <table>\n";
40 print INDEX " <tr>\n";
41 print INDEX " <td class=\"tableHead\">Test</td>\n";
42 print INDEX " <td class=\"tableHead\">Environment</td>\n";
43 print INDEX " <td class=\"tableHead\">Result</td>\n";
44 print INDEX " </tr>\n";
49 sub print_html_header($$$)
51 my ($self, $title, $fh) = @_;
53 print $fh "<html lang=\"en\">\n";
55 print $fh " <title>$title</title>\n";
56 print $fh " <link rel=\"stylesheet\" type=\"text/css\" href=\"testresults.css\"/>\n";
57 print $fh "</head>\n";
59 print $fh "<table width=\"100%\" border=\"0\" cellspacing=\"0\">\n";
60 print $fh " <tr><td class=\"title\">$title</td></tr>\n";
61 print $fh " <tr><td>\n";
64 sub print_html_footer($$)
68 print $fh "</td></tr>\n";
69 print $fh "</table>\n";
70 print $fh "</body>\n";
71 print $fh "</html>\n";
76 sub start_testsuite($$)
78 my ($self, $state) = @_;
80 $self->{local_statistics} = {
87 $state->{HTMLFILE} = "$state->{NAME}.html";
88 $state->{HTMLFILE} =~ s/[:\t\n \/]/_/g;
90 open(TEST, ">$self->{dirname}/$state->{HTMLFILE}") or die("Unable to open $state->{HTMLFILE} for writing");
92 $self->print_html_header("Test Results for $state->{NAME}",
94 print TEST " <table>\n";
99 my ($self, $state, $output) = @_;
101 $self->{msg} .= "<span class=\"control\">$output<br/></span>\n";
106 my ($self, $state, $output) = @_;
108 unless (defined($self->{active_test})) {
109 print TEST "$output<br/>";
111 $self->{msg} .= "$output<br/>";
115 sub end_testsuite($$$$$)
117 my ($self, $state, $expected_ret, $ret, $envlog) = @_;
119 print TEST "</table>\n";
121 print TEST "<div class=\"command\">$state->{CMD}</div>\n";
122 print TEST "<div class=\"duration\">Duration: " . (time() - $state->{START_TIME}) . "s</div>\n";
124 $self->print_html_footer(*TEST);
128 print INDEX "<tr>\n";
129 print INDEX " <td class=\"testSuite\"><a href=\"$state->{HTMLFILE}\">$state->{NAME}</a></td>\n";
130 print INDEX " <td class=\"environment\">$state->{ENVNAME}</td>\n";
131 my $st = $self->{local_statistics};
133 if ($ret == $expected_ret) {
135 print INDEX " <td class=\"resultExpectedFailure\">";
137 print INDEX " <td class=\"resultOk\">";
140 print INDEX " <td class=\"resultFailure\">";
144 if ($st->{success} > 0) {
145 print INDEX "$st->{success} ok";
148 if ($st->{skip} > 0) {
149 print INDEX ", " if ($l);
150 print INDEX "$st->{skip} skipped";
153 if ($st->{failure} > 0) {
154 print INDEX ", " if ($l);
155 print INDEX "$st->{failure} failures";
158 if ($st->{error} > 0) {
159 print INDEX ", " if ($l);
160 print INDEX "$st->{error} errors";
165 if ($ret == $expected_ret) {
174 print INDEX "</tr>\n";
179 my ($self, $state, $testname) = @_;
181 $self->{active_test} = $testname;
187 my ($self, $state, $testname, $result, $unexpected, $reason) = @_;
191 $self->{local_statistics}->{$result}++;
195 if ($result eq "skip") {
196 print TEST "<td class=\"outputSkipped\">\n";
197 $track_class = "skip";
198 } elsif ($unexpected) {
199 print TEST "<td class=\"outputFailure\">\n";
200 if ($result eq "error") {
201 $track_class = "error";
203 $track_class = "unexpected_$result";
206 if ($result eq "failure") {
207 print TEST "<td class=\"outputExpectedFailure\">\n";
209 print TEST "<td class=\"outputOk\">\n";
211 $track_class = "expected_$result";
214 push(@{$self->{error_summary}->{$track_class}}, ,
215 [$state->{HTMLFILE}, $testname, $state->{NAME},
218 print TEST "<a name=\"$testname\"><h3>$testname</h3></a>\n";
220 print TEST $self->{msg};
222 if (defined($reason)) {
223 print TEST "<div class=\"reason\">$reason</div>\n";
226 print TEST "</td></tr>\n";
228 $self->{active_test} = undef;
235 my $st = $self->{statistics};
236 print INDEX "<tr>\n";
237 print INDEX " <td class=\"testSuiteTotal\">Total</td>\n";
238 print INDEX " <td></td>\n";
240 if ($st->{SUITES_FAIL} == 0) {
241 print INDEX " <td class=\"resultOk\">";
243 print INDEX " <td class=\"resultFailure\">";
245 print INDEX ($st->{TESTS_EXPECTED_OK} + $st->{TESTS_UNEXPECTED_OK}) . " ok";
246 if ($st->{TESTS_UNEXPECTED_OK} > 0) {
247 print INDEX " ($st->{TESTS_UNEXPECTED_OK} unexpected)";
249 if ($st->{TESTS_SKIP} > 0) {
250 print INDEX ", $st->{TESTS_SKIP} skipped";
252 if (($st->{TESTS_UNEXPECTED_FAIL} + $st->{TESTS_EXPECTED_FAIL}) > 0) {
253 print INDEX ", " . ($st->{TESTS_UNEXPECTED_FAIL} + $st->{TESTS_EXPECTED_FAIL}) . " failures";
254 if ($st->{TESTS_UNEXPECTED_FAIL} > 0) {
255 print INDEX " ($st->{TESTS_EXPECTED_FAIL} expected)";
258 if ($st->{TESTS_ERROR} > 0) {
259 print INDEX ", $st->{TESTS_ERROR} errors";
264 print INDEX "</tr>\n";
266 print INDEX "</table>\n";
267 print INDEX "</center>\n";
268 $self->print_html_footer(*INDEX);
271 my $summ = $self->{error_summary};
272 open(SUMMARY, ">$self->{dirname}/summary.html");
273 $self->print_html_header("Summary", *SUMMARY);
274 sub print_table($$) {
275 my ($title, $list) = @_;
276 return if ($#$list == -1);
277 print SUMMARY "<h3>$title</h3>\n";
278 print SUMMARY "<table>\n";
279 print SUMMARY "<tr>\n";
280 print SUMMARY " <td class=\"tableHead\">Testsuite</td>\n";
281 print SUMMARY " <td class=\"tableHead\">Test</td>\n";
282 print SUMMARY " <td class=\"tableHead\">Reason</td>\n";
283 print SUMMARY "</tr>\n";
286 print SUMMARY "<tr>\n";
287 print SUMMARY " <td><a href=\"" . $$_[0] . "\">$$_[2]</a></td>\n";
288 print SUMMARY " <td><a href=\"" . $$_[0] . "#$$_[1]\">$$_[1]</a></td>\n";
289 if (defined($$_[3])) {
290 print SUMMARY " <td>$$_[3]</td>\n";
292 print SUMMARY " <td></td>\n";
294 print SUMMARY "</tr>\n";
297 print SUMMARY "</table>";
299 print_table("Errors", $summ->{error});
300 print_table("Unexpected successes", $summ->{unexpected_success});
301 print_table("Unexpected failures", $summ->{unexpected_failure});
302 print_table("Skipped tests", $summ->{skip});
303 print_table("Expected failures", $summ->{expected_failure});
304 $self->print_html_footer(*SUMMARY);
310 my ($self, $name, $envname) = @_;
312 print INDEX "<tr>\n";
313 print INDEX " <td class=\"testSuite\">$name</td>\n";
314 print INDEX " <td class=\"resultSkipped\" colspan=\"2\">SKIPPED - environment `$envname` not available!</td>\n";
315 print INDEX "</tr>\n";
318 sub skip_testsuite($$$$)
320 my ($self, $envname, $name, $reason) = @_;
322 print INDEX "<tr>\n";
323 print INDEX " <td class=\"testSuite\">$name</td>\n";
324 print INDEX " <td class=\"environment\">$envname</td>\n";
326 print INDEX " <td class=\"resultSkipped\">SKIPPED - $reason</td>\n";
328 print INDEX " <td class=\"resultSkipped\">SKIPPED</td>\n";
330 print INDEX "</tr>\n";