tests: extract _test_direct_kernel_boot_noacpi wrapper

Extract test logic from test_direct_kernel_boot_noacpi into
a shared _test_direct_kernel_boot_noacpi wrapper function in
tests_wrappers.rs. The kernel cmdline modification (acpi=off)
is kept in the parent test case. The wrapper uses
default_kernel_cmdline() for kernel/cmdline setup.

Signed-off-by: Muminul Islam <muislam@microsoft.com>
This commit is contained in:
Muminul Islam
2026-03-21 18:25:41 -07:00
committed by Rob Bradford
parent fb02146e2c
commit bff6e40eaa
2 changed files with 27 additions and 30 deletions

View File

@@ -2447,3 +2447,27 @@ pub(crate) fn _test_console_file(guest: &Guest) {
handle_child_output(r, &output);
}
pub(crate) fn _test_direct_kernel_boot_noacpi(guest: &Guest) {
let mut child = GuestCommand::new(guest)
.default_cpus()
.default_memory()
.default_kernel_cmdline()
.default_disks()
.default_net()
.capture_output()
.spawn()
.unwrap();
let r = std::panic::catch_unwind(|| {
guest.wait_vm_boot().unwrap();
assert_eq!(guest.get_cpu_count().unwrap_or_default(), 1);
assert!(guest.get_total_memory().unwrap_or_default() > 480_000);
});
kill_child(&mut child);
let output = child.wait_with_output().unwrap();
handle_child_output(r, &output);
}

View File

@@ -2455,36 +2455,9 @@ mod common_parallel {
#[test]
fn test_direct_kernel_boot_noacpi() {
let disk_config = UbuntuDiskConfig::new(JAMMY_IMAGE_NAME.to_string());
let guest = Guest::new(Box::new(disk_config));
let kernel_path = direct_kernel_boot_path();
let mut child = GuestCommand::new(&guest)
.default_cpus()
.default_memory()
.args(["--kernel", kernel_path.to_str().unwrap()])
.args([
"--cmdline",
format!("{DIRECT_KERNEL_BOOT_CMDLINE} acpi=off").as_str(),
])
.default_disks()
.default_net()
.capture_output()
.spawn()
.unwrap();
let r = std::panic::catch_unwind(|| {
guest.wait_vm_boot().unwrap();
assert_eq!(guest.get_cpu_count().unwrap_or_default(), 1);
assert!(guest.get_total_memory().unwrap_or_default() > 480_000);
});
kill_child(&mut child);
let output = child.wait_with_output().unwrap();
handle_child_output(r, &output);
let mut guest = basic_regular_guest!(JAMMY_IMAGE_NAME);
guest.kernel_cmdline = Some(format!("{DIRECT_KERNEL_BOOT_CMDLINE} acpi=off"));
_test_direct_kernel_boot_noacpi(&guest);
}
#[test]