Add ATS test client target <sf-send-testpkg> to default configuration. Default is off.
authorShabe Razvi <shaber@symbian.org>
Tue, 19 May 2009 14:51:44 +0100
changeset 122 2c7b53b5228f
parent 121 aa585d28e584
child 123 c222f4b27ad7
Add ATS test client target <sf-send-testpkg> to default configuration. Default is off.
common/build.xml
common/common_props.ant.xml
common/tools/ats/ats3_testdrop.pl
common/tools/ats/make_junction.pl
common/tools/ats/tester.bat
common/tools/ats/wshTestRunX.vbs
--- a/common/build.xml	Mon May 18 11:39:37 2009 +0100
+++ b/common/build.xml	Tue May 19 14:51:44 2009 +0100
@@ -420,21 +420,43 @@
         </hlm:fastcopy>
         </then>
     </if>
-  </target>
+    </target>
   
-    <target name="sf-send-testpkg">
-        <echo message="Sending test package ${sf.spec.test.package.name} to ${sf.spec.test.host.name}"/>
-        <exec executable="perl" dir="${sf.common.config.dir}/tools/" failonerror="true" output="${build.log.dir}/ATS_${build.id}_smoketest.log">
+    <target name ="sf-make-junction">
+        
+        <mkdir dir="${sf.spec.test.epocroot}"/>
+
+        <exec executable="perl" dir="${sf.common.config.dir}/tools/ats" failonerror="false" output="${build.log.dir}/ATS_${build.id}_make_junction.log">
+        <arg value="make_junction.pl"/>
+        <arg value="--link=${sf.spec.test.epocroot}/epoc32"/>
+        <arg value="--target=${build.drive}/epoc32"/>
+        <arg value="--force"/>
+      </exec>
+    </target>
+
+    <target name ="sf-delete-junction">
+        <exec executable="junction.exe" dir="${sf.spec.test.epocroot}" failonerror="false" output="${build.log.dir}/ATS_${build.id}_delete_junction.log">
+        <arg value="-d"/>
+        <arg value="epoc32"/>
+      </exec>
+    </target>  
+    
+    <target name="sf-send-testpkg" depends="sf-make-junction">
+        <mkdir dir="${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="${sf.spec.test.host.name}"/>
-            <arg value="${sf.spec.test.host.path}"/>
-            <arg value="${sf.spec.test.package.name}"/>
-            <arg value="${sf.spec.test.package.path}"/>
+            <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.name}"/>
+            <arg value="--local-drop-path=${sf.spec.test.package.droppath}"/>
+            <arg value="--host-drop-path=${sf.spec.test.host.droppath}"/>
         </exec>
-  </target>
+    </target>
   
-  <!-- runs analysis of missing bins and source -->
-  <target name="sf-run-analysis">
+    <!-- runs analysis of missing bins and source -->
+    <target name="sf-run-analysis">
         <mkdir dir="${build.log.dir}/analysis"/>
 
         <echo message="Running source analysis of ANT output"/>
@@ -461,9 +483,7 @@
             <arg value="${build.id}_list_results.log"/>
             <arg value="${build.id}_what_results.log"/>
         </exec>
-
-
-  </target>
+    </target>
   
 </project>
 
--- a/common/common_props.ant.xml	Mon May 18 11:39:37 2009 +0100
+++ b/common/common_props.ant.xml	Tue May 19 14:51:44 2009 +0100
@@ -68,11 +68,15 @@
 
     <!-- ATS client properties -->
     <property name="sf.spec.test.sendpkg.enable" value="false"/>
-    <property name="sf.spec.test.host.name" value=""/>
-    <property name="sf.spec.test.host.path" value=""/>
+    <property name="sf.spec.test.host.name"      value="172.16.11.11"/> <!-- sym-build01 -->
+    <property name="sf.spec.test.host.username"  value="admin"/>
+    <property name="sf.spec.test.host.pasasword" value="admin"/>
+    <property name="sf.spec.test.host.droppath"  value="T:\TestDrops"/>
+    <property name="sf.spec.test.epocroot"       value="D:\ATS3\winscw_smoketest"/>
 
-    <property name="sf.spec.test.package.name" value=""/>
-    <property name="sf.spec.test.package.path" value=""/>
+    <!-- ATS local properties -->
+    <property name="sf.spec.test.package.name"      value="D:\ATS3\smoketest_package\9.zip"/>
+    <property name="sf.spec.test.package.droppath"  value="D:\ATS3\TestDrops"/>
 
 </project>
 
--- a/common/tools/ats/ats3_testdrop.pl	Mon May 18 11:39:37 2009 +0100
+++ b/common/tools/ats/ats3_testdrop.pl	Tue May 19 14:51:44 2009 +0100
@@ -1,5 +1,6 @@
 #!/usr/bin/perl
 
+#curl "http://sym-build01:8080/ats3/XTestRunExecute.do?username=admin&password=admin&testrunpath=D:\smoketests\test_drops\9.zip
 use strict;
 use Getopt::Long;
 use File::Copy;
@@ -13,6 +14,7 @@
 my $local_drop_path;
 my $local_test_pkg;
 my $help;
+my $dev_null = $^O =~ /^MSWin/ ? "nul" : "/dev/null";
 
 sub usage($);
 sub help();
@@ -44,11 +46,12 @@
 
 usage_error(), unless (defined($host) && defined($local_test_pkg) && defined($local_drop_path) && defined($host_drop_path));
 
-my $cscript_help = `cscript /?`;
-die("Need command \"cscript\". Not in found"), if ($?);
-die("Need VB script wshTestRunX.vbs. Not found"), unless ( -f "wshTestRunX.vbs");
+my $curl_version = $^O =~ /^MSWin/ ? `curl --version 1> $dev_null 2>&1` : `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");
 
+$host .= ":8080", unless ($host =~ /:\d+$/);
+
 my ($vol,$dir,$pkg);
 my $local_test_drop;
 my $host_test_drop;
@@ -62,27 +65,30 @@
     die("Test package file \"$local_test_pkg\" not found"), unless ( -f "$local_test_pkg");
     ($vol,$dir,$pkg) = File::Spec->splitpath($local_test_pkg);
     $local_test_drop = File::Spec->catfile($local_drop_path,$pkg);
-    my $lc_local_test_drop = lc($local_test_drop);
-    my $lc_local_test_pkg = lc($local_test_pkg);    
-    if ("$lc_local_test_drop" ne "$lc_local_test_pkg") {
-        if (unlink($local_test_drop) == 0) {
-            die("Can't delete stale testdrop \"$local_test_drop\". $!");
+    if ( -f "$local_test_drop") {
+        my $cmp_local_test_drop = $local_test_drop;
+        my $cmp_local_test_pkg = $local_test_pkg;
+        if ($^O =~ /^MSWin/) {
+            $cmp_local_test_drop = lc($local_test_drop);
+            $cmp_local_test_pkg = lc($local_test_pkg);        
+        }   
+        if ("$cmp_local_test_drop" eq "$cmp_local_test_pkg") {
+            if (unlink($local_test_drop) == 0) {
+                die("Can't delete stale test drop \"$local_test_drop\". $!");
+            }
+            else {
+                print("A stale test drop \"$local_test_drop\" existed. Deleted\n");
+            }
         }
-        else {
-            print("A stale testtop \"$local_test_drop\" existed. Deleted\n");
-        }
-        copy("$local_test_pkg","$local_test_drop")
-            or die("Cannot copy \"$local_test_pkg\" -> \"$local_test_drop\". $!");
-    }    
+    }
+    copy("$local_test_pkg","$local_test_drop")
+        or die("Cannot copy \"$local_test_pkg\" -> \"$local_test_drop\". $!");
 }
 $host_test_drop = File::Spec->catfile($host_drop_path,$pkg);
-
-$ENV{'ats3.host'} = $host;
-$ENV{'ats3.pathToDrop'} = $host_test_drop;
-$ENV{'ats3.username'} = $username;
-$ENV{'ats3.password'} = $password;
-$ENV{'ats3.schedule'} = $schedule, if defined($schedule);
-system("cscript wshTestRunX.vbs");
+my $url ="http://$host/ats3/XTestRunExecute.do?username=$username&password=$password&testrunpath=$host_test_drop";
+$url .= "&schedule=$schedule", if (defined($schedule));
+my $curl_cmd = "curl \"$url\"";
+system("$curl_cmd");
 die("\nTest drop failed: $!"), if ($?);
 print("\nTest drop done");
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/tools/ats/make_junction.pl	Tue May 19 14:51:44 2009 +0100
@@ -0,0 +1,117 @@
+#!/usr/bin/perl
+
+use strict;
+use Getopt::Long;
+use File::Spec;
+
+my $link;
+my $target;
+my $help;
+my $force = 0;
+
+sub usage($);
+sub help();
+sub usage_error();
+
+my %optmap = (  'link' => \$link,
+			    'target' => \$target,
+			    'force' => \$force, 
+                'help' => \$help);
+
+GetOptions(\%optmap,
+          'link=s',
+          'target=s',
+          'force!',
+          'help!') 
+          or usage_error();
+
+if ($help) {
+	help();
+}
+
+usage_error(), unless (defined($link) && defined($target));
+
+my $junction_help = `junction /?`;
+die("Need command \"junction\". Not found\n"), if ($junction_help =~ /is not recognised/);
+die("Directory \"$target\" not found\n"), unless -d "$target";
+
+my ($vol,$dir,$file) = File::Spec->splitpath($target);
+my @subst_lines = `subst`;
+
+foreach (@subst_lines) {
+    my $line = $_;
+    chomp($line);
+    $line =~ /^(.:)\\: => (.*)$/;
+    die("Cannot parse output of 'subst'. Bailing out confused."), unless (defined($1) and defined($2));    
+    my $subst_drive = $1;
+    my $subst_targ = $2;
+    if (lc($subst_drive) eq lc($vol)) {
+        print("Target $target is in a substituted drive: $line\n");
+        $target = File::Spec->catfile(($subst_targ,$dir),$file);
+        print("Target $target will be used\n");
+        last;
+    }
+}
+
+
+if ( -e "$link") {
+    print("\"$link\" already exists. ");
+    if (!$force) {
+        my $choice;
+        while($choice ne 'y' and $choice ne 'n') {
+            print "Delete? (y/n)? ";
+            $choice = <STDIN>;
+            chomp($choice);
+            $choice = lc($choice);
+        }
+        $force = $choice eq 'y';
+    }    
+    if ($force) {
+        system("junction -d \"$link\" > nul");
+        if ($?) {
+            die("Cannot delete \"$link\": $!\n");
+        }
+        else {
+            print "Deleted \"$link\"\n";
+        }
+    }
+} 
+
+system("junction \"$link\" \"$target\" > nul");
+if ($?) {
+    die("Cannot cteate junction \"$link\" -> \"$target\": $!\n");
+}
+else {
+    print("Created junction \"$link\" -> \"$target\"\n");
+}
+exit 0;
+
+sub usage($)
+{
+    my $error = shift;
+    my $fh = $error == 0 ? *STDOUT : *STDERR;
+    print $fh "make_junction.pl\n" .
+            "Create a Windows junction (a.k.a symbolic link)\n" .
+            "usage:\n" .
+            "  make_junction.pl --help\n" .
+            "  make_junction.pl --link=LINKDIR --target=TARGDIR\n " .
+            "options:\n" .
+            "  --help                        Display this help and exit\n" .
+            "  --link=LINKDIR                LINKDIR specifies the junction to be created. Last component is the junction. The rest must exist\n" .
+            "  --target=TARGDIR              TARGDIR is directory to which the junction will point.\n" .
+            "                                If TARGDIR is in a substed drive, the real path will be used.\n";
+    exit $error;            
+}
+
+sub help()
+{
+    usage(0);
+}
+
+sub usage_error()
+{
+    usage(1);
+}             
+
+# EOF
+   
\ No newline at end of file
--- a/common/tools/ats/tester.bat	Mon May 18 11:39:37 2009 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-perl ats3_testdrop.pl --host=172.16.11.11 --local-test-pkg=...9.zip --local-drop-path=D:\ATS3\TestDrops --host-drop-path=T:\TestDrops
-
--- a/common/tools/ats/wshTestRunX.vbs	Mon May 18 11:39:37 2009 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,78 +0,0 @@
-'
-' WScript that will invoke the test run execute functionality at ATS3 web server without installing any ATS3
-' specific programs on the local PC.
-'
-' Password must be given in encrypted format and the path to test drop must be in URLEncoded
-'
-' Usage cscript wshRunX.vbs <username> <password> <server hostname> <path to testDrop.zip>
-'
-
-' Get the command line arguments
-set args = WScript.Arguments
-
-' Check that all arguments have been specified
-Set objShell = WScript.CreateObject("WScript.Shell")
-Set env = objShell.Environment("Process")
-checkEnvVars(env)
-
-' Invoke the web application and write the result to stdOut
-WScript.StdOut.Write doTestRunX(env("ats3.username"), env("ats3.password"), env("ats3.host"), URLEncode( env("ats3.pathToDrop") ), URLEncode( env("ats3.schedule") ))
-
-' Quit the script
-Wscript.Quit
-
-Function checkEnvVars(env)
-	if env("ats3.username") = "" then
-		WScript.Echo "Environment variable ats3.username not specified"
-		WScript.Quit 1
-	elseif env("ats3.password") = "" then
-		WScript.Echo "Environment variable ats3.password not specified"
-		WScript.Quit 1
-	elseif env("ats3.host") = "" then
-		WScript.Echo "Environment variable ats3.host not specified"
-		WScript.Quit 1		
-	elseif env("ats3.pathToDrop") = "" then
-		WScript.Echo "Environment variable ats3.pathToDrop not specified"
-		WScript.Quit 1	
-	end if
-End Function
-
-' Invoke the ATS3 web application in given host with the specified username, password and file path
-Function doTestRunX(uname, password, hostName, pathToDrop, schedule)
-    On Error Resume Next
-    
-	'If the given hostname contain port, use it otherwise use the default 8080
-        if(InStr(1, hostName, ":", VBTEXTCOMPARE) = 0) then
-        	hostName = hostName & ":8080"
-        end if    
-    
-	Set objxmlHTTP = CreateObject("Microsoft.XMLHTTP")
-	Call objxmlHTTP.open("GET", "http://" & hostName & "/ats3/XTestRunExecute.do?username=" & uname & "&password=" & password & "&testrunpath=" & pathToDrop & "&schedule=" & schedule, False)
-	objxmlHTTP.Send()
-	If Err.Number <> 0 Then
-		WScript.Echo "Error sending data to server: " + hostName
-    	WScript.Quit 1
-	End if		
-
-    if objxmlHTTP.status = 200 then
-    	doTestRunX = objxmlHTTP.ResponseText
-    else
-        WScript.Echo "Error importing test run: " + objxmlHTTP.ResponseText
-    	WScript.Quit 1
-	end if
-End Function
-
-Function URLEncode(data)
-	data = replace(data,"\","/")
-	data = replace(data,"$","%24")
-	data = replace(data,"&","%26")
-	data = replace(data,"+","%2B")
-	data = replace(data,",","%2C")
-	data = replace(data,"/","%2F")
-	data = replace(data,":","%3A")
-	data = replace(data,";","%3B")
-	data = replace(data,"=","%3D")
-	data = replace(data,"?","%3F")
-	data = replace(data,"@","%40")
-	URLEncode = data
-End Function
\ No newline at end of file