common/tools/ats/ats_specialise_test_drop.pl
author Maciej Seroka <maciejs@symbian.org>
Fri, 11 Jun 2010 09:20:11 +0100
changeset 1085 461755d25d57
parent 1028 11f25704ec27
child 1091 e29e83fc0026
permissions -rw-r--r--
Modified ats_specialise_test_drop to handle ats4 test plans
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
134
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
     1
#!/usr/bin/perl
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
     2
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
     3
# Copyright (c) 2009 Symbian Foundation Ltd
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
     4
# This component and the accompanying materials are made available
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
     5
# under the terms of the License "Eclipse Public License v1.0"
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
     6
# which accompanies this distribution, and is available
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
     7
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
     8
#
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
     9
# Initial Contributors:
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    10
# Symbian Foundation Ltd - initial contribution.
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    11
#   Mike Kinghan, mikek@symbian.org
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    12
#
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    13
# Contributors:
550
4128d08e7c08 Changed ats_specialise_testdrop and build.test.xml to use the 'HOST' device property to fix the devicem rather than the 'NAME' property
Brendan Donegan brendand@symbian.org
parents: 317
diff changeset
    14
#	Brendan Donegan, brendand@symbian.org
836
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents: 823
diff changeset
    15
#	Maciej Seroka, maciejs@symbian.org
134
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    16
#
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    17
# Description:
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    18
#   This is a tool for setting the name of an ATS test drop, and/or the build id
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    19
#   of the build being tested, and/or the name of the device on which
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    20
#   it is to be run, by modifying the XML test drop specificcation.
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    21
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    22
use strict;
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    23
use Getopt::Long;
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    24
use XML::Simple;
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    25
use File::Copy;
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    26
use Data::Dumper;
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    27
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    28
my $test_drop_name;	# Test drop name to be embedded in output XML
1085
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
    29
my $test_drop;
550
4128d08e7c08 Changed ats_specialise_testdrop and build.test.xml to use the 'HOST' device property to fix the devicem rather than the 'NAME' property
Brendan Donegan brendand@symbian.org
parents: 317
diff changeset
    30
my $build_id;   # Build ID to be embedded in output XML 
4128d08e7c08 Changed ats_specialise_testdrop and build.test.xml to use the 'HOST' device property to fix the devicem rather than the 'NAME' property
Brendan Donegan brendand@symbian.org
parents: 317
diff changeset
    31
my $host_name;  # Host name to be embedded in output XML
134
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    32
my $srcfile;	# Input test drop file, either .xml or .zip
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    33
my $destfile;	# Leafname for output file. Extension will be .xml or .zip as input.
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    34
				# If unspecified then the input file is updated. 
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    35
my $help;		# Do help?
550
4128d08e7c08 Changed ats_specialise_testdrop and build.test.xml to use the 'HOST' device property to fix the devicem rather than the 'NAME' property
Brendan Donegan brendand@symbian.org
parents: 317
diff changeset
    36
my $srctype;	# Type of input file, .xml or .zip
134
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    37
my $dev_null = $^O =~ /^MSWin/ ? "nul" : "/dev/null";	# OS-dependent nul device.
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    38
my $zipper;		# Zip command, depending on whether zip or 7z is available.
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    39
my $unzipper;	# Unzip command, depending on whether [unzip or 7z is available.
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    40
my $xml_in;		# Name of the input xml file. Always 'test.xml' if extracted from zipped test drop.
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    41
my $temp_dest_name; # Leafname of temporary output file, if $destfile undefined.
820
2a9e6403efaf Updated postbuild to publish smoketest results
Maciej Seroka <maciejs@symbian.org>
parents: 819
diff changeset
    42
my $publish;	# Publishing folder for ats reports.
836
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents: 823
diff changeset
    43
my $bld_drive;  # Subst'd drive
989
95924ae2e0d6 Added ROM image parameters to ats_specialise_drop
Brendan Donegan <brendand@symbian.org>
parents: 836
diff changeset
    44
my $test_target; # The target which the tests will be run on
95924ae2e0d6 Added ROM image parameters to ats_specialise_drop
Brendan Donegan <brendand@symbian.org>
parents: 836
diff changeset
    45
my $image_path; # The path to the ROM image used for testing (not valid for WINSCW target)
1085
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
    46
my $ats_version; # The version of ATS used for running tests
134
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    47
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    48
sub usage($);
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    49
sub help();
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    50
sub usage_error();
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    51
sub silent_command($);
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    52
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    53
my %optmap = (  'test-drop-name' => \$test_drop_name,
991
f2c5bb4624be Fixed ats_specialise_drop to insert ROM image parameters
Maciej Seroka <maciejs@symbian.org>
parents: 989
diff changeset
    54
                'host-name' => \$host_name,
f2c5bb4624be Fixed ats_specialise_drop to insert ROM image parameters
Maciej Seroka <maciejs@symbian.org>
parents: 989
diff changeset
    55
                'build-id' => \$build_id,
f2c5bb4624be Fixed ats_specialise_drop to insert ROM image parameters
Maciej Seroka <maciejs@symbian.org>
parents: 989
diff changeset
    56
                'src' => \$srcfile,
f2c5bb4624be Fixed ats_specialise_drop to insert ROM image parameters
Maciej Seroka <maciejs@symbian.org>
parents: 989
diff changeset
    57
                'dest' => \$destfile,
836
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents: 823
diff changeset
    58
                'publish' => \$publish,
991
f2c5bb4624be Fixed ats_specialise_drop to insert ROM image parameters
Maciej Seroka <maciejs@symbian.org>
parents: 989
diff changeset
    59
                'bld-drive' => \$bld_drive,
1085
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
    60
				'test-target' => \$test_target,
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
    61
                'image-path' => \$image_path,
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
    62
				'ats-version' => \$ats_version,
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
    63
                'help' => \$help);
134
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    64
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    65
GetOptions(\%optmap,
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    66
          'test-drop-name=s',
550
4128d08e7c08 Changed ats_specialise_testdrop and build.test.xml to use the 'HOST' device property to fix the devicem rather than the 'NAME' property
Brendan Donegan brendand@symbian.org
parents: 317
diff changeset
    67
          'host-name=s',
134
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    68
          'build-id=s',
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    69
          'src=s',
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    70
          'dest=s',
836
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents: 823
diff changeset
    71
          'publish=s', 
991
f2c5bb4624be Fixed ats_specialise_drop to insert ROM image parameters
Maciej Seroka <maciejs@symbian.org>
parents: 989
diff changeset
    72
          'bld-drive=s',
1085
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
    73
		  'test-target=s',
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
    74
          'image-path=s',
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
    75
		  'ats-version=s',
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
    76
          'help!') 
134
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    77
          or usage_error();
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    78
821
b24df46a3102 Implemented exporting Smoke Test Report to Diamonds
Maciej Seroka <maciejs@symbian.org>
parents: 820
diff changeset
    79
# Check if Tie::File module installed
b24df46a3102 Implemented exporting Smoke Test Report to Diamonds
Maciej Seroka <maciejs@symbian.org>
parents: 820
diff changeset
    80
eval("use Tie::File");
836
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents: 823
diff changeset
    81
if ($@) { $publish = ''; $bld_drive = ''; };
821
b24df46a3102 Implemented exporting Smoke Test Report to Diamonds
Maciej Seroka <maciejs@symbian.org>
parents: 820
diff changeset
    82
		  
134
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    83
if ($help) {
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    84
	help();
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    85
}
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    86
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    87
# --src is mandatory.
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    88
usage_error(), unless (defined($srcfile));
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    89
if ($srcfile =~ /(\.xml$)/i) {
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    90
    $srctype = lc($1);
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    91
}
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    92
elsif ($srcfile =~ /(\.zip$)/i) {
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    93
    $srctype = lc($1);
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    94
}
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    95
else {
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    96
	# src file must have extension .xml or .zip
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    97
    usage_error();
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    98
}
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    99
die("File \"$srcfile\" does not exist"), unless -f $srcfile;
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   100
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   101
if (!$destfile) { # dest file unspecified. We will update the src file.
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   102
	$temp_dest_name = "ats_specialise_test_drop.out";
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   103
	$destfile = $temp_dest_name;
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   104
}
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   105
else {
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   106
    # If dest file has same extension as src then strip off, cos we'll append it anyway.
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   107
    $destfile =~ s/$srctype$//;
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   108
}
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   109
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   110
if ($srctype =~ /^\.zip$/) { # Test drop is zip. Must contain test.xml.
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   111
    $xml_in = "test.xml"; # This is our input XML.
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   112
    if ( -f $xml_in) {
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   113
		# Pre-emptively delete anystale xml file.
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   114
        unlink($xml_in) or die("Cannot delete stale $xml_in: $!\n");
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   115
    }
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   116
    if (!silent_command("zip -v")) { # See if we've got zip
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   117
        $zipper = "zip -m $destfile.zip test.xml";
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   118
        $unzipper = "unzip -o $srcfile $xml_in -d .";
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   119
    }
279
6aa713519d4e Fixed usage of 7z in ats_specialise_test_drop.pl
ThomasE
parents: 134
diff changeset
   120
    elsif (!silent_command("7z -h")) { # Else see if we've got 7zip
134
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   121
        $zipper = "7z u $destfile.zip test.xml";
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   122
        $unzipper = "7z e $srcfile $xml_in";
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   123
    }
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   124
    else { # Got no archiver.
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   125
        die ("Need programs zip/unzip or 7z. Not found\n");
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   126
    }
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   127
    # Extract test.xml from zip.
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   128
    system("$unzipper > $dev_null") and die("Could not unzip \"$srcfile\"\n");
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   129
    die("Did not find $xml_in within \"$srcfile\"\n"), unless( -f "$xml_in");
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   130
    
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   131
}
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   132
else {
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   133
    $xml_in = $srcfile;
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   134
}
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   135
1085
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   136
# --test-target is not mandatory.
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   137
if (!defined($test_target)) { # Set winscw by default
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   138
	$test_target = "winscw" 
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   139
}
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   140
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   141
# --ats-version is not mandatory.
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   142
if (!defined($ats_version)) { # Set ats3 by default
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   143
	$ats_version = "ats3" 
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   144
}
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   145
134
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   146
# Parse the input XML into hashref.
1085
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   147
if (lc($ats_version) eq "ats4") {
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   148
	$test_drop = XMLin("./$xml_in", keeproot => 1,
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   149
        forcearray => [ 'metadata', 'meta', 'agents', 'agent', 'property', 'postActions', 'action', 'type', 'parameters', 'parameter', 'execution', 'initialization', 'task', 'alias' ],#
134
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   150
        keyattr => [] );
1085
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   151
} else { # ats3 format
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   152
	$test_drop = XMLin("./$xml_in", keeproot => 1,
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   153
        forcearray => [ 'name', 'id', 'owner', 'priority', 'buildid', 'postAction', 'type', 'target', 'device', 'property', 'command', 'param', 'plan', 'session', 'set', 'alias' ],#
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   154
        keyattr => [] );
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   155
}
134
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   156
    
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   157
# Insert the specified test drop name, if any.
1085
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   158
if (lc($ats_version) eq "ats4") {
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   159
	# Assumption: meta 'name' exists in test plan
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   160
	$test_drop->{'testrun'}->{'metadata'}->[0]->{'meta'}->[0] = { 'name' => "name", 'content' => $test_drop_name }, if $test_drop_name;
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   161
} else {
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   162
	$test_drop->{'test'}->{'name'}->[0] = $test_drop_name, if $test_drop_name;
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   163
}
134
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   164
# Insert the specified build id, if any.
1085
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   165
if (lc($ats_version) eq "ats4") {
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   166
	if ($build_id) {
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   167
		my $meta_num = @{$test_drop->{'testrun'}->{'metadata'}->[0]->{'meta'}};
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   168
		$test_drop->{'testrun'}->{'metadata'}->[0]->{'meta'}->[$meta_num];
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   169
		$test_drop->{'testrun'}->{'metadata'}->[0]->{'meta'}->[$meta_num] = { 'name' => "diamonds-buildid", 'content' => $build_id };
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   170
		$test_drop->{'testrun'}->{'metadata'}->[0]->{'meta'}->[$meta_num+1];
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   171
		$test_drop->{'testrun'}->{'metadata'}->[0]->{'meta'}->[$meta_num+1] = { 'name' => "diamonds-testtype", 'content' => "Smoke" }; # Hard-coded Smoke
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   172
	}
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   173
} else {
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   174
	$test_drop->{'test'}->{'buildid'}->[0] = $build_id, if $build_id;
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   175
}
989
95924ae2e0d6 Added ROM image parameters to ats_specialise_drop
Brendan Donegan <brendand@symbian.org>
parents: 836
diff changeset
   176
# Insert the path to the ROM image
1085
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   177
if (lc($ats_version) eq "ats4") {
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   178
	if (($image_path) && (lc($test_target) ne "winscw")) {
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   179
		my $agent_alias = $test_drop->{'testrun'}->{'agents'}->[0]->{'agent'}->[0]->{'alias'};
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   180
		my $task_num = @{$test_drop->{'testrun'}->{'execution'}->[0]->{'initialization'}->[0]->{'task'}};
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   181
		$test_drop->{'testrun'}->{'execution'}->[0]->{'initialization'}->[0]->{'task'}->[$task_num];
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   182
		$test_drop->{'testrun'}->{'execution'}->[0]->{'initialization'}->[0]->{'task'}->[$task_num] = { 'agents' => $agent_alias };
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   183
		$test_drop->{'testrun'}->{'execution'}->[0]->{'initialization'}->[0]->{'task'}->[$task_num]->{'type'}->[0];
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   184
		$test_drop->{'testrun'}->{'execution'}->[0]->{'initialization'}->[0]->{'task'}->[$task_num]->{'type'}->[0] = "FlashTask";
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   185
		$test_drop->{'testrun'}->{'execution'}->[0]->{'initialization'}->[0]->{'task'}->[$task_num]->{'parameters'}->[0];
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   186
		$test_drop->{'testrun'}->{'execution'}->[0]->{'initialization'}->[0]->{'task'}->[$task_num]->{'parameters'}->[0]->{'parameter'}->[0];
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   187
		$test_drop->{'testrun'}->{'execution'}->[0]->{'initialization'}->[0]->{'task'}->[$task_num]->{'parameters'}->[0]->{'parameter'}->[0] = { 'name' => "image-1", 'value' => $image_path };
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   188
		$test_drop->{'testrun'}->{'execution'}->[0]->{'initialization'}->[0]->{'task'}->[$task_num]->{'parameters'}->[0]->{'parameter'}->[1];
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   189
		$test_drop->{'testrun'}->{'execution'}->[0]->{'initialization'}->[0]->{'task'}->[$task_num]->{'parameters'}->[0]->{'parameter'}->[1] = { 'name' => "timeout", 'value' => "1200" };
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   190
	}
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   191
} else {
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   192
	if (($image_path) && (lc($test_target) ne "winscw")) {
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   193
		my $device_alias;
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   194
		my $set_params;
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   195
		my $flash_params;
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   196
		foreach $set_params (@{$test_drop->{'test'}->{'plan'}->[0]->{'session'}->[0]->{'set'}}) {
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   197
			$device_alias = $set_params->{'target'}->[0]->{'device'}->[0]->{'alias'};
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   198
			$set_params->{'flash'}->[0];
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   199
			$flash_params = $set_params->{'flash'};
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   200
			$flash_params->[0] = { 'target-alias' => $device_alias, 'images' => $image_path };
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   201
		}
1006
75c9a2f0ae9e Modified ats_specialise_test_drop to automatically set test-target param based on device alias
Maciej Seroka <maciejs@symbian.org>
parents: 993
diff changeset
   202
	}
991
f2c5bb4624be Fixed ats_specialise_drop to insert ROM image parameters
Maciej Seroka <maciejs@symbian.org>
parents: 989
diff changeset
   203
}
989
95924ae2e0d6 Added ROM image parameters to ats_specialise_drop
Brendan Donegan <brendand@symbian.org>
parents: 836
diff changeset
   204
819
3df98b3b0a8d Updated ats_specialise_test_drop.pl to insert FileStoreAction param
Maciej Seroka <maciejs@symbian.org>
parents: 730
diff changeset
   205
# Insert the FileStoreAction parameter
1085
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   206
if (lc($ats_version) eq "ats4") {
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   207
	if ($publish) {
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   208
		my $action_num = @{$test_drop->{'testrun'}->{'postActions'}->[0]->{'action'}};
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   209
		$test_drop->{'testrun'}->{'postActions'}->[0]->{'action'}->[$action_num];
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   210
		$test_drop->{'testrun'}->{'postActions'}->[0]->{'action'}->[$action_num]->{'type'}->[0];
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   211
		$test_drop->{'testrun'}->{'postActions'}->[0]->{'action'}->[$action_num]->{'type'}->[0] = "FileStoreAction";
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   212
		$test_drop->{'testrun'}->{'postActions'}->[0]->{'action'}->[$action_num]->{'parameters'}->[0];
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   213
		$test_drop->{'testrun'}->{'postActions'}->[0]->{'action'}->[$action_num]->{'parameters'}->[0]->{'parameter'}->[0];
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   214
		$test_drop->{'testrun'}->{'postActions'}->[0]->{'action'}->[$action_num]->{'parameters'}->[0]->{'parameter'}->[0] = { 'name' => "dst", 'value' => $publish };
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   215
	}
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   216
} else {
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   217
	if ($publish) {
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   218
		my $postaction_params = $test_drop->{'test'}->{'postAction'}->[0]->{'params'}->{'param'};
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   219
		$postaction_params->[1] = { 'name' => "to-folder", 'value' => $publish };
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   220
	}
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   221
}
134
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   222
1085
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   223
# Also insert specified host name
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   224
if (lc($ats_version) eq "ats4") {
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   225
	if ($host_name) {
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   226
		# Assumption: 'agent' element with 'property' exists in test plan
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   227
		my $agent_name = uc($test_target) . " on " . $host_name;
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   228
		$test_drop->{'testrun'}->{'agents'}->[0]->{'agent'}->[0]->{'property'}->[0] = { 'name' => "name", 'value' => $agent_name };
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   229
	}
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   230
} else {
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   231
	if ($host_name) { 
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   232
		my $devices = $test_drop->{'test'}->{'target'}->[0]->{'device'};
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   233
		
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   234
		foreach my $device (@{$devices}) {
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   235
			my $device_properties = $device->{'property'};
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   236
			my $num_properties = @{$device_properties};
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   237
			
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   238
			$device_properties->[$num_properties] = { 'name' => "HOST", 'value' => "$host_name" };
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   239
			$device->{'property'} = $device_properties;
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   240
		}
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   241
	}
134
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   242
}
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   243
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   244
if ($srctype =~ /^\.xml$/i ) { # Input file was XML
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   245
    # Write new XML to dest file.
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   246
    open OUT,">$destfile.xml" or die("Cannot open file \"$destfile.xml\" for writing. $!\n");
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   247
    print OUT XMLout($test_drop, keeproot => 1);
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   248
    close OUT;    
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   249
}
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   250
else { #Input file was a zip.
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   251
    # Write new XML to test.xml
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   252
    open OUT,">test.xml" or die("Cannot open file \"test.xml\" for writing. $!\n");
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   253
    print OUT XMLout($test_drop, keeproot => 1);
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   254
    close OUT;
1085
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   255
	if (($publish) && (lc($ats_version) eq "ats3")) { #Move <type>FileStoreAction</type> above <params>
821
b24df46a3102 Implemented exporting Smoke Test Report to Diamonds
Maciej Seroka <maciejs@symbian.org>
parents: 820
diff changeset
   256
		my @lines;
b24df46a3102 Implemented exporting Smoke Test Report to Diamonds
Maciej Seroka <maciejs@symbian.org>
parents: 820
diff changeset
   257
		tie @lines, 'Tie::File', "test.xml" or die("Cannot tie file \"test.xml\". $!\n");
b24df46a3102 Implemented exporting Smoke Test Report to Diamonds
Maciej Seroka <maciejs@symbian.org>
parents: 820
diff changeset
   258
		my $current_line = 0;
b24df46a3102 Implemented exporting Smoke Test Report to Diamonds
Maciej Seroka <maciejs@symbian.org>
parents: 820
diff changeset
   259
		for (@lines) {
b24df46a3102 Implemented exporting Smoke Test Report to Diamonds
Maciej Seroka <maciejs@symbian.org>
parents: 820
diff changeset
   260
			if (/FileStoreAction/) {
b24df46a3102 Implemented exporting Smoke Test Report to Diamonds
Maciej Seroka <maciejs@symbian.org>
parents: 820
diff changeset
   261
				my $line_to_move = @lines[$current_line];
b24df46a3102 Implemented exporting Smoke Test Report to Diamonds
Maciej Seroka <maciejs@symbian.org>
parents: 820
diff changeset
   262
				splice @lines, $current_line, 1;
b24df46a3102 Implemented exporting Smoke Test Report to Diamonds
Maciej Seroka <maciejs@symbian.org>
parents: 820
diff changeset
   263
				splice @lines, $current_line-4, 0, $line_to_move;
b24df46a3102 Implemented exporting Smoke Test Report to Diamonds
Maciej Seroka <maciejs@symbian.org>
parents: 820
diff changeset
   264
				last;
b24df46a3102 Implemented exporting Smoke Test Report to Diamonds
Maciej Seroka <maciejs@symbian.org>
parents: 820
diff changeset
   265
			}
b24df46a3102 Implemented exporting Smoke Test Report to Diamonds
Maciej Seroka <maciejs@symbian.org>
parents: 820
diff changeset
   266
		  $current_line++;
b24df46a3102 Implemented exporting Smoke Test Report to Diamonds
Maciej Seroka <maciejs@symbian.org>
parents: 820
diff changeset
   267
	    }
b24df46a3102 Implemented exporting Smoke Test Report to Diamonds
Maciej Seroka <maciejs@symbian.org>
parents: 820
diff changeset
   268
	untie @lines;
b24df46a3102 Implemented exporting Smoke Test Report to Diamonds
Maciej Seroka <maciejs@symbian.org>
parents: 820
diff changeset
   269
	}
836
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents: 823
diff changeset
   270
	if ($bld_drive) { #Replace D:\ATS\winscw_smoketest path with subst'd drive
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents: 823
diff changeset
   271
		my @LINE;
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents: 823
diff changeset
   272
		tie @LINE, 'Tie::File', "test.xml" or die("Cannot tie file \"test.xml\". $!\n");
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents: 823
diff changeset
   273
		for (@LINE) {
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents: 823
diff changeset
   274
			s/D:\\ATS\\winscw_smoketest/$bld_drive/g;
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents: 823
diff changeset
   275
		}
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents: 823
diff changeset
   276
	untie @LINE;	
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents: 823
diff changeset
   277
	}
134
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   278
    if ( -f "$destfile.zip") {
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   279
        unlink("$destfile.zip") or die("Could not delete \"$destfile.zip\": $!\n");
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   280
    } 
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   281
    copy("$srcfile","$destfile.zip") or die("Could not copy \"$srcfile\" -> \"$destfile.zip\": $!\n");
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   282
    system("$zipper > $dev_null") and die("Could not zip \"test.xml\" into \"$destfile\"\n");    
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   283
}
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   284
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   285
if ($temp_dest_name) { # We are to update the src file. dest file is a temporary.
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   286
   # Delete src file 
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   287
   unlink($srcfile) or die("Cannot delete file \"$srcfile\" to replace: $!\n");
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   288
   # Replace with temporary.
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   289
   move("$destfile$srctype","$srcfile") or die("Could not move \"$destfile$srctype\" -> \"$srcfile\": $!\n");
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   290
}
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   291
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   292
print "OK\n";
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   293
exit 0;
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   294
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   295
sub usage($)
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   296
{
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   297
    my $error = shift;
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   298
    my $fh = $error == 0 ? *STDOUT : *STDERR;
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   299
    print $fh "ats_specialise_test_drop.pl\n" .
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   300
            "Specify the name, build id and target device in an ATS XML test drop\n" .
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   301
            "synopsis:\n" .
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   302
            "  ats_specialise_test_drop.pl --help\n" .
1085
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   303
            "  ats_specialise_test_drop.pl [--test-drop-name=TESTNAME] [--build-id=BUILDID] [--host-name=HOSTNAME] [--dest=FILE] --src=FILE [--publish=DIR] [--bld-drive=DRIVE] [--test-target=TARGET] [--image-path=PATH] [--ats-version=VERSION]\n" .
134
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   304
            "options:\n" .
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   305
            "  --help                        Display this help and exit\n" .
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   306
            "  --test-drop-name=TESTNAME     TESTNAME is the desired name of the test drop. If not specified then the test drop name is not modified.\n" .
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   307
            "  --build-id=BUILDID            BUILDID is id of the build being tested. If not specified then the build id is not modified.\n" .            
1085
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   308
            "  --host-name=HOSTNAME          HOSTNAME  is the name of the ATS worker on which the test should be run. " .
134
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   309
            "If not specified then the test device name is not modified.\n" .
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   310
            "  --src=INFILE                  INFILE is the file containing the test drop XML to be modified, or else a zip file " .
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   311
            "                                containing the test drop XML in the file 'test.xml'. INFILE must have extension .xml or.zip\n" .
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   312
            "  --dest=OUTFILE                The modified output will be written to the file OUTFILE.EXT " .
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   313
            "where EXT is same extention, .xml or .zip, found on INFILE. " .
1085
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   314
            "If OUTFILE is not specified then INFILE is modified\n" . 
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   315
            "  --publish=DIR                 DIR is the publishing folder for ats reports (optional).\n" .
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   316
            "  --bld-drive=DRIVE             DRIVE is the subst'd drive on which the build is stored (optional).\n" .
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   317
			"  --test-target=TARGET          TARGET is the target which the tests will be run on. If not specified WINSCW will be set by default\n" .
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   318
            "  --image-path=PATH             PATH is the path to the ROM image used for testing (not valid for WINSCW target).\n" .
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   319
            "  --ats-version=VERSION         VERSION is the version of ATS which will be used to run the tests. If not specified ATS3 will be set by default.\n";
461755d25d57 Modified ats_specialise_test_drop to handle ats4 test plans
Maciej Seroka <maciejs@symbian.org>
parents: 1028
diff changeset
   320
			
134
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   321
    exit $error;            
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   322
}
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   323
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   324
sub help()
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   325
{
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   326
    usage(0);
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   327
}
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   328
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   329
sub usage_error()
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   330
{
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   331
    usage(1);
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   332
}             
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   333
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   334
sub silent_command($)
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   335
{
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   336
    my $cmd = shift;
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   337
    system("$cmd 1> $dev_null 2>&1");
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   338
    return $? >> 8;
039d0b7e56f3 Comments and code tidying for ats3_testdrop.pl
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   339
}