2 #****************************************************************************#
3 # Copyright (c) International Business Machines Corp., 2001 #
5 # This program is free software; you can redistribute it an#or modify #
6 # it under the terms of the GNU General Public License as published by #
7 # the Free Software Foundation; either version 2 of the License, or #
8 # (at your option) any later version. #
10 # This program is distributed in the hope that it will be useful, #
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See #
13 # the GNU General Public License for more details. #
15 # You should have received a copy of the GNU General Public License #
16 # along with this program; if not, write to the Free Software #
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #
19 #****************************************************************************#
21 #****************************************************************************#
25 # Description: This is a Parser which can parse the text output generated by #
26 # pan and convert the same to am HTML format, with proper high- #
27 # lighting of test result backgorund for easy identification of #
28 # pass/fail of testcases #
30 # Author: Subrata Modak: subrata@linux.vnet.ibm.com #
33 #****************************************************************************#
43 my $failed_test_counter = 0;
44 my $failed_test_counter_flag = 0;
45 my $brok_test_counter = 0;
46 my $brok_test_counter_flag = 0;
47 my $warn_test_counter = 0;
48 my $warn_test_counter_flag = 0;
49 my $retr_test_counter = 0;
50 my $retr_test_counter_flag = 0;
51 my $conf_test_counter = 0;
52 my $conf_test_counter_flag = 0;
54 my $detected_fail = 0;
55 my $detected_pass = 0;
56 my $detected_warn = 0;
57 my $detected_brok = 0;
58 my $detected_retr = 0;
59 my $detected_conf = 0;
60 my $background_colour =0;
62 my $header_file = shift (@ARGV) || syntax
();
63 my $start_tag = shift (@ARGV) || syntax
();
64 my $end_tag = shift (@ARGV) || syntax
();
65 my $output_tag = shift (@ARGV) || syntax
();
66 my $execution_tag = shift (@ARGV) || syntax
();
69 print "syntax: prtag2tag start_tag end_tag output_tag execution_tag file(s)\n";
73 sub get_background_colour_column
() {
74 if ( $detected_fail == 1 ) {
76 } elsif ( $detected_brok == 1 ) {
78 } elsif ( $detected_warn == 1 ) {
80 } elsif ( $detected_retr == 1 ) {
82 } elsif ( $detected_conf == 1 ) {
90 if ($start_tag eq "" || $end_tag eq "" || $output_tag eq "" || $execution_tag eq "") {
94 open (FILE
, "$header_file") || "Cannot open file: $header_file";
95 while ($line_2 = <FILE
>) {
96 $row_line = $row_line . $line_2;
98 $row_line =~ s/LTP\ Output\/Log/LTP\ Output\
/Log\ (Report\ Generated\ on\ $ENV{TEST_START_TIME})/;
104 foreach my $file (@ARGV) {
106 open (FILE
, $file) || die "Cannot open file: $file\n";
108 LINE
: while ($line = <FILE
>) {
111 if ($line =~ /$start_tag/) {
115 if ($line =~ /$end_tag/) {
118 $flag = 0; $flag2 = 0; $flag3 = 0; $flag4 = 0;
119 $detected_fail = 0; $detected_pass = 0; $detected_warn = 0; $detected_brok = 0; $detected_retr = 0; $detected_conf = 0;
120 $background_colour = 0; $failed_test_counter_flag = 0; $brok_test_counter_flag = 0; $warn_test_counter_flag = 0; $retr_test_counter_flag = 0; $conf_test_counter_flag = 0; $row_line= "";
124 if ( $flag == 2) { #Assuming we will find "tag" and "stime" values here
125 @variable_value_pair = split(/\ /, $line);
126 @tag_value = split(/=/,$variable_value_pair[0]);
127 @stime_value = split(/=/,$variable_value_pair[1]);
128 $row_line = $row_line . "<tr><td><p><strong>$test_counter</strong></p></td>\n" .
129 "<td><p><strong>$tag_value[1]</strong></p></td>\n" .
130 "<td><p><pre><strong>";
131 $get_proper_time = localtime ($stime_value[1]);
132 $row_line = $row_line . "$get_proper_time" . "</strong></pre></p></td>\n";
135 if ( $flag == 3) { #Assuming we will find "cmdling" value here
136 @variable_value_pair = split(/=/, $line);
137 $row_line = $row_line . "<td><p><strong> $variable_value_pair[1] </strong></p></td>\n";
139 if ( $flag == 4) { #Assuming we will find "contact" value here
140 @variable_value_pair = split(/=/, $line);
141 $row_line = $row_line . "<td><p><strong>$variable_value_pair[1]</strong></p></td>\n";
143 if ( $flag == 5) { #Assuming we will find "analysis" value here
144 @variable_value_pair = split(/=/, $line);
145 $row_line = $row_line . "<td><p><strong>$variable_value_pair[1]</strong></p></td>\n";
149 @variable_value_pair = split(/=/, $line);
150 $row_line = $row_line . "<td><p><strong>$variable_value_pair[1]</strong></p></td>\n";
153 @variable_value_pair = split(/\ /, $line);
154 @duration_value = split(/=/, $variable_value_pair[0]);
155 @termination_type_value = split(/=/, $variable_value_pair[1]);
156 @termination_id_value = split(/=/, $variable_value_pair[2]);
157 @corefile_value = split(/=/, $variable_value_pair[3]);
158 $background_colour = get_background_colour_column
();
159 $row_line = $row_line . "<td><p><strong>$duration_value[1]</strong></p></td>\n" .
160 "<td><p><strong>$termination_type_value[1]<strong></p></td>\n" .
161 "<td><p><strong>$termination_id_value[1]</strong></p></td>\n" .
162 "<td><p><strong>$corefile_value[1]</strong></p></td>\n";
163 $row_line =~ s/<tr>/<tr\ bgcolor=$background_colour>/;
166 @variable_value_pair = split(/\ /, $line);
167 @cutime_value = split(/=/, $variable_value_pair[0]);
168 @cstime_value = split(/=/, $variable_value_pair[1]);
169 $row_line = $row_line . "<td><p><strong>$cutime_value[1]</strong></p></td>\n" .
170 "<td><p><strong>$cstime_value[1]</strong></p></td></tr>\n";
174 if ( $line =~ /$execution_tag/ ) {
178 $row_line = $row_line . "</strong></pre></td>";
181 $row_line = $row_line . "$line \n";
182 if ($line =~ /\ TFAIL\ / ) {
184 if ( $failed_test_counter_flag == 0 ) {
185 $failed_test_counter++;
186 $failed_test_counter_flag=1;
188 } elsif ($line =~ /\ TBROK\ / ) {
190 if ( $brok_test_counter_flag == 0 ) {
191 $brok_test_counter++;
192 $brok_test_counter_flag=1;
194 } elsif ($line =~ /\ TWARN\ / ) {
196 if ( $warn_test_counter_flag == 0 ) {
197 $warn_test_counter++;
198 $warn_test_counter_flag=1;
200 } elsif ($line =~ /\ TRETR\ / ) {
202 if ( $retr_test_counter_flag == 0 ) {
203 $retr_test_counter++;
204 $retr_test_counter_flag=1;
206 } elsif ($line =~ /\ TCONF\ / ) {
208 if ( $conf_test_counter_flag == 0 ) {
209 $conf_test_counter++;
210 $conf_test_counter_flag=1;
216 if ( $line =~ /$output_tag/ ) {
218 $row_line = $row_line . "<td><pre><strong>";
226 print "</tbody></table></div> \n\n<h2 id=\"_2\">Summary Report</h2>\n\n<div>\n\n<table border=\"1\" cellspacing=\"3\"><tbody>\n<tr>\n<td ";
227 if ($ENV{LTP_EXIT_VALUE
} == 1 ) {
228 print "bgcolor=\"#ff0000\"> <strong>Test Summary</strong></p></td><td bgcolor=\"#ff0000\"><strong>Pan reported some Tests FAIL</strong></p></td></tr>\n";
231 print "bgcolor=\"#66ff66\"> <strong>Test Summary</strong></p></td><td bgcolor=\"#66ff66\"><strong>Pan reported all Test Pass</strong></p></td></tr>\n";
234 print "<tr><td><strong>LTP Version</strong> </td><td><strong> $ENV{LTP_VERSION} </strong></td></tr>\n";
235 print "<tr><td><strong>Start Time</strong> </td><td><strong> $ENV{TEST_START_TIME} </strong></td></tr>\n";
236 print "<tr><td><strong>End Time</strong> </td><td><strong> $ENV{TEST_END_TIME} </strong></td></tr>\n";
237 print "<tr><td><strong>Log Result</strong> </td><td><a href=\"file://$ENV{TEST_LOGS_DIRECTORY}/\"> <strong>$ENV{TEST_LOGS_DIRECTORY}</strong></a></td></tr>\n";
238 print "<tr><td><strong>Output/Failed Result</strong></td><td><a href=\"file://$ENV{TEST_OUTPUT_DIRECTORY}/\"> <strong>$ENV{TEST_OUTPUT_DIRECTORY}</strong></a></td></tr>\n";
239 print "<tr><td><strong>Total Tests</strong></td><td><strong>";
241 print "$test_counter </strong></td></tr>\n";
242 $test_passed=$test_counter-$failed_test_counter-$brok_test_counter-$warn_test_counter-$retr_test_counter-$conf_test_counter;
243 print "<tr><td><strong>Total Test TPASS:</strong></td><td><strong> $test_passed </strong></td></tr>\n";
244 print "<tr><td><strong>Total Test TFAIL:</strong></td><td><strong> $failed_test_counter </strong></td></tr>\n";
245 print "<tr><td><strong>Total Test TBROK</strong></td><td><strong> $brok_test_counter </strong></td></tr>\n";
246 print "<tr><td><strong>Total Test TWARN</strong></td><td><strong> $warn_test_counter </strong></td></tr>\n";
247 print "<tr><td><strong>Total Test TRETR</strong></td><td><strong> $retr_test_counter </strong></td></tr>\n";
248 print "<tr><td><strong>Total Test TCONF</strong></td><td><strong> $conf_test_counter </strong></td></tr>\n";
249 print "<tr><td><strong>Kernel Version</strong></td><td><strong> $ENV{KERNEL_VERSION} </strong></td></tr>\n";
250 print "<tr><td><strong>Machine Architecture</strong></td><td><strong> $ENV{MACHINE_ARCH} </strong></td></tr>\n";
251 print "<tr><td><strong>Hostname</strong> </td> <td><strong>";
252 $hostname=system("uname -n"); chop($hostname);
253 print " $hostname </strong></td></tr></tbody></table></div></body></html>\n";