diff options
author | dac <qt-info@nokia.com> | 2010-06-22 12:05:43 +1000 |
---|---|---|
committer | dac <qt-info@nokia.com> | 2010-06-22 12:05:43 +1000 |
commit | 1006d6be6384bdbfbb5352ef43168d5de16b8f59 (patch) | |
tree | bf37dbbb542938b6efbe845efe544587b9cd807c /scripts | |
parent | 24e9a7b8e31131506c89eebdea10f3520c833e1a (diff) |
Get make test / make storetest to work on Windows. Uses perl
script instead of shell + storetestresults binary.
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/storetest.pl | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/scripts/storetest.pl b/scripts/storetest.pl new file mode 100644 index 0000000..c477d4f --- /dev/null +++ b/scripts/storetest.pl @@ -0,0 +1,91 @@ +#!/bin/perl + +use File::Basename; +use File::Temp; +use File::Spec::Functions; +use Sys::Hostname; + +sub prompt { + my ($prompt, $default) = @_; + print("$prompt [$default] : "); + chop ($input=<STDIN>); + if ($input eq "") { + defined($default) or die "ERROR: $prompt must be specified\n"; + $input=$default; + } + return $input; +} + +if (`scp 2>&1` eq "") { + die "ERROR: Check for scp failed - is it in PATH?\n"; +} + +$args = join " ", @ARGV; + +$TESTPLATFORM = prompt("Test platform", $ENV{QTUITEST_PLATFORM}); +@platforms = ("symbian", "linux", "maemo", "meego", "windows", "wince", "mac"); +for (@platforms) { + if (index ($TESTPLATFORM, $_) != -1) { goto platform_ok; } +} +die "ERROR: Test platform must contain one of: @platforms\n"; +platform_ok: + +$TESTCHANGE = prompt("Change or build number", $ENV{QTUITEST_CHANGE}); +$TESTBRANCH = prompt("Branch", $ENV{QTUITEST_BRANCH}); +$TESTTESTR = prompt("Upload location", $ENV{QTUITEST_TESTR}); + +$TIMESTAMP=time(); +$HOSTNAME=hostname; +if (defined $ENV{BUILDDIR}) { + $TESTNAME=basename($ENV{BUILDDIR}); + chomp $TESTNAME; + chomp $TESTNAME; +} else { + $TESTNAME = "results"; +} +$TEMPDIR=($ENV{TMP} or $ENV{TMPDIR}); + +$RESULTSDIR=catfile($TEMPDIR, "qtuitest_results_$TIMESTAMP"); +$RESULTSFILE=catfile($RESULTSDIR, "$TESTNAME.xml"); +$UPLOADFILENAME="qtuitest_upload_$TIMESTAMP.xml"; +$UPLOADFILE=catfile($RESULTSDIR, $UPLOADFILENAME); +mkdir $RESULTSDIR; +print("Results directory is $RESULTSDIR\n"); + +print "qtuitestrunner $args -xml -o $RESULTSFILE\n"; +system "qtuitestrunner $args -xml -o $RESULTSFILE"; +-e $RESULTSFILE or die "ERROR: Results file $RESULTSFILE does not exist!"; +print "upload file is $UPLOADFILE\n"; + +($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = gmtime($TIMESTAMP); +$datefmt = sprintf "%04u-%02u-%02u", $year+1900, $mon+1, $mday; +$timefmt = sprintf "%02u:%02u:%02u", $hour, $min, $sec; + +$header = <<EOF; +<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?> +<Testrun> +<Environment> + <HostName>$HOSTNAME</HostName> + <MakeSpec>$TESTPLATFORM</MakeSpec> + <ChangeNumber>$TESTCHANGE</ChangeNumber> + <Branch>$TESTBRANCH</Branch> +</Environment> +<Timestamp date=\"$datefmt\" time=\"$timefmt\"/> +EOF +$footer = "</Testrun>\n"; + +open XMLOUT, ">$UPLOADFILE"; +print XMLOUT $header; +open XMLIN, "<$RESULTSFILE"; +@results = <XMLIN>; +print XMLOUT @results; +print XMLOUT $footer; +close XMLIN; +close XMLOUT; + +# By using chdir we avoid having to mangle the upload file path +# on Windows based on whether msys scp is used. +chdir $RESULTSDIR; +if (system "scp $UPLOADFILENAME $TESTTESTR") { + die "ERROR: Failed to send file using scp.\nPlease check you have entered the correct details.\nThe upload file is: $UPLOADFILE\n"; +} |