Merge
authorShabe Razvi <shaber@symbian.org>
Mon, 14 Jun 2010 14:13:44 +0100
changeset 1103 2fea6aa94be6
parent 1102 3bbdacdf4dc1 (current diff)
parent 1088 31677de59336 (diff)
child 1104 a4712e0fdd56
Merge
common/common_props.ant.xml
--- a/common/build.postbuild.xml	Mon Jun 14 13:53:46 2010 +0100
+++ b/common/build.postbuild.xml	Mon Jun 14 14:13:44 2010 +0100
@@ -100,7 +100,41 @@
     </target>
 
     <target name="sf-tag-hg-code">
-        <property name="sf.tagafterbuild.tag" value="${sf.spec.job.name}_${sf.spec.job.codeline}.${sf.spec.job.number}"/>
+        <!-- To do the tagging, we need to know what tag to use, and who the author is (from hg's perspective) -->
+        <fail message="This target needs to have all the details specified, or to be run interactively so it can query the user">
+            <condition>
+                <and>
+                    <isset property="sf.hudson.executor.number"/>
+                    <not>
+                        <or>
+                            <isset property="sf.tagafterbuild.tag"/>
+                            <isset property="sf.hg.ui.username"/>
+                        </or>
+                    </not>
+                </and>
+            </condition>
+        </fail>
+
+        <!-- Ask the user, interactively, what tag to use -->
+        <input addproperty="sf.tagafterbuild.tag" message="Enter the tag to apply to the code (eg &quot;PDK_1.0.1&quot;):"/>
+        <fail message="No tag supplied">
+            <condition>
+                <length string="${sf.tagafterbuild.tag}" trim="true" length="0"/>
+            </condition>
+        </fail>
+
+        <!-- Now get the username sorted out -->
+        <exec executable="hg" outputproperty="sf.hg.showconfig.ui.username">
+            <arg value="showconfig"/>
+            <arg value="ui.username"/>
+        </exec>
+        <input addproperty="sf.hg.ui.username" message="Enter hg author credentials (eg &quot;Fred Bloggs &lt;fredb@example.org&gt;&quot;) default is" defaultvalue="${sf.hg.showconfig.ui.username}"/>
+        <fail message="No author supplied">
+            <condition>
+                <length string="${sf.hg.ui.username}" trim="true" length="0"/>
+            </condition>
+        </fail>
+
         <fmpp sourceFile="${sf.common.config.dir}/templates/tag-hg-code.ant.xml.ftl"
               outputFile="${temp.build.dir}/tag-hg-code.ant.xml">
             <data expandProperties="yes">
@@ -111,6 +145,59 @@
         <ant antfile="${temp.build.dir}/tag-hg-code.ant.xml"/>
     </target>
 
+    <target name="sf-push-hg-tags">
+        <!-- To do the pushing, we need to have a set of credentials for the developer.symbian.org site -->
+        <fail message="This target needs to have loging credentials specified specified, or to be run interactively so it can query the user">
+            <condition>
+                <and>
+                    <isset property="sf.hudson.executor.number"/>
+                    <not>
+                        <or>
+                            <isset property="sf.symbian.account.username"/>
+                            <isset property="sf.symbian.account.password"/>
+                        </or>
+                    </not>
+                </and>
+            </condition>
+        </fail>
+
+        <input addproperty="sf.symbian.account.username" message="Enter symbian.org username (eg &quot;fredb&quot;)"/>
+        <fail message="No author supplied">
+            <condition>
+                <length string="${sf.hg.ui.username}" trim="true" length="0"/>
+            </condition>
+        </fail>
+
+        <input addproperty="sf.symbian.account.password" message="Enter symbian.org password (eg &quot;unguessable&quot;)">
+            <!-- Ant 1.8 supports secure here, which would be an improvement... -->
+            <handler type="default"/>
+        </input>
+        <fail message="No password supplied">
+            <condition>
+                <length string="${sf.hg.ui.password}" trim="true" length="0"/>
+            </condition>
+        </fail>
+
+        <if>
+            <not>
+                <available file="${build.drive}/tagging" type="dir"/>
+            </not>
+            <then>
+                <!-- No dir with tagged repos in - create them! -->
+                <runtarget target="sf-tag-hg-code"/>
+            </then>
+        </if>
+
+        <fmpp sourceFile="${sf.common.config.dir}/templates/push-hg-tags.ant.xml.ftl"
+              outputFile="${temp.build.dir}/push-hg-tags.ant.xml">
+            <data expandProperties="yes">
+                ant: antProperties()
+                data: csv(${sf.spec.sourcesync.sourcespecdir}/${sf.spec.sourcesync.sourcespecfile}, {separator:','})
+            </data>
+        </fmpp>
+        <ant antfile="${temp.build.dir}/push-hg-tags.ant.xml"/>
+    </target>
+
     <target name="sf-run-evalid" >
         <delete dir="${build.drive}/output/md5"/>
         <mkdir  dir="${build.drive}/output/md5"/>
@@ -630,12 +717,12 @@
           </exec>
           <echo message="Send ${build.log.dir}/diamonds_uh.xml to Diamonds"/>
           <exec executable="python">
-		    <arg value="${sf.common.config.dir}/tools/brag/send_xml_to_diamonds.py"/>
-		    <arg value="-u"/>
-		    <arg value="http://${diamonds.host}${diamonds.build.id}"/>
-		    <arg value="-f"/>
-		    <arg value="${build.log.dir}/diamonds_uh.xml"/>
-		  </exec>
+            <arg value="${sf.common.config.dir}/tools/brag/send_xml_to_diamonds.py"/>
+            <arg value="-u"/>
+            <arg value="http://${diamonds.host}${diamonds.build.id}"/>
+            <arg value="-f"/>
+            <arg value="${build.log.dir}/diamonds_uh.xml"/>
+          </exec>
         </then>
       </if>
     </target>
@@ -781,15 +868,29 @@
                     <exclude name="output/logs/releaseables/**"/>
                 </zip>
                 <!-- workaround for the time when when 'sf-run-analysis-raptor' has not been run -->
-                <mkdir dir="${build.drive}/output/logs/releaseables"/> 
-                <zip destfile="${build.output.dir}/zips/release/build_BOM.zip">
-                    <zipfileset dir="${build.drive}/output/logs/BOM" prefix="build_info/logs/BOM"/>
-                    <zipfileset dir="${build.drive}/output/logs/releaseables" prefix="build_info/logs/releaseables"/>
-                    <zipfileset dir="${build.drive}/output/logs" prefix="build_info/logs/BOM">
-                        <include name="envinfo.txt"/>
-                    </zipfileset>
-                    <zipfileset dir="${build.drive}/output/logs/package_definitions" prefix="build_info/package_definitions"/>
-                </zip>
+                <mkdir dir="${build.drive}/output/logs/releaseables"/>
+				<if>
+	                <available file="${build.drive}/output/logs/package_definitions" type="dir"/>
+	                <then>
+		                <zip destfile="${build.output.dir}/zips/release/build_BOM.zip">
+	            	        <zipfileset dir="${build.drive}/output/logs/BOM" prefix="build_info/logs/BOM"/>
+	        	            <zipfileset dir="${build.drive}/output/logs/releaseables" prefix="build_info/logs/releaseables"/>
+	    	                <zipfileset dir="${build.drive}/output/logs" prefix="build_info/logs/BOM">
+		                        <include name="envinfo.txt"/>
+	                    	</zipfileset>
+	                    	<zipfileset dir="${build.drive}/output/logs/package_definitions" prefix="build_info/package_definitions"/>
+	                	</zip>
+	                </then>
+	                <else>
+	                	<zip destfile="${build.output.dir}/zips/release/build_BOM.zip">
+	            	        <zipfileset dir="${build.drive}/output/logs/BOM" prefix="build_info/logs/BOM"/>
+	        	            <zipfileset dir="${build.drive}/output/logs/releaseables" prefix="build_info/logs/releaseables"/>
+	    	                <zipfileset dir="${build.drive}/output/logs" prefix="build_info/logs/BOM">
+		                        <include name="envinfo.txt"/>
+	                    	</zipfileset>
+	                	</zip>
+	                </else>
+	            </if>
                 <antcall target="sf-zip-content">
                     <param name="zip.config.file" value="${temp.build.dir}/zip.cfg.xml.ftl"/>
                     <param name="zip.target.name" value="info-just-metadata" />
--- a/common/build.test.xml	Mon Jun 14 13:53:46 2010 +0100
+++ b/common/build.test.xml	Mon Jun 14 14:13:44 2010 +0100
@@ -120,7 +120,7 @@
                               <arg value="--dest=${sf.spec.test.package.location}\${env.COMPUTERNAME}-bctest-${build.id}_${program}" />
                               <arg value="--publish=${publish.dir}\ats_reports\${program}"/>
                             </exec>
-                            <!-- Now ready to send to ATS3 -->  
+                            <!-- Now ready to send to ATS -->  
 					      <echo message="Sending Test drop :  ${program} ............" />									
 					<antcall target="sf-send-testpkg" inheritAll="false">
                         <param name="sf.spec.test.package.name" value="${env.COMPUTERNAME}-bctest-${build.id}_${program}"/>
@@ -138,7 +138,7 @@
 		</if>	
     </target>
     
-	<!-- Preparing smoketest package (zip) for sending to ATS3 -->
+	<!-- Preparing smoketest package (zip) for sending to ATS -->
 	
 	<target name="sf-build-smoketestpkg" depends="sf-getenv-tools">
         <echo message="INFO Building smoketest"/>
@@ -151,42 +151,30 @@
         <exec executable="perl" dir="${build.drive}/smoketest/group" failonerror="false" append="true" output="${build.log.dir}/ATS_${build.id}_smoketest.log">
             <arg value="smoketest.pl"/>
 			<arg value="--target=${sf.spec.test.target}"/>
+			<arg value="--ats-version=${sf.spec.ats.version}"/>
         </exec>
         <copy file="${build.drive}/smoketest/group/smoketest.zip" todir="${sf.spec.test.package.location}"  failonerror="false"/>
         
         <echo message="INFO Updating smoketest package with test info"/>
 
-        <if><equals arg1="${sf.spec.test.target}" arg2="syborg"/>
-          <then>
-            <exec executable="perl" dir="${sf.common.config.dir}/tools/ats/" failonerror="false" append="true" output="${build.log.dir}/ATS_${build.id}_smoketest.log">
-              <arg value="ats_specialise_test_drop.pl"/>
-              <arg value="--test-drop-name=Smoketest-${build.id}"/> 
-              <arg value="--host-name=${env.COMPUTERNAME}.ad-sfpd.intra"/>
-              <arg value="--src=${sf.spec.test.package.location}\smoketest.zip"/>
-              <arg value="--dest=${sf.spec.test.package.location}\${sf.spec.test.package.name}"/>	
-              <arg value="--build-id=http://${sf.spec.publish.diamonds.server}${diamonds.build.id}"/>	
-              <arg value="--publish=${publish.dir}\ats_reports"/>
-              <arg value="--bld-drive=${build.drive}"/>
-              <arg value="--image-path=${sf.spec.test.imagepath}"/>
-            </exec>
-          </then>
-          <else>		
-            <exec executable="perl" dir="${sf.common.config.dir}/tools/ats/" failonerror="false" append="true" output="${build.log.dir}/ATS_${build.id}_smoketest.log">
-              <arg value="ats_specialise_test_drop.pl"/>
-              <arg value="--test-drop-name=Smoketest-${build.id}"/> 
-              <arg value="--host-name=${env.COMPUTERNAME}.ad-sfpd.intra"/>
-              <arg value="--src=${sf.spec.test.package.location}\smoketest.zip"/>
-              <arg value="--dest=${sf.spec.test.package.location}\${sf.spec.test.package.name}"/>	
-              <arg value="--build-id=http://${sf.spec.publish.diamonds.server}${diamonds.build.id}"/>	
-              <arg value="--publish=${publish.dir}\ats_reports"/>
-              <arg value="--bld-drive=${build.drive}"/>
-            </exec>
-          </else>
-        </if>
-        <!-- Now ready to send to ATS3 -->
+        <exec executable="perl" dir="${sf.common.config.dir}/tools/ats/" failonerror="false" append="true" output="${build.log.dir}/ATS_${build.id}_smoketest.log">
+          <arg value="ats_specialise_test_drop.pl"/>
+          <arg value="--test-drop-name=Smoketest-${build.id}"/> 
+          <arg value="--host-name=${env.COMPUTERNAME}.ad-sfpd.intra"/>
+          <arg value="--src=${sf.spec.test.package.location}\smoketest.zip"/>
+          <arg value="--dest=${sf.spec.test.package.location}\${sf.spec.test.package.name}"/>	
+          <arg value="--build-id=http://${sf.spec.publish.diamonds.server}${diamonds.build.id}"/>	
+          <arg value="--publish=${publish.dir}\ats_reports"/>
+          <arg value="--bld-drive=${build.drive}"/>
+          <arg value="--test-target=${sf.spec.test.target}"/>
+          <arg value="--image-path=${sf.spec.test.imagepath}"/>
+          <arg value="--ats-version=${sf.spec.ats.version}"/>
+        </exec>
+
+        <!-- Now ready to send to ATS -->
     </target>   
 
-	<!-- Sending testdrop to ATS3 -->
+	<!-- Sending testdrop to ATS -->
 	
     <target name="sf-send-testpkg" depends="sf-start-ats,sf-find-ATS-worker-root,sf-make-junction">
         <if><equals arg1="${sf.spec.test.target}" arg2="syborg"/>
@@ -198,31 +186,67 @@
         <mkdir dir="${sf.spec.test.workerroot}/${sf.spec.test.package.droppath}"/>
         <echo message="Sending test package ${sf.spec.test.package.name} to ${sf.spec.test.host.name} path ${sf.spec.test.host.droppath}"/>
         <exec executable="perl" dir="${sf.common.config.dir}/tools/ats" failonerror="false" output="${build.log.dir}/ATS_${build.id}_testdrop.log">
-            <arg value="ats3_testdrop.pl"/>
+            <arg value="ats_testdrop.pl"/>
             <arg value="--host=${sf.spec.test.host.name}"/>
             <arg value="--username=${sf.spec.test.host.username}"/>
             <arg value="--password=${sf.spec.test.host.password}"/>
             <arg value="--local-test-pkg=${sf.spec.test.package.location}\${sf.spec.test.package.name}"/>
             <arg value="--local-drop-path=${sf.spec.test.workerroot}\${sf.spec.test.package.droppath}"/>
             <arg value="--host-drop-path=${sf.spec.test.host.droppath}"/>
+            <arg value="--ats-version=${sf.spec.ats.version}"/>
+            <arg value="--ats-worker-path=${sf.spec.ats_worker.drive}"/>
         </exec>
     </target>
     
     <target name="sf-start-ats">
-        <if><available file="${ats.drive}/start.cmd"/>        
+        <if><equals arg1="${sf.spec.ats.version}" arg2="ats3"/>
+            <then>
+                <if><available file="${ats.drive}/start.cmd"/>  
+                    <then>
+                        <forget>
+                            <exec executable="cmd" dir="${ats.drive}" failonerror="true">
+                                <arg value="/c"/>
+                                <arg value="start"/>
+                                <arg value='"ATS3 STAF"'/>
+                                <arg value="/D"/>
+                                <arg value="."/>
+                                <arg value="/MAX"/>
+                                <arg value="run.cmd"/>
+                            </exec>
+                        </forget>
+                        <echo message="Waiting for 10 seconds for the ATS Worker to start......."/>
+                        <sleep seconds="10"/>
+                    </then>
+                </if>
+            </then>
+        </if>
+        <if><equals arg1="${sf.spec.ats.version}" arg2="ats4"/>
             <then>
                 <forget>
                     <exec executable="cmd" dir="${ats.drive}" failonerror="true">
                         <arg value="/c"/>
                         <arg value="start"/>
-                        <arg value='"ATS3 STAF"'/>
+                        <arg value='"ATS4 Agent"'/>
                         <arg value="/D"/>
                         <arg value="."/>
                         <arg value="/MAX"/>
-                        <arg value="run.cmd"/>
+                        <arg value="startAgent.cmd"/>
                     </exec>
                 </forget>
-                <echo message="Waiting for 10 seconds for the ATS Worker to start......."/>
+                <echo message="Waiting for 10 seconds for the ATS4 Agent(s) to start......."/>
+                <sleep seconds="10"/>
+                <forget>
+                    <exec executable="cmd" dir="${ats.drive}" failonerror="true">
+                        <arg value="/c"/>
+                        <arg value="start"/>
+                        <arg value='"ATS4 Engine"'/>
+                        <arg value="/D"/>
+                        <arg value="."/>
+                        <arg value="/MAX"/>
+                        <arg value="startEngine.cmd"/>
+                    </exec>
+                </forget>
+                <echo message="Waiting for 10 seconds for the ATS4 Engine to start......."/>
                 <sleep seconds="10"/>
             </then>
         </if>
--- a/common/common_props.ant.xml	Mon Jun 14 13:53:46 2010 +0100
+++ b/common/common_props.ant.xml	Mon Jun 14 14:13:44 2010 +0100
@@ -77,7 +77,8 @@
     <property name="sf.spec.publish.diamonds.port" value="80"/>
     <property name="sf.spec.publish.diamonds.path" value="/diamonds/builds/"/>
     <property name="sf.spec.publish.diamonds.tag" value=""/>
-    <property name="sf.spec.ats_worker.drive" value="C:\apps\ATS3\bin"/>
+    <property name="sf.spec.ats.version" value="ats3"/>
+    <property name="sf.spec.ats_worker.drive" value="C:\apps\${sf.spec.ats.version}\bin"/>
     
     <property name="sf.spec.tagafterbuild.enable" value="false"/>
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/templates/push-hg-tags.ant.xml.ftl	Mon Jun 14 14:13:44 2010 +0100
@@ -0,0 +1,44 @@
+<?xml version="1.0"?>
+<project name="SF-TAG-HG-CODE" default="all" xmlns:hlm="http://www.nokia.com/helium">
+
+	<#assign dollar = "$"/>
+	
+	<#assign target_depends = "" />
+	<#assign count = 0 />
+	
+	<#list data as pkg_detail>
+		<target name="sf-push-hg-tag-${count}">
+			<!-- Work out the URL of the web *MCL* -->
+			<propertyregex property="mcl.${count}" input="${pkg_detail.source}" regexp="(developer.symbian.org)/(oss|sfl)/FCL/(sf|sftools)" casesensitive="false" replace="\1/\2/MCL/\3" defaultValue="${pkg_detail.source}"/>
+			<exec executable="hg" dir="${ant['build.drive']}/tagging${pkg_detail.dst}" logError="true">
+				<arg value="push"/>
+				<arg value="--force"/>
+				<arg value="--config"/>
+				<arg value="auth.fbf1.prefix=https://developer.symbian.org/"/>
+				<arg value="--config"/>
+				<arg value="auth.fbf1.username=${dollar}{sf.symbian.account.username}"/>
+				<arg value="--config"/>
+				<arg value="auth.fbf1.password=${dollar}{sf.symbian.account.password}"/>
+				<arg value="--config"/>
+				<arg value="auth.fbf2.prefix=http://developer.symbian.org/"/>
+				<arg value="--config"/>
+				<arg value="auth.fbf2.username=${dollar}{sf.symbian.account.username}"/>
+				<arg value="--config"/>
+				<arg value="auth.fbf2.password=${dollar}{sf.symbian.account.password}"/>
+				<arg value="--rev"/>
+				<arg value="TAGS"/>
+				<arg value="${dollar}{mcl.${count}}"/>
+			</exec>
+		</target>
+		
+		<#if (count > 0) >
+			<#assign target_depends ="${target_depends}" + ", "/>
+		</#if>
+		<#assign target_depends = "${target_depends}" + "sf-push-hg-tag-${count}" />
+		
+		<#assign count = count + 1 />
+	</#list>
+	
+	<target name="all" depends="${target_depends}"/>
+
+</project>
--- a/common/templates/tag-hg-code.ant.xml.ftl	Mon Jun 14 13:53:46 2010 +0100
+++ b/common/templates/tag-hg-code.ant.xml.ftl	Mon Jun 14 14:13:44 2010 +0100
@@ -80,19 +80,11 @@
 			<exec executable="hg" dir="${ant['build.drive']}/tagging${pkg_detail.dst}" logError="true">
 				<arg value="--quiet"/>
 				<arg value="commit"/>
+				<arg value="--user"/>
+				<arg value="${dollar}{sf.hg.ui.username}"/>
 				<arg value="--message"/>
 				<arg value="Added tag ${ant['sf.tagafterbuild.tag']} for changeset ${dollar}{hash12.${count}}"/>
 			</exec>
-			<!-- Work out the URL of the web *MCL* -->
-			<propertyregex property="mcl.${count}" input="${pkg_detail.source}" regexp="(developer.symbian.org)/(oss|sfl)/FCL/(sf|sftools)" casesensitive="false" replace="\1/\2/MCL/\3" defaultValue="${pkg_detail.source}"/>
-			<echo message="Outgoing changes for ${dollar}{mcl.${count}}:"/>
-			<exec executable="hg" dir="${ant['build.drive']}/tagging${pkg_detail.dst}" logError="true">
-				<arg value="out"/>
-				<arg value="--force"/>
-				<arg value="--rev"/>
-				<arg value="TAGS"/>
-				<arg value="${dollar}{mcl.${count}}"/>
-			</exec>
 		</target>
 		
 		<#if (count > 0) >
--- a/common/tools/ats/ats_specialise_test_drop.pl	Mon Jun 14 13:53:46 2010 +0100
+++ b/common/tools/ats/ats_specialise_test_drop.pl	Mon Jun 14 14:13:44 2010 +0100
@@ -26,6 +26,7 @@
 use Data::Dumper;
 
 my $test_drop_name;	# Test drop name to be embedded in output XML
+my $test_drop;
 my $build_id;   # Build ID to be embedded in output XML 
 my $host_name;  # Host name to be embedded in output XML
 my $srcfile;	# Input test drop file, either .xml or .zip
@@ -42,6 +43,7 @@
 my $bld_drive;  # Subst'd drive
 my $test_target; # The target which the tests will be run on
 my $image_path; # The path to the ROM image used for testing (not valid for WINSCW target)
+my $ats_version; # The version of ATS used for running tests
 
 sub usage($);
 sub help();
@@ -53,10 +55,12 @@
                 'build-id' => \$build_id,
                 'src' => \$srcfile,
                 'dest' => \$destfile,
-                'help' => \$help,
                 'publish' => \$publish,
                 'bld-drive' => \$bld_drive,
-                'image-path' => \$image_path);
+				'test-target' => \$test_target,
+                'image-path' => \$image_path,
+				'ats-version' => \$ats_version,
+                'help' => \$help);
 
 GetOptions(\%optmap,
           'test-drop-name=s',
@@ -64,10 +68,12 @@
           'build-id=s',
           'src=s',
           'dest=s',
-          'help!',
           'publish=s', 
           'bld-drive=s',
-          'image-path=s') 
+		  'test-target=s',
+          'image-path=s',
+		  'ats-version=s',
+          'help!') 
           or usage_error();
 
 # Check if Tie::File module installed
@@ -101,7 +107,6 @@
     $destfile =~ s/$srctype$//;
 }
 
-
 if ($srctype =~ /^\.zip$/) { # Test drop is zip. Must contain test.xml.
     $xml_in = "test.xml"; # This is our input XML.
     if ( -f $xml_in) {
@@ -128,41 +133,112 @@
     $xml_in = $srcfile;
 }
 
+# --test-target is not mandatory.
+if (!defined($test_target)) { # Set winscw by default
+	$test_target = "winscw" 
+}
+
+# --ats-version is not mandatory.
+if (!defined($ats_version)) { # Set ats3 by default
+	$ats_version = "ats3" 
+}
+
 # Parse the input XML into hashref.
-my $test_drop = XMLin("./$xml_in", keeproot => 1,
-    forcearray => [ 'name', 'id', 'owner', 'priority', 'buildid', 'postAction', 'type', 'target', 'device', 'property', 'command', 'param', 'plan', 'session', 'set', 'alias' ],#
+if (lc($ats_version) eq "ats4") {
+	$test_drop = XMLin("./$xml_in", keeproot => 1,
+        forcearray => [ 'metadata', 'meta', 'agents', 'agent', 'property', 'postActions', 'action', 'type', 'parameters', 'parameter', 'execution', 'initialization', 'task', 'alias' ],#
         keyattr => [] );
+} else { # ats3 format
+	$test_drop = XMLin("./$xml_in", keeproot => 1,
+        forcearray => [ 'name', 'id', 'owner', 'priority', 'buildid', 'postAction', 'type', 'target', 'device', 'property', 'command', 'param', 'plan', 'session', 'set', 'alias' ],#
+        keyattr => [] );
+}
     
 # Insert the specified test drop name, if any.
-$test_drop->{'test'}->{'name'}->[0] = $test_drop_name, if $test_drop_name;
+if (lc($ats_version) eq "ats4") {
+	# Assumption: meta 'name' exists in test plan
+	$test_drop->{'testrun'}->{'metadata'}->[0]->{'meta'}->[0] = { 'name' => "name", 'content' => $test_drop_name }, if $test_drop_name;
+} else {
+	$test_drop->{'test'}->{'name'}->[0] = $test_drop_name, if $test_drop_name;
+}
 # Insert the specified build id, if any.
-$test_drop->{'test'}->{'buildid'}->[0] = $build_id, if $build_id;
+if (lc($ats_version) eq "ats4") {
+	if ($build_id) {
+		my $meta_num = @{$test_drop->{'testrun'}->{'metadata'}->[0]->{'meta'}};
+		$test_drop->{'testrun'}->{'metadata'}->[0]->{'meta'}->[$meta_num];
+		$test_drop->{'testrun'}->{'metadata'}->[0]->{'meta'}->[$meta_num] = { 'name' => "diamonds-buildid", 'content' => $build_id };
+		$test_drop->{'testrun'}->{'metadata'}->[0]->{'meta'}->[$meta_num+1];
+		$test_drop->{'testrun'}->{'metadata'}->[0]->{'meta'}->[$meta_num+1] = { 'name' => "diamonds-testtype", 'content' => "Smoke" }; # Hard-coded Smoke
+	}
+} else {
+	$test_drop->{'test'}->{'buildid'}->[0] = $build_id, if $build_id;
+}
 # Insert the path to the ROM image
-if ($image_path) {
-	my $set_params;
-	my $flash_params;
-	foreach $set_params (@{$test_drop->{'test'}->{'plan'}->[0]->{'session'}->[0]->{'set'}}) {
-		$test_target = $set_params->{'target'}->[0]->{'device'}->[0]->{'alias'};
-		$set_params->{'flash'}->[0];
-		$flash_params = $set_params->{'flash'};
-		$flash_params->[0] = { 'target-alias' => $test_target, 'images' => $image_path };
+if (lc($ats_version) eq "ats4") {
+	if (($image_path) && (lc($test_target) ne "winscw")) {
+		my $agent_alias = $test_drop->{'testrun'}->{'agents'}->[0]->{'agent'}->[0]->{'alias'};
+		my $task_num = @{$test_drop->{'testrun'}->{'execution'}->[0]->{'initialization'}->[0]->{'task'}};
+		$test_drop->{'testrun'}->{'execution'}->[0]->{'initialization'}->[0]->{'task'}->[$task_num];
+		$test_drop->{'testrun'}->{'execution'}->[0]->{'initialization'}->[0]->{'task'}->[$task_num] = { 'agents' => $agent_alias };
+		$test_drop->{'testrun'}->{'execution'}->[0]->{'initialization'}->[0]->{'task'}->[$task_num]->{'type'}->[0];
+		$test_drop->{'testrun'}->{'execution'}->[0]->{'initialization'}->[0]->{'task'}->[$task_num]->{'type'}->[0] = "FlashTask";
+		$test_drop->{'testrun'}->{'execution'}->[0]->{'initialization'}->[0]->{'task'}->[$task_num]->{'parameters'}->[0];
+		$test_drop->{'testrun'}->{'execution'}->[0]->{'initialization'}->[0]->{'task'}->[$task_num]->{'parameters'}->[0]->{'parameter'}->[0];
+		$test_drop->{'testrun'}->{'execution'}->[0]->{'initialization'}->[0]->{'task'}->[$task_num]->{'parameters'}->[0]->{'parameter'}->[0] = { 'name' => "image-1", 'value' => $image_path };
+		$test_drop->{'testrun'}->{'execution'}->[0]->{'initialization'}->[0]->{'task'}->[$task_num]->{'parameters'}->[0]->{'parameter'}->[1];
+		$test_drop->{'testrun'}->{'execution'}->[0]->{'initialization'}->[0]->{'task'}->[$task_num]->{'parameters'}->[0]->{'parameter'}->[1] = { 'name' => "timeout", 'value' => "1200" };
+	}
+} else {
+	if (($image_path) && (lc($test_target) ne "winscw")) {
+		my $device_alias;
+		my $set_params;
+		my $flash_params;
+		foreach $set_params (@{$test_drop->{'test'}->{'plan'}->[0]->{'session'}->[0]->{'set'}}) {
+			$device_alias = $set_params->{'target'}->[0]->{'device'}->[0]->{'alias'};
+			$set_params->{'flash'}->[0];
+			$flash_params = $set_params->{'flash'};
+			$flash_params->[0] = { 'target-alias' => $device_alias, 'images' => $image_path };
+		}
 	}
 }
 
 # Insert the FileStoreAction parameter
-my $postaction_params = $test_drop->{'test'}->{'postAction'}->[0]->{'params'}->{'param'}, if $publish;
-$postaction_params->[1] = { 'name' => "to-folder", 'value' => $publish }, if $publish;
+if (lc($ats_version) eq "ats4") {
+	if ($publish) {
+		my $action_num = @{$test_drop->{'testrun'}->{'postActions'}->[0]->{'action'}};
+		$test_drop->{'testrun'}->{'postActions'}->[0]->{'action'}->[$action_num];
+		$test_drop->{'testrun'}->{'postActions'}->[0]->{'action'}->[$action_num]->{'type'}->[0];
+		$test_drop->{'testrun'}->{'postActions'}->[0]->{'action'}->[$action_num]->{'type'}->[0] = "FileStoreAction";
+		$test_drop->{'testrun'}->{'postActions'}->[0]->{'action'}->[$action_num]->{'parameters'}->[0];
+		$test_drop->{'testrun'}->{'postActions'}->[0]->{'action'}->[$action_num]->{'parameters'}->[0]->{'parameter'}->[0];
+		$test_drop->{'testrun'}->{'postActions'}->[0]->{'action'}->[$action_num]->{'parameters'}->[0]->{'parameter'}->[0] = { 'name' => "dst", 'value' => $publish };
+	}
+} else {
+	if ($publish) {
+		my $postaction_params = $test_drop->{'test'}->{'postAction'}->[0]->{'params'}->{'param'};
+		$postaction_params->[1] = { 'name' => "to-folder", 'value' => $publish };
+	}
+}
 
-if ($host_name) { # Also insert specified host name
-	my $devices = $test_drop->{'test'}->{'target'}->[0]->{'device'};
-    
-    foreach my $device (@{$devices}) {
-        my $device_properties = $device->{'property'};
-        my $num_properties = @{$device_properties};
-        
-        $device_properties->[$num_properties] = { 'name' => "HOST", 'value' => "$host_name" };
-        $device->{'property'} = $device_properties;
-    }
+# Also insert specified host name
+if (lc($ats_version) eq "ats4") {
+	if ($host_name) {
+		# Assumption: 'agent' element with 'property' exists in test plan
+		my $agent_name = uc($test_target) . " on " . $host_name;
+		$test_drop->{'testrun'}->{'agents'}->[0]->{'agent'}->[0]->{'property'}->[0] = { 'name' => "name", 'value' => $agent_name };
+	}
+} else {
+	if ($host_name) { 
+		my $devices = $test_drop->{'test'}->{'target'}->[0]->{'device'};
+		
+		foreach my $device (@{$devices}) {
+			my $device_properties = $device->{'property'};
+			my $num_properties = @{$device_properties};
+			
+			$device_properties->[$num_properties] = { 'name' => "HOST", 'value' => "$host_name" };
+			$device->{'property'} = $device_properties;
+		}
+	}
 }
 
 if ($srctype =~ /^\.xml$/i ) { # Input file was XML
@@ -176,7 +252,7 @@
     open OUT,">test.xml" or die("Cannot open file \"test.xml\" for writing. $!\n");
     print OUT XMLout($test_drop, keeproot => 1);
     close OUT;
-	if ($publish) { #Move <type>FileStoreAction</type> above <params>
+	if (($publish) && (lc($ats_version) eq "ats3")) { #Move <type>FileStoreAction</type> above <params>
 		my @lines;
 		tie @lines, 'Tie::File', "test.xml" or die("Cannot tie file \"test.xml\". $!\n");
 		my $current_line = 0;
@@ -224,18 +300,24 @@
             "Specify the name, build id and target device in an ATS XML test drop\n" .
             "synopsis:\n" .
             "  ats_specialise_test_drop.pl --help\n" .
-            "  ats_specialise_test_drop.pl [--test-drop-name=TESTNAME] [--build-id=BUILDID] [--host-name=HOSTNAME] [--dest=FILE] --src=FILE \n" .
+            "  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" .
             "options:\n" .
             "  --help                        Display this help and exit\n" .
             "  --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" .
             "  --build-id=BUILDID            BUILDID is id of the build being tested. If not specified then the build id is not modified.\n" .            
-            "  --host-name=HOSTNAME        HOSTNAME  is the name of the ATS worker on which the test should be run. " .
+            "  --host-name=HOSTNAME          HOSTNAME  is the name of the ATS worker on which the test should be run. " .
             "If not specified then the test device name is not modified.\n" .
             "  --src=INFILE                  INFILE is the file containing the test drop XML to be modified, or else a zip file " .
             "                                containing the test drop XML in the file 'test.xml'. INFILE must have extension .xml or.zip\n" .
             "  --dest=OUTFILE                The modified output will be written to the file OUTFILE.EXT " .
             "where EXT is same extention, .xml or .zip, found on INFILE. " .
-            "If OUTFILE is not specified then INFILE is modified\n";              
+            "If OUTFILE is not specified then INFILE is modified\n" . 
+            "  --publish=DIR                 DIR is the publishing folder for ats reports (optional).\n" .
+            "  --bld-drive=DRIVE             DRIVE is the subst'd drive on which the build is stored (optional).\n" .
+			"  --test-target=TARGET          TARGET is the target which the tests will be run on. If not specified WINSCW will be set by default\n" .
+            "  --image-path=PATH             PATH is the path to the ROM image used for testing (not valid for WINSCW target).\n" .
+            "  --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";
+			
     exit $error;            
 }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/tools/ats/ats_testdrop.pl	Mon Jun 14 14:13:44 2010 +0100
@@ -0,0 +1,194 @@
+#!/usr/bin/perl
+
+# Copyright (c) 2009 Symbian Foundation Ltd
+# This component and the accompanying materials are made available
+# under the terms of the License "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Symbian Foundation Ltd - initial contribution.
+#   Mike Kinghan, mikek@symbian.org
+#
+# Contributors:
+#   Maciej Seroka, maciejs@symbian.org
+#
+# Description:
+#   This is a tool for sending an ATS testdrop to an ATS server.
+
+use strict;
+use Getopt::Long;
+use File::Copy;
+use File::Spec;
+
+my $username = "admin"; # ATS server user name
+my $password = "admin"; # ATS server password
+my $host;   # ATS server hostname
+my $schedule;   # Schedule string for test drop, if any
+my $host_drop_path; # Directory path on the ATS server where the test drop will be placed.
+                    # This must be physically the same path as $local_drop_path, via drive mapping. 
+my $local_drop_path; # Local directory path where the test drop will be placed.
+                    # This must be physically the same path as $host_drop_path, via drive mapping.
+my $local_test_pkg; # Local pathname of the test drop (zip or xml file). The test drop will be
+                    # copied from here to $local_drop_path to make it accessible on the server,
+                    # unless $local_test_pkg begins with "...". This indicates the test drop is already
+                    # present in $local_drop_path and does need to be copied there. The remainder
+                    # following "..." is the filename of the test drop.    
+my $help;
+my $dev_null = $^O =~ /^MSWin/ ? "nul" : "/dev/null";
+my $ats_version; # The version of ATS used for running tests
+my $ats_worker_path;
+
+sub usage($);
+sub help();
+sub usage_error();
+
+my %optmap = (  'host' => \$host,
+			    'local-test-pkg' => \$local_test_pkg,
+				'host-drop-path' => \$host_drop_path,
+				'local-drop-path' =>\$local_drop_path,
+				'username' => \$username,
+				'password' => \$password,
+				'schedule' => \$schedule,
+				'ats-version' => \$ats_version,
+				'ats-worker-path' => \$ats_worker_path,
+                'help' => \$help);
+
+GetOptions(\%optmap,
+          'host=s',
+          'local-test-pkg=s',
+          'host-drop-path=s',
+          'local-drop-path=s',
+          'username=s',
+          'password=s',
+          'schedule=s',
+		  'ats-version=s',
+		  'ats-worker-path=s',
+          'help!') 
+          or usage_error();
+
+if ($help) {
+	help();
+}
+
+usage_error(), unless (defined($host) && defined($local_test_pkg) && defined($local_drop_path) && defined($host_drop_path));
+
+# --ats-version is not mandatory.
+if (!defined($ats_version)) { # Set ats3 by default
+	$ats_version = "ats3" 
+}
+
+# --ats-worker-path is not mandatory.
+if (!defined($ats_worker_path)) { # Set ats3 by default
+	$ats_worker_path = "c:\\apps\\$ats_version\\bin" 
+}
+
+my $curl_version = `curl --version 1> $dev_null 2>&1`;
+die("Need program \"curl\". Not found"), if ($?);
+die("Test drop path \"$local_drop_path\" not found"), unless ( -d "$local_drop_path");
+
+if (lc($ats_version) eq "ats4") {
+	$host = "http:\/\/" . $host . ":7780\/ServerService", unless ($host =~ /:\d+$/);
+} else {
+	$host .= ":8080", unless ($host =~ /:\d+$/);
+}
+
+my ($vol,$dir,$pkg);
+my $local_test_drop;
+my $host_test_drop;
+
+if ($local_test_pkg =~ /^\.\.\.(.+)/ ) { # Local test package name begins with "...". No need to copy. 
+    $pkg = $1; # Get the filename of the test package.
+    # Compose the full name of the test drop within the local drop path.
+    $local_test_drop = File::Spec->catfile($local_drop_path,$pkg);    
+    die("Test package file \"$local_test_drop\" not found"), unless ( -f "$local_test_drop");        
+}
+else { # Local test package must be copied to local drop path.
+    die("Test package file \"$local_test_pkg\" not found"), unless ( -f "$local_test_pkg");
+    # Compose the full name of the test drop within the local drop path.    
+    ($vol,$dir,$pkg) = File::Spec->splitpath($local_test_pkg);
+    $local_test_drop = File::Spec->catfile($local_drop_path,$pkg);
+    if ( -f "$local_test_drop") {
+        # A state test drop of the same name exists. Delete.
+        unlink($local_test_drop) or die("Can't delete stale test drop \"$local_test_drop\". $!");
+        print("A stale test drop \"$local_test_drop\" existed. Deleted\n");
+    }
+    # Copy the test drop to the local drop path.
+    copy("$local_test_pkg","$local_test_drop")
+        or die("Cannot copy \"$local_test_pkg\" -> \"$local_test_drop\". $!");
+}
+# Compose the full name of the test drop within the host drop path.
+$host_test_drop = File::Spec->catfile($host_drop_path,$pkg);
+# Compose URL to notify server of test drop, requesting run.
+my $url;
+if (lc($ats_version) eq "ats4") {
+	$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";
+} else {
+	$url ="http://$host/ats3/XTestRunExecute.do?username=$username&password=$password&testrunpath=$host_test_drop";
+	$url .= "&schedule=$schedule", if (defined($schedule));
+}
+# Post URL to server with cURL.
+my $curl_cmd;
+if (lc($ats_version) eq "ats4") {
+	$curl_cmd = "java $url";
+} else {
+	$curl_cmd = "curl \"$url\"";
+}
+my $curl_response = `$curl_cmd 2>&1`;
+#die("\nTest drop failed: $!\n"), if ($?);
+die("\nTest drop failed: $curl_response\n"), if ($?);
+if (lc($ats_version) eq "ats4") {
+	print "$curl_response\n";
+} else { 
+	if ($curl_response =~ /(TEST_RUN_REF_ID=\d+)/) {
+		#extract test run id from cURL response.
+		print "$1\n";
+	}
+	else {
+		print "$curl_response\n";
+		die("Test drop failed\n");
+	} 
+}
+print("Test drop done\n");
+
+exit 0;
+
+sub usage($)
+{
+    my $error = shift;
+    my $fh = $error == 0 ? *STDOUT : *STDERR;
+    print $fh "ats_testdrop.pl\n" .
+            "Send a test drop to an ATS server for execution\n" .
+            "usage:\n" .
+            "  ats_testdrop.pl --help\n" .
+            "  ats_testdrop.pl --host=HOSTNAME --local-test-pkg=PKGFILE --local-drop-path=LOCALPATH " .
+                " --host-drop-path=HOSTPATH " .
+                "[--username=ATS3USERNAME] [--password=ATS3PASSWORD] [--schedule=DD.MM.YYYY-HH:MM] [--ats-version=VERSION] [--ats-worker-path=ATSPATH]\n" .
+            "options:\n" .
+            "  --help                        Display this help and exit\n" .
+            "  --host=HOSTAME                HOSTNAME is ATS server\n" .
+            "  --local-test-pkg=PKGFILE      PKGFILE is the test package.\n" .
+            "                                If PKGFILE begins \"...\" a filename in LOCALPATH is assumed\n" .
+            "  --local-drop-path=LOCALPATH   Path to local directory where PKGFILE will be dropped\n" .            
+            "  --host-drop-path=HOSTPATH     Host directory that is mapped to LOCALPATH.\n" .
+            "                                Must agree with the properties of the registered device that the test package nominates\n" .
+            "  --username=ATS3USERNAME       ATS3 user to whome the test will belong. Default=admin\n" .
+            "  --password=ATS3PASSWORD       Password of ATS3 user. Default=admin\n" .
+            "  --schedule=DD.MM.YYYY-HH:MM   Date-time at which test is to run. Default=as soon as possible\n" .
+            "  --ats-version=VERSION         Version of ATS which will be used to run the tests. If not specified ATS3 will be set by default.\n" .
+            "  --ats-worker-path=ATSPATH     Path to the ATS bin directory. If not specified c:\\apps\\\$ats_version\\bin will set by default.\n";
+    exit $error;            
+}
+
+sub help()
+{
+    usage(0);
+}
+
+sub usage_error()
+{
+    usage(1);
+}             
+
+# EOF
+   
\ No newline at end of file