|
1 # |
|
2 # Copyright (c) 2007-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 # Perl script that test DumpInstallFileStatustool |
|
16 # |
|
17 |
|
18 use File::Basename; |
|
19 my $scriptdir= dirname $0; |
|
20 print "Changing dir to $scriptdir\n"; |
|
21 chdir $scriptdir; |
|
22 |
|
23 $logFile = "\\epoc32\\winscw\\c\\dumpinstallstatus_test.txt"; |
|
24 use File::Copy; |
|
25 use Cwd; |
|
26 |
|
27 # |
|
28 #Function to write log into file |
|
29 # |
|
30 sub WriteLog |
|
31 { |
|
32 my ($log) = @_; |
|
33 unless( open($fh, ">> $logFile")) |
|
34 { |
|
35 printf STDERR "Can\'t open $logfile:$!\n"; |
|
36 return; |
|
37 } |
|
38 printf $fh $log; |
|
39 printf $log; |
|
40 close $fh; |
|
41 } |
|
42 |
|
43 |
|
44 sub installstatus |
|
45 { |
|
46 my ($pkgfile) = @_[0]; |
|
47 my ($expectedResult) = @_[1]; |
|
48 my ($outputLog) = @_[2]; |
|
49 $outputLog =~ s/\.log//; |
|
50 $neededfolder=""; |
|
51 $neededfile=""; |
|
52 @retval = system("DumpInstallFileStatusTool.exe $pkgfile> $outputLog.log"); |
|
53 $logMsg = sprintf "Expected code:%5d result Code:%5d\n", $expectedResult, $?; |
|
54 WriteLog( $logMsg); |
|
55 $NumberOfTests++; |
|
56 if( $? == $expectedResult) |
|
57 { |
|
58 my $res=`diff "$outputLog.out" "$outputLog.log"`; |
|
59 if(length($res) == 0) |
|
60 { |
|
61 $NumberOfPassed++; |
|
62 WriteLog("Passed\n\n"); |
|
63 } |
|
64 else |
|
65 { |
|
66 $NumberOfFailed++; |
|
67 WriteLog("Failed: Files $outputLog.out and $outputLog.log are not matched\n\n"); |
|
68 } |
|
69 } |
|
70 else |
|
71 { |
|
72 $NumberOfFailed++; |
|
73 WriteLog("Failed\n\n"); |
|
74 } |
|
75 unlink("$outputLog.log"); |
|
76 sleep(1); |
|
77 } |
|
78 |
|
79 |
|
80 unlink($logFile); |
|
81 WriteLog("DumpinstallfilestatusTool test.\n\n"); |
|
82 # |
|
83 # Counters for results |
|
84 # |
|
85 $NumberOfTests = 0; |
|
86 $NUmberOfPassed = 0; |
|
87 $NumberOfFailed = 0; |
|
88 # |
|
89 # Array of contents of tests and expected results |
|
90 # |
|
91 # file name, expected , expected log, Title |
|
92 # result message |
|
93 # ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------- |
|
94 @TestItems = ( ["data\\testfor2exes_unsigned.SIS data\\swicertstore.dat" ,0, , "Created", "Unsigned SIS File", "installstatus-output\\unsignedSIS.log"], |
|
95 ["data\\testfor2exes_invaidsumchain.SIS data\\swicertstore.dat ReadUserData WriteUserData ReadDeviceData WriteDeviceData", 0, , "Created", "SIS File having executable whose capabiltites is satisfied by signing certificates in conjuction with User Specified Capabilities\n(ReadUserData WriteUserData ReadDeviceData WriteDeviceData)", "installstatus-output\\multichain_usercaps1.log"], |
|
96 ["data\\testfor2exes_multichain.SIS data\\swicertstore.dat" ,0, , "Created", "SIS File having executable whose capabiltites is satisfied by signing certificates.", "installstatus-output\\multichain_nomissingcaps.log"], |
|
97 ["data\\testfor2exes_multichain.SIS data\\swicertstore.dat Location" ,0, , "Created", "SIS File having executable whose capabiltites are neither satisfied by signing certificates nor by signing certificates in conjuction with User Specified Capabilities", "installstatus-output\\multichain_missingcaps.log"], |
|
98 ["data\\testfor2exes_devcert.SIS data\\swicertstore.dat",0, , "Created", "SIS File signed with developer certificate (granting ReadUserData,WriteUserData and Location) and not validated by certstore.\n Hence SIS File having executable whose capabiltites are not satisfied by signing certificates .", "installstatus-output\\Devcerts.log"], |
|
99 ["data\\testfor2exes_multichain.SIS data\\corrupted.dat" ,1792, , "File format error", "Test for installfilestatus with corrupted certstore", "installstatus-output\\corrupteddat.log"], |
|
100 ["data\\corrupted.sis data\\swicertstore.dat" ,1536, , "File format error", "Test for installfilestatus with corrupted sis file", "installstatus-output\\corruptedsis.log"], |
|
101 ); |
|
102 |
|
103 |
|
104 |
|
105 |
|
106 # |
|
107 # Do test for each elements of TestItems array |
|
108 # |
|
109 for my $Test ( @TestItems ) |
|
110 { |
|
111 $testid = sprintf "SEC-SWI-I-DUMPINSTALLFILESTATUS -000%d\n",$NumberOfTests+1; |
|
112 WriteLog($testid); |
|
113 $logMsg = sprintf "%s\n", $Test->[3]; |
|
114 WriteLog($logMsg); |
|
115 installstatus($Test->[0], $Test->[1],$Test->[4]); |
|
116 } |
|
117 |
|
118 |
|
119 opendir(DIR, ".\\Chain"); |
|
120 while (defined($file=readdir(DIR))) |
|
121 { |
|
122 $dirname="chain\\"; |
|
123 $file =~ s/\.pem//; |
|
124 $dirname.= $file; |
|
125 if(-e "$dirname.pem") |
|
126 { |
|
127 unlink("$dirname.pem"); |
|
128 } |
|
129 close(DIR); |
|
130 } |
|
131 $dirpath = "Chain"; |
|
132 rmdir($dirpath); |
|
133 unlink("Test.txt"); |
|
134 unlink("installstatus.txt"); |
|
135 |
|
136 # |
|
137 # Display the result |
|
138 # |
|
139 WriteLog("\n\nTests completed OK\n"); |
|
140 WriteLog(sprintf "Run: %d\n", $NumberOfTests ); |
|
141 WriteLog(sprintf "Passed: %d\n", $NumberOfPassed ); |
|
142 WriteLog(sprintf "%d tests failed out of %d\n", $NumberOfFailed, $NumberOfTests ); |