|
1 @rem |
|
2 @rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 @rem All rights reserved. |
|
4 @rem This component and the accompanying materials are made available |
|
5 @rem under the terms of "Eclipse Public License v1.0" |
|
6 @rem which accompanies this distribution, and is available |
|
7 @rem at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 @rem |
|
9 @rem Initial Contributors: |
|
10 @rem Nokia Corporation - initial contribution. |
|
11 @rem |
|
12 @rem Contributors: |
|
13 @rem |
|
14 @rem Description: |
|
15 @rem |
|
16 @rem = '--*-Perl-*-- |
|
17 @echo off |
|
18 if "%OS%" == "Windows_NT" goto WinNT |
|
19 perl -x -S "%0" %1 %2 %3 %4 %5 %6 %7 %8 %9 |
|
20 goto endofperl |
|
21 :WinNT |
|
22 perl -x -S "%0" %* |
|
23 if NOT "%COMSPEC%" == "%SystemRoot%\system32\cmd.exe" goto endofperl |
|
24 if %errorlevel% == 9009 echo You do not have Perl in your PATH. |
|
25 goto endofperl |
|
26 @rem '; |
|
27 #!perl |
|
28 #line 14 |
|
29 eval 'exec perl.exe -S $0 ${1+"$@"}' |
|
30 if $running_under_some_shell; |
|
31 |
|
32 use strict; # important pragma |
|
33 use File::Copy; |
|
34 use File::Find; |
|
35 |
|
36 |
|
37 my @Month =("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"); |
|
38 my ($sec,my $min,my $hour,my $mday,my $mon,my $year,my $wday,my $yday,my $isdst); |
|
39 |
|
40 |
|
41 my $BuildToUse="winscw"; |
|
42 my $EpocCDrive = "$ENV{EPOCROOT}epoc32\\$BuildToUse\\c"; |
|
43 my $ResultsDirectory = "$EpocCDrive\\Logs\\TestResults"; |
|
44 my $TestFrameworkOpts=""; |
|
45 my $TestFrameworkNoDelay=""; |
|
46 my $Debug=0; |
|
47 my $Warning=0; #controls how pernickety the output is |
|
48 my $Cmd; #general variable to carry system commands |
|
49 my $CodeCover=0; |
|
50 my $ScriptToRun='[\S]+\.script'; |
|
51 my $TimesToRun=1; |
|
52 |
|
53 |
|
54 if(@ARGV && (($ARGV[0] eq "-h") || |
|
55 ($ARGV[0] eq "--h") || |
|
56 ($ARGV[0] eq "-help") || |
|
57 ($ARGV[0] eq "--help") || |
|
58 ($ARGV[0] eq "help")) |
|
59 ) |
|
60 { |
|
61 print "Runs all the Test Framework and Test Execute script files.\n"; |
|
62 print "\nSyntax : runtests -b=sss -d -c -a -v=nnn -cc -rep=nnn -q\n"; |
|
63 print "-b Compiler version to use [wins\|winscw) (default=$BuildToUse)\n"; |
|
64 print "-d Force to run testframework at debug mode \n"; |
|
65 print "-c Clean results directory ($ResultsDirectory)\n"; |
|
66 print "-a Full output in testframework console\n"; |
|
67 print "-v Provide verbose output 1=limited 2=maximum\n"; |
|
68 print "-s Define a script to be executed (ommitting causes all scripts to be run)\n"; |
|
69 print "-cc Only run release builds for Code Cover\n"; |
|
70 print "-rep Repeat the test run a number of times\n"; |
|
71 print "-q Start testframework without the 20 second delay\n"; |
|
72 |
|
73 exit 0; |
|
74 } |
|
75 |
|
76 |
|
77 |
|
78 use Getopt::Long; |
|
79 my %optctl = (); |
|
80 keys(%optctl)=10; |
|
81 unless (GetOptions (\%optctl, "b=s","d","c","v=i", "cc", "s=s","rep=i","a","q")) |
|
82 {exit 1;} |
|
83 |
|
84 |
|
85 |
|
86 if($optctl{"b"}) |
|
87 { |
|
88 $BuildToUse=$optctl{"b"}; |
|
89 if((lc($BuildToUse) ne "wins") && (lc($BuildToUse) ne "winscw")) |
|
90 { |
|
91 print STDERR "only wins and winscw builds are supported\n"; |
|
92 exit 1; |
|
93 } |
|
94 |
|
95 $EpocCDrive = "$ENV{EPOCROOT}epoc32\\$BuildToUse\\c"; |
|
96 $ResultsDirectory = "$EpocCDrive\\Logs\\TestResults"; |
|
97 } |
|
98 #repeat test run a number of times |
|
99 if($optctl{"rep"}) |
|
100 { |
|
101 $TimesToRun = $optctl{"rep"}; |
|
102 if(($TimesToRun < 1)) |
|
103 { |
|
104 print STDERR "must specify a positive number of repeates\n"; |
|
105 exit 1; |
|
106 } |
|
107 } |
|
108 |
|
109 |
|
110 #debug on |
|
111 if($optctl{"v"}) |
|
112 {$Debug=$optctl{"v"};} |
|
113 |
|
114 if($Debug ==2) |
|
115 { |
|
116 print "Command line options:-\n"; |
|
117 while ((my $key, my $val) = each %optctl) |
|
118 {print "$key => $val\n";} |
|
119 } |
|
120 |
|
121 |
|
122 #Code Cover run |
|
123 if($optctl{"cc"}) |
|
124 {$CodeCover=1;} |
|
125 |
|
126 |
|
127 if($Debug ==2) |
|
128 { |
|
129 print "Command line options:-\n"; |
|
130 while ((my $key, my $val) = each %optctl) |
|
131 {print "$key => $val\n";} |
|
132 } |
|
133 |
|
134 |
|
135 |
|
136 if($optctl{"c"}) |
|
137 { |
|
138 print "Deleting Existing Results FIles\n"; |
|
139 |
|
140 my @ExistingResultsFiles; |
|
141 my $ExistingResultsFile; |
|
142 find( sub { push @ExistingResultsFiles, $File::Find::name if /\.htm/ }, ($ResultsDirectory) ); |
|
143 |
|
144 |
|
145 foreach $ExistingResultsFile (@ExistingResultsFiles) |
|
146 { |
|
147 $ExistingResultsFile =~ s/\//\\/g; |
|
148 $Cmd="del $ExistingResultsFile"; |
|
149 if($Debug==2) |
|
150 {print "executing $Cmd\n";} |
|
151 system($Cmd); |
|
152 } |
|
153 |
|
154 } |
|
155 |
|
156 if($optctl{"a"}) |
|
157 { |
|
158 print "Full output in testframework console\n"; |
|
159 $TestFrameworkOpts .= " -a"; |
|
160 } |
|
161 |
|
162 if($optctl{"s"}) |
|
163 { |
|
164 $ScriptToRun = $optctl{"s"}; |
|
165 |
|
166 print "Looking for script file $ScriptToRun\n"; |
|
167 } |
|
168 |
|
169 # Only add -q flag to textframework request |
|
170 if($optctl{"q"}) |
|
171 { |
|
172 $TestFrameworkNoDelay .= " -q"; |
|
173 } |
|
174 |
|
175 my $UrelTestFramework = "$ENV{EPOCROOT}epoc32\\release\\$BuildToUse\\urel\\testframework.exe" . $TestFrameworkOpts . $TestFrameworkNoDelay; |
|
176 my $UdebTestFramework = "$ENV{EPOCROOT}epoc32\\release\\$BuildToUse\\udeb\\testframework.exe -t" . $TestFrameworkOpts . $TestFrameworkNoDelay; |
|
177 my $RecogUrelTestFramework = "$ENV{EPOCROOT}epoc32\\release\\$BuildToUse\\urel\\testframeworkrecognizer.exe" . $TestFrameworkOpts . $TestFrameworkNoDelay; |
|
178 my $RecogUdebTestFramework = "$ENV{EPOCROOT}epoc32\\release\\$BuildToUse\\udeb\\testframeworkrecognizer.exe" . $TestFrameworkOpts . $TestFrameworkNoDelay; |
|
179 my $NoneUrelTestFramework = "$ENV{EPOCROOT}epoc32\\release\\$BuildToUse\\urel\\testframeworkNone.exe" . $TestFrameworkOpts . $TestFrameworkNoDelay; |
|
180 my $NoneUdebTestFramework = "$ENV{EPOCROOT}epoc32\\release\\$BuildToUse\\udeb\\testframeworkNone.exe" . $TestFrameworkOpts . $TestFrameworkNoDelay; |
|
181 my $MMDDCapUrelTestFramework = "$ENV{EPOCROOT}epoc32\\release\\$BuildToUse\\urel\\testframeworkMMDDCap.exe" . $TestFrameworkOpts . $TestFrameworkNoDelay; |
|
182 my $UECapUrelTestFramework = "$ENV{EPOCROOT}epoc32\\release\\$BuildToUse\\urel\\testframeworkUECap.exe" . $TestFrameworkOpts . $TestFrameworkNoDelay; |
|
183 my $UrelEpocEmulator = "$ENV{EPOCROOT}epoc32\\release\\$BuildToUse\\urel\\epoc.exe" . $TestFrameworkOpts; |
|
184 my $UdebEpocEmulator = "$ENV{EPOCROOT}epoc32\\release\\$BuildToUse\\udeb\\epoc.exe" . $TestFrameworkOpts; |
|
185 my $eka2IdentifyFile = "$ENV{EPOCROOT}epoc32\\release\\winscw\\udeb\\winsgui.dll"; # if file present, is EKA2 build |
|
186 my $UrelTestExecute = "$ENV{EPOCROOT}epoc32\\release\\$BuildToUse\\urel\\testexecute.exe" . $TestFrameworkOpts; |
|
187 my $UdebTestExecute = "$ENV{EPOCROOT}epoc32\\release\\$BuildToUse\\udeb\\testexecute.exe" . $TestFrameworkOpts; |
|
188 |
|
189 my $RecogniserCfgFile = "$EpocCDrive\\mm\\AutorunTests.cfg"; |
|
190 my $copy_ini_secdisp = "perl secdisp_ini_append.pl append"; |
|
191 my $delete_ini_secdisp = "perl secdisp_ini_append.pl restore"; |
|
192 if($Debug>=1) |
|
193 { |
|
194 print "\nUsing $RecogniserCfgFile to configure the Epoc recogniser\n"; |
|
195 } |
|
196 |
|
197 print "\nScanning $EpocCDrive for script files\n"; |
|
198 my @ScriptFilesFound; |
|
199 my $ScriptFile; |
|
200 my $ScriptToRunTmp = $ScriptToRun; |
|
201 |
|
202 #Firstly, try to find an exact script name |
|
203 print "ScriptToRunTmp = $ScriptToRunTmp\n"; |
|
204 |
|
205 if(!($ScriptToRun =~ /\.script/i)) |
|
206 {$ScriptToRunTmp = $ScriptToRun .'\.script';} |
|
207 |
|
208 #find all the required script files |
|
209 find( sub { push @ScriptFilesFound, $File::Find::name if /^$ScriptToRunTmp$/i }, ($EpocCDrive) ); |
|
210 |
|
211 #if no scripts were found, look for scripts that wildcard match |
|
212 if(@ScriptFilesFound < 1) |
|
213 { |
|
214 if(!($ScriptToRun =~ /\.script/i)) |
|
215 {$ScriptToRunTmp = '[\S]*' . $ScriptToRun .'[\S]*\.script';} |
|
216 else |
|
217 {$ScriptToRunTmp = $ScriptToRun;} |
|
218 |
|
219 find( sub { push @ScriptFilesFound, $File::Find::name if /$ScriptToRunTmp/i }, ($EpocCDrive) ); |
|
220 } |
|
221 |
|
222 if($Debug>=1) |
|
223 { |
|
224 my $len = @ScriptFilesFound; |
|
225 print "\nScanned $len script files in $EpocCDrive\n"; |
|
226 foreach $ScriptFile (@ScriptFilesFound) |
|
227 {print "$ScriptFile\n";} |
|
228 } |
|
229 |
|
230 |
|
231 #look for any scripts that are called from other scripts; no need to call these directly |
|
232 my @IndirectScripts; |
|
233 my $IndirectScript; |
|
234 foreach $ScriptFile (@ScriptFilesFound) |
|
235 { |
|
236 unless (open(SCRIPTFILE,"$ScriptFile")) |
|
237 { |
|
238 print STDERR "Can't open $ScriptFile: $!\n"; |
|
239 exit 1; |
|
240 } |
|
241 |
|
242 my $ScriptFileLine; |
|
243 my @ResultFileContents = <SCRIPTFILE>; |
|
244 |
|
245 foreach $ScriptFileLine (@ResultFileContents) |
|
246 { |
|
247 if($ScriptFileLine =~ /^RUN_SCRIPT[\s]+[\S]+[\s]*$/) |
|
248 { |
|
249 if($Debug==2) |
|
250 {print "File: $ScriptFile Line: $ScriptFileLine\n";} |
|
251 |
|
252 $IndirectScript = $ScriptFileLine; |
|
253 $_ = $IndirectScript; |
|
254 |
|
255 m/^RUN_SCRIPT[\s]+([\S]+)[\s]*$/; |
|
256 $IndirectScript=($1); |
|
257 |
|
258 if($Debug==2) |
|
259 {print "Secondary Script = $IndirectScript\n";} |
|
260 |
|
261 push @IndirectScripts, $IndirectScript; |
|
262 } |
|
263 } |
|
264 } |
|
265 |
|
266 |
|
267 #produce a list of the script files that need running |
|
268 my @ScriptsToRun; |
|
269 ScriptFile_LBL: foreach $ScriptFile (@ScriptFilesFound) |
|
270 { |
|
271 |
|
272 foreach $IndirectScript (@IndirectScripts) |
|
273 { |
|
274 if($ScriptFile =~ /$IndirectScript/) |
|
275 { |
|
276 if($Debug==2) |
|
277 {print "Not running $ScriptFile directly\n";} |
|
278 next ScriptFile_LBL;} |
|
279 } |
|
280 |
|
281 push @ScriptsToRun, $ScriptFile; |
|
282 } |
|
283 |
|
284 |
|
285 if($Debug>=1) |
|
286 { |
|
287 foreach $ScriptFile (@ScriptsToRun) |
|
288 {print "Running $ScriptFile\n";} |
|
289 } |
|
290 |
|
291 |
|
292 unless (open(TESTRUNLOG,">TestRunLog.txt")) |
|
293 { |
|
294 print STDERR "Can't open orphanedtests.txt: $!\n"; |
|
295 exit 1; |
|
296 } |
|
297 |
|
298 unless (open(MASTERSCRIPT,">master.script")) |
|
299 { |
|
300 print STDERR "Can't open master.script: $!\n"; |
|
301 exit 1; |
|
302 } |
|
303 unless (open(MASTERALLOCSCRIPT,">master_alloc.script")) |
|
304 { |
|
305 print STDERR "Can't open master_alloc.script: $!\n"; |
|
306 exit 1; |
|
307 } |
|
308 |
|
309 #create a master script file, this could be usefull for running on hardware. |
|
310 foreach $ScriptFile (@ScriptsToRun) |
|
311 { |
|
312 $ScriptFile =~ s/\//\\/g; |
|
313 $ScriptFile =~ s/^[\s]*[a-z]://i; |
|
314 |
|
315 my $regex = quotemeta $EpocCDrive; |
|
316 $ScriptFile =~ s/$regex//gi; |
|
317 |
|
318 #alloc tests must be run under debug |
|
319 if($ScriptFile =~ /_alloc(_wm)?.script/i) |
|
320 { |
|
321 print MASTERALLOCSCRIPT "RUN_SCRIPT $ScriptFile\n";} |
|
322 else |
|
323 {print MASTERSCRIPT "RUN_SCRIPT $ScriptFile\n";} |
|
324 |
|
325 } |
|
326 close MASTERSCRIPT; |
|
327 close MASTERALLOCSCRIPT; |
|
328 |
|
329 |
|
330 #remove any alloc tests from list. Alloc tests must be run on debug builds, Code Cover tests |
|
331 #are only done against release builds. |
|
332 if($CodeCover==1) |
|
333 { |
|
334 my @ScriptsToRunTmp=(); |
|
335 foreach $ScriptFile (@ScriptsToRun) |
|
336 { |
|
337 if(!($ScriptFile =~ /_alloc(_wm)?.script/i)) |
|
338 { |
|
339 push @ScriptsToRunTmp, $ScriptFile; |
|
340 } |
|
341 } |
|
342 @ScriptsToRun = @ScriptsToRunTmp; |
|
343 } |
|
344 |
|
345 |
|
346 my $TotalScriptFiles = @ScriptsToRun; |
|
347 if($TimesToRun > 1) |
|
348 { |
|
349 print "Running $TotalScriptFiles scripts $TimesToRun times\n"; |
|
350 } |
|
351 else |
|
352 { |
|
353 print "Running $TotalScriptFiles scripts\n"; |
|
354 } |
|
355 |
|
356 |
|
357 my $RunCount=0; |
|
358 for ($RunCount = 0; $RunCount < $TimesToRun; $RunCount++) |
|
359 { |
|
360 my $ScriptsRun=0; |
|
361 #run each script |
|
362 foreach $ScriptFile (@ScriptsToRun) |
|
363 { |
|
364 $ScriptFile =~ s/\//\\/g; |
|
365 $ScriptFile =~ s/^[\s]*[a-z]://i; |
|
366 |
|
367 my $regex = quotemeta $EpocCDrive; |
|
368 $ScriptFile =~ s/$regex//gi; |
|
369 |
|
370 # We must decide if the test needs to be run using epoc or the test framework. This is |
|
371 # done by looking for _WM (Window Manager) appended to the script name. |
|
372 # NB. This only applies to Typhoon, Jetstream is unaffected. |
|
373 |
|
374 if (!(-f $eka2IdentifyFile) && ($ScriptFile =~ /_wm.script/i)) # This script must be run using epoc and the recogniser |
|
375 { |
|
376 # First create the recogniser config file |
|
377 my $line1 = "// This file is generated by runtests.bat\n"; |
|
378 my $line2 = "RUN_SCRIPT\n"; |
|
379 my $line3 = ""; |
|
380 |
|
381 #alloc tests must be run under debug |
|
382 if($ScriptFile =~ /_alloc_wm.script/i) |
|
383 { |
|
384 $Cmd = "$UdebEpocEmulator"; |
|
385 $line3 = "C:$ScriptFile -t 15000000\n"; |
|
386 } |
|
387 else |
|
388 { |
|
389 $Cmd = "$UrelEpocEmulator"; |
|
390 $line3 = "C:$ScriptFile 15000000\n"; |
|
391 } |
|
392 open(RECOGNISER_CFG_FILE,">$RecogniserCfgFile") or die "Could not open $RecogniserCfgFile for writing\n"; |
|
393 print RECOGNISER_CFG_FILE $line1, $line2, $line3; |
|
394 close(RECOGNISER_CFG_FILE); |
|
395 } |
|
396 else # This script can be run from the test framework |
|
397 { |
|
398 #alloc tests must be run under debug |
|
399 if($ScriptFile =~ /_recog_alloc.script/i) |
|
400 { |
|
401 $Cmd = "$RecogUdebTestFramework $ScriptFile"; |
|
402 } |
|
403 elsif($ScriptFile =~ /_nocap_alloc.script/i) |
|
404 { |
|
405 $Cmd = "$NoneUdebTestFramework $ScriptFile"; |
|
406 } |
|
407 elsif(($ScriptFile =~ /_alloc.script/i) || ($ScriptFile =~ /_alloc_wm.script/i) || ($ScriptFile =~ /_debug.script/i) || ($optctl{"d"}) ) |
|
408 { |
|
409 $Cmd = "$UdebTestFramework $ScriptFile"; |
|
410 } |
|
411 elsif($ScriptFile =~ /_recog.script/i) |
|
412 { |
|
413 $Cmd = "$RecogUrelTestFramework $ScriptFile"; |
|
414 } |
|
415 elsif($ScriptFile =~ /_nocap.script/i) |
|
416 { |
|
417 $Cmd = "$NoneUrelTestFramework $ScriptFile"; |
|
418 } |
|
419 elsif($ScriptFile =~ /_mmddcap.script/i) |
|
420 { |
|
421 $Cmd = "$MMDDCapUrelTestFramework $ScriptFile"; |
|
422 } |
|
423 elsif($ScriptFile =~ /_uecap.script/i) |
|
424 { |
|
425 $Cmd = "$UECapUrelTestFramework $ScriptFile"; |
|
426 } |
|
427 elsif($ScriptFile =~ /_secdisp.script/i) |
|
428 { |
|
429 #Take a backup of the existing ini files to .OLD and copy our ini files from the current dir to \epoc folders |
|
430 if(!(system($copy_ini_secdisp)==0)) |
|
431 { |
|
432 print "Failure to execute - $Cmd: $!"; |
|
433 print TESTRUNLOG "Failure to execute - $Cmd: $!\n"; |
|
434 } |
|
435 $Cmd = "$UrelTestFramework $ScriptFile"; |
|
436 } |
|
437 elsif($ScriptFile =~ /\\te_/i) |
|
438 { |
|
439 $Cmd = "$UdebTestExecute $ScriptFile"; |
|
440 } |
|
441 elsif($ScriptFile =~ /_te.script/i) |
|
442 { |
|
443 $Cmd = "$UdebTestExecute $ScriptFile"; |
|
444 } |
|
445 else |
|
446 { |
|
447 $Cmd = "$UrelTestFramework $ScriptFile"; |
|
448 } |
|
449 } |
|
450 |
|
451 |
|
452 |
|
453 ($sec,my $min,my $hour,my $mday,my $mon,my $year,my $wday,my $yday,my $isdst) = localtime(time); |
|
454 print "Starting script at $hour:$min:$sec\n"; |
|
455 print TESTRUNLOG "Starting script at $hour:$min:$sec\n"; |
|
456 |
|
457 $ScriptsRun++; |
|
458 print "executing $Cmd ($ScriptsRun of $TotalScriptFiles)\n"; |
|
459 |
|
460 print TESTRUNLOG "executing $Cmd\n"; |
|
461 |
|
462 if(!(system($Cmd)==0)) |
|
463 { |
|
464 print "Failure to execute - $Cmd: $!"; |
|
465 print TESTRUNLOG "Failure to execute - $Cmd: $!\n"; |
|
466 } |
|
467 if($ScriptFile =~ /_secdisp.script/i) |
|
468 { |
|
469 #Delete .ini files and rename .OLD files to .ini files |
|
470 if(!(system($delete_ini_secdisp)==0)) |
|
471 { |
|
472 print "Failure to execute - $Cmd: $!"; |
|
473 print TESTRUNLOG "Failure to execute - $Cmd: $!\n"; |
|
474 } |
|
475 } |
|
476 |
|
477 }#foreach $ScriptFile (@ScriptsToRun) |
|
478 |
|
479 if($TimesToRun > 1) |
|
480 { |
|
481 #now copy the results to a new numbered directory |
|
482 $Cmd = "xcopy /E /R /I /Y P:\\epoc32\\wins\\c\\Logs\\TestResults P:\\epoc32\\wins\\c\\Logs\\TestResults$RunCount"; |
|
483 print "executing $Cmd"; |
|
484 |
|
485 if(!(system($Cmd)==0)) |
|
486 { |
|
487 print "Failure to execute - $Cmd: $!"; |
|
488 print TESTRUNLOG "Failure to execute - $Cmd: $!\n"; |
|
489 } |
|
490 } |
|
491 } |
|
492 |
|
493 |
|
494 |
|
495 $Cmd="del /F /Q $RecogniserCfgFile"; |
|
496 if($Debug==2) |
|
497 {print "executing $Cmd\n";} |
|
498 system($Cmd); |
|
499 |
|
500 ($sec,my $min,my $hour,my $mday,my $mon,my $year,my $wday,my $yday,my $isdst) = localtime(time); |
|
501 print "Test run completed at $hour:$min:$sec\n"; |
|
502 print TESTRUNLOG "Test run completed at $hour:$min:$sec\n"; |
|
503 |
|
504 |
|
505 __END__ |
|
506 |
|
507 :endofperl |
|
508 |