mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
tests: Add a test case for Arm64 ACPI power button
Signed-off-by: Henry Wang <Henry.Wang@arm.com>
This commit is contained in:
+43
-23
@@ -1061,6 +1061,43 @@ mod tests {
|
|||||||
handle_child_output(r, &output);
|
handle_child_output(r, &output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(unused_variables)]
|
||||||
|
fn _test_power_button(acpi: bool) {
|
||||||
|
let focal = UbuntuDiskConfig::new(FOCAL_IMAGE_NAME.to_string());
|
||||||
|
let guest = Guest::new(Box::new(focal));
|
||||||
|
let mut cmd = GuestCommand::new(&guest);
|
||||||
|
let api_socket = temp_api_path(&guest.tmp_dir);
|
||||||
|
|
||||||
|
#[cfg(target_arch = "x86_64")]
|
||||||
|
let kernel_path = direct_kernel_boot_path();
|
||||||
|
#[cfg(target_arch = "aarch64")]
|
||||||
|
let kernel_path = if acpi {
|
||||||
|
edk2_path()
|
||||||
|
} else {
|
||||||
|
direct_kernel_boot_path()
|
||||||
|
};
|
||||||
|
|
||||||
|
cmd.args(&["--cpus", "boot=1"])
|
||||||
|
.args(&["--memory", "size=512M"])
|
||||||
|
.args(&["--kernel", kernel_path.to_str().unwrap()])
|
||||||
|
.args(&["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE])
|
||||||
|
.capture_output()
|
||||||
|
.default_disks()
|
||||||
|
.default_net()
|
||||||
|
.args(&["--api-socket", &api_socket]);
|
||||||
|
|
||||||
|
let child = cmd.spawn().unwrap();
|
||||||
|
|
||||||
|
let r = std::panic::catch_unwind(|| {
|
||||||
|
guest.wait_vm_boot(None).unwrap();
|
||||||
|
assert!(remote_command(&api_socket, "power-button", None));
|
||||||
|
});
|
||||||
|
|
||||||
|
let output = child.wait_with_output().unwrap();
|
||||||
|
assert!(output.status.success());
|
||||||
|
handle_child_output(r, &output);
|
||||||
|
}
|
||||||
|
|
||||||
type PrepareNetDaemon =
|
type PrepareNetDaemon =
|
||||||
dyn Fn(&TempDir, &str, Option<&str>, usize, bool) -> (std::process::Command, String);
|
dyn Fn(&TempDir, &str, Option<&str>, usize, bool) -> (std::process::Command, String);
|
||||||
|
|
||||||
@@ -2289,30 +2326,13 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_power_button() {
|
fn test_power_button() {
|
||||||
let focal = UbuntuDiskConfig::new(FOCAL_IMAGE_NAME.to_string());
|
_test_power_button(false);
|
||||||
let guest = Guest::new(Box::new(focal));
|
}
|
||||||
let mut cmd = GuestCommand::new(&guest);
|
|
||||||
let api_socket = temp_api_path(&guest.tmp_dir);
|
|
||||||
|
|
||||||
cmd.args(&["--cpus", "boot=1"])
|
#[test]
|
||||||
.args(&["--memory", "size=512M"])
|
#[cfg(all(target_arch = "aarch64", feature = "acpi"))]
|
||||||
.args(&["--kernel", direct_kernel_boot_path().to_str().unwrap()])
|
fn test_power_button_acpi_aarch64() {
|
||||||
.args(&["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE])
|
_test_power_button(true);
|
||||||
.capture_output()
|
|
||||||
.default_disks()
|
|
||||||
.default_net()
|
|
||||||
.args(&["--api-socket", &api_socket]);
|
|
||||||
|
|
||||||
let child = cmd.spawn().unwrap();
|
|
||||||
|
|
||||||
let r = std::panic::catch_unwind(|| {
|
|
||||||
guest.wait_vm_boot(None).unwrap();
|
|
||||||
assert!(remote_command(&api_socket, "power-button", None));
|
|
||||||
});
|
|
||||||
|
|
||||||
let output = child.wait_with_output().unwrap();
|
|
||||||
assert!(output.status.success());
|
|
||||||
handle_child_output(r, &output);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
Reference in New Issue
Block a user