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