42 help(); |
44 help(); |
43 } |
45 } |
44 |
46 |
45 usage_error(), unless (defined($host) && defined($local_test_pkg) && defined($local_drop_path) && defined($host_drop_path)); |
47 usage_error(), unless (defined($host) && defined($local_test_pkg) && defined($local_drop_path) && defined($host_drop_path)); |
46 |
48 |
47 my $cscript_help = `cscript /?`; |
49 my $curl_version = $^O =~ /^MSWin/ ? `curl --version 1> $dev_null 2>&1` : `curl --version 1> $dev_null 2>&1`; |
48 die("Need command \"cscript\". Not in found"), if ($?); |
50 die("Need program \"curl\". Not found"), if ($?); |
49 die("Need VB script wshTestRunX.vbs. Not found"), unless ( -f "wshTestRunX.vbs"); |
|
50 die("Test drop path \"$local_drop_path\" not found"), unless ( -d "$local_drop_path"); |
51 die("Test drop path \"$local_drop_path\" not found"), unless ( -d "$local_drop_path"); |
|
52 |
|
53 $host .= ":8080", unless ($host =~ /:\d+$/); |
51 |
54 |
52 my ($vol,$dir,$pkg); |
55 my ($vol,$dir,$pkg); |
53 my $local_test_drop; |
56 my $local_test_drop; |
54 my $host_test_drop; |
57 my $host_test_drop; |
55 |
58 |
60 } |
63 } |
61 else { |
64 else { |
62 die("Test package file \"$local_test_pkg\" not found"), unless ( -f "$local_test_pkg"); |
65 die("Test package file \"$local_test_pkg\" not found"), unless ( -f "$local_test_pkg"); |
63 ($vol,$dir,$pkg) = File::Spec->splitpath($local_test_pkg); |
66 ($vol,$dir,$pkg) = File::Spec->splitpath($local_test_pkg); |
64 $local_test_drop = File::Spec->catfile($local_drop_path,$pkg); |
67 $local_test_drop = File::Spec->catfile($local_drop_path,$pkg); |
65 my $lc_local_test_drop = lc($local_test_drop); |
68 if ( -f "$local_test_drop") { |
66 my $lc_local_test_pkg = lc($local_test_pkg); |
69 my $cmp_local_test_drop = $local_test_drop; |
67 if ("$lc_local_test_drop" ne "$lc_local_test_pkg") { |
70 my $cmp_local_test_pkg = $local_test_pkg; |
68 if (unlink($local_test_drop) == 0) { |
71 if ($^O =~ /^MSWin/) { |
69 die("Can't delete stale testdrop \"$local_test_drop\". $!"); |
72 $cmp_local_test_drop = lc($local_test_drop); |
|
73 $cmp_local_test_pkg = lc($local_test_pkg); |
|
74 } |
|
75 if ("$cmp_local_test_drop" eq "$cmp_local_test_pkg") { |
|
76 if (unlink($local_test_drop) == 0) { |
|
77 die("Can't delete stale test drop \"$local_test_drop\". $!"); |
|
78 } |
|
79 else { |
|
80 print("A stale test drop \"$local_test_drop\" existed. Deleted\n"); |
|
81 } |
70 } |
82 } |
71 else { |
83 } |
72 print("A stale testtop \"$local_test_drop\" existed. Deleted\n"); |
84 copy("$local_test_pkg","$local_test_drop") |
73 } |
85 or die("Cannot copy \"$local_test_pkg\" -> \"$local_test_drop\". $!"); |
74 copy("$local_test_pkg","$local_test_drop") |
|
75 or die("Cannot copy \"$local_test_pkg\" -> \"$local_test_drop\". $!"); |
|
76 } |
|
77 } |
86 } |
78 $host_test_drop = File::Spec->catfile($host_drop_path,$pkg); |
87 $host_test_drop = File::Spec->catfile($host_drop_path,$pkg); |
79 |
88 my $url ="http://$host/ats3/XTestRunExecute.do?username=$username&password=$password&testrunpath=$host_test_drop"; |
80 $ENV{'ats3.host'} = $host; |
89 $url .= "&schedule=$schedule", if (defined($schedule)); |
81 $ENV{'ats3.pathToDrop'} = $host_test_drop; |
90 my $curl_cmd = "curl \"$url\""; |
82 $ENV{'ats3.username'} = $username; |
91 system("$curl_cmd"); |
83 $ENV{'ats3.password'} = $password; |
|
84 $ENV{'ats3.schedule'} = $schedule, if defined($schedule); |
|
85 system("cscript wshTestRunX.vbs"); |
|
86 die("\nTest drop failed: $!"), if ($?); |
92 die("\nTest drop failed: $!"), if ($?); |
87 print("\nTest drop done"); |
93 print("\nTest drop done"); |
88 |
94 |
89 exit 0; |
95 exit 0; |
90 |
96 |