common/tools/ats/ats_specialise_test_drop.pl
changeset 550 4128d08e7c08
parent 317 212621c49196
child 639 9b547c4a9812
equal deleted inserted replaced
547:19f9d5fc6406 550:4128d08e7c08
     9 # Initial Contributors:
     9 # Initial Contributors:
    10 # Symbian Foundation Ltd - initial contribution.
    10 # Symbian Foundation Ltd - initial contribution.
    11 #   Mike Kinghan, mikek@symbian.org
    11 #   Mike Kinghan, mikek@symbian.org
    12 #
    12 #
    13 # Contributors:
    13 # Contributors:
       
    14 #	Brendan Donegan, brendand@symbian.org
    14 #
    15 #
    15 # Description:
    16 # Description:
    16 #   This is a tool for setting the name of an ATS test drop, and/or the build id
    17 #   This is a tool for setting the name of an ATS test drop, and/or the build id
    17 #   of the build being tested, and/or the name of the device on which
    18 #   of the build being tested, and/or the name of the device on which
    18 #   it is to be run, by modifying the XML test drop specificcation.
    19 #   it is to be run, by modifying the XML test drop specificcation.
    22 use XML::Simple;
    23 use XML::Simple;
    23 use File::Copy;
    24 use File::Copy;
    24 use Data::Dumper;
    25 use Data::Dumper;
    25 
    26 
    26 my $test_drop_name;	# Test drop name to be embedded in output XML
    27 my $test_drop_name;	# Test drop name to be embedded in output XML
    27 my $build_id;    # Build ID to be embedded in output XML 
    28 my $build_id;   # Build ID to be embedded in output XML 
    28 my $device_name; # Device name to be embedded in output XML
    29 my $host_name;  # Host name to be embedded in output XML
    29 my $srcfile;	# Input test drop file, either .xml or .zip
    30 my $srcfile;	# Input test drop file, either .xml or .zip
    30 my $destfile;	# Leafname for output file. Extension will be .xml or .zip as input.
    31 my $destfile;	# Leafname for output file. Extension will be .xml or .zip as input.
    31 				# If unspecified then the input file is updated. 
    32 				# If unspecified then the input file is updated. 
    32 my $help;		# Do help?
    33 my $help;		# Do help?
    33 my $srctype;	# Type of inpout file, .xml or .zip
    34 my $srctype;	# Type of input file, .xml or .zip
    34 my $dev_null = $^O =~ /^MSWin/ ? "nul" : "/dev/null";	# OS-dependent nul device.
    35 my $dev_null = $^O =~ /^MSWin/ ? "nul" : "/dev/null";	# OS-dependent nul device.
    35 my $zipper;		# Zip command, depending on whether zip or 7z is available.
    36 my $zipper;		# Zip command, depending on whether zip or 7z is available.
    36 my $unzipper;	# Unzip command, depending on whether [unzip or 7z is available.
    37 my $unzipper;	# Unzip command, depending on whether [unzip or 7z is available.
    37 my $xml_in;		# Name of the input xml file. Always 'test.xml' if extracted from zipped test drop.
    38 my $xml_in;		# Name of the input xml file. Always 'test.xml' if extracted from zipped test drop.
    38 my $temp_dest_name; # Leafname of temporary output file, if $destfile undefined.
    39 my $temp_dest_name; # Leafname of temporary output file, if $destfile undefined.
    41 sub help();
    42 sub help();
    42 sub usage_error();
    43 sub usage_error();
    43 sub silent_command($);
    44 sub silent_command($);
    44 
    45 
    45 my %optmap = (  'test-drop-name' => \$test_drop_name,
    46 my %optmap = (  'test-drop-name' => \$test_drop_name,
    46 			    'device-name' => \$device_name,
    47 			    'host-name' => \$host_name,
    47 			    'build-id' => \$build_id,
    48 			    'build-id' => \$build_id,
    48 			    'src' => \$srcfile,
    49 			    'src' => \$srcfile,
    49 			    'dest' => \$destfile,
    50 			    'dest' => \$destfile,
    50                 'help' => \$help);
    51                 'help' => \$help);
    51 
    52 
    52 GetOptions(\%optmap,
    53 GetOptions(\%optmap,
    53           'test-drop-name=s',
    54           'test-drop-name=s',
    54           'device-name=s',
    55           'host-name=s',
    55           'build-id=s',
    56           'build-id=s',
    56           'src=s',
    57           'src=s',
    57           'dest=s',
    58           'dest=s',
    58           'help!') 
    59           'help!') 
    59           or usage_error();
    60           or usage_error();
   121 # Insert the specified test drop name, if any.
   122 # Insert the specified test drop name, if any.
   122 $test_drop->{'test'}->{'name'}->[0] = $test_drop_name, if $test_drop_name;
   123 $test_drop->{'test'}->{'name'}->[0] = $test_drop_name, if $test_drop_name;
   123 # Insert the specified build id, if any.
   124 # Insert the specified build id, if any.
   124 $test_drop->{'test'}->{'buildid'}->[0] = $build_id, if $build_id;
   125 $test_drop->{'test'}->{'buildid'}->[0] = $build_id, if $build_id;
   125 
   126 
   126 if ($device_name) { # Also insert sepcified device name.
   127 if ($host_name) { # Also insert specified host name
   127 	
   128 	
   128 	my $device_properties = $test_drop->{'test'}->{'target'}->[0]->{'device'}->[0]->{'property'};
   129 	my $device_properties = $test_drop->{'test'}->{'target'}->[0]->{'device'}->[0]->{'property'};
   129 	my $num_properties = @{$device_properties};
   130 	my $num_properties = @{$device_properties};
   130 	$device_properties->[$num_properties]= { 'name' => "NAME", 'value' => "$device_name" };
   131 	$device_properties->[$num_properties]= { 'name' => "HOST", 'value' => "$host_name" };
   131 	$test_drop->{'test'}->{'target'}->[0]->{'device'}->[0]->{'property'} = $device_properties;
   132 	$test_drop->{'test'}->{'target'}->[0]->{'device'}->[0]->{'property'} = $device_properties;
   132     #print Dumper($device_properties);
   133     #print Dumper($device_properties);
   133     #exit(0);		
   134     #exit(0);		
   134 }
   135 }
   135 
   136 
   167     my $fh = $error == 0 ? *STDOUT : *STDERR;
   168     my $fh = $error == 0 ? *STDOUT : *STDERR;
   168     print $fh "ats_specialise_test_drop.pl\n" .
   169     print $fh "ats_specialise_test_drop.pl\n" .
   169             "Specify the name, build id and target device in an ATS XML test drop\n" .
   170             "Specify the name, build id and target device in an ATS XML test drop\n" .
   170             "synopsis:\n" .
   171             "synopsis:\n" .
   171             "  ats_specialise_test_drop.pl --help\n" .
   172             "  ats_specialise_test_drop.pl --help\n" .
   172             "  ats_specialise_test_drop.pl [--test-drop-name=TESTNAME] [--build-id=BUILDID] [--device-name=DEVICENAME] [--dest=FILE] --src=FILE \n" .
   173             "  ats_specialise_test_drop.pl [--test-drop-name=TESTNAME] [--build-id=BUILDID] [--host-name=HOSTNAME] [--dest=FILE] --src=FILE \n" .
   173             "options:\n" .
   174             "options:\n" .
   174             "  --help                        Display this help and exit\n" .
   175             "  --help                        Display this help and exit\n" .
   175             "  --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" .
   176             "  --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" .
   176             "  --build-id=BUILDID            BUILDID is id of the build being tested. If not specified then the build id is not modified.\n" .            
   177             "  --build-id=BUILDID            BUILDID is id of the build being tested. If not specified then the build id is not modified.\n" .            
   177             "  --device-name=DEVICENAME      DEVICENAME  is the name of the device on which the test should be run. " .
   178             "  --device-name=HOSTNAME        HOSTNAME  is the name of the ATS worker on which the test should be run. " .
   178             "If not specified then the test device name is not modified.\n" .
   179             "If not specified then the test device name is not modified.\n" .
   179             "  --src=INFILE                  INFILE is the file containing the test drop XML to be modified, or else a zip file " .
   180             "  --src=INFILE                  INFILE is the file containing the test drop XML to be modified, or else a zip file " .
   180             "                                containing the test drop XML in the file 'test.xml'. INFILE must have extension .xml or.zip\n" .
   181             "                                containing the test drop XML in the file 'test.xml'. INFILE must have extension .xml or.zip\n" .
   181             "  --dest=OUTFILE                The modified output will be written to the file OUTFILE.EXT " .
   182             "  --dest=OUTFILE                The modified output will be written to the file OUTFILE.EXT " .
   182             "where EXT is same extention, .xml or .zip, found on INFILE. " .
   183             "where EXT is same extention, .xml or .zip, found on INFILE. " .