test_infra, tests: Introduce exec_host_command_status() function

This new function allows for better readability of the code by
factorizing a bunch of lines of code into a single one.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf
2021-06-04 09:51:25 +02:00
parent 3d8728488d
commit eca1df4e2d
2 changed files with 41 additions and 151 deletions

View File

@@ -11,6 +11,7 @@ use std::net::TcpListener;
use std::net::TcpStream;
use std::os::unix::io::AsRawFd;
use std::path::Path;
use std::process::ExitStatus;
use std::str::FromStr;
use std::thread;
use vmm_sys_util::tempdir::TempDir;
@@ -589,3 +590,10 @@ pub fn ssh_command_ip(
timeout,
)
}
pub fn exec_host_command_status(command: &str) -> ExitStatus {
std::process::Command::new("bash")
.args(&["-c", command])
.status()
.expect(&format!("Expected '{}' to run", command))
}