tests: validate CPU count in the test infra

Instead of validating number of CPU in the test case itself,
moving the checking of the CPU count to Guest struct with a
new function as The Guest already has the Default CPU number.

Signed-off-by: Muminul Islam <muislam@microsoft.com>
This commit is contained in:
Muminul Islam
2026-02-22 22:17:48 -08:00
committed by Rob Bradford
parent 60c6242bde
commit 45a5c7a04e
2 changed files with 9 additions and 1 deletions

View File

@@ -2559,7 +2559,7 @@ fn _test_simple_launch(guest: &Guest) {
let r = std::panic::catch_unwind(|| {
guest.wait_vm_boot().unwrap();
assert_eq!(guest.get_cpu_count().unwrap_or_default(), 1);
guest.validate_cpu_count(None);
assert!(guest.get_total_memory().unwrap_or_default() > 480_000);
assert_eq!(guest.get_pci_bridge_class().unwrap_or_default(), "0x060000");
assert!(check_sequential_events(

View File

@@ -1385,6 +1385,14 @@ impl Guest {
if self.nested { "" } else { ",nested=off" }
)
}
pub fn validate_cpu_count(&self, expected_cpu_count: Option<u32>) {
let cpu = match expected_cpu_count {
Some(count) => count,
None => self.num_cpu,
};
assert_eq!(self.get_cpu_count().unwrap_or_default(), cpu);
}
}
#[derive(Default)]