|
1 # |
|
2 # Copyright (c) 2005-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 the License "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: |
|
15 # |
|
16 |
|
17 |
|
18 use strict; |
|
19 use Getopt::Long; |
|
20 use IO::Handle; |
|
21 use IO::Seekable; |
|
22 use File::Basename; |
|
23 |
|
24 main(); |
|
25 exit(0); |
|
26 |
|
27 sub main { |
|
28 if ($#ARGV != 0) |
|
29 { |
|
30 print "usage: newdigest.pl <logfile>\n"; |
|
31 exit; |
|
32 } |
|
33 |
|
34 my ($log_file) = $ARGV[0]; |
|
35 |
|
36 if (-f $log_file) |
|
37 { |
|
38 system ("del $log_file"); |
|
39 } |
|
40 |
|
41 opendir( DIR, "." ) or die("Unable to open directory"); |
|
42 my @dirs = readdir DIR; |
|
43 my $entry; |
|
44 my $failed = 0; |
|
45 my $notests = 0; |
|
46 |
|
47 open (SUMMARY, ">$log_file") || die "couldn't open digest file: $!"; |
|
48 |
|
49 foreach $entry ( sort @dirs ) |
|
50 { |
|
51 next if ( $entry eq ".." or $entry eq "." ); |
|
52 next if ( -d $entry ); |
|
53 |
|
54 if ( $entry =~ /\.log/ || $entry =~ /\.txt/) |
|
55 { |
|
56 parseLog($entry, \$failed, \$notests); |
|
57 } |
|
58 elsif ($entry =~ /\.htm/) |
|
59 { |
|
60 parseHtm($entry, \$failed, \$notests); |
|
61 } |
|
62 } |
|
63 |
|
64 print SUMMARY "\r\nPassed\tFailed\tTotal\r\n"; |
|
65 printf SUMMARY ("%d\t%d\t%d\n", $notests-$failed, $failed, $notests); |
|
66 print SUMMARY "\n"; |
|
67 |
|
68 print SUMMARY "\r\n%Passed\t\t%Failed\r\n"; |
|
69 printf SUMMARY ("%.2f\t\t%.2f\r\n", 100-$failed/$notests*100, $failed/$notests*100); |
|
70 } |
|
71 |
|
72 |
|
73 sub parseLog($$$) { |
|
74 my ($entry, $failed, $notests) = @_; |
|
75 |
|
76 open (LOG, "$entry" ) or die("open failed"); |
|
77 my $found = "false"; |
|
78 while(<LOG>) |
|
79 { |
|
80 chomp; |
|
81 |
|
82 my $line = $_; |
|
83 $line =~ s/\x0//g; |
|
84 if ($line =~ /tests failed/) |
|
85 { |
|
86 $line =~ /(\d+) tests failed out of (\d+)/; |
|
87 printf SUMMARY (" %45s: %s\r\n", $entry, $&); |
|
88 $found = "true"; |
|
89 $$failed += $1; |
|
90 $$notests += $2; |
|
91 } |
|
92 } |
|
93 close LOG; |
|
94 |
|
95 if ( $found eq "false" && $entry ne "buildid.txt") |
|
96 { |
|
97 printf SUMMARY ("WARNING: Could not parse file %s\r\n", $entry); |
|
98 } |
|
99 } |
|
100 |
|
101 sub parseHtm($$$) { |
|
102 my ($entry, $failed, $notests) = @_; |
|
103 my ($textfile); |
|
104 $textfile = $entry; |
|
105 $textfile =~ s/\.htm/\.log/; |
|
106 next if ( -f $textfile); |
|
107 |
|
108 my $total = 0; |
|
109 my $pass = 0; |
|
110 my $unknown = 0; |
|
111 my $fail = 0; |
|
112 open (LOG, $entry) || die "couldn't open $entry: $!"; |
|
113 while (<LOG>) |
|
114 { |
|
115 my ($line) = $_; |
|
116 if ($line =~ /PASS = (\d+)/) |
|
117 { |
|
118 $pass += $1; |
|
119 } |
|
120 elsif ($line =~ /FAIL = (\d+)/) |
|
121 { |
|
122 $fail += $1; |
|
123 } |
|
124 elsif ($line =~ /ABORT = (\d+)/) |
|
125 { |
|
126 $unknown += $1; |
|
127 } |
|
128 elsif ($line =~ /PANIC = (\d+)/) |
|
129 { |
|
130 $unknown += $1; |
|
131 } |
|
132 elsif ($line =~ /INCONCLUSIVE = (\d+)/) |
|
133 { |
|
134 $unknown += $1; |
|
135 } |
|
136 elsif ($line =~ /UNKNOWN = (\d+)/) |
|
137 { |
|
138 $unknown += $1; |
|
139 } |
|
140 elsif ($line =~ /UNEXECUTED = (\d+)/) |
|
141 { |
|
142 $unknown += $1; |
|
143 } |
|
144 } |
|
145 $total = $pass + $fail + $unknown; |
|
146 close LOG; |
|
147 if($total != 0) |
|
148 { |
|
149 printf SUMMARY (" %45s: %d tests failed out of %d\r\n", $entry, $total-$pass, $total); |
|
150 } |
|
151 else |
|
152 { |
|
153 printf SUMMARY ("WARNING: %45s: %d tests failed out of %d\r\n", $entry, $total-$pass, $total); |
|
154 } |
|
155 $$notests += $total; |
|
156 $$failed += $fail + $unknown; |
|
157 } |