os/security/cryptomgmtlibs/securitytestfw/test/autotesting/panicscan_authserver.pl
Update contrib.
2 # Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
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".
9 # Initial Contributors:
10 # Nokia Corporation - initial contribution.
15 # This script scans epocwind.out log files resulting from an automated emulator test run
16 # and checks for panics. Files to skip or those with expected panics can be identified
17 # in the hash table "expectedPanicsHash".
18 # If looks for logs in %EPOCROOT%\logs\winscw - rhe DABS scripts will rename epocwind.out
19 # files for all tests to end in "_epocwind.txt" so this script scans only files matching
21 # If run without arguments the output logfile will be
22 # %EPOCROOT%\epoc32\winscw\c\panicscanlog.txt but a log path/name can be specified as the
23 # only command line argument.
31 use File::Copy; # for future portability
33 # Hash entries are in the form <skip check>, ([pattern1, expectedCount1], [pattern2, expectedCount2],...)
34 # where anything non-zero for the first entry will skip the check for the file.
35 # The match patterns are regular expressions.
37 my %expectedPanicsHash = ();
39 # TCAF test expects CafUtils 0 panics
40 push(@{$expectedPanicsHash{"TCAF_epocwind.txt"}}, (0,
41 ("Thread tcaf.exe::Worker.*Panic CafUtils 0",6)));
43 # tjavahelperserver test expects 4 kern-exec 0 panics
44 push(@{$expectedPanicsHash{"tjavahelperserver_epocwind.txt"}}, (0,
45 ("Thread tjavahelperserver.exe::Worker.*Panic KERN-EXEC 0", 5)));
47 # Authserver test should be uncommented when it is released.
48 # authserver related tests expect panics
49 push(@{$expectedPanicsHash{"tauthexpr_epocwind.txt"}}, (0,
50 ("Thread tauthcliserv.exe::Worker.*Panic AuthServer 3", 1)));
51 push(@{$expectedPanicsHash{"tauthcliserv_debug_epocwind.txt"}}, (0,
52 ("Thread tauthcliserv.exe::Worker.*Panic AUTHEXPR 64", 3)));
53 push(@{$expectedPanicsHash{"tauthsvr2_epocwind.txt"}}, (0,
54 ("Thread AuthServer.EXE::Main Panic AuthServer 5", 3)));
56 # crypto - padding related tests expect panics
57 push(@{$expectedPanicsHash{"tpaddingudeb_epocwind.txt"}}, (0,
58 ("Thread tpaddingserver.exe::Worker.*Panic CRYPTO-LIB 1", 1)));
61 push(@{$expectedPanicsHash{"tpolicycache_epocwind.txt"}}, (0,
62 ("Thread tupspolicies.exe::Worker.*Panic UPS-Policies 0", 2)));
63 push(@{$expectedPanicsHash{"tserviceconfig_epocwind.txt"}}, (0,
64 ("Thread tupspolicies.exe::Worker.*Panic UPS-Policies 0", 1)));
65 push(@{$expectedPanicsHash{"scstest_epocwind.txt"}},
67 ("Thread scstestserver.exe::Main Panic SCS-Server 0", 1),
68 ("Thread scstest.exe::ScsTestPanic Panic SCS-Client 0", 1),
69 ("Thread scstest.exe::ScsTestPanic Panic SCS-Client 1", 1),
70 ("Thread scstest.exe::ScsTestPanic Panic SCS-Client 2", 1)
73 die "EPOCROOT not defined, must specify directory" if !defined ($ENV{EPOCROOT});
75 # Searches for the most recently created Log directory
76 my @logDirectories = glob("$ENV{EPOCROOT}logs_*\\winscw");
77 @logDirectories = sort(@logDirectories);
79 my $emulatorLogDirectory = "$logDirectories[$#logDirectories]";
81 if ( ! -d $emulatorLogDirectory )
83 die "$emulatorLogDirectory is not a directory";
89 $outputFile = $ARGV[0];
93 $outputFile = "$ENV{EPOCROOT}epoc32\\winscw\\c\\panicscanlog.txt";
97 die "\nUnable to open log $outputFile\n" if( not open( SCANLOG, ">$outputFile" ) );
100 print SCANLOG "\nScanning epocwind.txt files in $emulatorLogDirectory for panics.\n\n";
102 my $failureCount = 0;
104 my @fileList = getFiles($emulatorLogDirectory, "_epocwind\.txt\$");
105 my $fileCount = @fileList;
107 foreach my $file (@fileList)
109 print (SCANLOG "$file: \n");
110 my @matchPatterns=();
111 if (exists $expectedPanicsHash{$file})
113 (my $skipFile, @matchPatterns) = @{$expectedPanicsHash{$file}};
116 print (SCANLOG "\tSkipping check.\n\n");
122 my @panicLines = grep(/Thread\s+.+\s+panic/i, ReadListFromFile("$emulatorLogDirectory/$file"));
127 if (@matchPatterns > 0)
129 print(SCANLOG "\tPanics found, checking against expected panics.\n");
131 my @remainingCounts=();
132 for ($j=1; $j < @matchPatterns; $j=$j+2)
134 push @remainingCounts,$matchPatterns[$j];
137 PANICLOOP: foreach my $panic (@panicLines)
140 for ($j=0; $j < @matchPatterns; $j=$j+2)
142 if (grep(/$matchPatterns[$j]/, $panic))
144 print (SCANLOG "\t\"$panic\" matches expected pattern.\n");
145 $remainingCounts[$j/2]--;
149 print (SCANLOG "\t\"$panic\" does not match expected patterns\n");
153 for ($j=0; $j < @remainingCounts; $j++)
155 if ($remainingCounts[$j] != 0)
158 my $expectedCount = $matchPatterns[$j*2+1];
159 my $actualCount = $expectedCount - $remainingCounts[$j];
160 print (SCANLOG "\tExpected $expectedCount occurrences of pattern \"$matchPatterns[$j*2]\", got $actualCount\n");
166 print (SCANLOG "\tPanics found and none expected.\n");
168 foreach my $panic (@panicLines)
170 print (SCANLOG "\t$panic");
176 if (exists $expectedPanicsHash{$file})
178 print(SCANLOG "\tPanics expected but none found.\n");
183 print(SCANLOG "\tNo panics expected and none found.\n");
189 print (SCANLOG "\tTest for $file FAILED.\n\n");
194 print (SCANLOG "\tTest for $file PASSED.\n\n");
200 print (SCANLOG "\nSkipped $skipCount files ($fileCount total.)");
202 my $testedCount = $fileCount - $skipCount;
203 print (SCANLOG "\nTested $testedCount files.\n");
204 print (SCANLOG "$failureCount tests failed out of $testedCount \n");
208 # --------------------------------------------------------------------------
210 # Return an array of files matching a regexp in a directory
213 my $regfiles = shift;
216 if ( opendir DIR, $dir ) {
217 @files = grep (/$regfiles/, readdir(DIR));
223 # --------------------------------------------------------------------------
225 # Read the contents of a file into an array and return it
226 sub ReadListFromFile ($) {
228 open FILE, "<$file" or die "Can't read from $file: $!";
234 # --------------------------------------------------------------------------