secureswitools/swisistools/test/tinterpretsisinteg/runtest.pl
changeset 0 ba25891c3a9e
equal deleted inserted replaced
-1:000000000000 0:ba25891c3a9e
       
     1 #
       
     2 # Copyright (c) 2004-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 # runtest.pl is used to runtests defined in an xml file.
       
    16 #
       
    17 
       
    18 use strict;
       
    19 
       
    20 use FindBin;
       
    21 use lib "$FindBin::Bin";
       
    22 use testcontroller;
       
    23 use testlistreader;
       
    24 use Cwd;
       
    25 use defaulttestroutine;
       
    26 use File::Copy;
       
    27 
       
    28 #processing of command line arguments
       
    29 sub processArgs {
       
    30     my ($controller, @args) = @_;
       
    31 	
       
    32 
       
    33     my $usage = <<EOF;
       
    34 runtests [-v] [-h] [<test list>] [-o <tests>]
       
    35      -v          verbose. Displays test title
       
    36      -h          this help text
       
    37      -e          Use enhanced test routine that checks result of setup and cleanup
       
    38      <test list> One or more xml filenames containing test definitions
       
    39                  If no test list is defined it will try the default file
       
    40                  testlist.xml
       
    41      -o <tests>  Only run the tests defined in the specified list. This option
       
    42                  allows a subset of tests to be executed. This option must be
       
    43                  the last option and the tests referenced in this file must
       
    44                  already have been defined in previous files.
       
    45 
       
    46 EOF
       
    47 
       
    48     my $hasTestFile = 0;
       
    49     my @normalFiles;
       
    50     my $specialFile;
       
    51     my $enhanced = 0;
       
    52     while (@args)
       
    53     {
       
    54 	my $arg = shift @args;
       
    55 	if (lc($arg) eq "-v")
       
    56 	{
       
    57 	    $controller->setVerbose();
       
    58 	}
       
    59 	elsif (lc($arg) eq "-o")
       
    60 	{
       
    61 	    $arg = shift @args;
       
    62 	    die  "File '$arg' does not exist\n" if (! (-e $arg) );
       
    63 	    $specialFile = $arg;
       
    64 	    last;
       
    65 	}
       
    66 	elsif (lc($arg) eq "-e")
       
    67 	{
       
    68 	    $enhanced = 1;
       
    69 	}
       
    70 	elsif (lc($arg) eq "-h")
       
    71 	{
       
    72 	    die $usage;
       
    73 	}
       
    74 	elsif (lc($arg) eq "-d")
       
    75 	{
       
    76 	    $controller->{'debug'} = 1;
       
    77 	}
       
    78 	else
       
    79 	{
       
    80 	    die  "File '$arg' does not exist\n" if (! (-e $arg) );
       
    81 	    push @normalFiles, $arg;
       
    82 	    $hasTestFile = 1;
       
    83 	}
       
    84     }
       
    85     
       
    86     return ($specialFile, $enhanced,$hasTestFile);
       
    87 }
       
    88 
       
    89 my %testEntry;
       
    90 my $controller = 0;
       
    91 my $parser = 0;
       
    92 
       
    93 my $special = 0;
       
    94 my $enhanced = 0; 
       
    95 my $hasTestFile = 0;
       
    96 my @file;
       
    97 
       
    98 sub StartTest
       
    99 {
       
   100 use XML::DOM;
       
   101 
       
   102 $parser->parseFiles($special, @file);
       
   103 if ($enhanced)
       
   104 {
       
   105     $controller->setTestRoutine(\&enhancedTestRoutine);
       
   106 }
       
   107 else
       
   108 {
       
   109     $controller->setTestRoutine(\&defaultTestRoutine);
       
   110 }
       
   111 
       
   112 $controller->runTests();
       
   113 use Cwd;
       
   114 my $dir = cwd;
       
   115 my $xml = "xml";
       
   116 my $domDir = $dir."/".$xml;
       
   117 chdir $domDir;
       
   118 my $dom = "dom.pm";
       
   119 unlink $dom;
       
   120 
       
   121 }
       
   122 
       
   123 my $epocRoot = $ENV{'EPOCROOT'};
       
   124 my $ScrMain = $epocRoot."epoc32\\release\\winscw\\udeb\\z\\sys\\install\\scr\\provisioned\\scr.db";
       
   125 my $ScrBackup = $epocRoot."epoc32\\winscw\\c\\tswi\\tinterpretsisinteg\\backupscr.db";
       
   126 	
       
   127 sub backupScr()
       
   128 	{
       
   129 	
       
   130 	copy($ScrMain, $ScrBackup);
       
   131 	}
       
   132 
       
   133 sub restoreScr()
       
   134 	{
       
   135 	copy($ScrBackup, $ScrMain);
       
   136 	}
       
   137 
       
   138 # -------------- Start of script --------------
       
   139 
       
   140 my $runType = shift;
       
   141 
       
   142 if($runType eq "native" || $runType eq "usifnative")
       
   143 {
       
   144 %testEntry;
       
   145 my $logIntFile = "\\epoc32\\winscw\\c\\interpretsis_test_harness.txt";
       
   146 $controller = testcontroller->new($logIntFile, $runType);
       
   147 
       
   148 $parser = testlistreader->new($controller,$runType);
       
   149 ($special, $enhanced, $hasTestFile) = processArgs($controller, @ARGV);
       
   150 
       
   151 my $nativeXmlFile="\\epoc32\\winscw\\c\\tswi\\tinterpretsisinteg\\testlist.xml"; # default filename
       
   152 if ($hasTestFile == 0)
       
   153     {
       
   154 	# use default test list filename
       
   155 	die  "File '$nativeXmlFile' does not exist\n" if (! (-e $nativeXmlFile) );
       
   156     }
       
   157 push(@file,$nativeXmlFile);
       
   158 
       
   159 
       
   160 
       
   161 # Delete the log file
       
   162 unlink("$logIntFile");
       
   163 
       
   164 StartTest();
       
   165 @file = ();
       
   166 }
       
   167 
       
   168 elsif( $runType eq "usif")
       
   169 {
       
   170 	my $regfilepath =0;
       
   171 	my @nativeregfiles = ("sisregistry_5.2.txt","sisregistry_5.3.txt","sisregistry_5.1.txt");
       
   172 	my $regfile = 0;
       
   173 	%testEntry;
       
   174 	my $logDbFile = "\\epoc32\\winscw\\c\\interpretsis_test_harness_db.txt";
       
   175 
       
   176 	backupScr();
       
   177 	$controller = testcontroller->new($logDbFile, $runType);
       
   178 	
       
   179 
       
   180 	$regfilepath = "\\epoc32\\release\\winscw\\udeb\\z\\system\\data\\";
       
   181 	# delete the registry file if present
       
   182 	
       
   183 	foreach $regfile (@nativeregfiles) 
       
   184 		{
       
   185 		$regfile = $regfilepath.$regfile;
       
   186 		unlink($regfile);
       
   187 		}
       
   188 	$parser = testlistreader->new($controller,$runType);
       
   189 
       
   190 	($special, $enhanced, $hasTestFile) = processArgs($controller, @ARGV);
       
   191 	my $dbXmlfile="\\epoc32\\winscw\\c\\tswi\\tinterpretsisinteg\\testlistdb.xml"; # default filename
       
   192 	if ($hasTestFile == 0)
       
   193 		{
       
   194 		# use default test list filename
       
   195 		die  "File '$dbXmlfile' does not exist\n" if (! (-e $dbXmlfile) );
       
   196 		}
       
   197 	push(@file,$dbXmlfile);
       
   198 	
       
   199 	# Delete the log file
       
   200 	unlink("$logDbFile");
       
   201 
       
   202 	StartTest();
       
   203 
       
   204 	restoreScr();
       
   205 
       
   206 }
       
   207 
       
   208 else
       
   209 	{
       
   210 	print "Please specify the type of installation to be performed (native or usif).";
       
   211 	}
       
   212