mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-10-02 11:35:46 +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 {
|
mod tests {
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
use ssh2::Session;
|
use ssh2::Session;
|
||||||
|
use std::ffi::OsStr;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::io::BufRead;
|
use std::io::BufRead;
|
||||||
use std::io::{Read, Write};
|
use std::io::{Read, Write};
|
||||||
use std::net::TcpStream;
|
use std::net::TcpStream;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::process::{Command, Stdio};
|
use std::process::{Child, Command, Stdio};
|
||||||
use std::string::String;
|
use std::string::String;
|
||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
use std::thread;
|
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)]
|
#[cfg_attr(not(feature = "mmio"), test)]
|
||||||
fn test_simple_launch() {
|
fn test_simple_launch() {
|
||||||
test_block!(tb, "", {
|
test_block!(tb, "", {
|
||||||
|
Loading…
Reference in New Issue
Block a user