messagingapp/msgutils/convergedmessageutils/tsrc/testconvergedmessageutils/testconvergedmessageutils.pl
changeset 48 4f501b74aeb1
parent 46 b1f0785c289d
child 49 2a272ef608c4
equal deleted inserted replaced
46:b1f0785c289d 48:4f501b74aeb1
     1 #
       
     2 # Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 # All rights reserved.
       
     4 # This component and the accompanying materials are made available
       
     5 # under the terms of "Eclipse Public License v1.0"
       
     6 # which accompanies this distribution, and is available
       
     7 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 #
       
     9 # Initial Contributors:
       
    10 # Nokia Corporation - initial contribution.
       
    11 #
       
    12 # Contributors:
       
    13 #
       
    14 # Description: Test Case Report Generation file for ConvergedMessageUtils
       
    15 #
       
    16 #!/usr/bin/perl -w
       
    17 use warnings;
       
    18 use strict;
       
    19 
       
    20 my $TOTALCASES 		= 0;
       
    21 my $TOTALPASSED 	= 0;
       
    22 my $TOTALRUN 			= 0;
       
    23 my $TOTALFAILED 	= 0;
       
    24 my $TOTALSKIPPED 	= 0;
       
    25 
       
    26 sub parse_line
       
    27 {
       
    28 	my $line = $_[0];
       
    29 	my @parts = split (" ", $line);
       
    30 	my $passed  = $parts[1];
       
    31 	my $failed  = $parts[3];
       
    32 	my $skipped = $parts[5];
       
    33 	
       
    34 	my $total = $passed + $failed + $skipped;
       
    35 	my $passrate = $passed * 100 / $total;
       
    36 	my $passrateround = sprintf("%.0f",$passrate);
       
    37 	my $runrate = ($total - $skipped)*100/$total;
       
    38 	my $runrateround = sprintf("%.0f",$runrate);
       
    39 	
       
    40 	$TOTALCASES += $total;
       
    41 	$TOTALPASSED += $passed;
       
    42 	$TOTALRUN += ($total - $skipped);
       
    43 	$TOTALFAILED += $failed;
       
    44 	$TOTALSKIPPED  += $skipped;
       
    45 	
       
    46 	printf MYFILE "<td>\n";
       
    47 	printf MYFILE "$passed\n";
       
    48 	printf MYFILE "</td>\n";
       
    49 	
       
    50 	if($failed > 0)
       
    51 	{
       
    52 	printf MYFILE "<td style=\"font-weight:bold;color:red\">\n";
       
    53 	printf MYFILE "$failed\n";
       
    54 	printf MYFILE "</td>\n";
       
    55 	}
       
    56 	else
       
    57 	{
       
    58 	printf MYFILE "<td>\n";
       
    59 	printf MYFILE "$failed\n";
       
    60 	printf MYFILE "</td>\n";	
       
    61 	}
       
    62 
       
    63 	printf MYFILE "<td>\n";
       
    64 	printf MYFILE "$skipped\n";
       
    65 	printf MYFILE "</td>\n";
       
    66 
       
    67 	printf MYFILE "<td>\n";
       
    68 	printf MYFILE "$total\n";
       
    69 	printf MYFILE "</td>\n";
       
    70 	 
       
    71 	printf MYFILE "<td>\n";
       
    72 	printf MYFILE ("$passrateround %%\n");
       
    73 	printf MYFILE "</td>\n";
       
    74 
       
    75 	printf MYFILE "<td>\n";
       
    76 	printf MYFILE "$runrateround %%\n";
       
    77 	printf MYFILE "</td>\n";
       
    78 	
       
    79 	
       
    80 }
       
    81 
       
    82 sub parse_file
       
    83 	{
       
    84 		my $pattern = "Totals";
       
    85 		my $file = $_[0];
       
    86 		open (FILE,$file);
       
    87 	
       
    88 		while (my $line= <FILE>)
       
    89 		{
       
    90 			chomp ($line);
       
    91 		if ($line =~ m/$pattern/)
       
    92 			{				
       
    93 			parse_line $line;
       
    94 			}
       
    95 		}
       
    96 		close(FILE);
       
    97 	}
       
    98 
       
    99 
       
   100 sub generate_report
       
   101 	{
       
   102 		open (MYFILE, '>/epoc32/winscw/c/logs/TestConvergedMessageUtils/report.html');
       
   103 		printf MYFILE "<html>\n"; 
       
   104 		printf MYFILE "<body>\n";
       
   105 		printf MYFILE "<head>\n"; 
       
   106 		printf MYFILE "<title>ConvergedMessageUtils Test Reports</title>"; 
       
   107 		printf MYFILE "</head>\n";
       
   108 		printf MYFILE "<h2 align = center>ConvergedMessageUtils Test Report</h2>\n";
       
   109 		printf MYFILE "<table border = 2 cellpadding = 10 align = center>\n";
       
   110 		printf MYFILE "<tr style = \" background-color:lavender \">\n";
       
   111 		printf MYFILE "<th>Module</th>\n";
       
   112 		printf MYFILE "<th style = color:green>Passed</th>\n";
       
   113 		printf MYFILE "<th style = color:red>Failed</th>\n";
       
   114 		printf MYFILE "<th style = color:chocolate>Skipped</th>\n";
       
   115 		printf MYFILE "<th>Total Cases</th>\n";
       
   116 		printf MYFILE "<th>Pass Rate</th>\n";
       
   117 		printf MYFILE "<th>Run Rate</th>\n";
       
   118 		printf MYFILE "</tr>\n";
       
   119 		
       
   120 		
       
   121 		my @files = </epoc32/winscw/c/logs/TestConvergedMessageUtils/*.txt>;
       
   122 		foreach my $file (@files) 
       
   123 		{	
       
   124 			my @splitedpath = split("/",$file);
       
   125 			my $filename = $splitedpath[-1];	
       
   126 			my $length = length($filename);
       
   127 		  my $name = substr($filename,11,$length-15);
       
   128 		  printf MYFILE "<tr>\n";
       
   129 		  printf MYFILE "<td>\n";
       
   130 		  printf MYFILE "<a HREF=$filename style = text-decoration:none><b>$name</b></a>\n";
       
   131 		  printf MYFILE "</td>\n";
       
   132 		  
       
   133 		  parse_file $file;
       
   134 		  
       
   135 		  printf MYFILE "</tr>\n";
       
   136 		}
       
   137 		
       
   138 		printf MYFILE "<tr style= \"font-weight:bold; color:white; background-color:gray\">\n";
       
   139 		printf MYFILE "<td>\n";
       
   140 		printf MYFILE "<b>Overall</b>\n";
       
   141 		printf MYFILE "</td>\n";
       
   142 		
       
   143 		
       
   144 		printf MYFILE "<td>\n";
       
   145 		printf MYFILE "$TOTALPASSED\n";
       
   146 		printf MYFILE "</td>\n";
       
   147 		
       
   148 		printf MYFILE "<td>\n";
       
   149 		printf MYFILE "$TOTALFAILED\n";
       
   150 		printf MYFILE "</td>\n";
       
   151 		
       
   152 		printf MYFILE "<td>\n";
       
   153 		printf MYFILE "$TOTALSKIPPED\n";
       
   154 		printf MYFILE "</td>\n";
       
   155 		
       
   156 		printf MYFILE "<td>\n";
       
   157 		printf MYFILE "$TOTALCASES\n";
       
   158 		printf MYFILE "</td>\n";
       
   159 		
       
   160 		my $passrate = $TOTALPASSED*100/$TOTALCASES;
       
   161 		my $passrateround = sprintf("%.0f",$passrate);
       
   162 		printf MYFILE "<td>\n";
       
   163 		printf MYFILE "$passrateround%%\n";
       
   164 		printf MYFILE "</td>\n";
       
   165 		
       
   166 		my $runrate = ($TOTALCASES - $TOTALSKIPPED)*100/$TOTALCASES;
       
   167 		my $runrateround = sprintf("%.0f",$runrate);
       
   168 		printf MYFILE "<td>\n";
       
   169 		printf MYFILE "$runrateround%%\n";
       
   170 		printf MYFILE "</td>\n";
       
   171 		
       
   172 		printf MYFILE "</tr>\n";
       
   173 		
       
   174 		printf MYFILE "</table>\n";
       
   175 	  printf MYFILE "</body>\n"; 
       
   176 		printf MYFILE "</html>\n";
       
   177 			
       
   178 		close (MYFILE);
       
   179 	}
       
   180 
       
   181 
       
   182 generate_report;