diff --git a/test/test-manager/src/vm/provision.rs b/test/test-manager/src/vm/provision.rs index 60d10b36463d..0e32c9528584 100644 --- a/test/test-manager/src/vm/provision.rs +++ b/test/test-manager/src/vm/provision.rs @@ -187,6 +187,18 @@ fn ssh_send_file + Copy>( session: &Session, source: P, dest_dir: &Path, +) -> Result { + ssh_send_file_with_opts(session, source, dest_dir, FileOpts::default()) +} + +/// Copy a `source` file to `dest_dir` in the test runner with opts. +/// +/// Returns the absolute path in the test runner where the file is stored. +fn ssh_send_file_with_opts + Copy>( + session: &Session, + source: P, + dest_dir: &Path, + opts: FileOpts, ) -> Result { let dest = dest_dir.join( source @@ -205,7 +217,10 @@ fn ssh_send_file + Copy>( .with_context(|| format!("Failed to open file at {}", source.as_ref().display()))?; let remote_file = ssh_write(session, &dest, &source[..])?; - make_executable(remote_file)?; + + if opts.executable { + make_executable(remote_file)?; + } Ok(dest) } @@ -221,6 +236,14 @@ fn ssh_write>(session: &Session, dest: P, mut source: impl Read) Ok(remote_file) } +/// Extra options that may be necessary to configure for files written to the test runner VM. +/// Used in conjunction with the `ssh_*_with_opts` functions. +#[derive(Clone, Copy, Debug, Default)] +struct FileOpts { + /// If file should be executable. + executable: bool, +} + fn make_executable(mut file: File) -> Result { // Make sure that the script is executable! let mut file_stat = file.stat()?;