#!/usr/bin/perl use CGI qw(:standard escapeHTML); # When something goes wrong before we start output, use this function # so there is still output sub failure { print header("text/html"),start_html; print "$_[0]\n"; print end_html; exit; } # Most of the work is done in this directory unless (chdir("/usr/tests/ltp/results")) { failure("Could not get to the results directory\n"); } # grab the parameters that determine what's going on then branch $get_df = param("get_df"); if ($get_df) { # copy a driver file and output it. $get_df = (<$get_df*>)[0]; ($host, $datestr, $suite, $type, $gz) = split(/\./, $get_df); #print start_html, "
\n";
	if ($gz) {
		open (DF, "gunzip -c $get_df|") || print "$get_df not found\n";
	} else {
		open (DF, "$get_df") || print "$get_df not found";
	}
	if ($type eq "driver" || $type eq "summary") {
		print header("text/plain");
		$zoom_tag = param("zoom_tag");
		if ($zoom_tag) {
			while () {
				# find the start of a test
				while () {
					if (/\<\<\\>\>/) {
						$line = ;
						if ($line =~ /^tag=$zoom_tag /) {
							print "<<>>\n";
							print $line;

							do {
								$line = ;
								print $line;
							} until ($line =~ /\<\<\\>\>/);
							exit;
						}
					}
				}
			}
			print "Did not find tag $zoom_tag\n";
		} else {
			while () {
				print $_;
			}
		}
	} elsif ($type eq "scanner") {
		print header("text/html");
		print start_html, "
\n";
		while () {
			print;
			if (/^-+/) { last;}
		}
		@rest = ;
		# this is just to put the * at the end of the test case list
		unless (param("raw")) {
			foreach (@rest) { s/\*/{/; }
			foreach (@rest) { s/(\s)-(\s)/\1}\2/; }
			@rest = sort @rest;
			foreach (@rest) { s/{/*/; }
			foreach (@rest) { s/}/-/; }
		}

		foreach (@rest) {
			s/(\S+)/\1<\/a>/;
			# colorize the status column
			s/\bPASS\b/\PASS\<\/font\>/i;
			s/\bFAIL\b/\FAIL\<\/font\>/i;
			s/\bCONF\b/\CONF\<\/font\>/i;
			s/\bBROK\b/\BROK\<\/font\>/i;
			print;
		}
		print "\n
",end_html; } close(DF); #print "\n
\n",end_html; } else { %results = (); # run through the files in the results directory @driver_files = <*driver*>; foreach $df (sort(@driver_files)) { ($host, $datestr, $suite, $type, $gz) = split(/\./, $df); $a_rec = (); $a_rec->{HOST} = $host; $a_rec->{DATE} = $datestr; $a_rec->{SUITE} = $suite; $a_rec->{DRIVER_FILE} = $df; $results{ $a_rec->{DRIVER_FILE} } = $a_rec; } # write the HTML file print header("text/html"),start_html; @ri = values %results; @ri = sort { $a->{HOST} cmp $b->{HOST} ||$b->{DATE} <=> $a->{DATE} ||$a->{SUITE} cmp $b->{SUITE} } @ri; $lasthost = ""; $lastdate = ""; $lastsuite = ""; $indent = 0; print "\n"; print "\n"; foreach $rp ( @ri ) { $thishost = $rp->{HOST}; $thisdate = $rp->{DATE}; $thissuite = $rp->{SUITE}; # figure out where is the table we need to start if ($lasthost ne $thishost) { $indent = 0; } elsif ($lastdate ne $thisdate) { $indent = 1; } elsif ($lastsuite ne $thissuite) { $indent = 2; } # write the rows we need depending on the starting point # host level if ($indent <= 0) { print "
HostnameDateSuite
$thishost\n"; } # date level if ($indent <= 1) { ($year, $month, $day, $hour, $min) = ($thisdate =~ /(\d+)(\d{2})(\d{2})(\d{2})(\d{2})/); print "
$year-$month-$day $hour:$min\n"; } # suite level if ($indent <= 2) { print "
"; print "$thissuite"; print " [{DRIVER_FILE}\">driver output]"; print " [results]"; print " [summary]"; print "\n"; } # make sure we update the $last... variables $lasthost = $thishost; $lastdate = $thisdate; $lastsuite = $thissuite; } print "
\n"; print end_html; }