livepatch test support
cover livepatch test support
I found that this series broke (of course) when run on xen.git trees without the dist-test target. These two patches fix this. The second patch will be folded into `ts-xen-build: Build livepatches test-cases' and I am then going to try to push it (again).
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH 1/2 substep handling improvements
* 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 $@.
--- Osstest/TestSupport.pm | 33 +++++++++++++++++++++++++++++++-- sg-run-job | 3 ++- 2 files changed, 33 insertions(+), 3 deletions(-)
Osstest/TestSupport.pm +31 -2
@@ -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;
sg-run-job +2 -1
@@ -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]
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH 2/2 fixup! ts-xen-build: Build livepatches test-cases
In reply to Ian JacksonUse substep_eval, so we cope with xen.git revisions which do not support `make dist-tests'.
--- ts-xen-build | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
ts-xen-build +3 -1
@@ -173,9 +173,11 @@ END } if ($enable_livepatch) { - buildcmd_stamped_logged(600, 'xen', 'xenlpt', '',<<END,'') + substep_eval('/dist-test', sub { + buildcmd_stamped_logged(600, 'xen', 'xenlpt', '',<<END,''); $make_prefix make $makeflags dist-tests END + }); } }
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel