From 25798a97b39d3d632048c50e9b7b33b3f95f1aa3 Mon Sep 17 00:00:00 2001 From: Henry Wang Date: Mon, 6 Sep 2021 22:21:26 -0400 Subject: [PATCH] tests: Restructure AArch64 tests Currently we need to test both device tree and ACPI on AArch64. As the number of ACPI test cases is gradually increasing and expected to increase in the future, it is better to extract all ACPI test cases on AArch64 to a single module. Signed-off-by: Henry Wang --- tests/integration.rs | 136 +++++++++++++++++++++---------------------- 1 file changed, 67 insertions(+), 69 deletions(-) diff --git a/tests/integration.rs b/tests/integration.rs index a2aa231b0..6066420c7 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -985,7 +985,7 @@ mod tests { } #[allow(unused_variables)] - fn test_guest_numa_nodes(acpi: bool) { + fn _test_guest_numa_nodes(acpi: bool) { let focal = UbuntuDiskConfig::new(FOCAL_IMAGE_NAME.to_string()); let guest = Guest::new(Box::new(focal)); let api_socket = temp_api_path(&guest.tmp_dir); @@ -2105,41 +2105,6 @@ mod tests { }); } - #[test] - #[cfg(all(target_arch = "aarch64", feature = "acpi"))] - fn test_edk2_acpi_launch() { - let focal = UbuntuDiskConfig::new(FOCAL_IMAGE_NAME.to_string()); - - vec![Box::new(focal)].drain(..).for_each(|disk_config| { - let guest = Guest::new(disk_config); - - let mut child = GuestCommand::new(&guest) - .args(&["--cpus", "boot=1"]) - .args(&["--memory", "size=512M"]) - .args(&["--kernel", edk2_path().to_str().unwrap()]) - .default_disks() - .default_net() - .args(&["--serial", "tty", "--console", "off"]) - .capture_output() - .spawn() - .unwrap(); - - let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(Some(120)).unwrap(); - - assert_eq!(guest.get_cpu_count().unwrap_or_default(), 1); - assert!(guest.get_total_memory().unwrap_or_default() > 400_000); - assert!(guest.get_entropy().unwrap_or_default() >= 900); - assert_eq!(guest.get_pci_bridge_class().unwrap_or_default(), "0x060000"); - }); - - let _ = child.kill(); - let output = child.wait_with_output().unwrap(); - - handle_child_output(r, &output); - }); - } - #[test] fn test_multi_cpu() { let bionic = UbuntuDiskConfig::new(BIONIC_IMAGE_NAME.to_string()); @@ -2203,24 +2168,6 @@ mod tests { test_cpu_topology(2, 6, 2, false); } - #[test] - #[cfg(all(target_arch = "aarch64", feature = "acpi"))] - fn test_cpu_topology_421_fw() { - test_cpu_topology(4, 2, 1, true); - } - - #[test] - #[cfg(all(target_arch = "aarch64", feature = "acpi"))] - fn test_cpu_topology_142_fw() { - test_cpu_topology(1, 4, 2, true); - } - - #[test] - #[cfg(all(target_arch = "aarch64", feature = "acpi"))] - fn test_cpu_topology_262_fw() { - test_cpu_topology(2, 6, 2, true); - } - #[test] #[cfg(target_arch = "x86_64")] fn test_cpu_physical_bits() { @@ -2329,12 +2276,6 @@ mod tests { _test_power_button(false); } - #[test] - #[cfg(all(target_arch = "aarch64", feature = "acpi"))] - fn test_power_button_acpi_aarch64() { - _test_power_button(true); - } - #[test] #[cfg(target_arch = "x86_64")] fn test_user_defined_memory_regions() { @@ -2404,15 +2345,8 @@ mod tests { } #[test] - #[cfg(feature = "acpi")] - fn test_guest_numa_nodes_acpi() { - test_guest_numa_nodes(true); - } - - #[test] - #[cfg(target_arch = "aarch64")] - fn test_guest_numa_nodes_dt() { - test_guest_numa_nodes(false); + fn test_guest_numa_nodes() { + _test_guest_numa_nodes(false); } #[test] @@ -7073,4 +7007,68 @@ mod tests { _test_live_migration(true) } } + + #[cfg(all(target_arch = "aarch64", feature = "acpi"))] + mod aarch64_acpi { + use crate::tests::*; + + #[test] + fn test_simple_launch_acpi() { + let focal = UbuntuDiskConfig::new(FOCAL_IMAGE_NAME.to_string()); + + vec![Box::new(focal)].drain(..).for_each(|disk_config| { + let guest = Guest::new(disk_config); + + let mut child = GuestCommand::new(&guest) + .args(&["--cpus", "boot=1"]) + .args(&["--memory", "size=512M"]) + .args(&["--kernel", edk2_path().to_str().unwrap()]) + .default_disks() + .default_net() + .args(&["--serial", "tty", "--console", "off"]) + .capture_output() + .spawn() + .unwrap(); + + let r = std::panic::catch_unwind(|| { + guest.wait_vm_boot(Some(120)).unwrap(); + + assert_eq!(guest.get_cpu_count().unwrap_or_default(), 1); + assert!(guest.get_total_memory().unwrap_or_default() > 400_000); + assert!(guest.get_entropy().unwrap_or_default() >= 900); + assert_eq!(guest.get_pci_bridge_class().unwrap_or_default(), "0x060000"); + }); + + let _ = child.kill(); + let output = child.wait_with_output().unwrap(); + + handle_child_output(r, &output); + }); + } + + #[test] + fn test_guest_numa_nodes_acpi() { + _test_guest_numa_nodes(true); + } + + #[test] + fn test_cpu_topology_421_acpi() { + test_cpu_topology(4, 2, 1, true); + } + + #[test] + fn test_cpu_topology_142_acpi() { + test_cpu_topology(1, 4, 2, true); + } + + #[test] + fn test_cpu_topology_262_acpi() { + test_cpu_topology(2, 6, 2, true); + } + + #[test] + fn test_power_button_acpi() { + _test_power_button(true); + } + } }