tests: Add a simple test case for ACPI on AArch64

In the test case, the guest boots from EDK2.

Signed-off-by: Michael Zhao <michael.zhao@arm.com>
This commit is contained in:
Michael Zhao 2021-05-27 09:11:00 +08:00 committed by Xin Wang
parent 3cb2b72e92
commit ce5c5833cb
2 changed files with 44 additions and 0 deletions

View File

@ -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

View File

@ -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());