diff --git a/tests/integration.rs b/tests/integration.rs index 8dac77dab..084a0dfe3 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -76,6 +76,7 @@ mod aarch64 { pub const FOCAL_IMAGE_NAME_VHD: &str = "focal-server-cloudimg-arm64-custom-20210929-0.vhd"; pub const FOCAL_IMAGE_NAME_VHDX: &str = "focal-server-cloudimg-arm64-custom-20210929-0.vhdx"; pub const GREP_SERIAL_IRQ_CMD: &str = "grep -c 'GICv3.*uart-pl011' /proc/interrupts || true"; + pub const GREP_PMU_IRQ_CMD: &str = "grep -c 'GICv3.*arm-pmu' /proc/interrupts || true"; } #[cfg(target_arch = "aarch64")] @@ -3516,6 +3517,43 @@ mod parallel { handle_child_output(r, &output); } + #[test] + #[cfg(target_arch = "aarch64")] + fn test_pmu_on() { + let focal = UbuntuDiskConfig::new(FOCAL_IMAGE_NAME.to_string()); + let guest = Guest::new(Box::new(focal)); + 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]) + .default_disks() + .default_net() + .capture_output() + .spawn() + .unwrap(); + + let r = std::panic::catch_unwind(|| { + guest.wait_vm_boot(None).unwrap(); + + // Test that PMU exists. + assert_eq!( + guest + .ssh_command(GREP_PMU_IRQ_CMD) + .unwrap() + .trim() + .parse::() + .unwrap_or_default(), + 1 + ); + }); + + let _ = child.kill(); + let output = child.wait_with_output().unwrap(); + + handle_child_output(r, &output); + } + #[test] fn test_serial_off() { let focal = UbuntuDiskConfig::new(FOCAL_IMAGE_NAME.to_string());