mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
tests: add basic_regular_guest macro and with_kernel
Introduce a basic_regular_guest! macro in integration.rs to reduce boilerplate when creating regular (non-CVM) guest instances. Also add a with_kernel() builder method to Guest in test_infra, allowing fluent configuration of the kernel path. Signed-off-by: Muminul Islam <muislam@microsoft.com>
This commit is contained in:
committed by
Rob Bradford
parent
7802470906
commit
0fc0f2bd0e
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user