Skip to content

Commit

Permalink
test_infra: Allow to not print commandline when spawning guest
Browse files Browse the repository at this point in the history
keep it as default to print out commandline when spawning guest in favor
of integration tests for debugging purpose, while allowing to disable
it when needed (e.g. for performance tests).

Signed-off-by: Bo Chen <[email protected]>
  • Loading branch information
likebreath committed Feb 10, 2022
1 parent 97d7623 commit 2ebc278
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions test_infra/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1185,6 +1185,7 @@ pub struct GuestCommand<'a> {
command: Command,
guest: &'a Guest,
capture_output: bool,
print_cmd: bool,
}

impl<'a> GuestCommand<'a> {
Expand All @@ -1197,6 +1198,7 @@ impl<'a> GuestCommand<'a> {
command: Command::new(clh_command(binary_name)),
guest,
capture_output: false,
print_cmd: true,
}
}

Expand All @@ -1205,13 +1207,20 @@ impl<'a> GuestCommand<'a> {
self
}

pub fn set_print_cmd(&mut self, print_cmd: bool) -> &mut Self {
self.print_cmd = print_cmd;
self
}

pub fn spawn(&mut self) -> io::Result<Child> {
println!(
"\n\n==== Start cloud-hypervisor command-line ====\n\n\
{:?}\n\
\n==== End cloud-hypervisor command-line ====\n\n",
self.command
);
if self.print_cmd {
println!(
"\n\n==== Start cloud-hypervisor command-line ====\n\n\
{:?}\n\
\n==== End cloud-hypervisor command-line ====\n\n",
self.command
);
}

if self.capture_output {
let child = self
Expand Down

0 comments on commit 2ebc278

Please sign in to comment.