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

[Xen-devel] [OSSTEST PATCH 03/11] TestSupport: target_cmd_output_root_status: New sub



From: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>

Similar to target_cmd_root_status except it outputs both output _and_
status.

Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
Signed-off-by: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
---
v2: Initial posting
v3: Sprinkle some comments.
v4: Move doc comments out of this patch (and rewrite them).
    Edit commit message.
---
 Osstest/TestSupport.pm | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm
index f54962a..fc1aa7d 100644
--- a/Osstest/TestSupport.pm
+++ b/Osstest/TestSupport.pm
@@ -52,7 +52,7 @@ BEGIN {
                       unique_incrementing_runvar next_unique_name
                       stashfilecontents
 
-                      target_cmd_root_status
+                      target_cmd_root_status target_cmd_output_root_status
                       target_cmd_root target_cmd target_cmd_build
                       target_cmd_output_root target_cmd_output
                       target_cmd_inputfh_root sshuho
@@ -708,19 +708,25 @@ sub target_cmd_root_status ($$;$$) { tcmd(undef,undef,1, 
'root',@_); }
 
 sub tcmdout {
     my $stdout= IO::File::new_tmpfile();
-    tcmd(undef,$stdout,0,@_);
+    my $badstatusok = $_[1];
+    my $rc = tcmd(undef,$stdout,@_);
     $stdout->seek(0,0) or die "$stdout $!";
     my $r;
     { local ($/) = undef;
       $r= <$stdout>; }
     die "$stdout $!" if !defined $r or $stdout->error or !close $stdout;
     chomp($r);
+    return ($rc, $r) if $badstatusok;
     return $r;
 }
 
 # Like target_cmd[_root], but collect the stdout and return it as a string.
-sub target_cmd_output ($$;$) { tcmdout('osstest',@_); }
-sub target_cmd_output_root ($$;$) { tcmdout('root',@_); }
+# Like target_cmd[_root], but collects the stdout and returns it as a string.
+sub target_cmd_output ($$;$) { tcmdout(0, 'osstest',@_); }
+sub target_cmd_output_root ($$;$) { tcmdout(0, 'root',@_); }
+
+# Like target_cmd_root_status but returns a tuple ($?, $stdout_data).
+sub target_cmd_output_root_status ($$;$$) { tcmdout(1, 'root',@_); }
 
 sub target_cmd_inputfh_root ($$$;$$) {
     my ($tho,$stdinfh,$tcmd,@rest) = @_;
-- 
2.1.4


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

 


Rackspace

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