From a85d27bd529794ad4ee885c4f709a7db65fd37c4 Mon Sep 17 00:00:00 2001 From: Wei Liu Date: Sat, 6 Aug 2022 16:09:07 +0000 Subject: [PATCH] tests: add OEM strings integration test Signed-off-by: Wei Liu --- tests/integration.rs | 57 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/tests/integration.rs b/tests/integration.rs index 64218c1fe..724563fbf 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -3135,6 +3135,63 @@ mod parallel { handle_child_output(r, &output); } + #[test] + #[cfg(target_arch = "x86_64")] + fn test_dmi_oem_strings() { + let focal = UbuntuDiskConfig::new(FOCAL_IMAGE_NAME.to_string()); + let guest = Guest::new(Box::new(focal)); + + 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) + .args(&["--cpus", "boot=1"]) + .args(&["--memory", "size=512M"]) + .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(None).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 + ); + }); + + let _ = child.kill(); + let output = child.wait_with_output().unwrap(); + + handle_child_output(r, &output); + } + #[test] fn test_virtio_fs() { _test_virtio_fs(&prepare_virtiofsd, false, None)