From ce5c5833cbb71e75ab412fc0aff6f85fd33ed66f Mon Sep 17 00:00:00 2001 From: Michael Zhao Date: Thu, 27 May 2021 09:11:00 +0800 Subject: [PATCH] tests: Add a simple test case for ACPI on AArch64 In the test case, the guest boots from EDK2. Signed-off-by: Michael Zhao --- scripts/run_integration_tests_aarch64.sh | 5 +++ tests/integration.rs | 39 ++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/scripts/run_integration_tests_aarch64.sh b/scripts/run_integration_tests_aarch64.sh index 623c42f11..e789c7b7c 100755 --- a/scripts/run_integration_tests_aarch64.sh +++ b/scripts/run_integration_tests_aarch64.sh @@ -308,6 +308,11 @@ echo "Integration test on FDT finished with result $RES." if [ $RES -eq 0 ]; then # Test with EDK2 + ACPI cargo build --all --release $features_build_acpi --target $BUILD_TARGET + strip target/$BUILD_TARGET/release/cloud-hypervisor + strip target/$BUILD_TARGET/release/vhost_user_net + strip target/$BUILD_TARGET/release/ch-remote + + time cargo test $features_test_acpi "tests::parallel::test_edk2_acpi_launch" RES=$? echo "Integration test on UEFI & ACPI finished with result $RES." fi diff --git a/tests/integration.rs b/tests/integration.rs index 382dcfdce..b6459dd74 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -1916,6 +1916,45 @@ mod tests { }); } + #[test] + #[cfg(all(target_arch = "aarch64", feature = "acpi"))] + fn test_edk2_acpi_launch() { + let focal = UbuntuDiskConfig::new(FOCAL_IMAGE_NAME.to_string()); + let mut workload_path = dirs::home_dir().unwrap(); + workload_path.push("workloads"); + let mut edk2_path = workload_path; + edk2_path.push("CLOUDHV_EFI.fd"); + + 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());