mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
tests: centralize default CPU arguments in test infrastructure
Replace the hard-coded .args(["--cpus", "boot=1"]) in the simple launch integration test with a shared helper (default_cpus) from test infrastructure. Extend Guest with explicit CPU-related defaults (num_cpu, nested) and add default_cpus_string() so CPU configuration is derived from guest state instead of being duplicated at call sites. This refactor improves consistency and makes CPU defaults easier to maintain across integration tests. Signed-off-by: Muminul Islam <muislam@microsoft.com>
This commit is contained in:
committed by
Rob Bradford
parent
fdc51d923f
commit
60c6242bde
@@ -2545,7 +2545,7 @@ fn _test_simple_launch(guest: &Guest) {
|
|||||||
let event_path = temp_event_monitor_path(&guest.tmp_dir);
|
let event_path = temp_event_monitor_path(&guest.tmp_dir);
|
||||||
|
|
||||||
let mut child = GuestCommand::new(guest)
|
let mut child = GuestCommand::new(guest)
|
||||||
.args(["--cpus", "boot=1"])
|
.default_cpus()
|
||||||
.args(["--memory", "size=512M"])
|
.args(["--memory", "size=512M"])
|
||||||
.default_kernel_cmdline()
|
.default_kernel_cmdline()
|
||||||
.default_disks()
|
.default_disks()
|
||||||
|
|||||||
@@ -916,6 +916,8 @@ pub struct Guest {
|
|||||||
pub kernel_path: Option<String>,
|
pub kernel_path: Option<String>,
|
||||||
pub kernel_cmdline: Option<String>,
|
pub kernel_cmdline: Option<String>,
|
||||||
pub console_type: Option<String>,
|
pub console_type: Option<String>,
|
||||||
|
pub num_cpu: u32,
|
||||||
|
pub nested: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the next id that can be used for this guest. This is stored in a
|
// Return the next id that can be used for this guest. This is stored in a
|
||||||
@@ -985,6 +987,8 @@ impl Guest {
|
|||||||
kernel_path: None,
|
kernel_path: None,
|
||||||
kernel_cmdline: None,
|
kernel_cmdline: None,
|
||||||
console_type: None,
|
console_type: None,
|
||||||
|
num_cpu: 1u32,
|
||||||
|
nested: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1373,6 +1377,14 @@ impl Guest {
|
|||||||
}
|
}
|
||||||
out_evt
|
out_evt
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn default_cpus_string(&self) -> String {
|
||||||
|
format!(
|
||||||
|
"boot={}{}",
|
||||||
|
self.num_cpu,
|
||||||
|
if self.nested { "" } else { ",nested=off" }
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
@@ -1555,6 +1567,10 @@ impl<'a> GuestCommand<'a> {
|
|||||||
|
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn default_cpus(&mut self) -> &mut Self {
|
||||||
|
self.args(["--cpus", self.guest.default_cpus_string().as_str()])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the absolute path into the workspaces target directory to locate the desired
|
/// Returns the absolute path into the workspaces target directory to locate the desired
|
||||||
|
|||||||
Reference in New Issue
Block a user