@@ -1,95 +1,95 | |||
|
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 'tools'; |
|
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/" . $job{'Config'} . "/"; |
|
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 | 28 | # Add qtdir to path |
|
29 | 29 | $ENV{'PATH'} .= ";" . $job{'QtDir'} . "\\bin"; |
|
30 | 30 | |
|
31 | 31 | # replace / -> \ |
|
32 | 32 | $ENV{'PATH'} =~ s/\//\\/g; |
|
33 | 33 | } |
|
34 | 34 | |
|
35 | 35 | when ("Linux") { |
|
36 | 36 | # Add qtdir to path |
|
37 | 37 | $ENV{'PATH'} = $job{'QtDir'} . "/bin:" . $ENV{'PATH'}; |
|
38 | 38 | |
|
39 | 39 | # If this is not set we get "cannot connect to X server" errors |
|
40 | 40 | $ENV{'DISPLAY'} = ":0.0"; |
|
41 | 41 | } |
|
42 | 42 | |
|
43 | 43 | when ("Mac") { |
|
44 | 44 | # Set QML_IMPORT_PATH point to QML plugin dir |
|
45 | 45 | $ENV{'QML_IMPORT_PATH'} = $bin_path; |
|
46 | 46 | } |
|
47 |
} |
|
|
47 | } | |
|
48 | 48 | |
|
49 | 49 | # Go through all the files in the test folder |
|
50 | 50 | # autotest is an executable beginning with "tst_" |
|
51 | 51 | my $script_exit_status = 0; |
|
52 | 52 | opendir (TESTAPPDIR, "$bin_path") or die "Couldn't open test app dir"; |
|
53 | 53 | @files = <TESTAPPDIR>; |
|
54 | 54 | while ($testapp = readdir TESTAPPDIR) { |
|
55 | 55 | if (index($testapp, "tst_") == 0) { |
|
56 | 56 | if (-x "$bin_path$testapp") { |
|
57 | 57 | my $status = executeTestApp($testapp); |
|
58 |
|
|
|
59 |
|
|
|
60 | } | |
|
58 | if ($status != 0) { | |
|
59 | $script_exit_status = $status; | |
|
60 | } | |
|
61 | 61 | } else { |
|
62 | 62 | #print "file $testapp not executable\n"; |
|
63 | 63 | } |
|
64 | 64 | } |
|
65 | 65 | } |
|
66 | 66 | closedir TESTAPPDIR; |
|
67 | 67 | |
|
68 | print "\n*** script exit status : $script_exit_status ***\n\n"; | |
|
69 | exit($script_exit_status); | |
|
68 | # Do not return error codes for bamboo. | |
|
69 | # Bamboo will determine test failures by parsing the xml logs. | |
|
70 | exit(0); | |
|
70 | 71 | |
|
71 | 72 | |
|
72 | 73 | sub executeTestApp($) { |
|
73 | 74 | my $testapp = $_[0]; |
|
74 | ||
|
75 |
|
|
|
76 |
|
|
|
77 |
|
|
|
78 |
|
|
|
79 |
|
|
|
80 | } | |
|
81 | ||
|
75 | ||
|
76 | # On OSX the actual test binary is in a sub folder | |
|
77 | my $cmd_postfix = ""; | |
|
78 | if ($^O eq "darwin") { | |
|
79 | $cmd_postfix = "/Contents/MacOS/$testapp"; | |
|
80 | $cmd_postfix = substr($cmd_postfix, 0, rindex($cmd_postfix, ".app")); | |
|
81 | } | |
|
82 | ||
|
82 | 83 | my $cmd = "$bin_path$testapp$cmd_postfix -xunitxml -o $reports_path/$testapp.xml"; |
|
83 | 84 | print "executing: $cmd\n"; |
|
84 | 85 | system($cmd); |
|
85 | ||
|
86 |
|
|
|
87 |
|
|
|
86 | ||
|
87 | # From http://perldoc.perl.org/perlvar.html about $?: | |
|
88 | # The upper eight bits reflect specific error conditions encountered by the | |
|
88 | 89 | # program (the program's exit() value). The lower eight bits reflect |
|
89 | 90 | # mode of failure, like signal death and core dump information. |
|
90 |
# See wait(2) for details. |
|
|
91 | # See wait(2) for details. | |
|
91 | 92 | my $exit_status = $? >> 8; |
|
92 | 93 | print "\texit status: $exit_status\n"; |
|
93 | ||
|
94 | return $exit_status; | |
|
94 | return $exit_status; | |
|
95 | 95 | } |
General Comments 0
You need to be logged in to leave comments.
Login now