tests: extract _test_dmi_oem_strings to tests_wrappers

Move the DMI OEM strings test logic from integration.rs
into a shared _test_dmi_oem_strings() function in
tests_wrappers.rs. The original test in integration.rs
now uses the basic_regular_guest! macro and 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 17:56:23 -07:00
committed by Rob Bradford
parent 43641cf714
commit c3976ccbda
2 changed files with 52 additions and 52 deletions

View File

@@ -2239,3 +2239,53 @@ pub(crate) fn _test_dmi_uuid(guest: &Guest) {
handle_child_output(r, &output);
}
pub(crate) fn _test_dmi_oem_strings(guest: &Guest) {
let s1 = "io.systemd.credential:xx=yy";
let s2 = "This is a test string";
let oem_strings = format!("oem_strings=[{s1},{s2}]");
let mut child = GuestCommand::new(guest)
.default_cpus()
.default_memory()
.default_kernel_cmdline_with_platform(Some(&oem_strings))
.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 dmidecode --oem-string count")
.unwrap()
.trim(),
"2"
);
assert_eq!(
guest
.ssh_command("sudo dmidecode --oem-string 1")
.unwrap()
.trim(),
s1
);
assert_eq!(
guest
.ssh_command("sudo dmidecode --oem-string 2")
.unwrap()
.trim(),
s2
);
});
kill_child(&mut child);
let output = child.wait_with_output().unwrap();
handle_child_output(r, &output);
}

View File

@@ -1741,58 +1741,8 @@ mod common_parallel {
#[test]
#[cfg(target_arch = "x86_64")]
fn test_dmi_oem_strings() {
let disk_config = UbuntuDiskConfig::new(JAMMY_IMAGE_NAME.to_string());
let guest = Guest::new(Box::new(disk_config));
let s1 = "io.systemd.credential:xx=yy";
let s2 = "This is a test string";
let oem_strings = format!("oem_strings=[{s1},{s2}]");
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", &oem_strings])
.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 dmidecode --oem-string count")
.unwrap()
.trim(),
"2"
);
assert_eq!(
guest
.ssh_command("sudo dmidecode --oem-string 1")
.unwrap()
.trim(),
s1
);
assert_eq!(
guest
.ssh_command("sudo dmidecode --oem-string 2")
.unwrap()
.trim(),
s2
);
});
kill_child(&mut child);
let output = child.wait_with_output().unwrap();
handle_child_output(r, &output);
let guest = basic_regular_guest!(JAMMY_IMAGE_NAME);
_test_dmi_oem_strings(&guest);
}
#[test]