mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-02-21 19:02:30 +00:00
tests: Introduce new GuestCommand to handle launching the guest
This is a thin wrapper over std::process:Command which currently only specifies the default binary but in future will handle more default behaviour. Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
8142c823ed
commit
67a5882415
@ -18,13 +18,14 @@ extern crate lazy_static;
|
||||
mod tests {
|
||||
#![allow(dead_code)]
|
||||
use ssh2::Session;
|
||||
use std::ffi::OsStr;
|
||||
use std::fs;
|
||||
use std::io;
|
||||
use std::io::BufRead;
|
||||
use std::io::{Read, Write};
|
||||
use std::net::TcpStream;
|
||||
use std::path::Path;
|
||||
use std::process::{Command, Stdio};
|
||||
use std::process::{Child, Command, Stdio};
|
||||
use std::string::String;
|
||||
use std::sync::Mutex;
|
||||
use std::thread;
|
||||
@ -712,6 +713,31 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
struct GuestCommand {
|
||||
command: Command,
|
||||
}
|
||||
|
||||
impl GuestCommand {
|
||||
fn new() -> Self {
|
||||
Self {
|
||||
command: Command::new("target/release/cloud-hypervisor"),
|
||||
}
|
||||
}
|
||||
|
||||
fn spawn(&mut self) -> io::Result<Child> {
|
||||
self.command.stderr(Stdio::piped()).stdout(Stdio::piped()).spawn()
|
||||
}
|
||||
|
||||
fn args<I, S>(&mut self, args: I) -> &mut Self
|
||||
where
|
||||
I: IntoIterator<Item = S>,
|
||||
S: AsRef<OsStr>,
|
||||
{
|
||||
self.command.args(args);
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(not(feature = "mmio"), test)]
|
||||
fn test_simple_launch() {
|
||||
test_block!(tb, "", {
|
||||
|
Loading…
x
Reference in New Issue
Block a user