sl@0: # sl@0: # Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). sl@0: # All rights reserved. sl@0: # This component and the accompanying materials are made available sl@0: # under the terms of the License "Eclipse Public License v1.0" sl@0: # which accompanies this distribution, and is available sl@0: # at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: # sl@0: # Initial Contributors: sl@0: # Nokia Corporation - initial contribution. sl@0: # sl@0: # Contributors: sl@0: # sl@0: # Description: sl@0: # This script runs security tests for chosen components on a local machine without DABS scripts and ONB. Follow the steps below sl@0: # in order to launch tests for a security component: sl@0: # 1. Choose a local drive to be used, e.g. p: sl@0: # 2. Download a CBR onto the chosen drive. sl@0: # 3. Download the security source tree onto the chosen drive, and ensure that your environment variable sl@0: # SECURITYSOURCEDIR points to the relevant root directory. It helps to use a drive independant value here sl@0: # as this will allow concurrent builds and test runs on seperate drives (assuming the source code has the same path in each case). sl@0: # 4. Download ExecTimeOut.exe, which is stored at //PR/share/DABSRelease/buildscripts/, onto the relevant location sl@0: # (by default this is the chosen drive's root). sl@0: # 5. Build the security code. Note that builds require the SECURITYSOURCEDIR environment variable to be set. sl@0: # 6. Run or modify the relevant wrapper batch file for your component, which will be stored in the root of the test directory. sl@0: # Components Summary sl@0: # This script works fine with the following components: Asnpkcs, Caf2, Certman, Common, Crypto, Cryptospi, CryptoTokens, sl@0: # FileTokens, Sistools, Streamingcaf, Swi, Switools, Ups. Other components must be tested and therefore sl@0: # further extensions may be needed. sl@0: # sl@0: sl@0: use Cwd; sl@0: use Getopt::Long; sl@0: sl@0: ########################### Start of Input Reading Block ########################### sl@0: sl@0: # Check environment variable SECURITYSOURCEDIR is correctly set sl@0: if ($ENV{'SECURITYSOURCEDIR'} eq "") sl@0: { sl@0: die "ERROR: The SECURITYSOURCEDIR environment variable has not been set. Set this to point to the root of the security source tree on your drive and rebuild the components you want to test. If you want to perform concurrent builds/tests use a drive relative value and use the same directory structure on each drive."; sl@0: } sl@0: else sl@0: { sl@0: my $current_dir = getcwd(); sl@0: $current_dir =~ /^(\D):/; # $1 = driveletter sl@0: sl@0: my $current_drive = lc $1; sl@0: sl@0: $ENV{'SECURITYSOURCEDIR'} =~ /^(\D):/; # $1 = driveletter if it exists sl@0: my $sourcedir_drive = lc $1; sl@0: sl@0: if (($sourcedir_drive ne "") && ($sourcedir_drive ne $current_drive)) sl@0: { sl@0: print "WARNING: Your SECURITYSOURCEDIR environment variable is set to an absolute path and points to a different drive than the current one\n" . "SECURITYSOURCEDIR= " . $ENV{'SECURITYSOURCEDIR'} . "\nAre you sure you want to continue (Y/N)?\n"; sl@0: my $user_decision = ; sl@0: $user_decision = lc $user_decision; sl@0: $user_decision =~ /^(.*)\n/; sl@0: if (($1 ne "y") && ($1 ne "yes")) sl@0: { sl@0: die "User decided not to continue, quiting..."; sl@0: } sl@0: } sl@0: } sl@0: sl@0: # Read in command line arguments sl@0: my $testedComponentsRaw; sl@0: my @testedComponents; sl@0: my $testedReleasesRaw; sl@0: my @testedReleases; sl@0: my $ExecTimeOut; sl@0: my $resultsOutputDir; sl@0: my $skipCleanAfterFinalComponent; sl@0: my $suppressBrowserPopup; sl@0: my $displayHelp; sl@0: sl@0: GetOptions("components=s" => \$testedComponentsRaw, sl@0: "testReleases=s" => \$testedReleasesRaw, sl@0: "resultsoutput=s" => \$resultsOutputDir, sl@0: "exectimeout=s" => \$ExecTimeOut, sl@0: "suppressbrowser" => \$suppressBrowserPopup, sl@0: "skipfinalclean" => \$skipCleanAfterFinalComponent, sl@0: "help" => \$displayHelp); sl@0: sl@0: if ($displayHelp) sl@0: { sl@0: DisplayHelp(); sl@0: } sl@0: sl@0: # Ensure necessary arguments are present sl@0: $shouldIDie = 0; sl@0: sl@0: while ($testedComponentsRaw =~ s/([^,]*),//) sl@0: { sl@0: push(@testedComponents, $1); sl@0: } sl@0: if ($testedComponentsRaw =~ /\S/) sl@0: { sl@0: push(@testedComponents, $testedComponentsRaw); sl@0: } sl@0: else sl@0: { sl@0: print "ERROR: Components to be tested not listed (e.g. -components caf2,streamingcaf).\n"; sl@0: $shouldIDie = 1; sl@0: } sl@0: sl@0: while ($testedReleasesRaw =~ s/([^,]*),//) sl@0: { sl@0: push(@testedReleases, $1); sl@0: } sl@0: if ($testedReleasesRaw =~ /\S/) sl@0: { sl@0: push(@testedReleases, $testedReleasesRaw); sl@0: } sl@0: else sl@0: { sl@0: print "ERROR: Releases to be tested not listed (e.g. -testReleases udeb,urel).\n"; sl@0: $shouldIDie = 1; sl@0: } sl@0: sl@0: sl@0: if (!defined $ExecTimeOut) sl@0: { sl@0: print "ERROR: Location of ExecTimeOut.exe not specified (e.g. -exectimeout \\ExecTimeOut.exe).\n"; sl@0: $shouldIDie = 1; sl@0: } sl@0: if (!defined $resultsOutputDir) sl@0: { sl@0: print "ERROR: Directory to place test results not specified (e.g. -resultsoutput \\logs\\winscw).\n"; sl@0: $shouldIDie = 1; sl@0: } sl@0: sl@0: if ($shouldIDie) sl@0: { sl@0: die "Input parameters incorrect, exiting."; sl@0: } sl@0: sl@0: sl@0: sl@0: my $buildTarget = 'winscw'; # At the moment the script only works for winscw sl@0: my $testSpec = "$ENV{SECURITYSOURCEDIR}\\testframework\\test\\autotesting\\test_spec.txt"; sl@0: my $testResultsPath = "$resultsOutputDir\\TestResults_Summary.html"; sl@0: ############################ End of Input Reading Block ############################ sl@0: sl@0: sl@0: use Text::ParseWords; sl@0: use File::Path 'rmtree'; sl@0: sl@0: # helper functions sl@0: sub ExecCmd; sl@0: sl@0: # helper functions taken from the TestUtilities.pm perl module sl@0: sub FullWin32Path; sl@0: sub FullPathToCDrive; sl@0: sub FullPathToZDrive; sl@0: sub DigestSecurityTestLog; sl@0: sub DigestTestExecuteTestLog; sl@0: sl@0: # create/empty directory for epoc window output files sl@0: ExecCmd("rmdir /s /q $resultsOutputDir"); sl@0: ExecCmd("mkdir $resultsOutputDir"); sl@0: sl@0: # set the location of epoc window output sl@0: my $tempDir=$ENV{'TMP'}; sl@0: my $epocWndPath = $tempDir.'\epocwind.out'; sl@0: sl@0: ExecCmd('mkdir \epoc32\drive_d'); sl@0: ExecCmd('mkdir \epoc32\drive_e'); sl@0: ExecCmd('mkdir \epoc32\drive_r'); sl@0: sl@0: if (!grep(/PlatSecDisabledCaps SwEvent/, ReadFile('\epoc32\data\epoc.ini'))) sl@0: { sl@0: # set up drives for emulator sl@0: ExecCmd('echo _epoc_drive_d \epoc32\drive_d >> \epoc32\data\epoc.ini'); sl@0: ExecCmd('echo _epoc_drive_e \epoc32\drive_e >> \epoc32\data\epoc.ini'); sl@0: ExecCmd('echo _epoc_drive_r \epoc32\drive_r >> \epoc32\data\epoc.ini'); sl@0: sl@0: # disable the SwEvent to test SWI's handling of loader grantable capabilities sl@0: ExecCmd('echo PlatSecDisabledCaps SwEvent >> \epoc32\data\epoc.ini'); sl@0: sl@0: # turn off panic dialogs requiring user interaction sl@0: ExecCmd('echo JustInTime none >> \epoc32\data\epoc.ini'); sl@0: } sl@0: sl@0: # remove watchers sl@0: ExecCmd('del /Q /F /S \epoc32\release\wins\*watcher.dll'); sl@0: ExecCmd('del /Q /F /S \epoc32\release\winscw\*watcher.dll'); sl@0: sl@0: # replace custom Java Installer with test version sl@0: my $cmiPath = "\\epoc32\\release\\$buildTarget\\$testedRelease"; sl@0: if ( -f "$cmiPath\\custommidletinstall.dll" && -f "$cmiPath\\tcustommidletinstall.dll" ) sl@0: { sl@0: ExecCmd("ren $path\\custommidletinstall.dll custommidletinstall.std"); sl@0: ExecCmd("copy $path\\tcustommidletinstall.dll $path\\custommidletinstall.dll"); sl@0: } sl@0: sl@0: rmtree("$ENV{'EPOCROOT'}backup\\wins\\c"); sl@0: rmtree("$ENV{'EPOCROOT'}backup\\winscw\\c"); sl@0: rmtree("$ENV{'EPOCROOT'}backup\\drive_d"); sl@0: rmtree("$ENV{'EPOCROOT'}backup\\drive_e"); sl@0: sl@0: # create backups of the current drive states sl@0: ExecCmd("xcopy /y/e/i/q $ENV{'EPOCROOT'}epoc32\\wins\\c $ENV{'EPOCROOT'}backup\\wins\\c"); sl@0: ExecCmd("xcopy /y/e/i/q $ENV{'EPOCROOT'}epoc32\\winscw\\c $ENV{'EPOCROOT'}backup\\winscw\\c"); sl@0: ExecCmd("xcopy /y/e/i/q $ENV{'EPOCROOT'}epoc32\\drive_d $ENV{'EPOCROOT'}backup\\drive_d"); sl@0: ExecCmd("xcopy /y/e/i/q $ENV{'EPOCROOT'}epoc32\\drive_e $ENV{'EPOCROOT'}backup\\drive_e"); sl@0: sl@0: # clean the results folder sl@0: rmtree("$resultsOutputDir"); sl@0: ExecCmd("mkdir $resultsOutputDir"); sl@0: sl@0: # open test result file sl@0: if (!open(TESTRESULTS, ">$testResultsPath")) sl@0: { sl@0: die "Can't open output file $testResultsPath"; sl@0: } sl@0: sl@0: # create HTML header sl@0: print TESTRESULTS "\n\nTitle of page\n"; sl@0: print TESTRESULTS "\n\n

Test Results

\n"; sl@0: print TESTRESULTS "

target: $buildTarget
\n"; sl@0: print TESTRESULTS "security sources: $ENV{SECURITYSOURCEDIR}
\n"; sl@0: print TESTRESULTS "test spec: $testSpec
\n"; sl@0: print TESTRESULTS "tested components: @testedComponents

\n"; sl@0: print TESTRESULTS "\n"; sl@0: sl@0: # for the first component being tested there is no need to perform a restore on the drives, this variable is used to make this optimisation sl@0: my $firstTestedComponent = 1; sl@0: sl@0: my $i = 0; sl@0: sl@0: foreach my $testedRelease (@testedReleases) sl@0: { sl@0: $logSuffix = ''; sl@0: if ($testedRelease eq 'urel') sl@0: { sl@0: $logSuffix = '1'; # so that the udeb results aren't overwritten by urel ones, matches ONB labelling sl@0: } sl@0: sl@0: # open test spec file sl@0: if (!open(TESTSPEC, "<$testSpec")) sl@0: { sl@0: die "Can't open input file $testSpec"; sl@0: } sl@0: sl@0: # set current directory sl@0: chdir("$ENV{'EPOCROOT'}epoc32\\release\\$buildTarget\\$testedRelease"); sl@0: sl@0: # walk through the test spec file line-by-line and execute matching tests sl@0: my $curComponent = ''; sl@0: sl@0: my $testingCurrentComponent = 0; sl@0: sl@0: while () sl@0: { sl@0: # skip comment lines sl@0: my $line = $_; sl@0: if ($line =~ /^\s*#/) sl@0: { sl@0: next; sl@0: } sl@0: sl@0: # set current component sl@0: if ($line =~ /^\s*\[\s*(\w+)\s*\]/) #find [component name] line sl@0: { sl@0: $curComponent = $1; sl@0: print "\n[$curComponent]\n"; sl@0: sl@0: # determine if we are testing this component. sl@0: if (!grep(/^$curComponent$/i,@testedComponents)) sl@0: { sl@0: $testingCurrentComponent = 0; sl@0: next; sl@0: } sl@0: sl@0: $testingCurrentComponent = 1; sl@0: # clean the system and mmc drives if necessary sl@0: if ($firstTestedComponent) sl@0: { sl@0: $firstTestedComponent = 0; sl@0: } sl@0: else sl@0: { sl@0: ExecCmd("$ENV{SECURITYSOURCEDIR}\\testframework\\test\\autotesting\\restoredrivesstates.bat"); # For some reason when these commands are executed directly from Perl the call to xcopy to backup winscw\c causes xcopy to halt after copying one of the kanji SIS files, as a call to a batch file the commands work correctly. sl@0: } sl@0: # setup ethernet support on the emulator sl@0: ExecCmd("$ENV{SECURITYSOURCEDIR}\\testframework\\test\\autotesting\\useautocfg.bat"); sl@0: next; sl@0: } sl@0: sl@0: # execute the test if we are testing this component sl@0: if ($testingCurrentComponent) sl@0: { sl@0: my $program = ''; sl@0: my $log = ''; sl@0: my $commdb = ''; sl@0: my $script = ''; sl@0: my $timeout = ''; sl@0: my $release = ''; sl@0: my $preCommand = ''; sl@0: my $postCommand = ''; sl@0: sl@0: sl@0: # parse line from the test spec file sl@0: ($program, $log, $commdb, $script, $timeout, $release, $preCommand, $postCommand) = quotewords(',', 1, $line); sl@0: sl@0: sl@0: sl@0: $program =~ s/^\s*//; sl@0: $program =~ s/\s*$//; sl@0: $script =~ s/^\s*//; sl@0: $script =~ s/\s*$//; sl@0: $preCommand =~ s/^\s*//; sl@0: $preCommand =~ s/\s*$//; sl@0: $preCommand =~ s/%SECURITYSOURCEDIR%/$ENV{SECURITYSOURCEDIR}/; sl@0: $postCommand =~ s/^\s*//; sl@0: $postCommand =~ s/\s*$//; sl@0: $postCommand =~ s/%SECURITYSOURCEDIR%/$ENV{SECURITYSOURCEDIR}/; sl@0: $log =~ s/^\s*//; sl@0: $log =~ s/\s*$//; sl@0: sl@0: sl@0: # check release sl@0: if($release =! /$testedRelease/i) sl@0: { sl@0: next; sl@0: } sl@0: $i++; sl@0: sl@0: # execute the pre-test command sl@0: if($preCommand ne "") sl@0: { sl@0: ExecCmd($preCommand); sl@0: } sl@0: sl@0: # execute the test command sl@0: ExecCmd("$ExecTimeOut \"$program $script\" $timeout"); sl@0: print "\n\nExecution of $program $script"; sl@0: sl@0: sl@0: # store test results and epoc window output files sl@0: my $bEpocWnd = 0; sl@0: sl@0: $trimmedLog = $log; sl@0: $trimmedLog =~ s/\\.*\\//; # perl does greedy pattern matching so strips off all directories in the path of the form \....\....\ sl@0: $trimmedLog =~ s/.*\\//; # in case the path is relative strip of the leading directory sl@0: $trimmedLog =~ /(.*)\.([^\.]*)/; # extract the filename and the extension sl@0: sl@0: $epocwindName = $1 . $logSuffix . "_epocwind.txt"; sl@0: $targetLogName = $1 . $logSuffix. "\." . $2; sl@0: sl@0: ExecCmd("copy $epocWndPath $resultsOutputDir\\$epocwindName"); sl@0: ExecCmd("del $epocWndPath"); sl@0: $bEpocWnd = 1; sl@0: sl@0: sl@0: # process log files sl@0: my $sText = ""; sl@0: my $iPass = 0; sl@0: my $iFail = 0; sl@0: my $iPass_case = 0; # not used sl@0: my $iFail_case = 0; # not used sl@0: my $bLogFile = 0; sl@0: my $logPath = FullWin32Path($buildTarget, $release, $log); sl@0: if (-f $logPath) sl@0: { sl@0: $bLogFile = 1; sl@0: ExecCmd("copy $logPath $resultsOutputDir\\$targetLogName"); sl@0: # Test Execute sl@0: if ($sText eq "") sl@0: { sl@0: ($sText, $iPass, $iFail, $iPass_case, $iFail_case) = DigestTestExecuteTestLog($logPath); sl@0: } sl@0: sl@0: # Security Test Logs sl@0: if ($sText eq "" ) sl@0: { sl@0: # Check to see if this is an Security RTest test log sl@0: ($sText, $iPass, $iFail) = DigestSecurityTestLog($logPath); sl@0: } sl@0: sl@0: # get rid of surrounding html tags sl@0: if ($sText) sl@0: { sl@0: if ($sText =~ /(.+)<\/td>/) sl@0: { sl@0: $sText = $1; sl@0: } sl@0: } sl@0: } sl@0: sl@0: # generate HTML results sl@0: my $htmlEpocWnd = "here"; sl@0: if(!$bEpocWnd) sl@0: { sl@0: $htmlEpocWnd = "not found"; sl@0: } sl@0: my $htmlColor = "white"; sl@0: my $htmlLog = "$log"; sl@0: sl@0: if($bLogFile) sl@0: { sl@0: if ($sText eq "" ) sl@0: { sl@0: $htmlColor = 'blue'; sl@0: $sText = 'log file not parsed'; sl@0: } sl@0: elsif(!$iPass or $iFail) sl@0: { sl@0: $htmlColor = "red"; sl@0: } sl@0: } sl@0: else sl@0: { sl@0: $htmlColor = 'yellow'; sl@0: $sText = 'log file not found'; sl@0: $htmlLog = ''; sl@0: } sl@0: sl@0: print TESTRESULTS "\n"; sl@0: print TESTRESULTS ""; sl@0: print TESTRESULTS ""; sl@0: sl@0: print "\nResults: $sText"; sl@0: sl@0: # execute the post-test command sl@0: if($postCommand ne "") sl@0: { sl@0: ExecCmd($postCommand); sl@0: } sl@0: } sl@0: } sl@0: close TESTSPEC; sl@0: } sl@0: sl@0: # restore the drives' states sl@0: if (!$skipCleanAfterFinalComponent) sl@0: { sl@0: ExecCmd("$ENV{SECURITYSOURCEDIR}\\testframework\\test\\autotesting\\restoredrivesstates.bat"); sl@0: } sl@0: sl@0: # final html stuff sl@0: print TESTRESULTS "\n
#ComponentReleaseProgramScriptResultsLog fileEpoc window
$i$curComponent$testedRelease$program$script$sText$htmlLog$htmlEpocWnd
"; sl@0: sl@0: close TESTRESULTS; sl@0: sl@0: if (!$suppressBrowserPopup) sl@0: { sl@0: # open test results in browser, this will halt script execution until the browser is closed sl@0: `$testResultsPath`; sl@0: } sl@0: sl@0: ###################################################################################### sl@0: # helper functions sl@0: ###################################################################################### sl@0: sub ExecCmd sl@0: { sl@0: my $cmd = $_[0]; sl@0: print "\n".`$cmd`; sl@0: } sl@0: sl@0: sub DisplayHelp { sl@0: print "\n\n\nHELP DIALOG:"; sl@0: print "\nThe following arguments are required:\n\n"; sl@0: print "-components: A comma separated (no spaces) list of component names.\n\n"; sl@0: print "-testreleases: A comma separated (no spaces) list of the releases tested.\n\n"; sl@0: print "-exectimeout: The path location of ExecTimeOut.exe relative to this drive. This is downloaded via Perforce from //PR/share/DABSRelease/buildscripts/ExecTimeOut.exe.\n\n"; sl@0: print "-resultsoutput: Directory used to store the test results and epocwind.out files from running the tests. Current contents will be deleted. Use a value of \\logs\\winscw if you want it to be compatible with the panicscan test.\n\n"; sl@0: print "-skipfinalclean: The script will restore the drives to their original state after each component has been tested. If you do not want the drives to be restored after the final component has been tested (typically used when debugging just one component's tests) then add this flag and before re-running the tests manually restore the drives from the contents of the \\backup\\ folder.\n\n"; sl@0: print "-suppressbrowser: Add this flag to prevent the halting of execution and presentation of the results in a browser window after the tests have been run."; sl@0: print "Example usage:\n"; sl@0: print "test_launcher.pl -components caf2,streamingcaf,swi -testreleases udeb,urel -exectimeout \\ExecTimeOut.exe resultsoutput \\logs\\winscw -skipfinalclean -suppressbrowser\n\n"; sl@0: die; sl@0: } sl@0: sl@0: ###################################################################################### sl@0: # helper functions taken from the TestUtilities.pm perl module sl@0: ###################################################################################### sl@0: sl@0: sub DigestTestExecuteTestLog sl@0: # Arg: [0] output log from a TestExecute run sl@0: # Returns: small HTML summary string of the run sl@0: { sl@0: my $filename = $_[0]; sl@0: my $TestConfirmed = $_[1]; sl@0: my $sHTML = ""; sl@0: sl@0: $filename =~ s/\s+$//; sl@0: return "" unless( -f $filename and open( TEST, $filename )); sl@0: sl@0: $/ = "\n"; sl@0: sl@0: my $iFail = 0; sl@0: my $iPass = 0; sl@0: my $iCheck = 0; sl@0: my $bTestExecute = 0; sl@0: my $TEST_STEP_SECTION = 0; sl@0: my $iFail_case = 0; sl@0: my $iPass_case = 0; sl@0: my $iCheck_case = 0; sl@0: my $TEST_CASE_SECTION = 0; sl@0: sl@0: sl@0: while( ) sl@0: { sl@0: chomp; sl@0: my $sLine = $_; sl@0: if ( $sLine =~ /TEST STEP SUMMARY:<\/font>/i) sl@0: { sl@0: $TEST_STEP_SECTION = 1; sl@0: $TEST_CASE_SECTION = 0; sl@0: } sl@0: elsif ( $sLine =~ /RUN PROGRAM SUMMARY:<\/font>/i) sl@0: { sl@0: $TEST_STEP_SECTION = 0; sl@0: } sl@0: elsif( $sLine =~ /TEST CASE SUMMARY:<\/font>/i) sl@0: { sl@0: $TEST_CASE_SECTION = 1; sl@0: $TEST_STEP_SECTION = 0; sl@0: } sl@0: elsif ( $sLine =~ /SUMMARY:<\/font>/i ) # To Keep Last sl@0: { sl@0: $TEST_STEP_SECTION = 1; sl@0: } sl@0: if ( $TEST_STEP_SECTION ) sl@0: { sl@0: $iPass += $1 if( $sLine =~ / PASS = (\d+)<\/font>/i); sl@0: $iPass += $1 if( $sLine =~ /PASS = (\d+)<\/font>/i); sl@0: sl@0: $iFail += $1 if( $sLine =~ /FAIL = (\d+)<\/font>/i); sl@0: $iFail += $1 if( $sLine =~ /ABORT = (\d+)<\/font>/i); sl@0: $iFail += $1 if( $sLine =~ /PANIC = (\d+)<\/font>/i); sl@0: $iFail += $1 if( $sLine =~ /INCONCLUSIVE = (\d+)<\/font>/i); sl@0: $iFail += $1 if( $sLine =~ /UNKNOWN = (\d+)<\/font>/i); sl@0: $iFail += $1 if( $sLine =~ /UNEXECUTED = (\d+)<\/font>/i); sl@0: } sl@0: if ( $TEST_CASE_SECTION ) sl@0: { sl@0: sl@0: $iPass_case += $1 if( $sLine =~ / PASS = (\d+)<\/font>/i); sl@0: $iPass_case += $1 if( $sLine =~ /PASS = (\d+)<\/font>/i); sl@0: $iFail_case += $1 if( $sLine =~ /FAIL = (\d+)<\/font>/i); sl@0: $iFail_case += $1 if( $sLine =~ /ABORT = (\d+)<\/font>/i); sl@0: $iFail_case += $1 if( $sLine =~ /PANIC = (\d+)<\/font>/i); sl@0: $iFail_case += $1 if( $sLine =~ /INCONCLUSIVE = (\d+)<\/font>/i); sl@0: $iFail_case += $1 if( $sLine =~ /UNKNOWN = (\d+)<\/font>/i); sl@0: $iFail_case += $1 if( $sLine =~ /UNEXECUTED = (\d+)<\/font>/i); sl@0: sl@0: } sl@0: $bTestExecute = 1 if( $sLine =~ /\*\*\*\s+TestExecute\s+Started/i); sl@0: sl@0: } sl@0: close( TEST ); sl@0: sl@0: if( $bTestExecute ) sl@0: { sl@0: if(( $iPass == 0 and $iFail == 0) and ($TestConfirmed == 1)) sl@0: { sl@0: $sHTML = "$iPass passed, $iFail failed"; sl@0: } sl@0: elsif ( $iPass == 0 and $iFail == 0) sl@0: { sl@0: $sHTML = "test crashed"; sl@0: } sl@0: elsif( $iFail > 0 ) sl@0: { sl@0: $sHTML = "$iPass passed, $iFail failed"; sl@0: } sl@0: else sl@0: { sl@0: $sHTML = "$iPass passed, $iFail failed"; sl@0: } sl@0: } sl@0: elsif( $iPass > 0 or $iFail > 0 ) sl@0: { sl@0: # sl@0: # Almost certainly a TEF log, but missing the "TestExecute Started" line. sl@0: # Possibly because of a loss of part of the log from the hardware. sl@0: # sl@0: if( $iFail > 0 ) sl@0: { sl@0: $sHTML = "$iPass passed, $iFail failed"; sl@0: } sl@0: else sl@0: { sl@0: $sHTML = "$iPass passed, $iFail failed"; sl@0: } sl@0: } sl@0: sl@0: return ($sHTML, $iPass, $iFail, $iPass_case, $iFail_case); sl@0: } sl@0: sl@0: sl@0: sub DigestSecurityTestLog sl@0: # Arg: [0] output log from an automated testcase run sl@0: # Returns: small HTML summary string of the run indicating test result extracted from log. sl@0: { sl@0: my $filename = $_[0]; sl@0: sl@0: my $sHTML = ""; sl@0: sl@0: my $sCmd = "type $filename |"; sl@0: $filename =~ s/\s+$//; sl@0: return "" unless( -f $filename and open( TEST, $sCmd )); sl@0: sl@0: $/ = "\n"; sl@0: sl@0: # For these tests the result x tests failed out of y is displayed in the 2nd last line of the log file. sl@0: sl@0: my $iFail = 0; sl@0: my $iPass = 0; sl@0: my $iTotal = 0; sl@0: sl@0: while( ) sl@0: { sl@0: chomp; sl@0: my $sLine = $_; sl@0: my $null = chr(0); sl@0: $sLine =~ s/$null|\s//g; sl@0: if( $sLine =~ /(\d+)testsfailedoutof(\d+)/i ) sl@0: { sl@0: $iFail += $1; sl@0: $iTotal += $2; sl@0: } sl@0: } sl@0: close( TEST ); sl@0: sl@0: if( $iTotal > 0 ) sl@0: { sl@0: $sHTML = ""; sl@0: $sHTML = "" if( $iFail > 0 ); sl@0: sl@0: $iPass = $iTotal - $iFail; sl@0: $sHTML .= "$iPass passed, $iFail failed"; sl@0: } sl@0: sl@0: return ($sHTML, $iPass, $iFail); sl@0: } sl@0: sl@0: ###################################################################################### sl@0: # helper functions taken from the BuildSpecifications.pm perl module sl@0: ###################################################################################### sl@0: sl@0: # Read the contents of a file into a string and return it sl@0: sub ReadFile ($) sl@0: { sl@0: my ($file) = @_; sl@0: open FILE, "<$file" or LogDie("Can't read file: $file", @StdLogs); sl@0: local $/ = undef; sl@0: my $data = ; sl@0: close FILE; sl@0: return $data; sl@0: } sl@0: sl@0: sl@0: ########################################################################### sl@0: # Return Path to z Drive sl@0: # Arguments: [0] Build Target (e.g. arm4, wins, etc) sl@0: # [1] Build Release (Optional) (e.g. UDEB/UREL) sl@0: # Returns Correspoonding Effective Z Drive sl@0: sub FullPathToZDrive sl@0: { sl@0: my ($buildTarget, $buildRelease) = @_; sl@0: $buildRelease="UDEB" unless( $buildRelease ); sl@0: sl@0: return "$ENV{'EPOCROOT'}epoc32\\release\\$buildTarget\\$buildRelease\\z" if( $buildTarget =~ /wins/i ); sl@0: return "$ENV{'EPOCROOT'}epoc32\\data\\z"; sl@0: } sl@0: sl@0: sl@0: ########################################################################### sl@0: # Return Path to C Drive sl@0: # Arguments: [0] Build Target (e.g. arm4, wins, etc) sl@0: # Returns Correspoonding Effective C Drive sl@0: sub FullPathToCDrive sl@0: { sl@0: my ($buildTarget) = @_; sl@0: sl@0: return "$ENV{'EPOCROOT'}epoc32\\$buildTarget\\c" if( $buildTarget =~ /wins/i ); sl@0: return "$ENV{'EPOCROOT'}epoc32\\data\\z"; sl@0: } sl@0: sl@0: sl@0: ########################################################################### sl@0: # EPOC paths can be drive-relative ("\scripts\bob") or absolute ("c:\scripts\bob"). sl@0: # Return an appropriate Win32 path, where - an additional complication sl@0: # is that the EPOC c: and z: aren't sibling Win32 paths sl@0: # Arguments: [0] Build Target (e.g. arm4, wins, etc) sl@0: # [1] Build Release (Optional) (e.g. UDEB/UREL) sl@0: # [2] EPOC path sl@0: # Returns: full Win32 path sl@0: sub FullWin32Path sl@0: { sl@0: my ($buildTarget, $buildRelease, $sPath) = @_; sl@0: sl@0: $sPath =~ s/^\s+//; sl@0: if($sPath =~ /^(\w):(.*)/) sl@0: { sl@0: my $sDrive = uc($1); sl@0: my $sDir = $2; sl@0: $sDir =~ s/^\\//; sl@0: if($sDrive eq "C") sl@0: { sl@0: return FullPathToCDrive($buildTarget) . "\\$sDir"; sl@0: } sl@0: elsif($sDrive eq "Z") sl@0: { sl@0: return FullPathToZDrive($buildTarget,$buildRelease) . "\\$sDir"; sl@0: } sl@0: else sl@0: { sl@0: # Maybe an actual pathname sl@0: return $sPath; sl@0: } sl@0: } sl@0: sl@0: # Presumption is that path is relative to EPOC C:\ sl@0: $sPath =~ s/^\\//; sl@0: return FullPathToCDrive($buildTarget) . "\\$sPath"; sl@0: }