sl@0
|
1 |
#
|
sl@0
|
2 |
# Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
# All rights reserved.
|
sl@0
|
4 |
# This component and the accompanying materials are made available
|
sl@0
|
5 |
# under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
6 |
# which accompanies this distribution, and is available
|
sl@0
|
7 |
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
#
|
sl@0
|
9 |
# Initial Contributors:
|
sl@0
|
10 |
# Nokia Corporation - initial contribution.
|
sl@0
|
11 |
#
|
sl@0
|
12 |
# Contributors:
|
sl@0
|
13 |
#
|
sl@0
|
14 |
# Description:
|
sl@0
|
15 |
# This script scans epocwind.out log files resulting from an automated emulator test run
|
sl@0
|
16 |
# and checks for panics. Files to skip or those with expected panics can be identified
|
sl@0
|
17 |
# in the hash table "expectedPanicsHash".
|
sl@0
|
18 |
# If looks for logs in %EPOCROOT%\logs\winscw - rhe DABS scripts will rename epocwind.out
|
sl@0
|
19 |
# files for all tests to end in "_epocwind.txt" so this script scans only files matching
|
sl@0
|
20 |
# this pattern.
|
sl@0
|
21 |
# If run without arguments the output logfile will be
|
sl@0
|
22 |
# %EPOCROOT%\epoc32\winscw\c\panicscanlog.txt but a log path/name can be specified as the
|
sl@0
|
23 |
# only command line argument.
|
sl@0
|
24 |
#
|
sl@0
|
25 |
|
sl@0
|
26 |
|
sl@0
|
27 |
use Cwd;
|
sl@0
|
28 |
use strict;
|
sl@0
|
29 |
use Getopt::Std;
|
sl@0
|
30 |
use File::Basename;
|
sl@0
|
31 |
use File::Copy; # for future portability
|
sl@0
|
32 |
|
sl@0
|
33 |
# Hash entries are in the form <skip check>, ([pattern1, expectedCount1], [pattern2, expectedCount2],...)
|
sl@0
|
34 |
# where anything non-zero for the first entry will skip the check for the file.
|
sl@0
|
35 |
# The match patterns are regular expressions.
|
sl@0
|
36 |
|
sl@0
|
37 |
my %expectedPanicsHash = ();
|
sl@0
|
38 |
|
sl@0
|
39 |
# TCAF test expects CafUtils 0 panics
|
sl@0
|
40 |
push(@{$expectedPanicsHash{"TCAF_epocwind.txt"}}, (0,
|
sl@0
|
41 |
("Thread tcaf.exe::Worker.*Panic CafUtils 0",6)));
|
sl@0
|
42 |
|
sl@0
|
43 |
# tjavahelperserver test expects 4 kern-exec 0 panics
|
sl@0
|
44 |
push(@{$expectedPanicsHash{"tjavahelperserver_epocwind.txt"}}, (0,
|
sl@0
|
45 |
("Thread tjavahelperserver.exe::Worker.*Panic KERN-EXEC 0", 5)));
|
sl@0
|
46 |
|
sl@0
|
47 |
# Authserver test should be uncommented when it is released.
|
sl@0
|
48 |
# authserver related tests expect panics
|
sl@0
|
49 |
#push(@{$expectedPanicsHash{"tauthexpr_epocwind.txt"}}, (0,
|
sl@0
|
50 |
# ("Thread tauthcliserv.exe::Worker.*Panic AuthServer 3", 1)));
|
sl@0
|
51 |
#push(@{$expectedPanicsHash{"tauthcliserv_debug_epocwind.txt"}}, (0,
|
sl@0
|
52 |
# ("Thread tauthcliserv.exe::Worker.*Panic AUTHEXPR 64", 3)));
|
sl@0
|
53 |
#push(@{$expectedPanicsHash{"tauthsvr2_epocwind.txt"}}, (0,
|
sl@0
|
54 |
# ("Thread AuthServer.EXE::Main Panic AuthServer 5", 2)));
|
sl@0
|
55 |
|
sl@0
|
56 |
# crypto - padding related tests expect panics
|
sl@0
|
57 |
push(@{$expectedPanicsHash{"tpaddingudeb_epocwind.txt"}}, (0,
|
sl@0
|
58 |
("Thread tpaddingserver.exe::Worker.*Panic CRYPTO-LIB 1", 1)));
|
sl@0
|
59 |
|
sl@0
|
60 |
# Expected UPS panics
|
sl@0
|
61 |
push(@{$expectedPanicsHash{"tpolicycache_epocwind.txt"}}, (0,
|
sl@0
|
62 |
("Thread tupspolicies.exe::Worker.*Panic UPS-Policies 0", 2)));
|
sl@0
|
63 |
push(@{$expectedPanicsHash{"tserviceconfig_epocwind.txt"}}, (0,
|
sl@0
|
64 |
("Thread tupspolicies.exe::Worker.*Panic UPS-Policies 0", 1)));
|
sl@0
|
65 |
push(@{$expectedPanicsHash{"scstest_epocwind.txt"}},
|
sl@0
|
66 |
(0,
|
sl@0
|
67 |
("Thread scstestserver.exe::Main Panic SCS-Server 0", 1),
|
sl@0
|
68 |
("Thread scstest.exe::ScsTestPanic Panic SCS-Client 0", 1),
|
sl@0
|
69 |
("Thread scstest.exe::ScsTestPanic Panic SCS-Client 1", 1),
|
sl@0
|
70 |
("Thread scstest.exe::ScsTestPanic Panic SCS-Client 2", 1)
|
sl@0
|
71 |
));
|
sl@0
|
72 |
|
sl@0
|
73 |
die "EPOCROOT not defined, must specify directory" if !defined ($ENV{EPOCROOT});
|
sl@0
|
74 |
|
sl@0
|
75 |
# Searches for the most recently created Log directory
|
sl@0
|
76 |
my @logDirectories = glob("$ENV{EPOCROOT}logs_*\\winscw");
|
sl@0
|
77 |
@logDirectories = sort(@logDirectories);
|
sl@0
|
78 |
|
sl@0
|
79 |
my $emulatorLogDirectory = "$logDirectories[$#logDirectories]";
|
sl@0
|
80 |
|
sl@0
|
81 |
if ( ! -d $emulatorLogDirectory )
|
sl@0
|
82 |
{
|
sl@0
|
83 |
die "$emulatorLogDirectory is not a directory";
|
sl@0
|
84 |
}
|
sl@0
|
85 |
|
sl@0
|
86 |
my $outputFile;
|
sl@0
|
87 |
if (@ARGV[0])
|
sl@0
|
88 |
{
|
sl@0
|
89 |
$outputFile = $ARGV[0];
|
sl@0
|
90 |
}
|
sl@0
|
91 |
else
|
sl@0
|
92 |
{
|
sl@0
|
93 |
$outputFile = "$ENV{EPOCROOT}epoc32\\winscw\\c\\panicscanlog.txt";
|
sl@0
|
94 |
}
|
sl@0
|
95 |
|
sl@0
|
96 |
unlink $outputFile;
|
sl@0
|
97 |
die "\nUnable to open log $outputFile\n" if( not open( SCANLOG, ">$outputFile" ) );
|
sl@0
|
98 |
|
sl@0
|
99 |
|
sl@0
|
100 |
print SCANLOG "\nScanning epocwind.txt files in $emulatorLogDirectory for panics.\n\n";
|
sl@0
|
101 |
|
sl@0
|
102 |
my $failureCount = 0;
|
sl@0
|
103 |
my $skipCount = 0;
|
sl@0
|
104 |
my @fileList = getFiles($emulatorLogDirectory, "_epocwind\.txt\$");
|
sl@0
|
105 |
my $fileCount = @fileList;
|
sl@0
|
106 |
|
sl@0
|
107 |
foreach my $file (@fileList)
|
sl@0
|
108 |
{
|
sl@0
|
109 |
print (SCANLOG "$file: \n");
|
sl@0
|
110 |
my @matchPatterns=();
|
sl@0
|
111 |
if (exists $expectedPanicsHash{$file})
|
sl@0
|
112 |
{
|
sl@0
|
113 |
(my $skipFile, @matchPatterns) = @{$expectedPanicsHash{$file}};
|
sl@0
|
114 |
if ($skipFile)
|
sl@0
|
115 |
{
|
sl@0
|
116 |
print (SCANLOG "\tSkipping check.\n\n");
|
sl@0
|
117 |
$skipCount++;
|
sl@0
|
118 |
next;
|
sl@0
|
119 |
}
|
sl@0
|
120 |
}
|
sl@0
|
121 |
|
sl@0
|
122 |
my @panicLines = grep(/Thread\s+.+\s+panic/i, ReadListFromFile("$emulatorLogDirectory/$file"));
|
sl@0
|
123 |
my $failed = 0;
|
sl@0
|
124 |
|
sl@0
|
125 |
if (@panicLines)
|
sl@0
|
126 |
{
|
sl@0
|
127 |
if (@matchPatterns > 0)
|
sl@0
|
128 |
{
|
sl@0
|
129 |
print(SCANLOG "\tPanics found, checking against expected panics.\n");
|
sl@0
|
130 |
my $j;
|
sl@0
|
131 |
my @remainingCounts=();
|
sl@0
|
132 |
for ($j=1; $j < @matchPatterns; $j=$j+2)
|
sl@0
|
133 |
{
|
sl@0
|
134 |
push @remainingCounts,$matchPatterns[$j];
|
sl@0
|
135 |
}
|
sl@0
|
136 |
|
sl@0
|
137 |
PANICLOOP: foreach my $panic (@panicLines)
|
sl@0
|
138 |
{
|
sl@0
|
139 |
chomp $panic;
|
sl@0
|
140 |
for ($j=0; $j < @matchPatterns; $j=$j+2)
|
sl@0
|
141 |
{
|
sl@0
|
142 |
if (grep(/$matchPatterns[$j]/, $panic))
|
sl@0
|
143 |
{
|
sl@0
|
144 |
print (SCANLOG "\t\"$panic\" matches expected pattern.\n");
|
sl@0
|
145 |
$remainingCounts[$j/2]--;
|
sl@0
|
146 |
next PANICLOOP;
|
sl@0
|
147 |
}
|
sl@0
|
148 |
}
|
sl@0
|
149 |
print (SCANLOG "\t\"$panic\" does not match expected patterns\n");
|
sl@0
|
150 |
$failed = 1;
|
sl@0
|
151 |
}
|
sl@0
|
152 |
|
sl@0
|
153 |
for ($j=0; $j < @remainingCounts; $j++)
|
sl@0
|
154 |
{
|
sl@0
|
155 |
if ($remainingCounts[$j] != 0)
|
sl@0
|
156 |
{
|
sl@0
|
157 |
$failed = 1;
|
sl@0
|
158 |
my $expectedCount = $matchPatterns[$j*2+1];
|
sl@0
|
159 |
my $actualCount = $expectedCount - $remainingCounts[$j];
|
sl@0
|
160 |
print (SCANLOG "\tExpected $expectedCount occurrences of pattern \"$matchPatterns[$j*2]\", got $actualCount\n");
|
sl@0
|
161 |
}
|
sl@0
|
162 |
}
|
sl@0
|
163 |
}
|
sl@0
|
164 |
else
|
sl@0
|
165 |
{
|
sl@0
|
166 |
print (SCANLOG "\tPanics found and none expected.\n");
|
sl@0
|
167 |
$failed = 1;
|
sl@0
|
168 |
foreach my $panic (@panicLines)
|
sl@0
|
169 |
{
|
sl@0
|
170 |
print (SCANLOG "\t$panic");
|
sl@0
|
171 |
}
|
sl@0
|
172 |
}
|
sl@0
|
173 |
}
|
sl@0
|
174 |
else
|
sl@0
|
175 |
{
|
sl@0
|
176 |
if (exists $expectedPanicsHash{$file})
|
sl@0
|
177 |
{
|
sl@0
|
178 |
print(SCANLOG "\tPanics expected but none found.\n");
|
sl@0
|
179 |
$failed = 1;
|
sl@0
|
180 |
}
|
sl@0
|
181 |
else
|
sl@0
|
182 |
{
|
sl@0
|
183 |
print(SCANLOG "\tNo panics expected and none found.\n");
|
sl@0
|
184 |
}
|
sl@0
|
185 |
}
|
sl@0
|
186 |
|
sl@0
|
187 |
if ($failed)
|
sl@0
|
188 |
{
|
sl@0
|
189 |
print (SCANLOG "\tTest for $file FAILED.\n\n");
|
sl@0
|
190 |
$failureCount++;
|
sl@0
|
191 |
}
|
sl@0
|
192 |
else
|
sl@0
|
193 |
{
|
sl@0
|
194 |
print (SCANLOG "\tTest for $file PASSED.\n\n");
|
sl@0
|
195 |
}
|
sl@0
|
196 |
}
|
sl@0
|
197 |
|
sl@0
|
198 |
if ($skipCount)
|
sl@0
|
199 |
{
|
sl@0
|
200 |
print (SCANLOG "\nSkipped $skipCount files ($fileCount total.)");
|
sl@0
|
201 |
}
|
sl@0
|
202 |
my $testedCount = $fileCount - $skipCount;
|
sl@0
|
203 |
print (SCANLOG "\nTested $testedCount files.\n");
|
sl@0
|
204 |
print (SCANLOG "$failureCount tests failed out of $testedCount \n");
|
sl@0
|
205 |
|
sl@0
|
206 |
close SCANLOG;
|
sl@0
|
207 |
|
sl@0
|
208 |
# --------------------------------------------------------------------------
|
sl@0
|
209 |
|
sl@0
|
210 |
# Return an array of files matching a regexp in a directory
|
sl@0
|
211 |
sub getFiles($$) {
|
sl@0
|
212 |
my $dir = shift;
|
sl@0
|
213 |
my $regfiles = shift;
|
sl@0
|
214 |
my @files;
|
sl@0
|
215 |
|
sl@0
|
216 |
if ( opendir DIR, $dir ) {
|
sl@0
|
217 |
@files = grep (/$regfiles/, readdir(DIR));
|
sl@0
|
218 |
closedir DIR;
|
sl@0
|
219 |
}
|
sl@0
|
220 |
return @files;
|
sl@0
|
221 |
}
|
sl@0
|
222 |
|
sl@0
|
223 |
# --------------------------------------------------------------------------
|
sl@0
|
224 |
|
sl@0
|
225 |
# Read the contents of a file into an array and return it
|
sl@0
|
226 |
sub ReadListFromFile ($) {
|
sl@0
|
227 |
my ($file) = @_;
|
sl@0
|
228 |
open FILE, "<$file" or die "Can't read from $file: $!";
|
sl@0
|
229 |
my @data = <FILE>;
|
sl@0
|
230 |
close FILE;
|
sl@0
|
231 |
return @data;
|
sl@0
|
232 |
}
|
sl@0
|
233 |
|
sl@0
|
234 |
# --------------------------------------------------------------------------
|