From patchwork Tue Dec 13 06:39:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Rzeszutek Wilk X-Patchwork-Id: 9471741 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CD0686021C for ; Tue, 13 Dec 2016 03:33:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C03042074F for ; Tue, 13 Dec 2016 03:33:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B35C928156; Tue, 13 Dec 2016 03:33:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.2 required=2.0 tests=BAYES_00, DATE_IN_FUTURE_03_06, RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6293E2074F for ; Tue, 13 Dec 2016 03:33:05 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cGdnV-0004s6-T7; Tue, 13 Dec 2016 03:30:33 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cGdnU-0004rX-G2 for xen-devel@lists.xenproject.org; Tue, 13 Dec 2016 03:30:32 +0000 Received: from [85.158.137.68] by server-17.bemta-3.messagelabs.com id 4B/69-31715-75B6F485; Tue, 13 Dec 2016 03:30:31 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrOLMWRWlGSWpSXmKPExsUyZ7p8oG54tn+ EwerXXBbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8aCbweYC24pVJy52MHawLhOsouRi0NIYCKT xL29J5khnN+MEv8OPmeHcDYySpz5spoNwulmlOg708PSxcjBwSZgIvFmlWMXIyeHiICtxL3G2 YwgYWaBIokV/+tAwsICYRLTVmwCC7MIqEos7ygBMXkF3CUarseAVEgIyEmcP/6TGcTmFPCQ+L j8HhNIiRBQyZyZSRAlhhKnH25jnMDIt4CRYRWjenFqUVlqka65XlJRZnpGSW5iZo6uoYGxXm5 qcXFiempOYlKxXnJ+7iZGYIAwAMEOxsbvTocYJTmYlER5zWP8I4T4kvJTKjMSizPii0pzUosP McpwcChJ8PJlAeUEi1LTUyvSMnOAoQqTluDgURLh/ZgBlOYtLkjMLc5Mh0idYlSUEud9lwmUE ABJZJTmwbXB4uMSo6yUMC8j0CFCPAWpRbmZJajyrxjFORiVhHmlQLbzZOaVwE1/BbSYCWjx83 3eIItLEhFSUg2MvTVGn3f7HeFMKfaaJrDtZrVdZFO94KIJ06+Wc/MuPcEstJt3QWtTypwTkZ+ q3fyyZ2WznDW8fLCp59ahpk7WE0EqU1Vn3vmSfPdY9ay1fN/vl58JTve4cW9T8DMxVtkFHMxP d4UK3jE+wXjx3ZSqliVlhx/PL/nGvPhxybEQtcbXBTHGbTF5SizFGYmGWsxFxYkAvsUMhYoCA AA= X-Env-Sender: konrad.wilk@oracle.com X-Msg-Ref: server-12.tower-31.messagelabs.com!1481599829!58985933!1 X-Originating-IP: [156.151.31.81] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTU2LjE1MS4zMS44MSA9PiAyODgzMzk=\n X-StarScan-Received: X-StarScan-Version: 9.0.16; banners=-,-,- X-VirusChecked: Checked Received: (qmail 44167 invoked from network); 13 Dec 2016 03:30:30 -0000 Received: from userp1040.oracle.com (HELO userp1040.oracle.com) (156.151.31.81) by server-12.tower-31.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 13 Dec 2016 03:30:30 -0000 Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id uBD3UOon028075 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 13 Dec 2016 03:30:25 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id uBD3UOQ1007829 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 13 Dec 2016 03:30:24 GMT Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id uBD3UN7G007941; Tue, 13 Dec 2016 03:30:23 GMT Received: from osstest.dumpdata.com (/209.6.196.81) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 12 Dec 2016 19:30:23 -0800 From: Konrad Rzeszutek Wilk To: xen-devel@lists.xenproject.org, Ian.Jackson@eu.citrix.com Date: Tue, 13 Dec 2016 01:39:47 -0500 Message-Id: <1481611195-105372-2-git-send-email-konrad.wilk@oracle.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1481611195-105372-1-git-send-email-konrad.wilk@oracle.com> References: <1481611195-105372-1-git-send-email-konrad.wilk@oracle.com> X-Source-IP: userv0021.oracle.com [156.151.31.71] Cc: ross.lagerwall@citrix.com, Marcos.Matsunaga@oracle.com, Konrad Rzeszutek Wilk Subject: [Xen-devel] [PATCH v2 1/9] OssTest: Add target_cmd_root_status which returns return code. X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 Acked-by: Ian Jackson --- 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 ($$$&) {