xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: xen-devel@lists.xenproject.org, Ian.Jackson@eu.citrix.com
Cc: ross.lagerwall@citrix.com, Marcos.Matsunaga@oracle.com,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Subject: [PATCH v2 1/9] OssTest: Add target_cmd_root_status which returns return code.
Date: Tue, 13 Dec 2016 01:39:47 -0500	[thread overview]
Message-ID: <1481611195-105372-2-git-send-email-konrad.wilk@oracle.com> (raw)
In-Reply-To: <1481611195-105372-1-git-send-email-konrad.wilk@oracle.com>

All the different target_cmd_* end up calling tcmdex
which has the unfortunate side-effect of calling 'die' if
the SSH sessions results in any return code not zero.

That is fine, except for tests where we want to get a non-zero
return value.

This patch adds the $badstatusok to tcmdex - and makes all
the existing callers pass in the value of zero to it. This
way the commands behave the normal old way.
to all the other functions which use tcmdex.

The only exposed function that does it differently
is target_cmd_root_status.

Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
---
v1: New submission
v2: Change to target_cmd_root_status
    Continue doing the 'die' in tcmdex, but only if $badstatusok is zero.
    Plumb the $badstatusok through to tcmd.
---
 Osstest/TestSupport.pm | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm
index 888f0ac..0d105ee 100644
--- a/Osstest/TestSupport.pm
+++ b/Osstest/TestSupport.pm
@@ -51,6 +51,7 @@ BEGIN {
                       get_runvar_default need_runvars
                       unique_incrementing_runvar next_unique_name
 
+                      target_cmd_root_status
                       target_cmd_root target_cmd target_cmd_build
                       target_cmd_output_root target_cmd_output
                       target_cmd_inputfh_root sshuho
@@ -419,20 +420,21 @@ sub sshopts () {
 }
 
 sub tcmdex {
-    my ($timeout,$stdin,$stdout,$cmd,$optsref,@args) = @_;
+    my ($timeout,$stdin,$stdout,$badstatusok,$cmd,$optsref,@args) = @_;
     logm("executing $cmd ... @args");
     # We use timeout(1) as a backstop, in case $cmd doesn't die.  We
     # need $cmd to die because we won't release the resources we own
     # until all of our children are dead.
     my $r= cmd($timeout,$stdin,$stdout,
 	       'timeout',$timeout+30, $cmd,@$optsref,@args);
+    return $r if $badstatusok;
     $r and die "status $r";
 }
 
 sub tgetfileex {
     my ($ruser, $ho,$timeout, $rsrc,$ldst) = @_;
     unlink $ldst or $!==&ENOENT or die "$ldst $!";
-    tcmdex($timeout,undef,undef,
+    tcmdex($timeout,undef,undef, 0,
            'scp', sshopts(),
            sshuho($ruser,$ho).":$rsrc", $ldst);
 } 
@@ -449,12 +451,12 @@ sub tputfileex {
     my ($ruser, $ho,$timeout, $lsrc,$rdst, $rsync) = @_;
     my @args= ($lsrc, sshuho($ruser,$ho).":$rdst");
     if (!defined $rsync) {
-        tcmdex($timeout,undef,undef,
+        tcmdex($timeout,undef,undef, 0,
                'scp', sshopts(),
                @args);
     } else {
         unshift @args, $rsync if length $rsync;
-        tcmdex($timeout,undef,undef,
+        tcmdex($timeout,undef,undef, 0,
                'rsync', [ '-e', 'ssh '.join(' ',@{ sshopts() }) ],
                @args);
     }
@@ -652,19 +654,20 @@ sub target_await_down ($$) {
 }    
 
 sub tcmd { # $tcmd will be put between '' but not escaped
-    my ($stdin,$stdout,$user,$ho,$tcmd,$timeout,$extrasshopts) = @_;
+    my ($stdin,$stdout,$badstatusok,$user,$ho,$tcmd,$timeout,$extrasshopts) = @_;
     $timeout=30 if !defined $timeout;
     target_adjust_timeout($ho,\$timeout);
-    tcmdex($timeout,$stdin,$stdout,
+    tcmdex($timeout,$stdin,$stdout, $badstatusok,
            'ssh', sshopts(), @{ $extrasshopts || [] },
            sshuho($user,$ho), $tcmd);
 }
-sub target_cmd ($$;$$) { tcmd(undef,undef,'osstest',@_); }
-sub target_cmd_root ($$;$$) { tcmd(undef,undef,'root',@_); }
+sub target_cmd ($$;$$) { tcmd(undef,undef,0, 'osstest',@_); }
+sub target_cmd_root ($$;$$) { tcmd(undef,undef,0, 'root',@_); }
+sub target_cmd_root_status ($$;$$) { tcmd(undef,undef,1, 'root',@_); }
 
 sub tcmdout {
     my $stdout= IO::File::new_tmpfile();
-    tcmd(undef,$stdout,@_);
+    tcmd(undef,$stdout,0,@_);
     $stdout->seek(0,0) or die "$stdout $!";
     my $r;
     { local ($/) = undef;
@@ -679,7 +682,7 @@ sub target_cmd_output_root ($$;$) { tcmdout('root',@_); }
 
 sub target_cmd_inputfh_root ($$$;$$) {
     my ($tho,$stdinfh,$tcmd,@rest) = @_;
-    tcmd($stdinfh,undef,'root',$tho,$tcmd,@rest);
+    tcmd($stdinfh,undef,0,'root',$tho,$tcmd,@rest);
 }
 
 sub poll_loop ($$$&) {
-- 
2.1.4


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

  reply	other threads:[~2016-12-13  3:30 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-13  6:39 [PATCH v2] OSSTest test-harness for livepatches Konrad Rzeszutek Wilk
2016-12-13  6:39 ` Konrad Rzeszutek Wilk [this message]
2016-12-13 16:20   ` [PATCH v2 1/9] OssTest: Add target_cmd_root_status which returns return code Ian Jackson
2016-12-13  6:39 ` [PATCH v2 2/9] Osstest: Add target_cmd_output_root_status Konrad Rzeszutek Wilk
2016-12-13 16:23   ` Ian Jackson
2016-12-13  6:39 ` [PATCH v2 3/9] OssTest: Add target_dir_exists Konrad Rzeszutek Wilk
2016-12-13 16:24   ` Ian Jackson
2017-05-17 20:59     ` Konrad Rzeszutek Wilk
2017-05-18 16:50       ` Ian Jackson
2016-12-13  6:39 ` [PATCH v2 4/9] ts-xen-build: Make {xen|}dist.tar.gz only if $builddir/install/{$xen|}install Konrad Rzeszutek Wilk
2016-12-13  6:39 ` [PATCH v2 5/9] ts-xen-build: Enable livepatch Konrad Rzeszutek Wilk
2016-12-13  6:39 ` [PATCH v2 6/9] ts-xen-build: Build the livepatch test-cases Konrad Rzeszutek Wilk
2016-12-13 16:49   ` Ian Jackson
2017-05-18  0:07     ` Konrad Rzeszutek Wilk
2017-05-17 20:30       ` Konrad Rzeszutek Wilk
2017-05-18 16:41         ` Ian Jackson
2017-05-18  6:49     ` Konrad Rzeszutek Wilk
2017-05-18 16:47       ` Ian Jackson
2017-05-18 19:57         ` Konrad Rzeszutek Wilk
2016-12-13  6:39 ` [PATCH v2 7/9] ts-livepatch-[install|run]: Install and initial test-cases Konrad Rzeszutek Wilk
2016-12-13 17:08   ` Ian Jackson
2016-12-13  6:39 ` [PATCH v2 8/9] sg-run-job: Add the test-livepatch Konrad Rzeszutek Wilk
2016-12-13 17:08   ` Ian Jackson
2016-12-13  6:39 ` [PATCH v2 9/9] make-flight/mfi-common: Add livepatch build/test target in the matrix Konrad Rzeszutek Wilk
2016-12-13 16:14   ` Wei Liu
2016-12-13 16:44     ` 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=1481611195-105372-2-git-send-email-konrad.wilk@oracle.com \
    --to=konrad.wilk@oracle.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=Marcos.Matsunaga@oracle.com \
    --cc=ross.lagerwall@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).