tests: extract _test_dmi_serial_number to tests_wrappers

Move the DMI serial number test logic from integration.rs
into a shared _test_dmi_serial_number() function in
tests_wrappers.rs. The original test now delegates to
this shared function, enabling reuse by CVM tests.

Signed-off-by: Muminul Islam <muislam@microsoft.com>
This commit is contained in:
Muminul Islam
2026-03-21 16:08:51 -07:00
committed by Rob Bradford
parent b65a3a58f3
commit 5f4ad4bb1e
2 changed files with 32 additions and 30 deletions

View File

@@ -2180,3 +2180,33 @@ pub fn _test_split_irqchip(guest: &Guest) {
handle_child_output(r, &output);
}
#[cfg(target_arch = "x86_64")]
pub(crate) fn _test_dmi_serial_number(guest: &Guest) {
let mut child = GuestCommand::new(guest)
.default_cpus()
.default_memory()
.default_kernel_cmdline_with_platform(Some("serial_number=a=b;c=d"))
.default_disks()
.default_net()
.capture_output()
.spawn()
.unwrap();
let r = std::panic::catch_unwind(|| {
guest.wait_vm_boot().unwrap();
assert_eq!(
guest
.ssh_command("sudo cat /sys/class/dmi/id/product_serial")
.unwrap()
.trim(),
"a=b;c=d"
);
});
kill_child(&mut child);
let output = child.wait_with_output().unwrap();
handle_child_output(r, &output);
}

View File

@@ -1738,37 +1738,9 @@ mod common_parallel {
#[test]
#[cfg(target_arch = "x86_64")]
fn test_dmi_serial_number() {
let disk_config = UbuntuDiskConfig::new(JAMMY_IMAGE_NAME.to_string());
let guest = Guest::new(Box::new(disk_config));
let guest = basic_regular_guest!(JAMMY_IMAGE_NAME);
let mut child = GuestCommand::new(&guest)
.default_cpus()
.default_memory()
.args(["--kernel", direct_kernel_boot_path().to_str().unwrap()])
.args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE])
.args(["--platform", "serial_number=a=b;c=d"])
.default_disks()
.default_net()
.capture_output()
.spawn()
.unwrap();
let r = std::panic::catch_unwind(|| {
guest.wait_vm_boot().unwrap();
assert_eq!(
guest
.ssh_command("sudo cat /sys/class/dmi/id/product_serial")
.unwrap()
.trim(),
"a=b;c=d"
);
});
kill_child(&mut child);
let output = child.wait_with_output().unwrap();
handle_child_output(r, &output);
_test_dmi_serial_number(&guest);
}
#[test]