Message ID | 20170725115759.21895-19-anthony.perard@citrix.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Anthony PERARD writes ("[OSSTEST PATCH v13 18/24] TestSupport: Introduce target_cmd_stashed"): > This works like target_cmd, but takes a ref to a filename as argument > and stash the output of the command then return a path to the stashed > output. ... > +# Like target_cmd, but stash cmd stdout and return a path to it. > +sub target_cmd_stashed ($$$;$$) { > + my ($tho,$leafref,$tcmd,$timeout,$extrasshopts) = @_; > + my $stdout = open_unique_stashfile($leafref); > + my $rc = tcmd(undef, $stdout, 0, 'osstest', $tho, $tcmd, $timeout, > + $extrasshopts); > + die "$stdout $!" if $stdout->error or !close $stdout; You can't sensibly interpolate a filehandle into a "" string. You should use the filename (probably, the whole filename). Ian.
On Tue, Jul 25, 2017 at 07:26:07PM +0100, Ian Jackson wrote: > Anthony PERARD writes ("[OSSTEST PATCH v13 18/24] TestSupport: Introduce target_cmd_stashed"): > > This works like target_cmd, but takes a ref to a filename as argument > > and stash the output of the command then return a path to the stashed > > output. > ... > > +# Like target_cmd, but stash cmd stdout and return a path to it. > > +sub target_cmd_stashed ($$$;$$) { > > + my ($tho,$leafref,$tcmd,$timeout,$extrasshopts) = @_; > > + my $stdout = open_unique_stashfile($leafref); > > + my $rc = tcmd(undef, $stdout, 0, 'osstest', $tho, $tcmd, $timeout, > > + $extrasshopts); > > + die "$stdout $!" if $stdout->error or !close $stdout; > > You can't sensibly interpolate a filehandle into a "" string. > You should use the filename (probably, the whole filename). Right, I did not think about that. I've just copy/past the line from the function tcmdout(). I'll use the filename.
diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm index 7215156..135289b 100644 --- a/Osstest/TestSupport.pm +++ b/Osstest/TestSupport.pm @@ -55,6 +55,7 @@ BEGIN { target_cmd_root_status target_cmd_output_root_status target_cmd_root target_cmd target_cmd_build + target_cmd_stashed target_cmd_output_root target_cmd_output target_cmd_inputfh_root sshuho target_getfile target_getfile_root @@ -764,6 +765,16 @@ sub target_cmd_inputfh_root ($$$;$$) { tcmd($stdinfh,undef,0,'root',$tho,$tcmd,@rest); } +# Like target_cmd, but stash cmd stdout and return a path to it. +sub target_cmd_stashed ($$$;$$) { + my ($tho,$leafref,$tcmd,$timeout,$extrasshopts) = @_; + my $stdout = open_unique_stashfile($leafref); + my $rc = tcmd(undef, $stdout, 0, 'osstest', $tho, $tcmd, $timeout, + $extrasshopts); + die "$stdout $!" if $stdout->error or !close $stdout; + return "$stash/$$leafref"; +} + sub poll_loop ($$$&) { my ($maxwait, $interval, $what, $code) = @_; # $code should return undef when all is well
This works like target_cmd, but takes a ref to a filename as argument and stash the output of the command then return a path to the stashed output. Signed-off-by: Anthony PERARD <anthony.perard@citrix.com> --- Osstest/TestSupport.pm | 11 +++++++++++ 1 file changed, 11 insertions(+)