|
1 # |
|
2 # Copyright (c) 2007 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 "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 # |
|
16 |
|
17 #------------------------------------------------------------------------------------ |
|
18 # Includes |
|
19 #------------------------------------------------------------------------------------ |
|
20 use strict; |
|
21 use warnings; |
|
22 use Cwd; # for cwd |
|
23 use FindBin; # for FindBin:Bin |
|
24 use File::Path; # for mkpath |
|
25 use Date::Calc; |
|
26 use File::Copy; |
|
27 use lib "$FindBin::Bin/../lib"; |
|
28 |
|
29 { # No globals. |
|
30 my $cgidir = GetCgiDir(); |
|
31 |
|
32 if ( ! -e( $cgidir . "rerunsubs.pl" ) ) |
|
33 { |
|
34 $cgidir = cwd; |
|
35 my $domain = "VideoApp_Domain"; |
|
36 my $pos = index( $cgidir, $domain ); |
|
37 if( $pos != -1 ) |
|
38 { |
|
39 $cgidir = substr( $cgidir, 0, $pos + length( $domain ) ) . "\\videoplayer\\tsrc\\testing\\tools\\"; |
|
40 |
|
41 } |
|
42 } |
|
43 require( $cgidir . "utils.pl" ); |
|
44 require( $cgidir . "rerunsubs.pl" ); |
|
45 } |
|
46 |
|
47 #------------------------------------------------------------------------------------ |
|
48 # GLOBAL CODE |
|
49 #------------------------------------------------------------------------------------ |
|
50 |
|
51 my $basePath = "testdrop"; # ATS XML |
|
52 my $dropFilePath = "ATS3Drop\\"; # All other files |
|
53 my $dropImagePath = "ATS3Drop\\images\\"; |
|
54 my $dropBinaryPath = "ATS3Drop\\armv5_urel\\"; # Binaries |
|
55 |
|
56 my $currentPlanId = 0; |
|
57 my $currentSessionId = 0; |
|
58 my $currentSetId = 0; |
|
59 my $currentCaseId = 0; |
|
60 my $currentStepId = 0; |
|
61 |
|
62 # Attributes for files which are copied to device. Or SIS installations. |
|
63 my $ATSFILE_NAME = 0; |
|
64 my $ATSFILE_HARNESS = 1; |
|
65 my $ATSFILE_ENABLED = 2; |
|
66 my $ATSFILE_PASSRATE = 3; |
|
67 my $ATSFILE_SIGNIFICANT = 4; |
|
68 my $ATSFILE_TYPE = 5; |
|
69 my $ATSFILE_SRC = 6; |
|
70 my $ATSFILE_DST = 7; |
|
71 my $ATSFILE_COMMAND = 9; |
|
72 my $ATSFILE_DROPFULL_PATH = 10; # Contains the path in drop to the file |
|
73 my $ATSFILE_STEP_XML = 11; # XML defining the step |
|
74 my $ATSFILE_STEP_TIMEOUT = 12; # only for SIS file |
|
75 |
|
76 # These must be replaced when writing a step into XML file |
|
77 my $ATSXML_DROPPRIORITY = "ATSXML_DROPPRIORITY"; |
|
78 my $ATSXML_TESTNAME = "ATSXML_TESTNAME"; |
|
79 my $ATSXML_FLASH_IMAGE_NAME = "ATSXML_FLASH_IMAGE_NAME"; |
|
80 my $ATSXML_TESTDEVICE = "ATSXML_TESTDEVICE"; |
|
81 my $ATSXML_TESTPLAN_NAME = "ATSXML_TESTPLAN_NAME"; |
|
82 my $ATSXML_TESTSESSION_NAME = "ATSXML_TESTSESSION_NAME"; |
|
83 my $ATSXML_TESTSET_NAME = "ATSXML_TESTSET_NAME"; |
|
84 my $ATSXML_STEP_NAME = "ATSXML_STEP_NAME"; |
|
85 my $ATSXML_TESTCASE_NAME = "ATSXML_TESTCASE_NAME"; |
|
86 my $ATSXML_STEP_HARNESS = "ATSXML_STEP_HARNESS"; |
|
87 my $ATSXML_STEP_ENABLED = "ATSXML_STEP_ENABLED"; |
|
88 my $ATSXML_STEP_PASSRATE = "ATSXML_STEP_PASSRATE"; |
|
89 my $ATSXML_STEP_SIGNIFICANT = "ATSXML_STEP_SIGNIFICANT"; |
|
90 my $ATSXML_STEP_COMMAND = "ATSXML_STEP_COMMAND"; |
|
91 my $ATSXML_STEP_PARAM_TYPE = "ATSXML_STEP_PARAM_TYPE"; |
|
92 my $ATSXML_STEP_PARAM_SRC = "ATSXML_STEP_PARAM_SRC"; |
|
93 my $ATSXML_STEP_PARAM_DST = "ATSXML_STEP_PARAM_DST"; |
|
94 my $ATSXML_STEP_RUNCASES_FILENAME = "ATSXML_STEP_RUNCASES_FILENAME"; |
|
95 my $ATSXML_STEP_RUNCASES_TIMEOUT = "ATSXML_STEP_RUNCASES_TIMEOUT"; |
|
96 #my $ATSXML_STEP_PARAM_COMPONENT_PATH = "ATSXML_STEP_PARAM_COMPONENT_PATH"; |
|
97 my $ATSXML_STEP_RUNCASE_CASENAME = "ATSXML_STEP_RUNCASE_CASENAME"; |
|
98 my $ATSXML_STEP_RUNCASE_FILENAME = "ATSXML_STEP_RUNCASE_FILENAME"; |
|
99 my $ATSXML_EMAIL = "ATSXML_EMAIL"; |
|
100 my $ATSXML_SIS_FILENAME = "ATSXML_SIS_FILENAME"; |
|
101 my $ATSXML_STEP_TIMEOUT = "ATSXML_STEP_TIMEOUT"; |
|
102 my $ATSXML_FETCH_PATH = "ATSXML_FETCH_PATH"; |
|
103 my $ATSXML_CTC_PATH = "ATSXML_CTC_PATH"; |
|
104 |
|
105 # These are initialized in the InitXml() |
|
106 my $ATSXML_HEADER_START; |
|
107 my $ATSXML_HEADER_END; |
|
108 my $ATSXML_FOOTER; |
|
109 my $ATSXML_PLANSTART; |
|
110 my $ATSXML_CREATEDIRS; |
|
111 my $ATSXML_FLASH; |
|
112 my $ATSXML_FORMAT_DRIVES; |
|
113 my $ATSXML_PLANEND; |
|
114 my $ATSXML_STEP; |
|
115 my $ATSXML_FETCH_STEPS; |
|
116 my $ATSXML_FETCH_STEP; |
|
117 my $ATSXML_CTCWRITE_STEP; |
|
118 my $ATSXML_STEP_DEFAULT; |
|
119 my $ATSXML_STEP_BINARY; |
|
120 my $ATSXML_STEP_RUNCASES; |
|
121 my $ATSXML_STEP_RUNCASES_WITH_BOOT; |
|
122 my $ATSXML_STEP_RUNCASES_INI; |
|
123 my $ATSXML_STEP_RUNCASES_INI_WITH_BOOT; |
|
124 my $ATSXML_STEP_RUNCASE; |
|
125 my $ATSXML_STEP_INSTALLSIS; |
|
126 my $ATSXML_POSTACTION; |
|
127 |
|
128 my $atsCfgFileName = ""; |
|
129 my $atsUsername = ""; |
|
130 my $atsPassword = ""; |
|
131 |
|
132 my $paramStartDir = ".."; |
|
133 my $paramVerbose = 1; |
|
134 my $paramDebug = 0; |
|
135 my $paramFindPkgFilePath = ""; |
|
136 my $paramExecuteDrop = ""; |
|
137 my $paramDontDeleteGeneratedFiles = 0; |
|
138 my $paramCTC = 0; |
|
139 my $paramNameFilter = ""; |
|
140 my $paramSkipFlashCopy = 0; |
|
141 my $paramForcedBuild = ""; |
|
142 my $paramRerunXml = 0; |
|
143 my $paramUseSecondaryIni = 0; |
|
144 my $paramCaseClass = ""; |
|
145 |
|
146 my $globalAtsHost = "10.11.2.4"; |
|
147 my $globalCtcExePath = "xxx"; |
|
148 my @globalFlashFiles; |
|
149 my @globalSisFiles; |
|
150 my @globalPkgFiles; |
|
151 my $globalDeviceName = ""; |
|
152 my $globalDeviceVersion = ""; |
|
153 my $globalDeviceHWID = ""; |
|
154 my $globalEmail = ""; |
|
155 my $globalIgnoreSis = 0; |
|
156 my @globalFailedCfgs; |
|
157 |
|
158 # The code |
|
159 |
|
160 InitXml(); |
|
161 |
|
162 ReadArgs(); |
|
163 |
|
164 if($paramExecuteDrop ne "") |
|
165 { |
|
166 ExecuteDrop($paramExecuteDrop, 1); |
|
167 } |
|
168 else |
|
169 { |
|
170 if($atsCfgFileName eq "") |
|
171 { |
|
172 ShowHelp(); |
|
173 } |
|
174 |
|
175 ParseFile( $atsCfgFileName ); |
|
176 } |
|
177 |
|
178 exit(); |
|
179 |
|
180 |
|
181 #------------------------------------------------------------------------------------ |
|
182 # ReadArgs |
|
183 #------------------------------------------------------------------------------------ |
|
184 sub ReadArgs |
|
185 { |
|
186 ShowHelp() if(scalar(@ARGV) == 0); |
|
187 |
|
188 while(scalar(@ARGV) >= 1) |
|
189 { |
|
190 my $argument = shift(@ARGV); |
|
191 |
|
192 if($argument eq "-f") |
|
193 { |
|
194 $atsCfgFileName = shift(@ARGV) |
|
195 } |
|
196 elsif($argument eq "-u") |
|
197 { |
|
198 $atsUsername = shift(@ARGV) |
|
199 } |
|
200 elsif($argument eq "-p") |
|
201 { |
|
202 $atsPassword = shift(@ARGV) |
|
203 } |
|
204 elsif($argument eq "-h") |
|
205 { |
|
206 ShowHelp(); |
|
207 } |
|
208 elsif($argument eq "-q") |
|
209 { |
|
210 $paramVerbose = 0; |
|
211 } |
|
212 elsif($argument eq "-d") |
|
213 { |
|
214 $paramVerbose = 1; |
|
215 $paramDebug = 1; |
|
216 } |
|
217 elsif($argument eq -"filepath") |
|
218 { |
|
219 $paramFindPkgFilePath = shift(@ARGV); |
|
220 } |
|
221 elsif($argument eq "-run") |
|
222 { |
|
223 $paramExecuteDrop = shift(@ARGV); |
|
224 $paramVerbose = 1; |
|
225 } |
|
226 elsif($argument eq "-nodelete") |
|
227 { |
|
228 $paramDontDeleteGeneratedFiles = 1; |
|
229 } |
|
230 elsif($argument eq "-ctcrom") |
|
231 { |
|
232 $paramCTC = 1; |
|
233 $globalCtcExePath = "z:\\sys\\bin\\ctcman.exe"; |
|
234 } |
|
235 elsif($argument eq "-ctcsis") |
|
236 { |
|
237 $globalCtcExePath = "c:\\sys\\bin\\ctcman.exe"; |
|
238 $paramCTC = 1; |
|
239 } |
|
240 elsif($argument eq "-dropname") |
|
241 { |
|
242 $paramNameFilter = shift(@ARGV); |
|
243 } |
|
244 elsif($argument eq "-noflash") |
|
245 { |
|
246 $paramSkipFlashCopy = 1; |
|
247 } |
|
248 elsif( $argument eq "-atshost" ) |
|
249 { |
|
250 $globalAtsHost = shift(@ARGV); |
|
251 } |
|
252 elsif( $argument eq "-forcebuild" ) |
|
253 { |
|
254 $paramForcedBuild = shift(@ARGV); |
|
255 if( !defined($paramForcedBuild) || ( $paramForcedBuild ne "udeb" && $paramForcedBuild ne "urel" ) ) |
|
256 { |
|
257 die("\n-forcebuild parameter must be 'udeb' or 'urel'"); |
|
258 } |
|
259 } |
|
260 elsif( $argument eq "-rerun" ) |
|
261 { |
|
262 $paramRerunXml = 1; |
|
263 my $file = shift(@ARGV); |
|
264 die("Could not read failed cases!") if ( Rerun_ReadFailedCases( $file, \@globalFailedCfgs ) ); |
|
265 if( scalar( @globalFailedCfgs ) <= 0 ) |
|
266 { |
|
267 print("No fails to rerun!\n"); |
|
268 exit(); |
|
269 } |
|
270 } |
|
271 elsif( $argument eq "-allini" ) |
|
272 { |
|
273 $paramUseSecondaryIni = 1; |
|
274 } |
|
275 elsif( $argument eq "-caseclass" ) |
|
276 { |
|
277 $paramCaseClass = shift(@ARGV); |
|
278 } |
|
279 else |
|
280 { |
|
281 die("Unknown command line option: '$argument'.\n"); |
|
282 } |
|
283 |
|
284 } |
|
285 |
|
286 die("Parameter -f is required.\n") if( $atsCfgFileName eq "" ); |
|
287 } |
|
288 |
|
289 #------------------------------------------------------------------------------------ |
|
290 # ShowHelp |
|
291 #------------------------------------------------------------------------------------ |
|
292 sub ShowHelp |
|
293 { |
|
294 print <<USAGE_EOF; |
|
295 genATSdrop.pl -f <drop or master cfg.txt> -u <ats username> -p <ats password> |
|
296 |
|
297 Params: |
|
298 -f <filename> Filename of ATS cfg file. |
|
299 -u <username> ATS username. not required. |
|
300 -p <password> ATS password. not required. |
|
301 -q Quiet mode |
|
302 -d Debug information |
|
303 -run xxx Run xxx drop in the ATS farm. xxx can be a folder or a zip file (w/o .zip) |
|
304 -filepath xxx Where files from PKG are searched for, default is the path in PKG file. |
|
305 -h help |
|
306 -nodelete For default the script deletes generated files. |
|
307 -noflash Skip copying flash files to drop. |
|
308 -ctcrom CTC++ is installed in the ROM. Fetches the CTC result files from the device. |
|
309 -ctcsis CTC++ is installed from SIS. Fetches the CTC result files from the device. |
|
310 -atshost Address of ATS host to run the tests. |
|
311 -dropname xxx Runs only drops which match with xxx string. |
|
312 -forcebuild udeb or urel -> forces to use the defined build for all executables read from PKGs |
|
313 -rerun xxx Reads results from xml and writes only failed cases into ATS3 drop CFG files. |
|
314 -allini Uses secondary testframework.ini file to run the cases, if it's found from init/all/ folder. |
|
315 |
|
316 Below is example for the ATS master cfg file. The commands override the |
|
317 ATS drop cfg commands, except PKG command. |
|
318 |
|
319 [MASTERCFG] |
|
320 DEVICE Ivalo |
|
321 FLASH \\\\network\\flashimages\\core.fpsx |
|
322 FLASH \\\\network\\flashimages\\variant.fpsx |
|
323 FLASH \\\\network\\flashimages\\eraseuserdisk.fpsx |
|
324 SIS \\\\app\\sis\\app.sisx |
|
325 SIS \\\\app\\tsrc\\sistests.sisx |
|
326 IGNORESIS |
|
327 PKG \\\\app\\tsrc\\data\\cenrepchanges.pkg |
|
328 EMAIL xxx |
|
329 ; Drop configs must be in tsrc folders and they must be defined after other commands. |
|
330 INC /ido/api/module1/tsrc/conf/ats_config.txt |
|
331 INC /ido/api2/module/tsrc/conf/ats_config.txt |
|
332 [EMDMASTERCFG] |
|
333 |
|
334 Available commands for the ATS drop cfg file. List order is also the recommended order in the cfg file. |
|
335 |
|
336 NAME XXX Test drop name. |
|
337 PRIORITY xxx Test drop execution priority, 0 is the highest |
|
338 DEVICE x1 x2 x3 x1 = Device name in the ATS system, x2 = device version (optional), x3 = device HWID (optional) |
|
339 FLASH File to be flashed. Can be defined with path. |
|
340 PKG xxx Text file listing the files which are copied into the device by ATS. |
|
341 Uses same format as Symbian PKG files. |
|
342 SIS x1 x1 = SIS/SISX file which needs to be installed. |
|
343 IGNORESIS Master cfg only, ignores SIS commands afterwards. |
|
344 BOOT Reboots the device. Testframework.ini must have cfg with cases Dummy1 and Dummy2. |
|
345 INI xxx Command to execute ini file in ATS system. |
|
346 CFG xxx Command to execute cfg in ATS system. Cfg files must be listed |
|
347 in the PKG files. No path support. |
|
348 CASELIST xxx Command to execute invidual STIF cases from CFG files. |
|
349 FETCH xxx Fetches file(s) from a directory. ( FETCH e:\\analyzetool\\* ) |
|
350 EMAIL xxx Email address(es) where ATS sends the report. |
|
351 |
|
352 USERNAME xxx Username for ATS login |
|
353 PASSWORD xxx Password for ATS login |
|
354 |
|
355 Example: |
|
356 |
|
357 [DROP] |
|
358 NAME STIF_TestDrop |
|
359 DEVICE Tube B1 1001 |
|
360 FLASH \\\\network\\flashimages\\core.fpsx |
|
361 FLASH \\\\network\\flashimages\\variant.fpsx |
|
362 FLASH \\\\network\\flashimages\\eraseuserdisk.fpsx |
|
363 PKG \\\\app\\tsrc\\data\cenrepchanges.pkg |
|
364 SIS \\\\app\\sis\\app.sisx |
|
365 SIS \\\\app\\tsrc\\sis\\tests.sisx |
|
366 BOOT |
|
367 INI atsconfig\\drop1\\TestFramework.ini 1200 |
|
368 EMAIL dude\@nokia.com |
|
369 [ENDDROP] |
|
370 |
|
371 USAGE_EOF |
|
372 |
|
373 exit(); |
|
374 } |
|
375 |
|
376 #------------------------------------------------------------------------------------ |
|
377 # ParseFile |
|
378 # Parameters: |
|
379 # $filename |
|
380 #------------------------------------------------------------------------------------ |
|
381 sub ParseFile |
|
382 { |
|
383 my($filename) = @_; |
|
384 |
|
385 # Read the file and check if it's drop conf or master conf file. |
|
386 open(FILE_HANDLE, $filename) or die("ERROR! Could not open config file '" . $filename . "'\n"); |
|
387 my @lines = <FILE_HANDLE>; |
|
388 close(FILE_HANDLE); |
|
389 |
|
390 my $isDropFile = 0; |
|
391 |
|
392 foreach my $line (@lines) |
|
393 { |
|
394 if( $line =~ m/\[DROP\]/i || $line =~ m/\[ENDDROP\]/i ) |
|
395 { |
|
396 $isDropFile++; |
|
397 } |
|
398 } |
|
399 |
|
400 if( $isDropFile >= 2 ) |
|
401 { |
|
402 ParseAtsCfg( $filename ); |
|
403 } |
|
404 else |
|
405 { |
|
406 ParseMasterCfg( $filename ); |
|
407 } |
|
408 } |
|
409 |
|
410 #------------------------------------------------------------------------------------ |
|
411 # ParseMasterCfg |
|
412 # Parameters: |
|
413 # $filename |
|
414 #------------------------------------------------------------------------------------ |
|
415 sub ParseMasterCfg |
|
416 { |
|
417 my($filename) = @_; |
|
418 |
|
419 my $index = 0; |
|
420 |
|
421 open(FILE_HANDLE, $filename) or die("ERROR! Could not open master config file '" . $filename . "'\n"); |
|
422 my @lines = <FILE_HANDLE>; |
|
423 close(FILE_HANDLE); |
|
424 |
|
425 while($index < scalar(@lines)) |
|
426 { |
|
427 my $line = $lines[$index]; |
|
428 |
|
429 my $cmd; |
|
430 my $params; |
|
431 ReadCmdFromLine( \$line, \$cmd, \$params ); |
|
432 |
|
433 # |
|
434 # CMD FLASH |
|
435 # |
|
436 if($cmd eq "FLASH") |
|
437 { |
|
438 push @globalFlashFiles, $params; |
|
439 } |
|
440 |
|
441 # |
|
442 # CMD DEVICE |
|
443 # |
|
444 if( $cmd eq "DEVICE" ) |
|
445 { |
|
446 my @paramArray = split( / /, $params ); |
|
447 $globalDeviceName = $paramArray[0] if( defined( $paramArray[0] ) ); |
|
448 $globalDeviceVersion = $paramArray[1] if( defined( $paramArray[1] ) ); |
|
449 $globalDeviceHWID = $paramArray[2] if( defined( $paramArray[2] ) ); |
|
450 print("Global device: $globalDeviceName\n"); |
|
451 print("Global device version: $globalDeviceVersion\n"); |
|
452 print("Global device HWID: $globalDeviceHWID\n"); |
|
453 } |
|
454 |
|
455 # |
|
456 # CMD EMAIL |
|
457 # |
|
458 if( $cmd eq "EMAIL" ) |
|
459 { |
|
460 $globalEmail = $params; |
|
461 } |
|
462 |
|
463 # |
|
464 # CMD INC |
|
465 # |
|
466 if($cmd eq "INC") |
|
467 { |
|
468 # Forward slashes to backward. |
|
469 $params =~ s/\//\\/g; |
|
470 |
|
471 my $pos = index( $params, "tsrc" ); |
|
472 if( $pos != -1 ) |
|
473 { |
|
474 print("\nReading config file $params\n"); |
|
475 my $path = substr( $params, 0, $pos+4 ); |
|
476 my $file = substr( $params, $pos+5 ); |
|
477 |
|
478 $pos = index( $file, "conf" ); |
|
479 |
|
480 die("INC file must be in conf directory! Incorrect params: $params") if( $pos == -1); |
|
481 |
|
482 if( $pos != 0 ) |
|
483 { |
|
484 $path .= "\\" . substr( $file, 0, $pos-1 ); |
|
485 $file = substr( $file, $pos ); |
|
486 } |
|
487 |
|
488 my $startDir = cwd; |
|
489 |
|
490 # Change where the master config file is. |
|
491 if( rindex($filename, "\\") != -1 ) |
|
492 { |
|
493 chdir( substr($filename, 0, rindex($filename, "\\") ) ); |
|
494 } |
|
495 |
|
496 # Go where the drop config file is. |
|
497 chdir( $path ); |
|
498 |
|
499 ParseAtsCfg( $file ); |
|
500 |
|
501 chdir( $startDir ); |
|
502 } |
|
503 else |
|
504 { |
|
505 die("ERROR! The path $params is invalid, config must be under tsrc folder.\n"); |
|
506 } |
|
507 } |
|
508 |
|
509 # |
|
510 # CMD SIS |
|
511 # |
|
512 if( $cmd eq "SIS" ) |
|
513 { |
|
514 print("Master CFG has SIS: $params\n"); |
|
515 push @globalSisFiles, $params; |
|
516 } |
|
517 |
|
518 # |
|
519 # CMD SIS |
|
520 # |
|
521 if( $cmd eq "IGNORESIS" ) |
|
522 { |
|
523 print("Master CFG ignore sis command.\n"); |
|
524 $globalIgnoreSis = 1; |
|
525 } |
|
526 |
|
527 # |
|
528 # CMD PKG |
|
529 # |
|
530 if( $cmd eq "PKG" ) |
|
531 { |
|
532 print("Master CFG has PKG: $params\n"); |
|
533 push @globalPkgFiles, $params; |
|
534 } |
|
535 |
|
536 $index++; |
|
537 } |
|
538 } |
|
539 |
|
540 #------------------------------------------------------------------------------------ |
|
541 # ParseAtsCfg |
|
542 # Parameters: |
|
543 # $filename |
|
544 #------------------------------------------------------------------------------------ |
|
545 sub ParseAtsCfg |
|
546 { |
|
547 my($filename) = @_; |
|
548 |
|
549 open(FILE_HANDLE, $filename) or die("ERROR! Could not open drop config file '" . $filename . "'\n"); |
|
550 my @lines = <FILE_HANDLE>; |
|
551 close(FILE_HANDLE); |
|
552 |
|
553 my $index = 0; |
|
554 |
|
555 my $testname = ""; |
|
556 my $testpriority = 0; |
|
557 my $deviceName = ""; |
|
558 my $deviceVersion = ""; |
|
559 my $deviceHWID = ""; |
|
560 my $testClosed = 1; # is file handle closed? |
|
561 my $planStartWritten = 0; |
|
562 my $installationStepsWritten = 0; |
|
563 my $additionalFilesCopiedToDrop = 0; # have ini and flash files copied to drop already. |
|
564 my @atsFiles; |
|
565 my @flashFiles; |
|
566 my @sisFiles; |
|
567 my @pkgFiles; |
|
568 my @globalPkgFilesForConf; |
|
569 my $startOfDropIndex = 0; |
|
570 my $email = ""; |
|
571 |
|
572 my $cmdDropStartRead = 0; |
|
573 my $cmdNameRead = 0; |
|
574 my $cmdDeviceRead = 0; |
|
575 my $cmdPkgRead = 0; |
|
576 my $cmdSisRead = 0; |
|
577 my $skipCurrentDrop = 0; |
|
578 |
|
579 my $bootDefined = 0; |
|
580 |
|
581 my @preRunCustomXmlData; |
|
582 my @postRunCustomXmlData; |
|
583 |
|
584 if( -e "custom\\prerun_custom.xml" ) |
|
585 { |
|
586 open( FILE_HANDLE, "custom\\prerun_custom.xml" ) or die("ERROR! Could not read conf/prerun_custom.xml.\n"); |
|
587 @preRunCustomXmlData = <FILE_HANDLE>; |
|
588 close(FILE_HANDLE); |
|
589 } |
|
590 if( -e "custom\\postrun_custom.xml" ) |
|
591 { |
|
592 open( FILE_HANDLE, "custom\\postrun_custom.xml" ) or die("ERROR! Could not read conf/postrun_custom.xml.\n"); |
|
593 @postRunCustomXmlData = <FILE_HANDLE>; |
|
594 close(FILE_HANDLE); |
|
595 } |
|
596 |
|
597 if( $paramCaseClass ne "" ) |
|
598 { |
|
599 my $cgiDir = GetCgiDir(); |
|
600 system("perl $cgiDir" . "genCfgs.pl -c $paramCaseClass"); |
|
601 |
|
602 my @newCfgs; |
|
603 FindFiles(".\\conf_temp", "cfg", 1, \@newCfgs); |
|
604 if( scalar(@newCfgs) < 1 ) |
|
605 { |
|
606 print("No class in cases. Aborting drop.\n"); |
|
607 return; |
|
608 } |
|
609 |
|
610 push @globalPkgFilesForConf, "conf_temp\\cfgs.pkg"; |
|
611 } |
|
612 |
|
613 while($index < scalar(@lines)) |
|
614 { |
|
615 my $line = $lines[$index]; |
|
616 |
|
617 my $cmd; |
|
618 my $params; |
|
619 ReadCmdFromLine( \$line, \$cmd, \$params ); |
|
620 |
|
621 # |
|
622 # CMD DROP |
|
623 # |
|
624 if($cmd eq "[DROP]") |
|
625 { |
|
626 $startOfDropIndex = $index; |
|
627 # Reset variables for this drop |
|
628 $testpriority = 10; |
|
629 $testname = ""; |
|
630 $deviceName = ""; |
|
631 $deviceVersion = ""; |
|
632 $deviceHWID = ""; |
|
633 $planStartWritten = 0; |
|
634 $installationStepsWritten = 0; |
|
635 $additionalFilesCopiedToDrop = 0; |
|
636 undef( @atsFiles ); |
|
637 undef( @flashFiles ); |
|
638 undef( @sisFiles ); |
|
639 undef( @pkgFiles ); |
|
640 $email = ""; |
|
641 |
|
642 $basePath = ""; |
|
643 |
|
644 $currentPlanId = 0; |
|
645 $currentSessionId = 0; |
|
646 $currentSetId = 0; |
|
647 $currentCaseId = 0; |
|
648 $currentStepId = 0; |
|
649 |
|
650 $cmdDropStartRead = 1; |
|
651 $cmdNameRead = 0; |
|
652 $cmdDeviceRead = 0; |
|
653 $cmdPkgRead = 0; |
|
654 $cmdSisRead = 0; |
|
655 } |
|
656 |
|
657 # |
|
658 # CMD NAME |
|
659 # |
|
660 if($cmd eq "NAME" && !$skipCurrentDrop) |
|
661 { |
|
662 die ("Command [DROP] missing or NAME in wrong place. Line $index.") if(!$cmdDropStartRead); |
|
663 $testname = $params; |
|
664 |
|
665 $basePath = $params; |
|
666 $basePath =~ s/ /_/g; |
|
667 |
|
668 if( -e "$basePath.zip" ) |
|
669 { |
|
670 print("\ndel $basePath.zip\n"); |
|
671 system("del $basePath.zip"); |
|
672 } |
|
673 |
|
674 if( -e $basePath ) |
|
675 { |
|
676 print("rmdir /s /q $basePath\n"); |
|
677 system("rmdir /s /q $basePath"); |
|
678 } |
|
679 |
|
680 $skipCurrentDrop = 0; |
|
681 if( $paramNameFilter ne "" ) |
|
682 { |
|
683 if( !($testname =~ m/$paramNameFilter/i) ) |
|
684 { |
|
685 $skipCurrentDrop = 1; |
|
686 print("Skipping drop: $testname\n"); |
|
687 } |
|
688 } |
|
689 |
|
690 if( !$skipCurrentDrop ) |
|
691 { |
|
692 print("\nCreating testdrop: $testname\n"); |
|
693 |
|
694 # Create needed directories |
|
695 mkdir($basePath); |
|
696 mkdir($basePath . "\\" . $dropFilePath); |
|
697 mkdir($basePath . "\\" . $dropImagePath); |
|
698 mkdir($basePath . "\\" . $dropBinaryPath); |
|
699 |
|
700 # Open XML file for writing |
|
701 my $xmlfilename = "$basePath\\test.xml"; |
|
702 if(!open(FILE_HANDLE_XML, ">$xmlfilename") ) |
|
703 { |
|
704 print("ERROR! Could not open file for writing '" . $xmlfilename . "'\n"); |
|
705 return 0; |
|
706 } |
|
707 $cmdNameRead = 1; |
|
708 } |
|
709 $testClosed = 0; |
|
710 } |
|
711 |
|
712 # |
|
713 # CMD PRIORITY |
|
714 # |
|
715 if($cmd eq "PRIORITY" && !$skipCurrentDrop) |
|
716 { |
|
717 die ("Command [DROP] missing or PRIORITY in wrong place. Line $index.") if(!$cmdDropStartRead); |
|
718 $testpriority = $params; |
|
719 } |
|
720 |
|
721 # |
|
722 # CMD DEVICE |
|
723 # |
|
724 if($cmd eq "DEVICE" && !$skipCurrentDrop) |
|
725 { |
|
726 die ("Command DEVICE in wrong place. Line $index.") if(!$cmdDropStartRead || $cmdPkgRead || $cmdSisRead ); |
|
727 # Write XML header with test name and device |
|
728 die("Device must be set in the CFG!") if($params eq ""); |
|
729 die("NAME must be set in the cfg!") if($testname eq ""); |
|
730 |
|
731 my @paramArray = split( / /, $params ); |
|
732 $deviceName = $paramArray[0] if( defined( $paramArray[0] ) ); |
|
733 $deviceVersion = $paramArray[1] if( defined( $paramArray[1] ) ); |
|
734 $deviceHWID = $paramArray[2] if( defined( $paramArray[2] ) ); |
|
735 |
|
736 $deviceName = $globalDeviceName if( $globalDeviceName ne "" ); |
|
737 $deviceVersion = $globalDeviceVersion if( $globalDeviceVersion ne "" ); |
|
738 $deviceHWID = $globalDeviceHWID if( $globalDeviceHWID ne "" ); |
|
739 |
|
740 my $data = $ATSXML_HEADER_START; |
|
741 $data =~ s/$ATSXML_TESTNAME/$testname/; |
|
742 $data =~ s/$ATSXML_TESTDEVICE/$deviceName/; |
|
743 $data =~ s/$ATSXML_DROPPRIORITY/$testpriority/; |
|
744 |
|
745 if( $deviceVersion ne "" ) |
|
746 { |
|
747 $data .= " <property name=\"PROTO_VERSION\" value=\"$deviceVersion\" />\n"; |
|
748 } |
|
749 if( $deviceHWID ne "" ) |
|
750 { |
|
751 $data .= " <property name=\"HWID\" value=\"$deviceHWID\" />\n"; |
|
752 } |
|
753 |
|
754 $data .= $ATSXML_HEADER_END; |
|
755 |
|
756 print FILE_HANDLE_XML ($data); |
|
757 |
|
758 if($paramVerbose) |
|
759 { |
|
760 print("Device name: '$deviceName'\n"); |
|
761 print("Device version: '$deviceVersion'\n"); |
|
762 print("Device HWID: '$deviceHWID'\n"); |
|
763 } |
|
764 $cmdDeviceRead = 1; |
|
765 } |
|
766 |
|
767 # |
|
768 # CMD FLASH |
|
769 # |
|
770 if($cmd eq "FLASH" && !$skipCurrentDrop) |
|
771 { |
|
772 die ("Command FLASH in wrong place. Line $index.") if(!$cmdDropStartRead || !$cmdNameRead || !$cmdDeviceRead || $cmdPkgRead || $cmdSisRead ); |
|
773 |
|
774 push @flashFiles, $params; |
|
775 } |
|
776 |
|
777 # |
|
778 # Write the XML start before test run commands. |
|
779 # |
|
780 if( ( $cmd eq "INI" || $cmd eq "CFG" || $cmd eq "CASELIST" ) && !$skipCurrentDrop ) |
|
781 { |
|
782 # Write plan start and flashing commands to XML. |
|
783 if($planStartWritten == 0) |
|
784 { |
|
785 WriteXmlPlanStart(\*FILE_HANDLE_XML, $deviceName); |
|
786 |
|
787 my $refFlashFiles = \@flashFiles; |
|
788 $refFlashFiles = \@globalFlashFiles if( scalar(@globalFlashFiles) > 0 ); |
|
789 |
|
790 foreach my $flashFile ( @$refFlashFiles ) |
|
791 { |
|
792 my $file = GetPathFileName( $flashFile ); |
|
793 my $data = $ATSXML_FLASH; |
|
794 $data =~ s/$ATSXML_FLASH_IMAGE_NAME/$file/; |
|
795 print FILE_HANDLE_XML ($data); |
|
796 print("Flash file: $file\n") if($paramVerbose); |
|
797 } |
|
798 |
|
799 # Steps to format drives. |
|
800 #WriteXmlFormatDrives(\*FILE_HANDLE_XML); |
|
801 |
|
802 # Tsrc prerun custom steps. |
|
803 if( scalar(@preRunCustomXmlData) > 0 ) |
|
804 { |
|
805 print("Steps from prerun xml.\n"); |
|
806 print FILE_HANDLE_XML (@preRunCustomXmlData) |
|
807 } |
|
808 |
|
809 $planStartWritten = 1; |
|
810 } |
|
811 |
|
812 # Copy files to drop. |
|
813 if( $additionalFilesCopiedToDrop == 0 ) |
|
814 { |
|
815 # Copy flash files to drop. |
|
816 my $refFlashFiles = \@flashFiles; |
|
817 $refFlashFiles = \@globalFlashFiles if( scalar(@globalFlashFiles) > 0 ); |
|
818 CopyFlashFilesToDrop( $refFlashFiles, \@atsFiles ); |
|
819 |
|
820 # Copy SIS files to drop and add to files to install. |
|
821 my $refSisFiles = \@sisFiles; |
|
822 $refSisFiles = \@globalSisFiles if( scalar( @globalSisFiles ) > 0 ); |
|
823 foreach my $sisFile ( @$refSisFiles ) |
|
824 { |
|
825 CopySisFileToDrop( $sisFile, \@atsFiles ); |
|
826 } |
|
827 |
|
828 my @allPkgFiles = ( @pkgFiles, @globalPkgFiles, @globalPkgFilesForConf ); |
|
829 |
|
830 foreach my $pkgFile ( @allPkgFiles ) |
|
831 { |
|
832 CopyPkgFilesToDrop( $pkgFile, \@atsFiles ); |
|
833 } |
|
834 |
|
835 # Copy testframework.ini of drop to drop. |
|
836 CopyTestframeworkIniOfDropToDrop( \@lines, $startOfDropIndex, \@atsFiles ) if( $paramCaseClass eq "" ); |
|
837 |
|
838 $additionalFilesCopiedToDrop = 1; |
|
839 } |
|
840 |
|
841 # XML file installation steps before these commands. |
|
842 if( $cmd eq "INI" || $cmd eq "CFG" || $cmd eq "CASELIST" ) |
|
843 { |
|
844 if($installationStepsWritten == 0) |
|
845 { |
|
846 print("File installation steps.\n") if($paramVerbose); |
|
847 $installationStepsWritten = 1; |
|
848 WriteXmlInstallationSteps(\@atsFiles, \*FILE_HANDLE_XML); |
|
849 } |
|
850 } |
|
851 } |
|
852 |
|
853 # |
|
854 # CMD PKG |
|
855 # |
|
856 if( $cmd eq "PKG" && !$skipCurrentDrop ) |
|
857 { |
|
858 die ("Command PKG in wrong place. Line $index.") if(!$cmdDropStartRead || !$cmdNameRead || !$cmdDeviceRead ); |
|
859 push @pkgFiles, $params; |
|
860 $cmdPkgRead = 1; |
|
861 } |
|
862 |
|
863 # |
|
864 # CMD BOOT |
|
865 # |
|
866 if( $cmd eq "BOOT" ) |
|
867 { |
|
868 $bootDefined = 1; |
|
869 } |
|
870 |
|
871 # |
|
872 # CMD INI & CFG |
|
873 # |
|
874 if( ($cmd eq "INI" || $cmd eq "CFG") && !$skipCurrentDrop) |
|
875 { |
|
876 die ("Command $cmd in wrong place. Line $index.") if(!$cmdDropStartRead || !$cmdNameRead || !$cmdDeviceRead ); |
|
877 my $refData; |
|
878 if($cmd eq "CFG") |
|
879 { |
|
880 if( !$bootDefined ) |
|
881 { |
|
882 $refData = \$ATSXML_STEP_RUNCASES; |
|
883 } |
|
884 else |
|
885 { |
|
886 $refData = \$ATSXML_STEP_RUNCASES_WITH_BOOT; |
|
887 } |
|
888 |
|
889 } |
|
890 else |
|
891 { |
|
892 if( !$bootDefined ) |
|
893 { |
|
894 $refData = \$ATSXML_STEP_RUNCASES_INI; |
|
895 } |
|
896 else |
|
897 { |
|
898 $refData = \$ATSXML_STEP_RUNCASES_INI_WITH_BOOT; |
|
899 } |
|
900 } |
|
901 |
|
902 my $pos = index($params, " "); |
|
903 my $testfilename = substr($params, 0, $pos); |
|
904 my $timeout = substr($params, $pos); |
|
905 |
|
906 RemoveWhiteSpaces(\$testfilename); |
|
907 RemoveWhiteSpaces(\$timeout); |
|
908 |
|
909 $testfilename = GetPathFileName($testfilename); |
|
910 |
|
911 die("Commands INI and CFG must be have params file and timeout!") if($testfilename eq "" or $timeout eq ""); |
|
912 |
|
913 WriteXmlRunStepsForFile($testfilename, $timeout, $refData, \*FILE_HANDLE_XML); |
|
914 } |
|
915 |
|
916 # |
|
917 # CMD SIS |
|
918 # |
|
919 if( $cmd eq "SIS" && !$skipCurrentDrop && !$globalIgnoreSis ) |
|
920 { |
|
921 die ("Command $cmd in wrong place. Line $index.") if(!$cmdDropStartRead || !$cmdNameRead || !$cmdDeviceRead ); |
|
922 push @sisFiles, $params; |
|
923 $cmdSisRead = 1; |
|
924 } |
|
925 |
|
926 # |
|
927 # CMD CASELIST |
|
928 # |
|
929 if($cmd eq "CASELIST" && !$skipCurrentDrop) |
|
930 { |
|
931 die ("Command CASELIST in wrong place. Line $index.") if(!$cmdDropStartRead || !$cmdNameRead || !$cmdDeviceRead ); |
|
932 my @caseListLines; |
|
933 my $caseCount = 0; |
|
934 |
|
935 if( !open(FILE_HANDLE_CASELIST, $params) ) |
|
936 { |
|
937 die("ERROR! Could not open file '" . $params . "'\n"); |
|
938 } |
|
939 @caseListLines = <FILE_HANDLE_CASELIST>; |
|
940 close(FILE_HANDLE_CASELIST); |
|
941 |
|
942 WriteXmlRunStepsForCases(\@caseListLines, \*FILE_HANDLE_XML); |
|
943 } |
|
944 |
|
945 # |
|
946 # CMD FETCH |
|
947 # |
|
948 if($cmd eq "FETCH" && !$skipCurrentDrop) |
|
949 { |
|
950 die ("Command FETCH in wrong place. Line $index.") if(!$cmdDropStartRead || !$cmdNameRead || !$cmdDeviceRead ); |
|
951 WriteXmlFetchStep(\*FILE_HANDLE_XML, $params); |
|
952 } |
|
953 |
|
954 # |
|
955 # CMD EMAIL |
|
956 # |
|
957 if($cmd eq "EMAIL" && !$skipCurrentDrop) |
|
958 { |
|
959 $email = $params; |
|
960 $email = $globalEmail if( $globalEmail ne "" ); |
|
961 } |
|
962 |
|
963 # |
|
964 # CMD ENDDROP |
|
965 # |
|
966 if($cmd eq "[ENDDROP]" && !$skipCurrentDrop) |
|
967 { |
|
968 $skipCurrentDrop = 0; |
|
969 |
|
970 die ("[ENDDROP] in wrong place. Line $index.") if(!$cmdDropStartRead || !$cmdNameRead || !$cmdDeviceRead ); |
|
971 |
|
972 # Tsrc prerun custom steps. |
|
973 if( scalar(@postRunCustomXmlData) > 0 ) |
|
974 { |
|
975 print("Steps from postrun xml.\n"); |
|
976 print FILE_HANDLE_XML (@postRunCustomXmlData) |
|
977 } |
|
978 else |
|
979 { |
|
980 WriteXmlFetchSteps(\*FILE_HANDLE_XML); |
|
981 } |
|
982 |
|
983 # End case, set, plan, session |
|
984 print FILE_HANDLE_XML ($ATSXML_PLANEND); |
|
985 |
|
986 ## Post action, fetches reports to network drive |
|
987 #print FILE_HANDLE_XML ($ATSXML_POSTACTION); |
|
988 |
|
989 WriteFileList(\@atsFiles, \*FILE_HANDLE_XML); |
|
990 |
|
991 # Write footer with email address |
|
992 my $data = $ATSXML_FOOTER; |
|
993 $data =~ s/$ATSXML_EMAIL/$email/; |
|
994 $data =~ s/$ATSXML_TESTNAME/$testname/; |
|
995 print FILE_HANDLE_XML ($data); |
|
996 |
|
997 if($testClosed == 0) |
|
998 { |
|
999 $testClosed = 1; |
|
1000 close(FILE_HANDLE_XML); |
|
1001 } |
|
1002 |
|
1003 if( $paramRerunXml ) |
|
1004 { |
|
1005 my $failedCaseCount = 0; |
|
1006 |
|
1007 foreach my $pkgFile ( @pkgFiles ) |
|
1008 { |
|
1009 $failedCaseCount += GetFailedCasesCountForPkg( $pkgFile, \@globalFailedCfgs ); |
|
1010 } |
|
1011 foreach my $pkgFile ( @globalPkgFiles ) |
|
1012 { |
|
1013 $failedCaseCount += GetFailedCasesCountForPkg( $pkgFile, \@globalFailedCfgs ); |
|
1014 } |
|
1015 |
|
1016 if( $failedCaseCount > 0 ) |
|
1017 { |
|
1018 ExecuteDrop($basePath, 0); |
|
1019 } |
|
1020 else |
|
1021 { |
|
1022 print("No fails. Removing the drop.\n"); |
|
1023 if( -e "$basePath.zip" ) |
|
1024 { |
|
1025 print("\ndel $basePath.zip\n"); |
|
1026 system("del $basePath.zip"); |
|
1027 } |
|
1028 |
|
1029 if( -e $basePath ) |
|
1030 { |
|
1031 print("rmdir /s /q $basePath\n"); |
|
1032 system("rmdir /s /q $basePath"); |
|
1033 } |
|
1034 } |
|
1035 } |
|
1036 else |
|
1037 { |
|
1038 ExecuteDrop($basePath, 0); |
|
1039 } |
|
1040 } |
|
1041 |
|
1042 # |
|
1043 # CMD USERNAME |
|
1044 # |
|
1045 if($cmd eq "USERNAME" && !$skipCurrentDrop) |
|
1046 { |
|
1047 $atsUsername = $params if( $atsUsername ) eq ""; |
|
1048 } |
|
1049 |
|
1050 # |
|
1051 # CMD PASSWORD |
|
1052 # |
|
1053 if($cmd eq "PASSWORD" && !$skipCurrentDrop) |
|
1054 { |
|
1055 $atsPassword = $params if( $atsPassword ) eq ""; |
|
1056 } |
|
1057 |
|
1058 $index++; |
|
1059 } |
|
1060 |
|
1061 if($testClosed == 0) |
|
1062 { |
|
1063 close(FILE_HANDLE_XML); |
|
1064 $testClosed = 1; |
|
1065 } |
|
1066 |
|
1067 print("Done.\n"); |
|
1068 } |
|
1069 |
|
1070 #------------------------------------------------------------------------------------ |
|
1071 # ReadCmdFromLine |
|
1072 # Parameters: |
|
1073 # $refLine, $refCmd, $refParams |
|
1074 # Return |
|
1075 # 1 if it's a command, otherwise 0. |
|
1076 #------------------------------------------------------------------------------------ |
|
1077 sub ReadCmdFromLine |
|
1078 { |
|
1079 my ($refLine, $refCmd, $refParams) = @_; |
|
1080 |
|
1081 RemoveWhiteSpaces($refLine); |
|
1082 |
|
1083 $$refCmd = $$refLine; |
|
1084 $$refParams = ""; |
|
1085 |
|
1086 if(index($$refLine, ";") == 0 || index($$refLine, "#") == 0) |
|
1087 { |
|
1088 return 0; |
|
1089 } |
|
1090 |
|
1091 my $pos = index($$refLine, " "); |
|
1092 if($pos != -1) |
|
1093 { |
|
1094 $$refCmd = substr($$refLine, 0, $pos); |
|
1095 $$refParams = substr($$refLine, $pos); |
|
1096 } |
|
1097 RemoveWhiteSpaces($refCmd); |
|
1098 RemoveWhiteSpaces($refParams); |
|
1099 |
|
1100 print("CMD: '$$refCmd', Params: '$$refParams'\n") if($paramDebug); |
|
1101 return 1; |
|
1102 } |
|
1103 |
|
1104 #------------------------------------------------------------------------------------ |
|
1105 # CopySisFileToDrop |
|
1106 # Parameters: |
|
1107 # $sisFile, $refAtsFiles |
|
1108 #------------------------------------------------------------------------------------ |
|
1109 sub CopySisFileToDrop |
|
1110 { |
|
1111 my( $sisFile, $refAtsFiles ) = @_; |
|
1112 |
|
1113 # Copy file to drop. |
|
1114 my $pkgline = "\"$sisFile\" - \"c:\\testframework\\$sisFile\""; |
|
1115 print("SIS file to drop: $sisFile.\n") if($paramVerbose); |
|
1116 CopyFileToDrop($pkgline, $refAtsFiles, 1); |
|
1117 |
|
1118 $sisFile = GetPathFileName($sisFile); |
|
1119 |
|
1120 # Installation step. |
|
1121 my @atsFile; |
|
1122 $atsFile[$ATSFILE_SRC] = "c:\\testframework\\$sisFile"; |
|
1123 $atsFile[$ATSFILE_STEP_XML] = $ATSXML_STEP_INSTALLSIS; |
|
1124 $atsFile[$ATSFILE_STEP_TIMEOUT] = 5000; |
|
1125 push @$refAtsFiles, [ @atsFile ]; |
|
1126 } |
|
1127 |
|
1128 #------------------------------------------------------------------------------------ |
|
1129 # CopyTestframeworkIniOfDropToDrop |
|
1130 # Parameters: |
|
1131 # $refAtsConfLines, $refAtsFiles |
|
1132 #------------------------------------------------------------------------------------ |
|
1133 sub CopyTestframeworkIniOfDropToDrop |
|
1134 { |
|
1135 my( $refAtsConfLines, $startOfDropIndex, $refAtsFiles ) = @_; |
|
1136 |
|
1137 my $index2 = $startOfDropIndex+1; |
|
1138 while($index2 < scalar(@$refAtsConfLines)) |
|
1139 { |
|
1140 my $line = @$refAtsConfLines[$index2]; |
|
1141 RemoveWhiteSpaces(\$line); |
|
1142 if($line eq "[ENDDROP]" or $line eq "[DROP]") |
|
1143 { |
|
1144 last; |
|
1145 } |
|
1146 |
|
1147 $index2++; |
|
1148 my $cmd = $line; |
|
1149 my $filename = ""; |
|
1150 |
|
1151 my $pos = index($line, " "); |
|
1152 if($pos != -1) |
|
1153 { |
|
1154 $cmd = substr($line, 0, $pos); |
|
1155 $filename = substr($line, $pos); |
|
1156 RemoveWhiteSpaces(\$filename); |
|
1157 } |
|
1158 RemoveWhiteSpaces(\$cmd); |
|
1159 RemoveWhiteSpaces(\$filename); |
|
1160 |
|
1161 if( $cmd eq "INI" ) |
|
1162 { |
|
1163 if(index($filename, " ") != -1) |
|
1164 { |
|
1165 $filename = substr($filename, 0, index($filename, " ")); |
|
1166 } |
|
1167 print("INI file to drop: $filename.\n") if($paramVerbose); |
|
1168 |
|
1169 my $pkgline = "\"$filename\" - \"c:\\testframework\\$filename\""; |
|
1170 CopyFileToDrop($pkgline, $refAtsFiles, 1); |
|
1171 } |
|
1172 } |
|
1173 } |
|
1174 |
|
1175 #------------------------------------------------------------------------------------ |
|
1176 # CopyFlashFilesToDrop |
|
1177 # Parameters: |
|
1178 # $refFlashFiles, $refAtsFiles |
|
1179 #------------------------------------------------------------------------------------ |
|
1180 sub CopyFlashFilesToDrop |
|
1181 { |
|
1182 my( $refFlashFiles, $refAtsFiles ) = @_; |
|
1183 |
|
1184 my $refCopyFlashFiles = $refFlashFiles; |
|
1185 |
|
1186 $refCopyFlashFiles = \@globalFlashFiles if( scalar(@globalFlashFiles) > 0 ); |
|
1187 foreach my $flashFile ( @$refCopyFlashFiles ) |
|
1188 { |
|
1189 # Strip the path from the flash file |
|
1190 my $flashfilename = GetPathFileName($flashFile); |
|
1191 my $dstpath = $basePath . "\\" . $dropImagePath . $flashfilename; |
|
1192 |
|
1193 if( !$paramSkipFlashCopy ) |
|
1194 { |
|
1195 print("copy $flashFile -> $dstpath\n") if($paramVerbose);; |
|
1196 if(! -e $flashFile) |
|
1197 { |
|
1198 print("File $flashFile does not exist! Must be copied manually to '$dstpath'!\n"); |
|
1199 } |
|
1200 else |
|
1201 { |
|
1202 copy($flashFile, $dstpath); |
|
1203 die("Failed to copy '$flashFile' -> '$dstpath'") if(! -e $dstpath); |
|
1204 } |
|
1205 } |
|
1206 my @atsFile; |
|
1207 $atsFile[$ATSFILE_SRC] = $flashfilename; |
|
1208 $atsFile[$ATSFILE_DROPFULL_PATH] = $dropImagePath; |
|
1209 push @$refAtsFiles, [ @atsFile ]; |
|
1210 } |
|
1211 } |
|
1212 |
|
1213 #------------------------------------------------------------------------------------ |
|
1214 # CopyPkgFilesToDrop |
|
1215 # Parameters: |
|
1216 # $filename, pkg file to be read |
|
1217 # $refAtsFiles |
|
1218 # returns 0 if something fails, otherwise 1 |
|
1219 #------------------------------------------------------------------------------------ |
|
1220 sub CopyPkgFilesToDrop |
|
1221 { |
|
1222 my($filename, $refAtsFiles) = @_; |
|
1223 |
|
1224 print("Reading PKG $filename\n") if($paramDebug); |
|
1225 |
|
1226 if( !open(FILE_HANDLE, $filename) ) |
|
1227 { |
|
1228 print("ERROR! Could not open file '" . $filename . "'\n"); |
|
1229 #die( cwd ); |
|
1230 return 0; |
|
1231 } |
|
1232 my @array = <FILE_HANDLE>; |
|
1233 close(FILE_HANDLE); |
|
1234 |
|
1235 mkdir($basePath); |
|
1236 mkdir($basePath . "\\" . $dropFilePath); |
|
1237 mkdir($basePath . "\\" . $dropImagePath); |
|
1238 mkdir($basePath . "\\" . $dropBinaryPath); |
|
1239 |
|
1240 foreach my $line (@array) |
|
1241 { |
|
1242 my $fileCopied = CopyFileToDrop($line, $refAtsFiles); |
|
1243 |
|
1244 # Error, file was not copied and it was under epoc32 directory |
|
1245 if(!$fileCopied and index(lc($line), "\\epoc32\\") != -1) |
|
1246 { |
|
1247 |
|
1248 } |
|
1249 } |
|
1250 |
|
1251 return 1; |
|
1252 } |
|
1253 |
|
1254 #------------------------------------------------------------------------------------ |
|
1255 # CopyFileToDrop |
|
1256 # Parameters: |
|
1257 # $line from pkg |
|
1258 # $refAtsFiles |
|
1259 # $force, file is added to drop even if it does not exist |
|
1260 # returns 0 if something fails, otherwise 1 |
|
1261 #------------------------------------------------------------------------------------ |
|
1262 sub CopyFileToDrop |
|
1263 { |
|
1264 my ($line, $refAtsFiles, $force) = @_; |
|
1265 |
|
1266 my $src; # File location on the workstation |
|
1267 my $dst; # Where file would be installed from SIS |
|
1268 |
|
1269 # Change forward slahes to backward. |
|
1270 $line =~ s/\//\\/g; |
|
1271 |
|
1272 # Lets hope there's only one level change. |
|
1273 #$line =~ s/\.\./\./g; |
|
1274 |
|
1275 # SRC DST |
|
1276 #"\epoc32\data\z\system\data\IptvServiceManagementApiTestIapSelection.cfg" - "c:\TestFramework\IptvServiceManagementApiTestIapSelection.cfg" |
|
1277 |
|
1278 print("\n") if($paramDebug); |
|
1279 |
|
1280 RemoveWhiteSpaces(\$line); |
|
1281 if( index($line, ";") == 0 && !( $line =~ m/testframework.ini/i ) ) |
|
1282 { |
|
1283 print("Skipping, comment: $line\n") if($paramDebug); |
|
1284 return 0; |
|
1285 } |
|
1286 |
|
1287 if( index($line, "\\") == -1 ) |
|
1288 { |
|
1289 print("Skipping, not a file: $line\n") if($paramDebug); |
|
1290 return 0; |
|
1291 } |
|
1292 |
|
1293 if( index($line, "http:\\") != -1 ) |
|
1294 { |
|
1295 print("Skipping, url: $line\n") if($paramDebug); |
|
1296 return 0; |
|
1297 } |
|
1298 |
|
1299 if(substr($line, 0, 9) eq "IF exists") |
|
1300 { |
|
1301 print("Skipping, not a file: $line\n") if($paramDebug); |
|
1302 return 0; |
|
1303 } |
|
1304 |
|
1305 # Solve src |
|
1306 |
|
1307 my $startPos = index($line, "\"")+1; |
|
1308 my $endPos = index($line, "\"", $startPos+1); |
|
1309 |
|
1310 return 0 if($startPos == -1 || $endPos == -1); |
|
1311 |
|
1312 $src = substr($line, $startPos, $endPos - $startPos); |
|
1313 |
|
1314 # We are not in group folder, like the pkg file is written. |
|
1315 if( index( $src, "..\\" ) == 0 ) |
|
1316 { |
|
1317 $src = substr( $src, 3 ); |
|
1318 } |
|
1319 |
|
1320 if($paramFindPkgFilePath ne "") |
|
1321 { |
|
1322 my $newsrc = $paramFindPkgFilePath . "\\" . GetPathFileName($src); |
|
1323 if(-e $newsrc) |
|
1324 { |
|
1325 $src = $newsrc; |
|
1326 } |
|
1327 } |
|
1328 |
|
1329 # Check for forced builds. |
|
1330 if( $paramForcedBuild eq "udeb" && index($src, "\\urel\\") != -1 ) |
|
1331 { |
|
1332 $src =~ s/\\urel\\/\\udeb\\/g; |
|
1333 } |
|
1334 if( $paramForcedBuild eq "urel" && index($src, "\\udeb\\") != -1 ) |
|
1335 { |
|
1336 $src =~ s/\\udeb\\/\\urel\\/g; |
|
1337 } |
|
1338 |
|
1339 print("src $src\n") if($paramDebug); |
|
1340 |
|
1341 # Solve dst |
|
1342 |
|
1343 $startPos = index($line, "\"", $endPos+1)+1; |
|
1344 $endPos = index($line, "\"", $startPos); |
|
1345 |
|
1346 return 0 if($startPos == -1 || $endPos == -1); |
|
1347 |
|
1348 $dst = substr($line, $startPos, $endPos - $startPos); |
|
1349 print("dst $dst\n") if($paramDebug); |
|
1350 |
|
1351 # Resolve copy directory and construct info for the ATS XML |
|
1352 |
|
1353 my @atsFile; |
|
1354 $atsFile[$ATSFILE_NAME] = ""; |
|
1355 $atsFile[$ATSFILE_HARNESS] = "STIF"; |
|
1356 $atsFile[$ATSFILE_ENABLED] = "true"; |
|
1357 $atsFile[$ATSFILE_PASSRATE] = "100"; |
|
1358 $atsFile[$ATSFILE_SIGNIFICANT] = "false"; |
|
1359 $atsFile[$ATSFILE_TYPE] = ""; |
|
1360 $atsFile[$ATSFILE_SRC] = ""; |
|
1361 $atsFile[$ATSFILE_DST] = ""; |
|
1362 $atsFile[$ATSFILE_DROPFULL_PATH] = ""; |
|
1363 $atsFile[$ATSFILE_COMMAND] = "install"; |
|
1364 $atsFile[$ATSFILE_STEP_XML] = $ATSXML_STEP_DEFAULT; |
|
1365 $atsFile[$ATSFILE_STEP_TIMEOUT] = 5000; |
|
1366 |
|
1367 my $copyDest = ""; |
|
1368 |
|
1369 #\Sys\Bin\ |
|
1370 # -> dropBinaryPath |
|
1371 |
|
1372 my $found = 0; |
|
1373 |
|
1374 if(!$found and index(lc($dst), "\\sys\\bin\\") != -1) |
|
1375 { |
|
1376 print(" - Binary\n") if($paramDebug); |
|
1377 |
|
1378 $atsFile[$ATSFILE_NAME] = "Install binary file"; |
|
1379 $atsFile[$ATSFILE_TYPE] = "binary"; |
|
1380 $atsFile[$ATSFILE_DST] = "c:\\sys\\bin\\" . GetPathFileName($dst); |
|
1381 $atsFile[$ATSFILE_STEP_XML] = $ATSXML_STEP_BINARY; |
|
1382 $atsFile[$ATSFILE_DROPFULL_PATH] = $dropBinaryPath; |
|
1383 |
|
1384 $found = 1; |
|
1385 $copyDest = $basePath . "\\" . $dropBinaryPath; |
|
1386 } |
|
1387 |
|
1388 #c:\testing\verifyzip\ |
|
1389 # -> dropFilePath |
|
1390 |
|
1391 if(!$found and index(lc($dst), "c:\\testing\\data\\verifyzip\\") != -1) |
|
1392 { |
|
1393 print(" - Verify\n") if($paramDebug); |
|
1394 $found = 1; |
|
1395 $copyDest = $basePath . "\\" . $dropFilePath; |
|
1396 |
|
1397 $atsFile[$ATSFILE_NAME] = "Install verify file"; |
|
1398 $atsFile[$ATSFILE_DST] = "c:\\testing\\data\\verifyzip\\" . GetPathFileName($dst); |
|
1399 $atsFile[$ATSFILE_DROPFULL_PATH] = $dropFilePath; |
|
1400 } |
|
1401 |
|
1402 #c:\TestFramework\ |
|
1403 # -> dropFilePath |
|
1404 |
|
1405 if(!$found and index(lc($dst), "c:\\testframework\\") != -1) |
|
1406 { |
|
1407 print(" - STIF file\n") if($paramDebug); |
|
1408 if( $src =~ m/init\\TestFramework.ini/i && $paramUseSecondaryIni ) |
|
1409 { |
|
1410 my $secIni = "init\\all\\testframework.ini"; |
|
1411 if( -e $secIni ) |
|
1412 { |
|
1413 $src = $secIni; |
|
1414 } |
|
1415 } |
|
1416 $found = 1; |
|
1417 $copyDest = $basePath . "\\" . $dropFilePath; |
|
1418 |
|
1419 $atsFile[$ATSFILE_NAME] = "Install testscript file"; |
|
1420 $atsFile[$ATSFILE_DST] = "c:\\testframework\\" . GetPathFileName($dst); |
|
1421 $atsFile[$ATSFILE_DROPFULL_PATH] = $dropFilePath; |
|
1422 } |
|
1423 |
|
1424 #c:\ |
|
1425 # -> dropFilePath |
|
1426 |
|
1427 if(!$found and index(lc($dst), "c:\\") != -1 && index(lc($dst), "\\") == rindex(lc($dst), "\\") ) |
|
1428 { |
|
1429 print(" - Other test file\n") if($paramDebug); |
|
1430 $found = 1; |
|
1431 $copyDest = $basePath . "\\" . $dropFilePath; |
|
1432 |
|
1433 $atsFile[$ATSFILE_NAME] = "Install testscript file"; |
|
1434 $atsFile[$ATSFILE_DST] = "c:\\" . GetPathFileName($dst); |
|
1435 $atsFile[$ATSFILE_DROPFULL_PATH] = $dropFilePath; |
|
1436 } |
|
1437 |
|
1438 # All other files |
|
1439 |
|
1440 if(!$found) |
|
1441 { |
|
1442 print(" - Some other file\n") if($paramDebug); |
|
1443 $copyDest = $basePath . "\\" . $dropFilePath; |
|
1444 |
|
1445 $atsFile[$ATSFILE_NAME] = "Install other file"; |
|
1446 $atsFile[$ATSFILE_DROPFULL_PATH] = $dropFilePath; |
|
1447 |
|
1448 $dst =~ s/!:\\/c:\\/g; |
|
1449 $atsFile[$ATSFILE_DST] = $dst; |
|
1450 } |
|
1451 |
|
1452 $copyDest .= GetPathFileName($dst); |
|
1453 print("-> $copyDest\n") if($paramDebug); |
|
1454 |
|
1455 my $error = 0; |
|
1456 if(! -e $src) |
|
1457 { |
|
1458 if(!$force) |
|
1459 { |
|
1460 print("File does not exist: '$src'. File not added.\n"); |
|
1461 $error = 1; |
|
1462 } |
|
1463 else |
|
1464 { |
|
1465 print("File does not exist: '$src'. Must be copied manually!\n"); |
|
1466 } |
|
1467 } |
|
1468 |
|
1469 if( $src =~ m/\.cfg/i && $paramRerunXml ) |
|
1470 { |
|
1471 Rerun_GenerateCfg( $src, $copyDest, \@globalFailedCfgs ); |
|
1472 } |
|
1473 else |
|
1474 { |
|
1475 copy($src, $copyDest); |
|
1476 } |
|
1477 |
|
1478 if(! -e $copyDest and !$error and !$force) |
|
1479 { |
|
1480 print("Copy failed for some reason. '$src' -> '$copyDest'. File not added.\n"); |
|
1481 $error = 1; |
|
1482 } |
|
1483 |
|
1484 return 1 if($error); |
|
1485 |
|
1486 $atsFile[$ATSFILE_SRC] = GetPathFileName($dst); |
|
1487 |
|
1488 if( $atsFile[$ATSFILE_NAME] ne "" and $atsFile[$ATSFILE_SRC] ne "") |
|
1489 { |
|
1490 print("ADDING to ATS files\n\n") if($paramDebug); |
|
1491 push @$refAtsFiles, [ @atsFile ]; |
|
1492 } |
|
1493 |
|
1494 return 1; |
|
1495 } |
|
1496 |
|
1497 #------------------------------------------------------------------------------------ |
|
1498 # GetFailedCasesCountForPkg |
|
1499 # Parameters: |
|
1500 # $filename, pkg file to be read |
|
1501 # $refFailedCfgs |
|
1502 # returns count of failed case for a PKGs cfg files. |
|
1503 #------------------------------------------------------------------------------------ |
|
1504 sub GetFailedCasesCountForPkg |
|
1505 { |
|
1506 my( $filename, $refFailedCfgs ) = @_; |
|
1507 |
|
1508 if( !open(FILE_HANDLE, $filename) ) |
|
1509 { |
|
1510 print("ERROR! Could not open file '" . $filename . "'\n"); |
|
1511 die( cwd ); |
|
1512 } |
|
1513 my @array = <FILE_HANDLE>; |
|
1514 close(FILE_HANDLE); |
|
1515 |
|
1516 my $failedCaseCount = 0; |
|
1517 |
|
1518 foreach my $line (@array) |
|
1519 { |
|
1520 if( $line =~ m/\.cfg/i ) |
|
1521 { |
|
1522 foreach my $cfg( @$refFailedCfgs ) |
|
1523 { |
|
1524 my $cfgFile = @$cfg[0]; |
|
1525 |
|
1526 if( $line =~ m/$cfgFile/i ) |
|
1527 { |
|
1528 my $refCases = @$cfg[1]; |
|
1529 $failedCaseCount += scalar(@$refCases); |
|
1530 } |
|
1531 } |
|
1532 } |
|
1533 } |
|
1534 |
|
1535 return $failedCaseCount; |
|
1536 } |
|
1537 |
|
1538 #------------------------------------------------------------------------------------ |
|
1539 # ExecuteDrop |
|
1540 # Parameters: |
|
1541 # $dropName, $forceNoDelete |
|
1542 #------------------------------------------------------------------------------------ |
|
1543 sub ExecuteDrop |
|
1544 { |
|
1545 my($dropName, $forceNoDelete) = @_; |
|
1546 |
|
1547 if($atsUsername eq "" or $atsPassword eq "") |
|
1548 { |
|
1549 print("User credentials not given as params, drop $basePath must be run manually!\n"); |
|
1550 return; |
|
1551 } |
|
1552 |
|
1553 my $cgidir = GetCgiDir(); |
|
1554 |
|
1555 # Create zip if it doesn't exist. |
|
1556 if(!-e "$dropName.zip") |
|
1557 { |
|
1558 if(!-e "$dropName") |
|
1559 { |
|
1560 die("$dropName.zip or $dropName directory does not exist! Cannot execute.\n"); |
|
1561 } |
|
1562 # Make zip |
|
1563 chdir $dropName; |
|
1564 my $runcmd = "zip -r ..\\$dropName.zip ATS3Drop test.xml"; |
|
1565 print($runcmd . "\n") if($paramVerbose); |
|
1566 $runcmd .= ">NUL" if($paramDebug == 0); |
|
1567 system($runcmd); |
|
1568 chdir ".."; |
|
1569 } |
|
1570 else |
|
1571 { |
|
1572 print("$dropName.zip exists. Executing the drop.\n"); |
|
1573 } |
|
1574 |
|
1575 my $dropDir = cwd; |
|
1576 |
|
1577 # Copy file to network. |
|
1578 |
|
1579 my $dropNetworkPath = "\\\\147.243.252.83\\Groups2\\cats\\"; |
|
1580 my $dropPath = $dropNetworkPath . "$dropName.zip"; |
|
1581 |
|
1582 my $notifyCmdFile = ""; |
|
1583 |
|
1584 print("Copying drop to network...\n"); |
|
1585 if( copy( "$dropName.zip", $dropPath ) ) |
|
1586 { |
|
1587 $notifyCmdFile = "notifydrop_network.cmd"; |
|
1588 } |
|
1589 else |
|
1590 { |
|
1591 print("Could not copy drop to network: $dropPath, sending via web.\n"); |
|
1592 $notifyCmdFile = "notifydrop_local.cmd"; |
|
1593 $dropPath = "$dropDir/$dropName.zip"; |
|
1594 } |
|
1595 # $notifyCmdFile = "notifydrop_local.cmd"; |
|
1596 # $dropPath = "$dropDir/$dropName.zip"; |
|
1597 |
|
1598 # Run the drop |
|
1599 my $runcmd = ""; |
|
1600 my $printcmd = ""; |
|
1601 |
|
1602 $runcmd = "$notifyCmdFile $globalAtsHost $dropPath $atsUsername $atsPassword"; |
|
1603 $printcmd = "$notifyCmdFile $globalAtsHost $dropPath $atsUsername <password>"; |
|
1604 print($printcmd . "\n") if($paramVerbose); |
|
1605 |
|
1606 if(!-e "$cgidir$notifyCmdFile") |
|
1607 { |
|
1608 print("ATS $cgidir$notifyCmdFile is missing!\n"); |
|
1609 } |
|
1610 else |
|
1611 { |
|
1612 chdir( $cgidir ); |
|
1613 system( $runcmd ); |
|
1614 sleep(5); |
|
1615 chdir( $dropDir ); |
|
1616 |
|
1617 # Delete generated files. |
|
1618 if( $paramDontDeleteGeneratedFiles == 0 && $forceNoDelete == 0 ) |
|
1619 { |
|
1620 print("\ndel $dropName.zip\n"); |
|
1621 system("del $dropName.zip"); |
|
1622 |
|
1623 print("rmdir /s /q $dropName\n"); |
|
1624 system("rmdir /s /q $dropName"); |
|
1625 } |
|
1626 } |
|
1627 } |
|
1628 |
|
1629 #------------------------------------------------------------------------------------ |
|
1630 # WriteFileList |
|
1631 # Parameters: |
|
1632 # $refAtsFiles |
|
1633 # $fh |
|
1634 #------------------------------------------------------------------------------------ |
|
1635 sub WriteFileList |
|
1636 { |
|
1637 my ($refAtsFiles, $fh) = @_; |
|
1638 |
|
1639 # Write list of the files |
|
1640 print $fh ("<files>\n"); |
|
1641 foreach my $file (@$refAtsFiles) |
|
1642 { |
|
1643 if( defined( @$file[$ATSFILE_DROPFULL_PATH] ) and defined( @$file[$ATSFILE_SRC] ) ) |
|
1644 { |
|
1645 my $file = @$file[$ATSFILE_DROPFULL_PATH] . @$file[$ATSFILE_SRC]; |
|
1646 print $fh ("<file>$file</file>\n"); |
|
1647 } |
|
1648 } |
|
1649 print $fh ("</files>\n"); |
|
1650 } |
|
1651 |
|
1652 #------------------------------------------------------------------------------------ |
|
1653 # WriteXmlPlanStart |
|
1654 # Parameters: |
|
1655 # $fh |
|
1656 #------------------------------------------------------------------------------------ |
|
1657 sub WriteXmlPlanStart |
|
1658 { |
|
1659 my ($fh, $deviceName) = @_; |
|
1660 |
|
1661 my $data = $ATSXML_PLANSTART; |
|
1662 |
|
1663 my $replacement = "$deviceName - "; |
|
1664 |
|
1665 $replacement .= "$paramCaseClass - " if( $paramCaseClass ); |
|
1666 |
|
1667 if( -e "\\currentRelease.xml" ) |
|
1668 { |
|
1669 if( open(FILE_HANDLE, "\\currentRelease.xml") ) |
|
1670 { |
|
1671 my @lines = <FILE_HANDLE>; |
|
1672 close(FILE_HANDLE); |
|
1673 |
|
1674 foreach my $line ( @lines ) |
|
1675 { |
|
1676 if( $line =~ m/\<release name=\"([[a-z0-9_]+)\"/i ) |
|
1677 { |
|
1678 $replacement .= "$1 - "; |
|
1679 last; |
|
1680 } |
|
1681 } |
|
1682 } |
|
1683 } |
|
1684 |
|
1685 $replacement .= Timestamp(); |
|
1686 |
|
1687 $data =~ s/$ATSXML_TESTPLAN_NAME/$replacement/; |
|
1688 |
|
1689 $replacement = "Session"; |
|
1690 $data =~ s/$ATSXML_TESTSESSION_NAME/$replacement/; |
|
1691 |
|
1692 $replacement = "Set"; |
|
1693 $data =~ s/$ATSXML_TESTSET_NAME/$replacement/; |
|
1694 |
|
1695 $replacement = "Case"; |
|
1696 $data =~ s/$ATSXML_TESTCASE_NAME/$replacement/; |
|
1697 |
|
1698 print $fh ($data); |
|
1699 } |
|
1700 |
|
1701 #------------------------------------------------------------------------------------ |
|
1702 # WriteXmlFormatDrives |
|
1703 # Parameters: |
|
1704 # $fh |
|
1705 #------------------------------------------------------------------------------------ |
|
1706 sub WriteXmlFormatDrives |
|
1707 { |
|
1708 my ($fh) = @_; |
|
1709 |
|
1710 my $data = $ATSXML_FORMAT_DRIVES; |
|
1711 |
|
1712 print $fh ($data); |
|
1713 } |
|
1714 |
|
1715 #------------------------------------------------------------------------------------ |
|
1716 # WriteXmlCreateDirsSteps |
|
1717 # Parameters: |
|
1718 # $fh |
|
1719 #------------------------------------------------------------------------------------ |
|
1720 sub WriteXmlCreateDirsSteps |
|
1721 { |
|
1722 my ($fh) = @_; |
|
1723 |
|
1724 my $data = $ATSXML_CREATEDIRS; |
|
1725 |
|
1726 print $fh ($data); |
|
1727 } |
|
1728 |
|
1729 #------------------------------------------------------------------------------------ |
|
1730 # WriteXmlRunStepsForFile |
|
1731 # Parameters: |
|
1732 # $filename |
|
1733 # $timeout |
|
1734 # $refData |
|
1735 # $fh |
|
1736 #------------------------------------------------------------------------------------ |
|
1737 sub WriteXmlRunStepsForFile |
|
1738 { |
|
1739 my ($filename, $timeout, $refData, $fh) = @_; |
|
1740 |
|
1741 my $data = $$refData; |
|
1742 |
|
1743 my $replacement = $filename; |
|
1744 XmlReadyText(\$replacement); |
|
1745 $data =~ s/$ATSXML_STEP_NAME/$replacement/; |
|
1746 |
|
1747 print("Run step for '" . $filename . "'\n") if($paramVerbose); |
|
1748 |
|
1749 $replacement = "C:\\testframework\\" . $filename; |
|
1750 XmlReadyText(\$replacement); |
|
1751 $data =~ s/$ATSXML_STEP_RUNCASES_FILENAME/$replacement/; |
|
1752 |
|
1753 $replacement = $timeout; |
|
1754 XmlReadyText(\$replacement); |
|
1755 $data =~ s/$ATSXML_STEP_RUNCASES_TIMEOUT/$replacement/; |
|
1756 |
|
1757 print $fh ($data); |
|
1758 } |
|
1759 |
|
1760 #------------------------------------------------------------------------------------ |
|
1761 # WriteXmlRunStepsForCases |
|
1762 # Parameters: |
|
1763 # $refCaseList |
|
1764 # $fh |
|
1765 #------------------------------------------------------------------------------------ |
|
1766 sub WriteXmlRunStepsForCases |
|
1767 { |
|
1768 my ($refCaseList, $fh) = @_; |
|
1769 |
|
1770 my $caseCount = 0; |
|
1771 my $currCfgFileName = ""; |
|
1772 |
|
1773 foreach my $line (@$refCaseList) |
|
1774 { |
|
1775 my $cmd; |
|
1776 my $param; |
|
1777 my $pos = index($line, " "); |
|
1778 die("Case list file should have format: [cfg/case] [filename/casename]!\n") if($pos == -1); |
|
1779 $cmd = substr($line, 0, $pos); |
|
1780 $pos += 1; |
|
1781 $param = substr($line, $pos, length($line) - $pos - 1); |
|
1782 |
|
1783 if($cmd eq "cfg") |
|
1784 { |
|
1785 $currCfgFileName = $param; |
|
1786 } |
|
1787 else |
|
1788 { |
|
1789 die("Case list file first line must be 'cfg [filename]'!") if($currCfgFileName eq ""); |
|
1790 |
|
1791 my $data = $ATSXML_STEP_RUNCASE; |
|
1792 |
|
1793 #$replacement = "Case $caseCount"; |
|
1794 my $replacement = $param; |
|
1795 XmlReadyText(\$replacement); |
|
1796 $data =~ s/$ATSXML_STEP_NAME/$replacement/; |
|
1797 $caseCount++; |
|
1798 |
|
1799 $replacement = "c:\\testframework\\$currCfgFileName"; |
|
1800 XmlReadyText(\$replacement); |
|
1801 $data =~ s/$ATSXML_STEP_RUNCASE_FILENAME/$replacement/; |
|
1802 |
|
1803 $replacement = "$param"; |
|
1804 XmlReadyText(\$replacement); |
|
1805 $data =~ s/$ATSXML_STEP_RUNCASE_CASENAME/$replacement/; |
|
1806 |
|
1807 print $fh ($data); |
|
1808 } |
|
1809 |
|
1810 } |
|
1811 } |
|
1812 |
|
1813 #------------------------------------------------------------------------------------ |
|
1814 # WriteXmlFetchSteps |
|
1815 # Parameters: |
|
1816 # $refAtsFiles |
|
1817 # $fh |
|
1818 #------------------------------------------------------------------------------------ |
|
1819 sub WriteXmlFetchSteps |
|
1820 { |
|
1821 my ($fh) = @_; |
|
1822 |
|
1823 # |
|
1824 # Fetch logs etc. 5 steps |
|
1825 # |
|
1826 |
|
1827 my $data = $ATSXML_FETCH_STEPS; |
|
1828 my $replacement = ""; |
|
1829 |
|
1830 print $fh ($data); |
|
1831 |
|
1832 if($paramCTC) |
|
1833 { |
|
1834 $data = $ATSXML_CTCWRITE_STEP; |
|
1835 $data =~ s/$ATSXML_CTC_PATH/$globalCtcExePath/; |
|
1836 print $fh ($data); |
|
1837 |
|
1838 WriteXmlFetchStep($fh, "c:\\data\\ctc\\ctcdata.txt"); |
|
1839 } |
|
1840 } |
|
1841 |
|
1842 |
|
1843 #------------------------------------------------------------------------------------ |
|
1844 # WriteXmlFetchStep |
|
1845 # Parameters: |
|
1846 # $refAtsFiles |
|
1847 # $fh |
|
1848 #------------------------------------------------------------------------------------ |
|
1849 sub WriteXmlFetchStep |
|
1850 { |
|
1851 my ($fh, $path) = @_; |
|
1852 |
|
1853 my $data = $ATSXML_FETCH_STEP; |
|
1854 |
|
1855 $data =~ s/$ATSXML_FETCH_PATH/$path/; |
|
1856 |
|
1857 print $fh ($data); |
|
1858 } |
|
1859 |
|
1860 #------------------------------------------------------------------------------------ |
|
1861 # WriteXmlInstallationSteps |
|
1862 # Parameters: |
|
1863 # $refAtsFiles |
|
1864 # $fh |
|
1865 #------------------------------------------------------------------------------------ |
|
1866 sub WriteXmlInstallationSteps |
|
1867 { |
|
1868 my ($refAtsFiles, $fh) = @_; |
|
1869 |
|
1870 if($paramDebug) |
|
1871 { |
|
1872 print("ATS install file count: " . scalar( @$refAtsFiles ) . "\n") if($paramDebug); |
|
1873 } |
|
1874 |
|
1875 my $replacement = ""; |
|
1876 |
|
1877 foreach my $file( @$refAtsFiles ) |
|
1878 { |
|
1879 next if( !defined( @$file[$ATSFILE_STEP_XML] ) ); |
|
1880 |
|
1881 my $data = @$file[$ATSFILE_STEP_XML]; |
|
1882 |
|
1883 if( $data =~ m/$ATSXML_STEP_NAME/ ) |
|
1884 { |
|
1885 die("ATSFILE_NAME is not defined!") if( !defined( @$file[$ATSFILE_NAME] ) ); |
|
1886 $replacement = @$file[$ATSFILE_NAME]; |
|
1887 XmlReadyText(\$replacement); |
|
1888 $data =~ s/$ATSXML_STEP_NAME/$replacement/; |
|
1889 } |
|
1890 |
|
1891 if( $data =~ m/$ATSXML_STEP_HARNESS/ ) |
|
1892 { |
|
1893 die("ATSFILE_HARNESS is not defined!") if( !defined( @$file[$ATSFILE_HARNESS] ) ); |
|
1894 $replacement = @$file[$ATSFILE_HARNESS]; |
|
1895 XmlReadyText(\$replacement); |
|
1896 $data =~ s/$ATSXML_STEP_HARNESS/$replacement/; |
|
1897 } |
|
1898 |
|
1899 if( $data =~ m/$ATSXML_STEP_ENABLED/ ) |
|
1900 { |
|
1901 die("ATSFILE_ENABLED is not defined!") if( !defined( @$file[$ATSFILE_ENABLED] ) ); |
|
1902 $replacement = @$file[$ATSFILE_ENABLED]; |
|
1903 XmlReadyText(\$replacement); |
|
1904 $data =~ s/$ATSXML_STEP_ENABLED/$replacement/; |
|
1905 } |
|
1906 |
|
1907 if( $data =~ m/$ATSXML_STEP_PASSRATE/ ) |
|
1908 { |
|
1909 die("ATSFILE_PASSRATE is not defined!") if( !defined( @$file[$ATSFILE_PASSRATE] ) ); |
|
1910 $replacement = @$file[$ATSFILE_PASSRATE]; |
|
1911 XmlReadyText(\$replacement); |
|
1912 $data =~ s/$ATSXML_STEP_PASSRATE/$replacement/; |
|
1913 } |
|
1914 |
|
1915 if( $data =~ m/$ATSXML_STEP_SIGNIFICANT/ ) |
|
1916 { |
|
1917 die("ATSFILE_SIGNIFICANT is not defined!") if( !defined( @$file[$ATSFILE_SIGNIFICANT] ) ); |
|
1918 $replacement = @$file[$ATSFILE_SIGNIFICANT]; |
|
1919 XmlReadyText(\$replacement); |
|
1920 $data =~ s/$ATSXML_STEP_SIGNIFICANT/$replacement/; |
|
1921 } |
|
1922 |
|
1923 if( $data =~ m/$ATSXML_STEP_PARAM_TYPE/ ) |
|
1924 { |
|
1925 die("ATSFILE_TYPE is not defined!") if( !defined( @$file[$ATSFILE_TYPE] ) ); |
|
1926 $replacement = @$file[$ATSFILE_TYPE]; |
|
1927 XmlReadyText(\$replacement); |
|
1928 $data =~ s/$ATSXML_STEP_PARAM_TYPE/$replacement/; |
|
1929 } |
|
1930 |
|
1931 if( $data =~ m/$ATSXML_STEP_PARAM_SRC/ ) |
|
1932 { |
|
1933 die("ATSFILE_NAME is not defined!") if( !defined( @$file[$ATSFILE_SRC] ) ); |
|
1934 $replacement = @$file[$ATSFILE_SRC]; |
|
1935 XmlReadyText(\$replacement); |
|
1936 $data =~ s/$ATSXML_STEP_PARAM_SRC/$replacement/; |
|
1937 } |
|
1938 |
|
1939 if( $data =~ m/$ATSXML_STEP_PARAM_DST/ ) |
|
1940 { |
|
1941 die("ATSFILE_DST is not defined!") if( !defined( @$file[$ATSFILE_DST] ) ); |
|
1942 $replacement = @$file[$ATSFILE_DST]; |
|
1943 XmlReadyText(\$replacement); |
|
1944 $data =~ s/$ATSXML_STEP_PARAM_DST/$replacement/; |
|
1945 } |
|
1946 |
|
1947 if( $data =~ m/$ATSXML_STEP_COMMAND/ ) |
|
1948 { |
|
1949 die("ATSFILE_COMMAND is not defined!") if( !defined( @$file[$ATSFILE_COMMAND] ) ); |
|
1950 $replacement = @$file[$ATSFILE_COMMAND]; |
|
1951 XmlReadyText(\$replacement); |
|
1952 $data =~ s/$ATSXML_STEP_COMMAND/$replacement/; |
|
1953 } |
|
1954 |
|
1955 if( $data =~ m/$ATSXML_STEP_TIMEOUT/ ) |
|
1956 { |
|
1957 die("ATSFILE_STEP_TIMEOUT is not defined!") if( !defined( @$file[$ATSFILE_STEP_TIMEOUT] ) ); |
|
1958 $replacement = @$file[$ATSFILE_STEP_TIMEOUT]; |
|
1959 XmlReadyText(\$replacement); |
|
1960 $data =~ s/$ATSXML_STEP_TIMEOUT/$replacement/; |
|
1961 } |
|
1962 |
|
1963 print $fh ($data); |
|
1964 } |
|
1965 } |
|
1966 |
|
1967 #------------------------------------------------------------------------------------ |
|
1968 # GetNextPlanId |
|
1969 #------------------------------------------------------------------------------------ |
|
1970 sub GetNextPlanId |
|
1971 { |
|
1972 $currentPlanId++; |
|
1973 my $id = "1.$currentPlanId"; |
|
1974 |
|
1975 $currentSessionId = 0; |
|
1976 $currentSetId = 0; |
|
1977 $currentCaseId = 0; |
|
1978 $currentStepId = 0; |
|
1979 |
|
1980 return $id; |
|
1981 } |
|
1982 |
|
1983 #------------------------------------------------------------------------------------ |
|
1984 # GetNextSessionId |
|
1985 #------------------------------------------------------------------------------------ |
|
1986 sub GetNextSessionId |
|
1987 { |
|
1988 $currentSessionId++; |
|
1989 my $id = "1.$currentPlanId.$currentSessionId"; |
|
1990 return $id; |
|
1991 } |
|
1992 |
|
1993 #------------------------------------------------------------------------------------ |
|
1994 # GetNextSetId |
|
1995 #------------------------------------------------------------------------------------ |
|
1996 sub GetNextSetId |
|
1997 { |
|
1998 $currentSetId++; |
|
1999 my $id = "1.$currentPlanId.$currentSessionId.$currentSetId"; |
|
2000 return $id; |
|
2001 } |
|
2002 |
|
2003 #------------------------------------------------------------------------------------ |
|
2004 # GetNextCaseId |
|
2005 #------------------------------------------------------------------------------------ |
|
2006 sub GetNextCaseId |
|
2007 { |
|
2008 $currentCaseId++; |
|
2009 my $id = "1.$currentPlanId.$currentSessionId.$currentSetId.$currentCaseId"; |
|
2010 return $id; |
|
2011 } |
|
2012 |
|
2013 #------------------------------------------------------------------------------------ |
|
2014 # GetNextStepId |
|
2015 #------------------------------------------------------------------------------------ |
|
2016 sub GetNextStepId |
|
2017 { |
|
2018 $currentStepId++; |
|
2019 my $id = "1.$currentPlanId.$currentSessionId.$currentSetId.$currentCaseId.$currentStepId"; |
|
2020 return $id; |
|
2021 } |
|
2022 |
|
2023 #------------------------------------------------------------------------------------ |
|
2024 # Timestamp |
|
2025 # |
|
2026 # Parameters: |
|
2027 #------------------------------------------------------------------------------------ |
|
2028 sub Timestamp |
|
2029 { |
|
2030 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time); |
|
2031 |
|
2032 $mday = "0$mday" if( length($mday) < 2 ); |
|
2033 $hour = "0$hour" if( length($hour) < 2 ); |
|
2034 $min = "0$min" if( length($min) < 2 ); |
|
2035 |
|
2036 return "" . ($year+1900) . "-" . ($mon+1) . "-" . $mday . " " . $hour . ":" . $min; |
|
2037 } |
|
2038 |
|
2039 #------------------------------------------------------------------------------------ |
|
2040 # InitXml |
|
2041 # |
|
2042 # Parameters: |
|
2043 #------------------------------------------------------------------------------------ |
|
2044 sub InitXml |
|
2045 { |
|
2046 |
|
2047 $ATSXML_HEADER_START = |
|
2048 #"<?xml version=\"1.0\"?>\n" . |
|
2049 "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>" . |
|
2050 "<test>\n" . |
|
2051 "<priority>ATSXML_DROPPRIORITY</priority>" . |
|
2052 " <id>1</id>\n" . |
|
2053 " <name>ATSXML_TESTNAME</name>\n" . |
|
2054 " <target>\n" . |
|
2055 " <device rank=\"none\" alias=\"DEFAULT\">\n" . |
|
2056 " <property name=\"HARNESS\" value=\"STIF\" />\n" . |
|
2057 " <property name=\"TYPE\" value=\"ATSXML_TESTDEVICE\" />\n"; |
|
2058 |
|
2059 $ATSXML_HEADER_END = |
|
2060 " </device>\n" . |
|
2061 " </target>\n"; |
|
2062 |
|
2063 $ATSXML_PLANSTART = |
|
2064 " <plan name=\"ATSXML_TESTPLAN_NAME\" harness=\"STIF\" enabled=\"true\" passrate=\"100\">\n" . |
|
2065 " <session name=\"ATSXML_TESTSESSION_NAME\" harness=\"STIF\" enabled=\"true\" passrate=\"100\">\n" . |
|
2066 " <set name=\"ATSXML_TESTSET_NAME\" harness=\"STIF\" enabled=\"true\" passrate=\"100\">\n" . |
|
2067 " <target>\n" . |
|
2068 " <device rank=\"master\" alias=\"DEFAULT\"/>\n" . |
|
2069 " </target>\n" . |
|
2070 " <case name=\"ATSXML_TESTCASE_NAME\" harness=\"STIF\" enabled=\"true\" passrate=\"100\">\n"; |
|
2071 |
|
2072 |
|
2073 $ATSXML_FLASH = " <flash target-alias=\"DEFAULT\" images=\"ATS3Drop/images/ATSXML_FLASH_IMAGE_NAME\" />\n"; |
|
2074 |
|
2075 $ATSXML_FORMAT_DRIVES = |
|
2076 " <step name=\"Format drive E\" harness=\"STIF\" enabled=\"true\" passrate=\"100\" significant=\"false\">\n" . |
|
2077 " <command>format</command>\n" . |
|
2078 " <params>\n" . |
|
2079 " <param drive=\"e\"/>" . |
|
2080 " <param mode=\"quick\"/>\n" . |
|
2081 " </params>\n" . |
|
2082 " </step>\n" . |
|
2083 " <step name=\"Format drive F\" harness=\"STIF\" enabled=\"true\" passrate=\"100\" significant=\"false\">\n" . |
|
2084 " <command>format</command>\n" . |
|
2085 " <params>\n" . |
|
2086 " <param drive=\"f\"/>" . |
|
2087 " <param mode=\"quick\"/>\n" . |
|
2088 " </params>\n" . |
|
2089 " </step>\n" . |
|
2090 " <step name=\"Format drive G\" harness=\"STIF\" enabled=\"true\" passrate=\"100\" significant=\"false\">\n" . |
|
2091 " <command>format</command>\n" . |
|
2092 " <params>\n" . |
|
2093 " <param drive=\"g\"/>" . |
|
2094 " <param mode=\"quick\"/>\n" . |
|
2095 " </params>\n" . |
|
2096 " </step>\n"; |
|
2097 |
|
2098 $ATSXML_CREATEDIRS = |
|
2099 " <step name=\"Create log directory for testmodule\" harness=\"STIF\" enabled=\"true\" passrate=\"100\" significant=\"false\">\n" . |
|
2100 " <command>makedir</command>\n" . |
|
2101 " <params>\n" . |
|
2102 " <param dir=\"c:\\logs\\testframework\"/>\n" . |
|
2103 " </params>\n" . |
|
2104 " </step>\n" . |
|
2105 " <step name=\"Create log directory for iptvlogs\" harness=\"STIF\" enabled=\"true\" passrate=\"100\" significant=\"false\">\n" . |
|
2106 " <command>makedir</command>\n" . |
|
2107 " <params>\n" . |
|
2108 " <param dir=\"c:\\logs\\Fusion\"/>\n" . |
|
2109 " </params>\n" . |
|
2110 " </step>\n" . |
|
2111 " <step name=\"Create log directory for livetvlogs\" harness=\"STIF\" enabled=\"true\" passrate=\"100\" significant=\"false\">\n" . |
|
2112 " <command>makedir</command>\n" . |
|
2113 " <params>\n" . |
|
2114 " <param dir=\"c:\\logs\\Livetv\"/>\n" . |
|
2115 " </params>\n" . |
|
2116 " </step>\n" . |
|
2117 " <step name=\"Create directory for verify files\" harness=\"STIF\" enabled=\"true\" passrate=\"100\" significant=\"false\">\n" . |
|
2118 " <command>makedir</command>\n" . |
|
2119 " <params>\n" . |
|
2120 " <param dir=\"c:\\testing\\data\\verifyzip\"/>\n" . |
|
2121 " </params>\n" . |
|
2122 " </step>\n" . |
|
2123 " <step name=\"Create directory for verify files\" harness=\"STIF\" enabled=\"true\" passrate=\"100\" significant=\"false\">\n" . |
|
2124 " <command>makedir</command>\n" . |
|
2125 " <params>\n" . |
|
2126 " <param dir=\"c:\\testing\\data\\verifynew\"/>\n" . |
|
2127 " </params>\n" . |
|
2128 " </step>\n" . |
|
2129 " <step name=\"Create directory for TestScripter logs\" harness=\"STIF\" enabled=\"true\" passrate=\"100\" significant=\"false\">\n" . |
|
2130 " <command>makedir</command>\n" . |
|
2131 " <params>\n" . |
|
2132 " <param dir=\"c:\\logs\\testframework\\TestScripter\"/>\n" . |
|
2133 " </params>\n" . |
|
2134 " </step>\n"; |
|
2135 |
|
2136 $ATSXML_PLANEND = |
|
2137 " </case>\n" . |
|
2138 " </set>\n" . |
|
2139 " </session>\n" . |
|
2140 " </plan>\n"; |
|
2141 |
|
2142 |
|
2143 $ATSXML_FOOTER = |
|
2144 "<postAction>\n" . |
|
2145 " <type>SendEmailAction</type>\n" . |
|
2146 " <params>\n" . |
|
2147 " <param name='type' value='ATS3_REPORT'/>\n" . |
|
2148 " <param name='to' value='ATSXML_EMAIL'/>\n" . |
|
2149 " <param name='subject' value='ATS3 Report - ATSXML_TESTNAME'/>\n" . |
|
2150 " <param name='send-files' value='true'/>\n" . |
|
2151 " </params>\n" . |
|
2152 " </postAction>\n" . |
|
2153 "</test>\n"; |
|
2154 |
|
2155 $ATSXML_STEP_DEFAULT = |
|
2156 " <step name=\"ATSXML_STEP_NAME\" harness=\"ATSXML_STEP_HARNESS\" enabled=\"ATSXML_STEP_ENABLED\" passrate=\"ATSXML_STEP_PASSRATE\" significant=\"ATSXML_STEP_SIGNIFICANT\">\n" . |
|
2157 " <command>ATSXML_STEP_COMMAND</command>\n" . |
|
2158 " <params>\n" . |
|
2159 " <param src=\"ATSXML_STEP_PARAM_SRC\"/>\n" . |
|
2160 " <param dst=\"ATSXML_STEP_PARAM_DST\"/>\n" . |
|
2161 #" <param component-path=\"ATSXML_STEP_PARAM_COMPONENT_PATH\"/>\n" . |
|
2162 " </params>\n" . |
|
2163 " </step>\n"; |
|
2164 |
|
2165 $ATSXML_STEP_BINARY = |
|
2166 " <step name=\"ATSXML_STEP_NAME\" harness=\"ATSXML_STEP_HARNESS\" enabled=\"ATSXML_STEP_ENABLED\" passrate=\"ATSXML_STEP_PASSRATE\" significant=\"ATSXML_STEP_SIGNIFICANT\">\n" . |
|
2167 " <command>ATSXML_STEP_COMMAND</command>\n" . |
|
2168 " <params>\n" . |
|
2169 " <param type=\"ATSXML_STEP_PARAM_TYPE\"/>\n" . |
|
2170 " <param src=\"ATSXML_STEP_PARAM_SRC\"/>\n" . |
|
2171 " <param dst=\"ATSXML_STEP_PARAM_DST\"/>\n" . |
|
2172 #" <param component-path=\"ATSXML_STEP_PARAM_COMPONENT_PATH\"/>\n" . |
|
2173 " </params>\n" . |
|
2174 " </step>\n"; |
|
2175 |
|
2176 $ATSXML_STEP_RUNCASES = |
|
2177 " <step name=\"ATSXML_STEP_NAME\" harness=\"STIF\" enabled=\"true\" passrate=\"100\" significant=\"true\">\n" . |
|
2178 " <command>run-cases</command>\n" . |
|
2179 " <params>\n" . |
|
2180 " <param module=\"TestScripter\"/>\n" . |
|
2181 " <param testcase-file=\"ATSXML_STEP_RUNCASES_FILENAME\"/>\n" . |
|
2182 " <param filter=\"*\"/>\n" . |
|
2183 " <param timeout=\"ATSXML_STEP_RUNCASES_TIMEOUT\"/>\n" . |
|
2184 " <param component-path=\"ATS3Drop\"/>\n" . |
|
2185 " </params>\n" . |
|
2186 " </step>\n"; |
|
2187 |
|
2188 $ATSXML_STEP_RUNCASES_WITH_BOOT = |
|
2189 " <step name=\"ATSXML_STEP_NAME\" harness=\"STIF\" enabled=\"true\" passrate=\"100\" significant=\"true\">\n" . |
|
2190 " <command>run-cases</command>\n" . |
|
2191 " <reboot target-alias=\"*\" when=\"before\"/>\n" . |
|
2192 " <params>\n" . |
|
2193 " <param module=\"TestScripter\"/>\n" . |
|
2194 " <param testcase-file=\"ATSXML_STEP_RUNCASES_FILENAME\"/>\n" . |
|
2195 " <param filter=\"*\"/>\n" . |
|
2196 " <param timeout=\"ATSXML_STEP_RUNCASES_TIMEOUT\"/>\n" . |
|
2197 " <param component-path=\"ATS3Drop\"/>\n" . |
|
2198 " </params>\n" . |
|
2199 " </step>\n"; |
|
2200 |
|
2201 $ATSXML_STEP_RUNCASES_INI = |
|
2202 " <step name=\"ATSXML_STEP_NAME\" harness=\"STIF\" enabled=\"true\" passrate=\"100\" significant=\"true\">\n" . |
|
2203 " <command>run-cases</command>\n" . |
|
2204 " <params>\n" . |
|
2205 " <param engineini=\"ATSXML_STEP_RUNCASES_FILENAME\"/>\n" . |
|
2206 " <param filter=\"*\"/>\n" . |
|
2207 " <param timeout=\"ATSXML_STEP_RUNCASES_TIMEOUT\"/>\n" . |
|
2208 " <param repeat=\"1\"/>\n" . |
|
2209 " </params>\n" . |
|
2210 " </step>\n"; |
|
2211 |
|
2212 $ATSXML_STEP_RUNCASES_INI_WITH_BOOT = |
|
2213 " <step name=\"ATSXML_STEP_NAME\" harness=\"STIF\" enabled=\"true\" passrate=\"100\" significant=\"true\">\n" . |
|
2214 " <command>run-cases</command>\n" . |
|
2215 " <reboot target-alias=\"*\" when=\"before\" />\n" . |
|
2216 " <params>\n" . |
|
2217 " <param engineini=\"ATSXML_STEP_RUNCASES_FILENAME\"/>\n" . |
|
2218 " <param filter=\"*\"/>\n" . |
|
2219 " <param timeout=\"ATSXML_STEP_RUNCASES_TIMEOUT\"/>\n" . |
|
2220 " <param repeat=\"1\"/>\n" . |
|
2221 " </params>\n" . |
|
2222 " </step>\n"; |
|
2223 |
|
2224 |
|
2225 $ATSXML_STEP_RUNCASE = |
|
2226 " <step name=\"ATSXML_STEP_NAME\" harness=\"STIF\" enabled=\"true\" passrate=\"100\" significant=\"true\">\n" . |
|
2227 " <command>run-case</command>\n" . |
|
2228 " <params>\n" . |
|
2229 " <param module=\"TestScripter\"/>\n" . |
|
2230 " <param testcase-file=\"ATSXML_STEP_RUNCASE_FILENAME\"/>\n" . |
|
2231 " <param id=\"ATSXML_STEP_RUNCASE_CASENAME\"/>\n" . |
|
2232 " <param timeout=\"600\"/>\n" . |
|
2233 " </params>\n" . |
|
2234 " </step>\n"; |
|
2235 |
|
2236 $ATSXML_STEP_INSTALLSIS = |
|
2237 " <step name=\"Install SIS\" harness=\"STIF\" enabled=\"true\" passrate=\"100\" significant=\"false\">\n" . |
|
2238 " <command>install-software</command>\n" . |
|
2239 " <params>\n" . |
|
2240 " <param sisPackageName=\"ATSXML_STEP_PARAM_SRC\"/>\n" . |
|
2241 " <param upgradeAllowed=\"true\"/>\n" . |
|
2242 " <param optionalItemsAllowed=\"true\"/>\n" . |
|
2243 " <param OCSP_Done=\"true\"/>\n" . |
|
2244 " <param ignoreOCSPWarnings=\"true\"/>\n" . |
|
2245 " <param untrustedAllowed=\"true\"/>\n" . |
|
2246 " <param packageInfoAllowed=\"true\"/>\n" . |
|
2247 " <param userCapGranted=\"true\"/>\n" . |
|
2248 " <param killApp=\"true\"/>\n" . |
|
2249 " <param overWriteAllowed=\"true\"/>\n" . |
|
2250 " <param downloadAllowed=\"false\"/>\n" . |
|
2251 "<!-- <param downloadUsername=\"user\"/>-->\n" . |
|
2252 "<!-- <param downloadPassword=\"passwd\"/>-->\n" . |
|
2253 " <param installDrive=\"C\"/>\n" . |
|
2254 " <param upgradeData=\"true\"/>\n" . |
|
2255 " <param timeout=\"ATSXML_STEP_TIMEOUT\"/>\n" . |
|
2256 " </params>\n" . |
|
2257 " </step>\n"; |
|
2258 |
|
2259 $ATSXML_FETCH_STEPS = |
|
2260 " <step name=\"Fetch Test module Report\" harness=\"STIF\" enabled=\"true\" passrate=\"100\" significant=\"false\">\n" . |
|
2261 " <command>fetch-log</command>\n" . |
|
2262 " <params>\n" . |
|
2263 " <param type=\"text\"/>\n" . |
|
2264 " <param delete=\"true\"/>\n" . |
|
2265 " <param path=\"C:\\Logs\\TestFramework\\*\"/>\n" . |
|
2266 " </params>\n" . |
|
2267 " </step>\n" . |
|
2268 " <step name=\"Fetch TestScripter logs\" harness=\"STIF\" enabled=\"true\" passrate=\"100\" significant=\"false\">\n" . |
|
2269 " <command>fetch-log</command>\n" . |
|
2270 " <params>\n" . |
|
2271 " <param type=\"text\"/>\n" . |
|
2272 " <param delete=\"true\"/>\n" . |
|
2273 " <param path=\"C:\\Logs\\TestFramework\\TestScripter\\*\"/>\n" . |
|
2274 " </params>\n" . |
|
2275 " </step>\n"; |
|
2276 |
|
2277 $ATSXML_FETCH_STEP = |
|
2278 " <step name=\"Fetch Test module Report\" harness=\"STIF\" enabled=\"true\" passrate=\"100\" significant=\"false\">\n" . |
|
2279 " <command>fetch-log</command>\n" . |
|
2280 " <params>\n" . |
|
2281 " <param type=\"text\"/>\n" . |
|
2282 " <param delete=\"true\"/>\n" . |
|
2283 " <param path=\"ATSXML_FETCH_PATH\"/>\n" . |
|
2284 " </params>\n" . |
|
2285 " </step>\n"; |
|
2286 |
|
2287 $ATSXML_CTCWRITE_STEP = |
|
2288 " <step name=\"Save CTC data\" harness=\"STIF\" enabled=\"true\" passrate=\"100\" significant=\"false\">\n" . |
|
2289 " <command>execute</command>\n" . |
|
2290 " <params>\n" . |
|
2291 " <param parameters=\"writefile\"/>\n" . |
|
2292 " <param file=\"ATSXML_CTC_PATH\"/>\n" . |
|
2293 " </params>\n" . |
|
2294 " </step>\n"; |
|
2295 |
|
2296 $ATSXML_POSTACTION = |
|
2297 " <postAction>" . |
|
2298 " <type>FileStoreAction</type>" . |
|
2299 " <params>" . |
|
2300 #" <param name=\"to-folder\" value=\"\\someserver\somefolder\§RUN_NAME§\"/>" . |
|
2301 " <param name=\"to-folder\" value=\"\\\\oucifs1\\cp_sw\\programs\\video_applications_stream\\iptv\\testing\\CI_reports\\§RUN_START_DATE§_§RUN_START_TIME§_§RUN_NAME§\"/>" . |
|
2302 " <param name=\"report type\" value=\"STIF_COMPONENT_REPORT_ALL_CASES\"/>" . |
|
2303 " </params>" . |
|
2304 " </postAction>"; |
|
2305 |
|
2306 } |
|
2307 |
|
2308 |
|
2309 |
|
2310 sub GetCgiDir |
|
2311 { |
|
2312 # Solve where the script is located. |
|
2313 $0=~/^(.+[\\\/])[^\\\/]+[\\\/]*$/; |
|
2314 my $cgidir= $1 || "./"; |
|
2315 |
|
2316 # And try to solve relative path. |
|
2317 if( index( $cgidir, "..\\" ) != -1 ) |
|
2318 { |
|
2319 my $p = cwd; |
|
2320 $p =~ s/\//\\/g; |
|
2321 $cgidir =~ s/\//\\/g; |
|
2322 while(1) |
|
2323 { |
|
2324 my $pos = index( $cgidir, "..\\" ); |
|
2325 last if( $pos == -1 ); |
|
2326 $cgidir = substr( $cgidir, $pos+3 ); |
|
2327 |
|
2328 $pos = rindex( $p, "\\" ); |
|
2329 last if( $pos == -1 ); |
|
2330 $p = substr( $p, 0, $pos); |
|
2331 } |
|
2332 $cgidir = $p . "\\" . $cgidir; |
|
2333 } |
|
2334 return $cgidir; |
|
2335 } |
|
2336 |
|
2337 |
|
2338 |
|
2339 #------------------------------------------------------------------------------------ |
|
2340 # FindFiles |
|
2341 # Parameters: |
|
2342 # $goDir, where to start finding |
|
2343 # $fileSearch, filename search |
|
2344 # $searchType, 0 = fullname search, 1 = filetype search |
|
2345 # $refIncfiles, reference to array which will hold found files |
|
2346 #------------------------------------------------------------------------------------ |
|
2347 sub FindFiles |
|
2348 { |
|
2349 my ($godir, $fileSearch, $searchType, $refIncfiles) = @_; |
|
2350 |
|
2351 my $startDir = cwd; |
|
2352 |
|
2353 chdir($godir); |
|
2354 |
|
2355 #print("Now in: " . cwd . "\n"); |
|
2356 |
|
2357 opendir(DIR, "."); |
|
2358 my @filelist = sort(readdir(DIR)); |
|
2359 closedir(DIR); |
|
2360 |
|
2361 foreach my $file(@filelist) |
|
2362 { |
|
2363 if($file eq "." or $file eq "..") {next}; |
|
2364 |
|
2365 if (-d $file) |
|
2366 { |
|
2367 FindFiles( $file, $fileSearch, $searchType, $refIncfiles); |
|
2368 } else |
|
2369 { |
|
2370 if( ($file =~ m/$fileSearch/i and $searchType == 0 ) or ($file =~ m/$fileSearch$/i and $searchType == 1 ) ) |
|
2371 { |
|
2372 $file = cwd . "/" . $file; |
|
2373 push @$refIncfiles, $file; |
|
2374 #print("$file\n"); |
|
2375 } |
|
2376 } |
|
2377 } |
|
2378 |
|
2379 chdir ($startDir); |
|
2380 } |