diff mbox

[OSSTEST,01/11] TestSupport: Provide stashfilecontents

Message ID 1492531012-14315-2-git-send-email-ian.jackson@eu.citrix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Ian Jackson April 18, 2017, 3:56 p.m. UTC
Like target_putfilecontents_* but for files on controller.

No callers yet.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
 Osstest/TestSupport.pm | 11 +++++++++++
 1 file changed, 11 insertions(+)
diff mbox

Patch

diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm
index 2b4a1f4..d482e1d 100644
--- a/Osstest/TestSupport.pm
+++ b/Osstest/TestSupport.pm
@@ -50,6 +50,7 @@  BEGIN {
                       store_runvar get_runvar get_runvar_maybe
                       get_runvar_default need_runvars
                       unique_incrementing_runvar next_unique_name
+                      stashfilecontents
 
                       target_cmd_root target_cmd target_cmd_build
                       target_cmd_output_root target_cmd_output
@@ -520,6 +521,16 @@  sub target_putfilecontents_root_stash ($$$$;$) {
     tpfcs_core(\&target_putfile_root, @_);
 }
 
+sub stashfilecontents ($$;$) {
+    my ($filedata,$leafbase, $leafref) = @_;
+    # returns full pathname
+    $$leafref = $leafbase;
+    my $fh = open_unique_stashfile($leafref);
+    print $fh $filedata or die "$$leafref: $!";
+    close $fh or die "$$leafref: $!";
+    return "$stash/$$leafref";
+}
+
 sub target_file_exists ($$) {
     my ($ho,$rfile) = @_;
     my $out= target_cmd_output($ho, "if test -e $rfile; then echo y; fi");