common/tools/ats/ats_testdrop.pl
author Shabe Razvi <shaber@symbian.org>
Mon, 11 Oct 2010 16:04:35 +0100
changeset 1300 fe97a9594f6c
parent 1087 73af6e555060
permissions -rw-r--r--
Add reallyclean step prior to tools model build
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1087
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
     1
#!/usr/bin/perl
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
     2
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
     3
# Copyright (c) 2009 Symbian Foundation Ltd
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
     4
# This component and the accompanying materials are made available
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
     5
# under the terms of the License "Eclipse Public License v1.0"
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
     6
# which accompanies this distribution, and is available
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
     7
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
     8
#
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
     9
# Initial Contributors:
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    10
# Symbian Foundation Ltd - initial contribution.
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    11
#   Mike Kinghan, mikek@symbian.org
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    12
#
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    13
# Contributors:
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    14
#   Maciej Seroka, maciejs@symbian.org
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    15
#
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    16
# Description:
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    17
#   This is a tool for sending an ATS testdrop to an ATS server.
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    18
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    19
use strict;
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    20
use Getopt::Long;
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    21
use File::Copy;
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    22
use File::Spec;
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    23
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    24
my $username = "admin"; # ATS server user name
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    25
my $password = "admin"; # ATS server password
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    26
my $host;   # ATS server hostname
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    27
my $schedule;   # Schedule string for test drop, if any
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    28
my $host_drop_path; # Directory path on the ATS server where the test drop will be placed.
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    29
                    # This must be physically the same path as $local_drop_path, via drive mapping. 
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    30
my $local_drop_path; # Local directory path where the test drop will be placed.
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    31
                    # This must be physically the same path as $host_drop_path, via drive mapping.
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    32
my $local_test_pkg; # Local pathname of the test drop (zip or xml file). The test drop will be
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    33
                    # copied from here to $local_drop_path to make it accessible on the server,
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    34
                    # unless $local_test_pkg begins with "...". This indicates the test drop is already
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    35
                    # present in $local_drop_path and does need to be copied there. The remainder
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    36
                    # following "..." is the filename of the test drop.    
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    37
my $help;
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    38
my $dev_null = $^O =~ /^MSWin/ ? "nul" : "/dev/null";
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    39
my $ats_version; # The version of ATS used for running tests
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    40
my $ats_worker_path;
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    41
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    42
sub usage($);
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    43
sub help();
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    44
sub usage_error();
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    45
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    46
my %optmap = (  'host' => \$host,
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    47
			    'local-test-pkg' => \$local_test_pkg,
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    48
				'host-drop-path' => \$host_drop_path,
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    49
				'local-drop-path' =>\$local_drop_path,
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    50
				'username' => \$username,
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    51
				'password' => \$password,
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    52
				'schedule' => \$schedule,
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    53
				'ats-version' => \$ats_version,
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    54
				'ats-worker-path' => \$ats_worker_path,
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    55
                'help' => \$help);
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    56
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    57
GetOptions(\%optmap,
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    58
          'host=s',
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    59
          'local-test-pkg=s',
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    60
          'host-drop-path=s',
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    61
          'local-drop-path=s',
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    62
          'username=s',
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    63
          'password=s',
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    64
          'schedule=s',
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    65
		  'ats-version=s',
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    66
		  'ats-worker-path=s',
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    67
          'help!') 
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    68
          or usage_error();
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    69
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    70
if ($help) {
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    71
	help();
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    72
}
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    73
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    74
usage_error(), unless (defined($host) && defined($local_test_pkg) && defined($local_drop_path) && defined($host_drop_path));
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    75
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    76
# --ats-version is not mandatory.
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    77
if (!defined($ats_version)) { # Set ats3 by default
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    78
	$ats_version = "ats3" 
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    79
}
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    80
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    81
# --ats-worker-path is not mandatory.
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    82
if (!defined($ats_worker_path)) { # Set ats3 by default
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    83
	$ats_worker_path = "c:\\apps\\$ats_version\\bin" 
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    84
}
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    85
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    86
my $curl_version = `curl --version 1> $dev_null 2>&1`;
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    87
die("Need program \"curl\". Not found"), if ($?);
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    88
die("Test drop path \"$local_drop_path\" not found"), unless ( -d "$local_drop_path");
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    89
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    90
if (lc($ats_version) eq "ats4") {
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    91
	$host = "http:\/\/" . $host . ":7780\/ServerService", unless ($host =~ /:\d+$/);
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    92
} else {
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    93
	$host .= ":8080", unless ($host =~ /:\d+$/);
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    94
}
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    95
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    96
my ($vol,$dir,$pkg);
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    97
my $local_test_drop;
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    98
my $host_test_drop;
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    99
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   100
if ($local_test_pkg =~ /^\.\.\.(.+)/ ) { # Local test package name begins with "...". No need to copy. 
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   101
    $pkg = $1; # Get the filename of the test package.
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   102
    # Compose the full name of the test drop within the local drop path.
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   103
    $local_test_drop = File::Spec->catfile($local_drop_path,$pkg);    
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   104
    die("Test package file \"$local_test_drop\" not found"), unless ( -f "$local_test_drop");        
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   105
}
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   106
else { # Local test package must be copied to local drop path.
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   107
    die("Test package file \"$local_test_pkg\" not found"), unless ( -f "$local_test_pkg");
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   108
    # Compose the full name of the test drop within the local drop path.    
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   109
    ($vol,$dir,$pkg) = File::Spec->splitpath($local_test_pkg);
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   110
    $local_test_drop = File::Spec->catfile($local_drop_path,$pkg);
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   111
    if ( -f "$local_test_drop") {
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   112
        # A state test drop of the same name exists. Delete.
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   113
        unlink($local_test_drop) or die("Can't delete stale test drop \"$local_test_drop\". $!");
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   114
        print("A stale test drop \"$local_test_drop\" existed. Deleted\n");
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   115
    }
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   116
    # Copy the test drop to the local drop path.
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   117
    copy("$local_test_pkg","$local_test_drop")
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   118
        or die("Cannot copy \"$local_test_pkg\" -> \"$local_test_drop\". $!");
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   119
}
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   120
# Compose the full name of the test drop within the host drop path.
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   121
$host_test_drop = File::Spec->catfile($host_drop_path,$pkg);
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   122
# Compose URL to notify server of test drop, requesting run.
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   123
my $url;
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   124
if (lc($ats_version) eq "ats4") {
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   125
	$url ="-Xmx512M -cp  $ats_worker_path\/..\/plugins\/*;$ats_worker_path\/..\/lib\/util.jar com.nokia.ats.util.server.CommandLineClient -url $host -path $local_test_pkg";
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   126
} else {
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   127
	$url ="http://$host/ats3/XTestRunExecute.do?username=$username&password=$password&testrunpath=$host_test_drop";
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   128
	$url .= "&schedule=$schedule", if (defined($schedule));
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   129
}
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   130
# Post URL to server with cURL.
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   131
my $curl_cmd;
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   132
if (lc($ats_version) eq "ats4") {
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   133
	$curl_cmd = "java $url";
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   134
} else {
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   135
	$curl_cmd = "curl \"$url\"";
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   136
}
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   137
my $curl_response = `$curl_cmd 2>&1`;
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   138
#die("\nTest drop failed: $!\n"), if ($?);
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   139
die("\nTest drop failed: $curl_response\n"), if ($?);
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   140
if (lc($ats_version) eq "ats4") {
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   141
	print "$curl_response\n";
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   142
} else { 
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   143
	if ($curl_response =~ /(TEST_RUN_REF_ID=\d+)/) {
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   144
		#extract test run id from cURL response.
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   145
		print "$1\n";
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   146
	}
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   147
	else {
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   148
		print "$curl_response\n";
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   149
		die("Test drop failed\n");
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   150
	} 
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   151
}
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   152
print("Test drop done\n");
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   153
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   154
exit 0;
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   155
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   156
sub usage($)
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   157
{
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   158
    my $error = shift;
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   159
    my $fh = $error == 0 ? *STDOUT : *STDERR;
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   160
    print $fh "ats_testdrop.pl\n" .
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   161
            "Send a test drop to an ATS server for execution\n" .
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   162
            "usage:\n" .
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   163
            "  ats_testdrop.pl --help\n" .
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   164
            "  ats_testdrop.pl --host=HOSTNAME --local-test-pkg=PKGFILE --local-drop-path=LOCALPATH " .
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   165
                " --host-drop-path=HOSTPATH " .
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   166
                "[--username=ATS3USERNAME] [--password=ATS3PASSWORD] [--schedule=DD.MM.YYYY-HH:MM] [--ats-version=VERSION] [--ats-worker-path=ATSPATH]\n" .
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   167
            "options:\n" .
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   168
            "  --help                        Display this help and exit\n" .
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   169
            "  --host=HOSTAME                HOSTNAME is ATS server\n" .
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   170
            "  --local-test-pkg=PKGFILE      PKGFILE is the test package.\n" .
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   171
            "                                If PKGFILE begins \"...\" a filename in LOCALPATH is assumed\n" .
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   172
            "  --local-drop-path=LOCALPATH   Path to local directory where PKGFILE will be dropped\n" .            
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   173
            "  --host-drop-path=HOSTPATH     Host directory that is mapped to LOCALPATH.\n" .
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   174
            "                                Must agree with the properties of the registered device that the test package nominates\n" .
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   175
            "  --username=ATS3USERNAME       ATS3 user to whome the test will belong. Default=admin\n" .
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   176
            "  --password=ATS3PASSWORD       Password of ATS3 user. Default=admin\n" .
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   177
            "  --schedule=DD.MM.YYYY-HH:MM   Date-time at which test is to run. Default=as soon as possible\n" .
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   178
            "  --ats-version=VERSION         Version of ATS which will be used to run the tests. If not specified ATS3 will be set by default.\n" .
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   179
            "  --ats-worker-path=ATSPATH     Path to the ATS bin directory. If not specified c:\\apps\\\$ats_version\\bin will set by default.\n";
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   180
    exit $error;            
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   181
}
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   182
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   183
sub help()
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   184
{
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   185
    usage(0);
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   186
}
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   187
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   188
sub usage_error()
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   189
{
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   190
    usage(1);
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   191
}             
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   192
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   193
# EOF
73af6e555060 Replaced ats3_testdrop with ats_testdrop to handle sending test drops to ATS4 server
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   194