• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/perl
2
3use CGI qw(:standard escapeHTML);
4
5# When something goes wrong before we start output, use this function
6# so there is still output
7sub failure {
8	print header("text/html"),start_html;
9	print "$_[0]\n";
10	print end_html;
11	exit;
12}
13
14# Most of the work is done in this directory
15unless (chdir("/usr/tests/ltp/results")) {
16	failure("Could not get to the results directory\n");
17}
18
19
20# grab the parameters that determine what's going on then branch
21$get_df = param("get_df");
22if ($get_df) {
23	# copy a driver file and output it.
24	$get_df = (<$get_df*>)[0];
25	($host, $datestr, $suite, $type, $gz) = split(/\./, $get_df);
26	#print start_html, "<pre>\n";
27	if ($gz) {
28		open (DF, "gunzip -c $get_df|") || print "$get_df not found\n";
29	} else {
30		open (DF, "$get_df") || print "$get_df not found";
31	}
32	if ($type eq "driver" || $type eq "summary") {
33		print header("text/plain");
34		$zoom_tag = param("zoom_tag");
35		if ($zoom_tag) {
36			while (<DF>) {
37				# find the start of a test
38				while (<DF>) {
39					if (/\<\<\<test_start\>\>\>/) {
40						$line = <DF>;
41						if ($line =~ /^tag=$zoom_tag /) {
42							print "<<<test_start>>>\n";
43							print $line;
44
45							do {
46								$line = <DF>;
47								print $line;
48							} until ($line =~ /\<\<\<test_end\>\>\>/);
49							exit;
50						}
51					}
52				}
53			}
54			print "Did not find tag $zoom_tag\n";
55		} else {
56			while (<DF>) {
57				print $_;
58			}
59		}
60	} elsif ($type eq "scanner") {
61		print header("text/html");
62		print start_html, "<pre>\n";
63		while (<DF>) {
64			print;
65			if (/^-+/) { last;}
66		}
67		@rest = <DF>;
68		# this is just to put the * at the end of the test case list
69		unless (param("raw")) {
70			foreach (@rest) { s/\*/{/; }
71			foreach (@rest) { s/(\s)-(\s)/\1}\2/; }
72			@rest = sort @rest;
73			foreach (@rest) { s/{/*/; }
74			foreach (@rest) { s/}/-/; }
75		}
76
77		foreach (@rest) {
78			s/(\S+)/<a href="results.cgi?get_df=$host.$datestr.$suite.driver&zoom_tag=\1">\1<\/a>/;
79			# colorize the status column
80			s/\bPASS\b/\<font color\=green\>PASS\<\/font\>/i;
81			s/\bFAIL\b/\<font color\=\"red\"\>FAIL\<\/font\>/i;
82			s/\bCONF\b/\<font color\=\"yellow\"\>CONF\<\/font\>/i;
83			s/\bBROK\b/\<font color\=\"blue\"\>BROK\<\/font\>/i;
84			print;
85		}
86		print "\n</pre>",end_html;
87	}
88	close(DF);
89	#print "\n</pre>\n",end_html;
90} else {
91	%results = ();
92
93	# run through the files in the results directory
94	@driver_files = <*driver*>;
95	foreach $df (sort(@driver_files)) {
96
97		($host, $datestr, $suite, $type, $gz) = split(/\./, $df);
98
99		$a_rec = ();
100		$a_rec->{HOST} = $host;
101		$a_rec->{DATE} = $datestr;
102		$a_rec->{SUITE} = $suite;
103		$a_rec->{DRIVER_FILE} = $df;
104
105		$results{ $a_rec->{DRIVER_FILE} } = $a_rec;
106	}
107
108	# write the HTML file
109	print header("text/html"),start_html;
110
111	@ri = values %results;
112	@ri = sort { $a->{HOST} cmp $b->{HOST}
113			||$b->{DATE} <=> $a->{DATE}
114			||$a->{SUITE} cmp $b->{SUITE} } @ri;
115	$lasthost = "";
116	$lastdate = "";
117	$lastsuite = "";
118	$indent = 0;
119	print "<table>\n";
120	print "<tr><th>Hostname<th>Date<th>Suite</tr>\n";
121	foreach $rp ( @ri ) {
122		$thishost = $rp->{HOST};
123		$thisdate = $rp->{DATE};
124		$thissuite = $rp->{SUITE};
125
126		# figure out where is the table we need to start
127		if ($lasthost ne $thishost) {
128			$indent = 0;
129		} elsif ($lastdate ne $thisdate) {
130			$indent = 1;
131		} elsif ($lastsuite ne $thissuite) {
132			$indent = 2;
133		}
134
135		# write the rows we need depending on the starting point
136		# host level
137		if ($indent <= 0) {
138			print "<tr><td>$thishost\n";
139		}
140		# date level
141		if ($indent <= 1) {
142			($year, $month, $day, $hour, $min) = ($thisdate =~ /(\d+)(\d{2})(\d{2})(\d{2})(\d{2})/);
143			print "<tr><td><td>$year-$month-$day $hour:$min\n";
144		}
145		# suite level
146		if ($indent <= 2) {
147			print "<tr><td><td><td>";
148			print "$thissuite";
149			print " [<a href=\"results.cgi?get_df=$rp->{DRIVER_FILE}\">driver output</a>]";
150			print " [<a href=\"results.cgi?get_df=$thishost.$thisdate.$thissuite.scanner\">results</a>]";
151			print " [<a href=\"results.cgi?get_df=$thishost.$thisdate.$thissuite.summary\">summary</a>]";
152
153			print "\n";
154		}
155
156		# make sure we update the $last... variables
157		$lasthost = $thishost;
158		$lastdate = $thisdate;
159		$lastsuite = $thissuite;
160	}
161	print "</table>\n";
162	print end_html;
163}
164
165