[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [OSSTEST PATCH 08/10] sg-run-job, etc.: Infrastructure for test script repetition



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@xxxxxxxxxxxxx>
---
 sg-run-job     |    4 ++++
 ts-repeat-test |   66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 70 insertions(+)
 create mode 100755 ts-repeat-test

diff --git a/sg-run-job b/sg-run-job
index 070534d..0a49c93 100755
--- a/sg-run-job
+++ b/sg-run-job
@@ -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
index 0000000..e3b1426
--- /dev/null
+++ b/ts-repeat-test
@@ -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 ==========");
-- 
1.7.10.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.