secureswitools/swianalysistoolkit/test/tdumpregistry/testregistry.pl
changeset 0 ba25891c3a9e
equal deleted inserted replaced
-1:000000000000 0:ba25891c3a9e
       
     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 DumpSWIRegistrytool
       
    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\\dumpregistry_test.txt";
       
    24 unlink("$logFile");
       
    25 use File::Copy;
       
    26 
       
    27 #
       
    28 #Function to write log into file
       
    29 #
       
    30 sub WriteLog {
       
    31 	my ($log) = @_;
       
    32 	unless( open($fh, ">> $logFile")) 
       
    33 		{
       
    34 		rintf STDERR "Can\'t open $logfile:$!\n";
       
    35 		return;
       
    36 		}
       
    37 	printf $fh $log;
       
    38 	printf $log;
       
    39 	close $fh;
       
    40 }
       
    41 
       
    42 
       
    43 sub registryTest {
       
    44 	my ($pkgfile) = @_[0];
       
    45 	my ($expectedResult) = @_[1];
       
    46 	my ($pkgname) = @_[2];
       
    47 	my ($vendorname) = @_[3];
       
    48 	$registryPath = ".\\data";
       
    49 	$registryOutputPath = ".\\dumpregistry-output\\";
       
    50 	$pkgfile =~ s/\.dat//;
       
    51 	WriteLog( "Package test\n\n");
       
    52 	@retval = system("DumpSWIRegistryTool.exe $registryPath -p $pkgfile > $pkgfile.log ");
       
    53 	$logMsg = sprintf "Expected code:%5d   result Code:%5d\n", $expectedResult, $?;
       
    54 	WriteLog( $logMsg);
       
    55 	$NumberOfTests++;
       
    56 	if( $? == $expectedResult) 
       
    57 		{
       
    58 		if(!($pkgfile eq 80000003))
       
    59 			{
       
    60 			my $respkg=`diff "$registryOutputPath$pkgfile.out" "$pkgfile.log"`;
       
    61 			if(length($respkg) == 0)
       
    62 				{
       
    63 				$NumberOfPassed++;
       
    64 				WriteLog("Passed\n\n");
       
    65 				}
       
    66 			else
       
    67 				{
       
    68 				$NumberOfFailed++;
       
    69 				WriteLog("Failed: Files $pkgfile.out and $pkgfile.log are not matched\n\n");
       
    70 				}
       
    71 			unlink("$pkgfile.log");
       
    72 			}
       
    73 		else
       
    74 			{
       
    75 			$NumberOfPassed++;
       
    76 			WriteLog("Passed\n\n");
       
    77 			}
       
    78 		}
       
    79 	else
       
    80 		{
       
    81 		$NumberOfFailed++;
       
    82 		WriteLog("Failed\n\n");
       
    83 		}
       
    84 
       
    85 	WriteLog( "Registry test\n\n");
       
    86 	@retval = system("DumpSWIRegistryTool.exe $registryPath -r $pkgfile \"$pkgname\" \"$vendorname\"> $pkgfile.log");
       
    87 	$logMsg = sprintf "Expected code:%5d   result Code:%5d\n", $expectedResult, $?;
       
    88 	WriteLog( $logMsg);
       
    89 	$NumberOfTests++;
       
    90 	
       
    91 	if( $? == $expectedResult) 
       
    92 		{
       
    93 		if(!($pkgfile eq 80000003))
       
    94 			{
       
    95 			my $resreg=`diff "$registryOutputPath$pkgfile.tmp" "$pkgfile.log"`;
       
    96 			if(length($resreg) == 0)
       
    97 				{
       
    98 				$NumberOfPassed++;
       
    99 				WriteLog("Passed\n\n");
       
   100 				}
       
   101 			else
       
   102 				{
       
   103 				$NumberOfFailed++;
       
   104 				WriteLog("Failed: Files $pkgfile.tmp and $pkgfile.log are not matched\n\n");
       
   105 				}
       
   106 
       
   107 			}
       
   108 		else
       
   109 			{
       
   110 			$NumberOfPassed++;
       
   111 			WriteLog("Passed\n\n");
       
   112 			}
       
   113 		unlink("$pkgfile.log");	
       
   114 		}
       
   115 	else
       
   116 		{
       
   117 		$NumberOfFailed++;
       
   118 		WriteLog("Failed\n\n");
       
   119 		}	
       
   120 	}
       
   121 
       
   122 WriteLog("DumpSWIRegistryTool test.\n\n");
       
   123 
       
   124 #
       
   125 # Counters for results
       
   126 #
       
   127 $NumberOfTests  = 0;
       
   128 $NUmberOfPassed = 0;
       
   129 $NumberOfFailed = 0;
       
   130 
       
   131 #
       
   132 # Array of contents of test pkgs and expected results
       
   133 #
       
   134 #                file name,   expected , expected log,            Title
       
   135 #				result     message
       
   136 #               ---------------------------------------------------------------------------------------------------- 
       
   137 @TestItems = (	["1000000d", 0,    , "Created",		"Registry Test for SIS files having SIS Properties","Test capabilities2","Vendor"],
       
   138 		["80000010", 0,    , "Created",		"Registry Test for SIS files having MIME Type","Test Mime-GE","Vendor"],
       
   139 		["80212345", 0,    , "Created",		"Registry Test for SIS files having Embedded and Dependency","TestSA","Vendor"],
       
   140 		["8100000b", 0,    , "Created",		"Registry Test for Big file(4MB)","BigNc","Vendor"],
       
   141 		["811111f8", 0,    , "Created",		"Registry to check operators","testexpressions_operators","Unique Vendor Name"],
       
   142 		["811111fb", 0,    , "Created",		"Registry to for sis file with else options (ConditionalEvaluation)","testexpressions_else","Unique Vendor Name"],
       
   143 		["811111fc", 0,    , "Created",		"Registry to check sis file with else if options (ConditionalEvaluation)","testexpressions_elseif","Unique Vendor Name"],
       
   144 		["81111107", 0,    , "Created",		"Registry Test for MultiLanguage","MultiLanguageOption-FR","Vendor"],
       
   145 		["81115000", 0,    , "Created",		"Registry Test for executable in embedded","053177c_0","Unique Vendor Name"],
       
   146 		["81115011", 0,    , "Created",		"Registry Test with no executable","053177c_0","Unique Vendor Name"],
       
   147 		["81115013", 0,    , "Created",		"Registry Test with 2 Embedded SIS files executable","053177c_3","Unique Vendor Name"],
       
   148 	#	["81231235", 0,    , "Created",		"Registry Test for Partial Upgrade","TestAppInUse Suite","Unique Vendor Name"],
       
   149 		["81231235", 0,    , "Created",		"Registry Test for Patch","testappinuse_patch","Unique Vendor Name"],
       
   150 		["a0000206", 0,    , "Created",		"Registry Test for SIS files having multiple Data files","3 Data Files","Symbian"],
       
   151 		["81000008", 0,    , "Created",		"Registry Test for File NULL","File Null - Remove a file created in another apps import directory","Symbian"],
       
   152 	#	["80000003",768,    , "Created",	"Registry Test for old registry format","Depend-EN","Vendor"],
       
   153 	     );
       
   154 
       
   155 #
       
   156 # Do test for each elements of TestItems array
       
   157 #
       
   158 for my $Test ( @TestItems )  
       
   159 	{
       
   160 	$testid = sprintf "SEC-SWI-I- REGISTRY -000%d\n",$NumberOfTests+1;
       
   161 	WriteLog($testid);
       
   162 	$logMsg = sprintf "%s\n", $Test->[3];
       
   163 	WriteLog($logMsg);
       
   164 	registryTest($Test->[0], $Test->[1],$Test->[4],$Test->[5]);
       
   165 	}
       
   166 
       
   167 #
       
   168 # Display the result
       
   169 #
       
   170 WriteLog("\n\nTests completed OK\n");
       
   171 WriteLog(sprintf "Run: %d\n", $NumberOfTests );
       
   172 WriteLog(sprintf "Passed: %d\n", $NumberOfPassed );
       
   173 WriteLog(sprintf "%d tests failed out of %d\n", $NumberOfFailed, $NumberOfTests );