From: Ian Jackson <ian.jackson@eu.citrix.com>
To: xen-devel@lists.xenproject.org
Cc: Ian Jackson <Ian.Jackson@eu.citrix.com>
Subject: [OSSTEST PATCH 1/2] substep handling improvements
Date: Mon, 12 Jun 2017 14:29:24 +0100 [thread overview]
Message-ID: <1497274165-24051-2-git-send-email-ian.jackson@eu.citrix.com> (raw)
In-Reply-To: <1497274165-24051-1-git-send-email-ian.jackson@eu.citrix.com>
* Change sg-run-job to pass OSSTEST_TESTID to ts-* scripts
* If the specified $testid starts with /, prepend OSSTEST_TESTID
(with a fallback for ad-hoc by-hand invocations).
* Default $script to the leafname from $0.
* Provide substep_eval, which does the obvious thing with eval and $@.
Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
Osstest/TestSupport.pm | 33 +++++++++++++++++++++++++++++++--
sg-run-job | 3 ++-
2 files changed, 33 insertions(+), 3 deletions(-)
diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm
index fc1aa7d..ce9ffaa 100644
--- a/Osstest/TestSupport.pm
+++ b/Osstest/TestSupport.pm
@@ -43,7 +43,8 @@ BEGIN {
ts_get_host_guest ts_check_done
fail broken logm $logm_handle $logm_prefix
- substep_start substep_finish intended_blessing
+ substep_start substep_finish substep_eval
+ intended_blessing
get_filecontents
report_once
@@ -236,16 +237,44 @@ END
: "($flight.$job not marked $newst)");
}
-sub substep_start ($$) {
+sub complete_testid ($) {
+ my ($testidr) = @_;
+ $$testidr =~ s{^(?=/)}{
+ $ENV{OSSTEST_TESTID} // sprintf('SUBSTEP-%s-%s', time, $$)
+ }e;
+}
+
+sub substep_start ($;$) {
my ($testid,$script) = @_;
+ complete_testid(\$testid);
+ if (!defined $script) {
+ $script = $0;
+ $script =~ s{^.*/}{};
+ }
$mjobdb->step_start($testid,$script);
}
sub substep_finish ($$) {
my ($testid,$stepstatus) = @_;
+ complete_testid(\$testid);
$mjobdb->step_finish($testid,$stepstatus);
}
+sub substep_eval ($$;$) {
+ # substep_eval(TESTID, [SCRIPTNAME], sub { ... });
+ my $fn = pop @_;
+ my ($testid,$script) = @_;
+ substep_start($testid,$script);
+ eval { $fn->(); };
+ if (length $@) {
+ logm("substep ($testid) failed: $@");
+ substep_finish($testid,'fail');
+ } else {
+ substep_finish($testid,'pass');
+ }
+}
+
+
sub intended_blessing () {
# must be run outside transaction
my $intended;
diff --git a/sg-run-job b/sg-run-job
index 0af86fa..4b98e2b 100755
--- a/sg-run-job
+++ b/sg-run-job
@@ -253,11 +253,12 @@ proc spawn-ts {iffail testid args} {
[list sh -xc "
OSSTEST_JOB=$jobinfo(job)
export OSSTEST_JOB
+ OSSTEST_TESTID=\$1; shift; export OSSTEST_TESTID
$xprefix \"$@\" >&2
rc=\$?
date -u +\"%Y-%m-%d %H:%M:%S Z exit status \$rc\" >&2
exit \$rc
- " x ./$ts] \
+ " x $testid ./$ts] \
$real_args $redirects]
set fh [open |$cmd r]
return [list fh $fh $details]
--
2.1.4
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-06-12 13:29 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-12 13:29 [OSSTEST PATCH v4-v4.1 delta 0/2] livepatch test support Ian Jackson
2017-06-12 13:29 ` Ian Jackson [this message]
2017-06-12 13:29 ` [OSSTEST PATCH 2/2] fixup! ts-xen-build: Build livepatches test-cases Ian Jackson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1497274165-24051-2-git-send-email-ian.jackson@eu.citrix.com \
--to=ian.jackson@eu.citrix.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).