From f1151cb55ee4a7454dd9099e619d170aec4671ff Mon Sep 17 00:00:00 2001 From: Bo Chen Date: Wed, 9 Feb 2022 16:57:26 -0800 Subject: [PATCH] test_infra: Allow to not print commandline when spawning guest 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 --- test_infra/src/lib.rs | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/test_infra/src/lib.rs b/test_infra/src/lib.rs index d4441886b..4d1f20508 100644 --- a/test_infra/src/lib.rs +++ b/test_infra/src/lib.rs @@ -1185,6 +1185,7 @@ pub struct GuestCommand<'a> { command: Command, guest: &'a Guest, capture_output: bool, + print_cmd: bool, } impl<'a> GuestCommand<'a> { @@ -1197,6 +1198,7 @@ impl<'a> GuestCommand<'a> { command: Command::new(clh_command(binary_name)), guest, capture_output: false, + print_cmd: true, } } @@ -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 { - 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