First drop of smoketest support
authordario
Wed, 13 May 2009 13:59:56 +0100
changeset 80 1b428f25477e
parent 79 91ad95e5509a
child 81 8eef886f83b9
First drop of smoketest support
common/build.xml
common/common_props.ant.xml
common/smoketest/ats3_testdrop.pl
common/smoketest/make_junction.pl
common/smoketest/smoke_test.ant.xml
--- a/common/build.xml	Thu May 07 12:06:21 2009 +0100
+++ b/common/build.xml	Wed May 13 13:59:56 2009 +0100
@@ -28,6 +28,9 @@
     <!-- import all core HELIUM targets -->
     <import file="${helium.dir}/helium.ant.xml" />
     
+    <!-- import other files -->
+    <import file="${sf.common.config.dir}/smoketest/smoke_test.ant.xml" />
+    
     <!-- import common references -->
     <import file="${sf.common.config.dir}/common_refs.ant.xml" />
              
@@ -134,7 +137,7 @@
                     <arg value="${sf.spec.baseline.location}"/>
                 </exec>
                 
-                <!-- run interal target preparation-getenv -->
+                <!-- run internal target preparation-getenv -->
                 <runtarget target="preparation-getenv"/>
                 
             </then>
@@ -176,6 +179,9 @@
       </then>
     </if>
     
+    <!-- EXEC SMOKE TEST -->
+    <runtarget target="sf-smoke-test"/>
+    
   </target>
 
   <!-- package all logs into zipfile before publish -->
--- a/common/common_props.ant.xml	Thu May 07 12:06:21 2009 +0100
+++ b/common/common_props.ant.xml	Wed May 13 13:59:56 2009 +0100
@@ -62,6 +62,17 @@
     
     <!-- zip all logs before publish -->
     <property name="sf.spec.logs.zip.enable"  value="true"/>
+    
+    <property name="sf.spec.smoketest.enable" value="true"/>
+    <property name="sf.spec.smoketest.host" value="sym-build01"/>
+    <property name="sf.spec.smoketest.epocroot" value="D:\ATS3\winscw_smoketest"/>
+    <property name="sf.spec.smoketest.localtestpkg" value="D:\ATS3\smoketest_package\9.zip"/>
+    <property name="sf.spec.smoketest.localdroppath" value="D:\ATS3\TestDrops"/>
+    <property name="sf.spec.smoketest.hostdroppath" value="T:\TestDrops"/>
+    <property name="sf.spec.smoketest.ats3.username" value="admin"/>
+    <property name="sf.spec.smoketest.ats3.password" value="admin"/>
+    
+    
 	
 </project>
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/smoketest/ats3_testdrop.pl	Wed May 13 13:59:56 2009 +0100
@@ -0,0 +1,133 @@
+#!/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;
+use File::Spec;
+
+my $username = "admin";
+my $password = "admin";
+my $host;
+my $schedule;
+my $host_drop_path;
+my $local_drop_path;
+my $local_test_pkg;
+my $help;
+my $dev_null = $^O =~ /^MSWin/ ? "nul" : "/dev/null";
+
+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,
+                'help' => \$help);
+
+GetOptions(\%optmap,
+          'host=s',
+          'local-test-pkg=s',
+          'host-drop-path=s',
+          'local-drop-path=s',
+          'username=s',
+          'password=s',
+          'schedule=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));
+
+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;
+
+if ($local_test_pkg =~ /^\.\.\.(.+)/ ) {
+    $pkg = $1;
+    $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 {
+    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);
+    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");
+            }
+        }
+    }
+    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);
+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");
+
+exit 0;
+
+sub usage($)
+{
+    my $error = shift;
+    my $fh = $error == 0 ? *STDOUT : *STDERR;
+    print $fh "ats3_testdrop.pl\n" .
+            "Send a test drop to an ATS3 server for execution\n" .
+            "usage:\n" .
+            "  ats3_testdrop.pl --help\n" .
+            "  ats3_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]\n" .
+            "options:\n" .
+            "  --help                        Display this help and exit\n" .
+            "  --host=HOSTAME                HOSTNAME is ATS3 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";
+    exit $error;            
+}
+
+sub help()
+{
+    usage(0);
+}
+
+sub usage_error()
+{
+    usage(1);
+}             
+
+# EOF
+   
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/smoketest/make_junction.pl	Wed May 13 13:59:56 2009 +0100
@@ -0,0 +1,96 @@
+#!/usr/bin/perl
+
+use strict;
+use Getopt::Long;
+
+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";
+
+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";
+    exit $error;            
+}
+
+sub help()
+{
+    usage(0);
+}
+
+sub usage_error()
+{
+    usage(1);
+}             
+
+# EOF
+   
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/smoketest/smoke_test.ant.xml	Wed May 13 13:59:56 2009 +0100
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="SF-SMOKE-TEST">
+
+  <target name="sf-smoke-test">
+    <echo>[SF-SMOKE-TEST]</echo>
+    
+    <exec executable="perl" dir="${sf.common.config.dir}/smoketest" failonerror="true" output="${build.drive}/output/logs/smoke_test_1.log">
+      <arg value="make_junction.pl"/>
+      <arg value="--link=${sf.spec.smoketest.epocroot}/epoc32"/>
+      <arg value="--target=${build.drive}/epoc32"/>
+      <arg value="--force"/>
+    </exec>
+    
+    <exec executable="perl" dir="${sf.common.config.dir}/smoketest" failonerror="true" output="${build.drive}/output/logs/smoke_test_2.log">
+      <arg value="ats3_testdrop.pl"/>
+      <arg value="--host=${sf.spec.smoketest.host}"/>
+      <arg value="--username=${sf.spec.smoketest.ats3.username}"/>
+      <arg value="--password=${sf.spec.smoketest.ats3.password}"/>
+      <arg value="--local-test-pkg=${sf.spec.smoketest.localtestpkg}"/>
+      <arg value="--local-drop-path=${sf.spec.smoketest.localdroppath}"/>
+      <arg value="--host-drop-path=${sf.spec.smoketest.hostdroppath}"/>
+    </exec>
+    
+  </target>
+  
+</project>
\ No newline at end of file