@@ -1,84 +1,90 | |||
|
1 | 1 | use Cwd; |
|
2 | 2 | use Cwd 'abs_path'; |
|
3 | 3 | use File::Basename; |
|
4 | 4 | use File::Copy; |
|
5 | 5 | use feature "switch"; |
|
6 | 6 | use lib 'test/scripts'; |
|
7 | 7 | use Jobs; |
|
8 | 8 | |
|
9 | 9 | # read command line params |
|
10 | 10 | my $jobname = shift; |
|
11 | 11 | |
|
12 | 12 | # read ini file |
|
13 | 13 | my $inifile = File::Basename::dirname($0) . "/jobs.ini"; |
|
14 | 14 | my %job = Jobs::get($inifile, $jobname); |
|
15 | 15 | |
|
16 | 16 | # set/get paths |
|
17 | 17 | my $root_path = abs_path(); |
|
18 | 18 | my $bin_path = "$root_path/bin/"; |
|
19 | 19 | my $reports_path = "test-reports"; |
|
20 | 20 | |
|
21 | 21 | # create reports path |
|
22 | 22 | mkdir $reports_path; |
|
23 | 23 | |
|
24 | 24 | # setup environment for running tests |
|
25 | 25 | given ($job{'Platform'}) { |
|
26 | 26 | |
|
27 | 27 | when ("Win7") { |
|
28 | $ENV{'PATH'} .= ";" . $job{'QtDir'} . "\\bin"; # Add qtdir to path | |
|
29 | $ENV{'PATH'} =~ s/\//\\/g; # replace / -> \ | |
|
28 | # Add qtdir to path | |
|
29 | $ENV{'PATH'} .= ";" . $job{'QtDir'} . "\\bin"; | |
|
30 | ||
|
31 | # replace / -> \ | |
|
32 | $ENV{'PATH'} =~ s/\//\\/g; | |
|
30 | 33 | } |
|
31 | 34 | |
|
32 | 35 | when ("Linux") { |
|
36 | # Add qtdir to path | |
|
33 | 37 | $ENV{'PATH'} = $job{'QtDir'} . "/bin:" . $ENV{'PATH'}; |
|
38 | ||
|
39 | # If this is not set we get "cannot connect to X server" errors | |
|
34 | 40 | $ENV{'DISPLAY'} = ":0.0"; |
|
35 | 41 | } |
|
36 | 42 | } |
|
37 | 43 | |
|
38 | 44 | # Go through all the files in the test folder |
|
39 | 45 | # autotest is an executable beginning with "tst_" |
|
40 | 46 | my $script_exit_status = 0; |
|
41 | 47 | opendir (TESTAPPDIR, "$bin_path") or die "Couldn't open test app dir"; |
|
42 | 48 | @files = <TESTAPPDIR>; |
|
43 | 49 | while ($testapp = readdir TESTAPPDIR) { |
|
44 | 50 | if (index($testapp, "tst_") == 0) { |
|
45 | 51 | if (-x "$bin_path$testapp") { |
|
46 | 52 | my $status = executeTestApp($testapp); |
|
47 | 53 | if ($status != 0) { |
|
48 | 54 | $script_exit_status = $status; |
|
49 | 55 | } |
|
50 | 56 | } else { |
|
51 | 57 | #print "file $testapp not executable\n"; |
|
52 | 58 | } |
|
53 | 59 | } |
|
54 | 60 | } |
|
55 | 61 | closedir TESTAPPDIR; |
|
56 | 62 | |
|
57 | 63 | print "\n*** script exit status : $script_exit_status ***\n\n"; |
|
58 | 64 | exit($script_exit_status); |
|
59 | 65 | |
|
60 | 66 | |
|
61 | 67 | sub executeTestApp($) { |
|
62 | 68 | my $testapp = $_[0]; |
|
63 | 69 | |
|
64 | 70 | # On OSX the actual test binary is in a sub folder |
|
65 | 71 | my $cmd_postfix = ""; |
|
66 | 72 | if ($^O eq "darwin") { |
|
67 | 73 | $cmd_postfix = "/Contents/MacOS/$testapp"; |
|
68 | 74 | $cmd_postfix = substr($cmd_postfix, 0, rindex($cmd_postfix, ".app")); |
|
69 | 75 | } |
|
70 | 76 | |
|
71 | 77 | my $cmd = "$bin_path$testapp$cmd_postfix -xunitxml -o $reports_path/$testapp.xml"; |
|
72 | 78 | print "executing: $cmd\n"; |
|
73 | 79 | system($cmd); |
|
74 | 80 | |
|
75 | 81 | # From http://perldoc.perl.org/perlvar.html about $?: |
|
76 | 82 | # The upper eight bits reflect specific error conditions encountered by the |
|
77 | 83 | # program (the program's exit() value). The lower eight bits reflect |
|
78 | 84 | # mode of failure, like signal death and core dump information. |
|
79 | 85 | # See wait(2) for details. |
|
80 | 86 | my $exit_status = $? >> 8; |
|
81 | 87 | print "\texit status: $exit_status\n"; |
|
82 | 88 | |
|
83 | 89 | return $exit_status; |
|
84 | 90 | } |
General Comments 0
You need to be logged in to leave comments.
Login now