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