]> xenbits.xensource.com Git - people/liuw/osstest.git/commitdiff
sg-run-job, etc.: Infrastructure for test script repetition
authorIan Jackson <ian.jackson@eu.citrix.com>
Fri, 6 Feb 2015 17:07:16 +0000 (17:07 +0000)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Fri, 13 Feb 2015 14:01:46 +0000 (14:01 +0000)
Provide:
 * ts-repeat-test, a script to run multiple other test scripts in a loop
 * repeat-ts, a proc in sg-run-job which invokes it

No callers yet.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
sg-run-job
ts-repeat-test [new file with mode: 0755]

index 070534dfa6d0a0de6681e9ca8aa09882dab6a829..0a49c93fa945f6ddb4cdbf85f49ae27f77691cb8 100755 (executable)
@@ -103,6 +103,10 @@ proc run-ts {args} {
     if {![reap-ts $reap]} { error "test script failed" }
 }
 
+proc repeat-ts {reps testid args} {
+     eval [list run-ts . $testid + ts-repeat-test $reps +] $args
+}
+
 proc spawn-ts {iffail testid args} {
     global flight c jobinfo reap_details env
 
diff --git a/ts-repeat-test b/ts-repeat-test
new file mode 100755 (executable)
index 0000000..e3b1426
--- /dev/null
@@ -0,0 +1,66 @@
+#!/usr/bin/perl -w
+#
+# usage:
+#   ./ts-repeat-test COUNT ARGSPECS...
+#   ./ts-repeat-test COUNT [-] ts-SCRIPT [ARGS...] [; ...]
+#
+# ts-SCRIPT  will be prefixed with ./ before execution
+#             (provided it actually starts with `ts-')
+# ;          separates multiple scripts to be run
+# -          before script name means to ignore errors
+# \          at the start of any ARGSPEC is removed (after the checks above)
+
+use strict;
+use Osstest::TestSupport;
+
+use Data::Dumper;
+
+tsreadconfig();
+
+my $reps = shift @ARGV;
+die unless @ARGV && $reps =~ m/^\d+$/;
+
+my @cmdis = ();
+my $cmdi = { };
+# $cmds[]{L} = qw(./ts-foo-bar arg arg...);
+# $cmds[]{IgnoreError} = undef or 1
+
+push @ARGV, ';';
+
+foreach (@ARGV) {
+    if ($_ eq ';') {
+       if (%$cmdi) {
+           push @cmdis, $cmdi;
+           $cmdi = { };
+       }
+    } else {
+       if (!$cmdi->{L}) {
+           if ($_ eq '-') {
+               $cmdi->{IgnoreError} = 1;
+               next;
+           }
+           s#^(?=ts-)#./#;
+       }
+       s#^\\##;
+       push @{ $cmdi->{L} }, $_;
+    }
+}
+
+my $dumper = new Data::Dumper [\@cmdis], [qw(*cmdis)];
+$dumper->Indent(0);
+print $dumper->Dump,"\n";
+
+foreach my $rep (1..$reps) {
+    logm("========== rep $rep ==========");
+    foreach my $cmdi (@cmdis) {
+       my $l = $cmdi->{L};
+       logm("---------- rep $rep @$l ----------");
+       my $r = system @$l;
+       if ($r) {
+           my $m = "$l->[0]: ".($r==-1 ? "$!" : "status $?")."\n";
+           if ($cmdi->{IgnoreError}) { warn $m; } else { die $m; }
+       }
+    }
+}
+
+logm("========== did $reps ==========");