diff --git a/cloud-hypervisor/tests/integration.rs b/cloud-hypervisor/tests/integration.rs index 3af45c35c..04f61f59e 100644 --- a/cloud-hypervisor/tests/integration.rs +++ b/cloud-hypervisor/tests/integration.rs @@ -29,6 +29,13 @@ mod common; use common::tests_wrappers::*; use common::utils::*; +macro_rules! basic_regular_guest { + ($image_name:expr) => {{ + let disk_config = UbuntuDiskConfig::new($image_name.to_string()); + GuestFactory::new_regular_guest_factory().create_guest(Box::new(disk_config)) + }}; +} + mod common_parallel { use std::io::{self, SeekFrom}; use std::process::Command; @@ -41,8 +48,8 @@ mod common_parallel { #[cfg(target_arch = "x86_64")] fn test_focal_hypervisor_fw() { let disk_config = UbuntuDiskConfig::new(FOCAL_IMAGE_NAME.to_string()); - let mut guest = Guest::new(Box::new(disk_config)); - guest.kernel_path = Some(fw_path(FwType::RustHypervisorFirmware)); + let guest = basic_regular_guest!(FOCAL_IMAGE_NAME) + .with_kernel(fw_path(FwType::RustHypervisorFirmware)); _test_simple_launch(&guest); } diff --git a/test_infra/src/lib.rs b/test_infra/src/lib.rs index b6d7641f6..a299b2c49 100644 --- a/test_infra/src/lib.rs +++ b/test_infra/src/lib.rs @@ -1018,6 +1018,11 @@ impl Guest { self } + pub fn with_kernel(mut self, kernel: String) -> Self { + self.kernel_path = Some(kernel); + self + } + pub fn default_net_string(&self) -> String { format!( "tap=,mac={},ip={},mask=255.255.255.128",