mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
tests: extract _test_pvpanic to tests_wrappers
Extract test logic from test_pvpanic into a shared _test_pvpanic wrapper function in tests_wrappers.rs. Update the parent test case to use the basic_regular_guest macro. The wrapper uses default_kernel_cmdline() for kernel/cmdline setup. Signed-off-by: Muminul Islam <muislam@microsoft.com>
This commit is contained in:
committed by
Rob Bradford
parent
93a3fc5b91
commit
17774ee564
@@ -3151,3 +3151,45 @@ pub(crate) fn _test_watchdog(guest: &Guest) {
|
||||
|
||||
handle_child_output(r, &output);
|
||||
}
|
||||
|
||||
pub(crate) fn _test_pvpanic(guest: &Guest) {
|
||||
let api_socket = temp_api_path(&guest.tmp_dir);
|
||||
let event_path = temp_event_monitor_path(&guest.tmp_dir);
|
||||
|
||||
let mut cmd = GuestCommand::new(guest);
|
||||
cmd.default_cpus()
|
||||
.default_memory()
|
||||
.default_kernel_cmdline()
|
||||
.default_disks()
|
||||
.args(["--net", guest.default_net_string().as_str()])
|
||||
.args(["--pvpanic"])
|
||||
.args(["--api-socket", &api_socket])
|
||||
.args(["--event-monitor", format!("path={event_path}").as_str()])
|
||||
.capture_output();
|
||||
|
||||
let mut child = cmd.spawn().unwrap();
|
||||
|
||||
let r = std::panic::catch_unwind(|| {
|
||||
guest.wait_vm_boot().unwrap();
|
||||
|
||||
// Trigger guest a panic
|
||||
make_guest_panic(guest);
|
||||
|
||||
// Wait a while for guest
|
||||
thread::sleep(std::time::Duration::new(10, 0));
|
||||
|
||||
let expected_sequential_events = [&MetaEvent {
|
||||
event: "panic".to_string(),
|
||||
device_id: None,
|
||||
}];
|
||||
assert!(check_latest_events_exact(
|
||||
&expected_sequential_events,
|
||||
&event_path
|
||||
));
|
||||
});
|
||||
|
||||
kill_child(&mut child);
|
||||
let output = child.wait_with_output().unwrap();
|
||||
|
||||
handle_child_output(r, &output);
|
||||
}
|
||||
|
||||
@@ -5105,50 +5105,8 @@ mod common_parallel {
|
||||
|
||||
#[test]
|
||||
fn test_pvpanic() {
|
||||
let disk_config = UbuntuDiskConfig::new(JAMMY_IMAGE_NAME.to_string());
|
||||
let guest = Guest::new(Box::new(disk_config));
|
||||
let api_socket = temp_api_path(&guest.tmp_dir);
|
||||
let event_path = temp_event_monitor_path(&guest.tmp_dir);
|
||||
|
||||
let kernel_path = direct_kernel_boot_path();
|
||||
|
||||
let mut cmd = GuestCommand::new(&guest);
|
||||
cmd.default_cpus()
|
||||
.default_memory()
|
||||
.args(["--kernel", kernel_path.to_str().unwrap()])
|
||||
.args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE])
|
||||
.default_disks()
|
||||
.args(["--net", guest.default_net_string().as_str()])
|
||||
.args(["--pvpanic"])
|
||||
.args(["--api-socket", &api_socket])
|
||||
.args(["--event-monitor", format!("path={event_path}").as_str()])
|
||||
.capture_output();
|
||||
|
||||
let mut child = cmd.spawn().unwrap();
|
||||
|
||||
let r = std::panic::catch_unwind(|| {
|
||||
guest.wait_vm_boot().unwrap();
|
||||
|
||||
// Trigger guest a panic
|
||||
make_guest_panic(&guest);
|
||||
|
||||
// Wait a while for guest
|
||||
thread::sleep(std::time::Duration::new(10, 0));
|
||||
|
||||
let expected_sequential_events = [&MetaEvent {
|
||||
event: "panic".to_string(),
|
||||
device_id: None,
|
||||
}];
|
||||
assert!(check_latest_events_exact(
|
||||
&expected_sequential_events,
|
||||
&event_path
|
||||
));
|
||||
});
|
||||
|
||||
kill_child(&mut child);
|
||||
let output = child.wait_with_output().unwrap();
|
||||
|
||||
handle_child_output(r, &output);
|
||||
let guest = basic_regular_guest!(JAMMY_IMAGE_NAME);
|
||||
_test_pvpanic(&guest);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user