SmokeTestROM.pm
branchSymbian2
changeset 1 8758140453c0
child 6 c108117318cb
equal deleted inserted replaced
0:e8c1ea2c6496 1:8758140453c0
       
     1 # Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 # All rights reserved.
       
     3 # This component and the accompanying materials are made available
       
     4 # under the terms of the License "Symbian Foundation License v1.0"
       
     5 # which accompanies this distribution, and is available
       
     6 # at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
       
     7 #
       
     8 # Initial Contributors:
       
     9 # Nokia Corporation - initial contribution.
       
    10 #
       
    11 # Contributors:
       
    12 #
       
    13 # Description:
       
    14 # The SmokeTestROM package contains all the subroutines needed to build a ROM for
       
    15 # automated smoke testing.
       
    16 # This script was born on 18/04/2005
       
    17 # Revision number 1: 11/08/2005
       
    18 # 
       
    19 #
       
    20 
       
    21 #!/usr/bin/perl -w
       
    22 
       
    23 package SmokeTestROM;
       
    24 use strict;
       
    25 
       
    26 # Define Core IMAGE file name as created by rombuild
       
    27 my $coreImage = "*techview.nand.img";
       
    28 
       
    29 # Define the target filename for the Core ROM
       
    30 my $newCoreImage = "core.img";
       
    31 
       
    32 # Define ROFS IMAGE file name as created by rombuild
       
    33 my $ROFSImage = "*techview.nand.rofs.img";
       
    34 
       
    35 # Define the target file name for the ROFS ROM
       
    36 my $newROFSImage = "rofs1.img";
       
    37 
       
    38 # Define NAND image file name.
       
    39 my $nandImage = "*ARMV5.IMG";
       
    40 #
       
    41 # CR 0844 (Both H2 and H4 use -D_NAND2)
       
    42 # PrepareNANDROM  - subroutine to create the NAND ROM for smoke testing; zero arguments
       
    43 # USAGE: PrepareNANDROM("h2"); 
       
    44 # USAGE: PrepareNANDROM("h4hrp"); 
       
    45 #
       
    46 sub PrepareNANDROM
       
    47 {
       
    48 	my ($arg) = @_; # Grab the first and only argument
       
    49 	
       
    50 	# Change dir to NAND Loader directory
       
    51 	chdir "$SmokeTest::NandDir" or &SmokeTest::DieLog("Can't cd to $SmokeTest::NandDir");
       
    52 	
       
    53 	if(lc($arg) eq "h2") # Here we are in the H2 NAND case
       
    54 	{
       
    55 		# Run the rom command to create the image ... H2 also to use -D_NAND2
       
    56 		SmokeTest::ExecCommand ("rom -v=h2 -i=armv5 -t=nandtest_load_noext -d=_NAND2 -b=urel");
       
    57 	}
       
    58 	elsif(lc($arg) eq "h4hrp") # Here we are in the H4 NAND case
       
    59 	{
       
    60 		SmokeTest::ExecCommand ("rom -v=h4hrp -i=armv5 -t=nandtest_load_noext -d=_NAND2 -b=urel");
       
    61 	}
       
    62 	
       
    63 	# Change directory to Smoketest directory
       
    64 	chdir "$SmokeTest::SmokeTestDir" or &SmokeTest::DieLog("Can't cd to $SmokeTest::SmokeTestDir");
       
    65 	
       
    66 	# Get the filename of the NAND image file
       
    67 	my @NANDname = glob("$SmokeTest::NandDir\\$nandImage");
       
    68 	
       
    69 	# There should be exactly one file matching $nandImage. If not give warning.
       
    70 	if(@NANDname != 1)
       
    71 	{
       
    72 		print "PrepareNANDROM: warning: " . scalar(@NANDname) . " files matching $nandImage in $SmokeTest::NandDir\\: [@NANDname].\n";
       
    73 	}
       
    74 	
       
    75 	# Attempt to delete any files already in this directory left over from previous runs
       
    76 	print "PrepareNANDROM: attempting to delete any debris from the last run:\n";
       
    77 	SmokeTest::ExecCommand ("DEL /Q $nandImage");
       
    78 
       
    79 	for my $filename(@NANDname)
       
    80 	{
       
    81 		if((lc($arg) eq "h2") && ($filename =~ /h2/i)) # This is the H2 NAND case, so copy H2 image
       
    82 		{
       
    83 			# Copy $nandImage to the current working directory
       
    84 			print "PrepareNANDROM: copying $filename to .\n";
       
    85 			SmokeTest::ExecCommand ("COPY $filename");
       
    86 		}
       
    87 		elsif((lc($arg) eq "h4hrp") && ($filename =~ /h4hrp/i)) # This is the H4 NAND case, so copy H4 image
       
    88 		{
       
    89 			# Copy $nandImage to the current working directory
       
    90 			print "PrepareNANDROM: copying $filename to .\n";
       
    91 			SmokeTest::ExecCommand ("COPY $filename");
       
    92 		}
       
    93 	}
       
    94 }
       
    95 
       
    96 #
       
    97 # CR 0844 (Both H2 and H4 use -D_NAND2)
       
    98 # CreateAndZipROM creates the various ROMS; up to 5 arguments.
       
    99 # Usage:
       
   100 # CreateAndZipROM("ARMV5", "lubbock", "-DRVCT", "PlatSec");
       
   101 # CreateAndZipROM("ARMV5", "h2", "-DRVCT", "PlatSec");
       
   102 # CreateAndZipROM("ARMV5", "h2", "-DRVCT", "PlatSec", "-D_NAND2");
       
   103 # CreateAndZipROM("ARMV5", "h4hrp", "-DRVCT", "PlatSec", "-D_NAND2");
       
   104 #
       
   105 sub CreateAndZipROM
       
   106 {
       
   107 	my @args = @_; # Array to hold the arguments
       
   108 	
       
   109 	# This sixth argument $args[5] determines whether to build the NAND version
       
   110 	# of the ROM or not. Set it equal to the empty string if the argument
       
   111 	# isn't defined otherwise it should equal the argument
       
   112 	my $nandROM;
       
   113 	if(defined $args[5])
       
   114 	{
       
   115 		if($args[5] =~  /-D_NAND/)
       
   116 		{
       
   117 			$nandROM = $args[5];
       
   118 		}
       
   119 		else
       
   120 		{
       
   121 			die "Invalid final argument in CreateAndZipROM. Exiting.\n";
       
   122 		}
       
   123 	}
       
   124 	else
       
   125 	{
       
   126 		$nandROM = "";
       
   127 	}
       
   128 	
       
   129 	print "\n";
       
   130 	# 
       
   131 	# Build ROM with STAT run automatically
       
   132 	#
       
   133 	print "\n";
       
   134 	print "#\n# Build $args[0] $args[1] ROM with STAT run automatically\n#\n"; 
       
   135 	print "\n";
       
   136 	SmokeTest::PrintDateTime();
       
   137 	
       
   138 	my $eabi = "";
       
   139 	if ($args[0] eq "ARMV5")
       
   140 	{
       
   141 		$eabi = "-D_EABI=$args[0]";
       
   142 	}
       
   143 
       
   144     my ($iProductNum,$buildrom);
       
   145 	$iProductNum = $args[4];
       
   146 	
       
   147 	if ($iProductNum eq 'Future' || $iProductNum  >= 9.5)
       
   148 	{
       
   149 ####????DavidZjang#$buildrom = SmokeTest::ExecCommand ("buildrom -D_STARTUPMODE2 -D_EABI=ARMV5 -fm=\\epoc32\\rom\\include\\featuredatabase.xml h4hrp techview statauto.iby -osys$rom.bin");
       
   150 ####????MCL########$buildrom = SmokeTest::ExecCommand ("buildrom -D_STARTUPMODE2 $eabi -fm=\\epoc32\\rom\\include\\featuredatabase.XML GTC_Standard statauto.iby testconfigfileparser.iby");
       
   151 	    $buildrom = SmokeTest::ExecCommand ("buildrom -D_STARTUPMODE2 $eabi -fm=\\epoc32\\rom\\include\\featuredatabase.XML GTC_Standard statauto.iby testconfigfileparser.iby");
       
   152 	}
       
   153 	else
       
   154 	{
       
   155 	    $buildrom = SmokeTest::ExecCommand ("buildrom -D_STARTUPMODE2 $eabi -fr=\\epoc32\\rom\\include\\featureUIDs.XML GTC_Standard statauto.iby testconfigfileparser.iby");
       
   156 	}
       
   157 	print $buildrom;
       
   158 	
       
   159 	if ( ($buildrom =~ m/rombuild.*failed/i) )
       
   160 	{
       
   161 		print "\n*** Error In Smoke Test ***\n Building the ROM failed\n$!\n";
       
   162 		#&SmokeTest::DieLog("Error In Smoke Test: Building the ROM failed");
       
   163 	} 
       
   164 	else 
       
   165 	{
       
   166 		print "\n*** ROM built successfully ***\n";	
       
   167 	}
       
   168 	
       
   169 	if ($nandROM =~ /-D_NAND/)
       
   170 	{
       
   171 		# Need to rename each on individually as there are several files ending in ".img"
       
   172 		print "\n";
       
   173 		print "#\n# Renaming NAND ROMs\n#\n"; 
       
   174 		print "\n";
       
   175 		SmokeTest::ExecCommand ("MOVE /Y $ROFSImage $newROFSImage");
       
   176 		SmokeTest::ExecCommand ("MOVE /Y $coreImage $newCoreImage");
       
   177 
       
   178 		# Copy each of the image files to the \epoc32\rom directory
       
   179 		print "\n";
       
   180 		print "#\n# Copying NAND ROMs\n#\n"; 
       
   181 		print "\n";
       
   182 		SmokeTest::ExecCommand ("COPY $newROFSImage \\epoc32\\rom\\");
       
   183 		SmokeTest::ExecCommand ("COPY $newCoreImage \\epoc32\\rom\\");
       
   184 		
       
   185 		# Delete the images
       
   186 		print "\n";
       
   187 		print "#\n# Deleting images\n#\n"; 
       
   188 		print "\n";
       
   189 		SmokeTest::ExecCommand ("DEL *.img");
       
   190 
       
   191 #  passing $args[1] i.e. h2 / h4hrp to PrepareNANDROM due to CR 0844 (Both H2 and H4 use -D_NAND2)
       
   192     	&PrepareNANDROM("$args[1]");
       
   193 	}
       
   194 	
       
   195 	# Rename the IMG file to sys$rom.bin
       
   196 	my $ImgDir = SmokeTest::ExecCommand ("DIR *.img");
       
   197 		
       
   198 	$ImgDir =~ /(\S+\.img)/i;
       
   199 		
       
   200 	#&SmokeTest::DieLog("Building ROMs failed: Cannot find .IMG file") unless defined $1;
       
   201 	print "Name of ROM : $1 \n";
       
   202 	SmokeTest::ExecCommand ("MOVE /Y $1 sys\$rom.bin");
       
   203 	print "\n";
       
   204 		
       
   205 	# 
       
   206 	# ZIP ROM using \epoc32\tools\zip.exe
       
   207 	# 
       
   208 	print "\n";
       
   209 	print "#\n# ZIP ROM using \\epoc32\\tools\\zip.exe\n#\n";
       
   210 	print "\n";
       
   211 	SmokeTest::PrintDateTime();
       
   212 	
       
   213 	# Now zip the file
       
   214 	my $zipresult = SmokeTest::ExecCommand ("$SmokeTest::BuildDir$ENV{EPOCROOT}epoc32\\tools\\zip.exe -Tv sys\$rom sys\$rom.bin");
       
   215 	print "\n";
       
   216 	
       
   217 	# Test for zip errors
       
   218 	if ($zipresult =~ m/No errors detected/i) # Good case: no errors detected.
       
   219 	{
       
   220 		print "*** ROM zip successful: no errors detected ***\n";	
       
   221 	}
       
   222 	elsif ($zipresult =~ m/zip error/i) # Zip error
       
   223 	{
       
   224 		print "*** Error In Smoke Test ***\n Zipping the ROM failed $!\n";
       
   225 		#&SmokeTest::DieLog("Error In Smoke Test: Zipping the ROM failed");
       
   226 	}
       
   227 	else # Worst case
       
   228 	{
       
   229 		print "*** Error In Smoke Test ***\n Zipping unable to start $!\n";
       
   230 	}
       
   231 	
       
   232 	# Form the string for the temporary zip file locations
       
   233 	my $tempZipLocation = "$SmokeTest::SmokeTestDir\\$args[0]\\$args[1]";
       
   234 	if ($nandROM =~ /-D_NAND/) # Add \NAND folder if a NAND ROM is being built
       
   235 	{
       
   236 		
       
   237 		if ($args[2] eq "pagedrom") # Add \NAND_DP folder if a Demand Paging NAND ROM is being built
       
   238 		{
       
   239 			$tempZipLocation .= "\\NAND\(DP\)";
       
   240 		}
       
   241 		else
       
   242 		{
       
   243 			$tempZipLocation .= "\\NAND";
       
   244 		}
       
   245 	}
       
   246 
       
   247 	# Make the temp zip folder
       
   248 	SmokeTest::ExecCommand ("MKDIR $tempZipLocation");
       
   249 	print "\n";
       
   250 	
       
   251 	# Copy the ROM to the appropriate directory to be copied later
       
   252 	SmokeTest::ExecCommand ("MOVE /Y sys\$rom.zip $tempZipLocation\\sys\$rom.zip");
       
   253 	
       
   254 	print "\n";
       
   255 	
       
   256 	SmokeTest::PrintDateTime();
       
   257 }
       
   258 
       
   259 1;