mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
ci: Add integration test for virtio-rtc
Integration test for virtio-devices/src/rtc.rs. Requires that the test kernel has the following configs: CONFIG_PTP_1588_CLOCK=y CONFIG_VIRTIO_RTC=y CONFIG_VIRTIO_RTC_PTP=y Signed-off-by: Cameron Baird <cameronbaird@microsoft.com>
This commit is contained in:
@@ -2091,6 +2091,70 @@ mod common_parallel {
|
|||||||
_test_virtio_fs(&prepare_virtiofsd, false, true, Some(15));
|
_test_virtio_fs(&prepare_virtiofsd, false, true, Some(15));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_virtio_rtc() {
|
||||||
|
let disk_config = UbuntuDiskConfig::new(JAMMY_IMAGE_NAME.to_string());
|
||||||
|
let guest = Guest::new(Box::new(disk_config));
|
||||||
|
|
||||||
|
let kernel_path = direct_kernel_boot_path();
|
||||||
|
|
||||||
|
// virtio-rtc is disabled by default and needs to be explicitly enabled.
|
||||||
|
let mut child = GuestCommand::new(&guest)
|
||||||
|
.default_cpus()
|
||||||
|
.default_memory()
|
||||||
|
.args(["--kernel", kernel_path.to_str().unwrap()])
|
||||||
|
.args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE])
|
||||||
|
.args(["--rtc"])
|
||||||
|
.default_disks()
|
||||||
|
.default_net()
|
||||||
|
.capture_output()
|
||||||
|
.spawn()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let r = std::panic::catch_unwind(|| {
|
||||||
|
guest.wait_vm_boot().unwrap();
|
||||||
|
|
||||||
|
// Fail fast if the virtio-rtc driver is not loaded.
|
||||||
|
assert_eq!(
|
||||||
|
guest
|
||||||
|
.ssh_command(
|
||||||
|
"test -d /sys/bus/virtio/drivers/virtio_rtc && echo ok || echo missing"
|
||||||
|
)
|
||||||
|
.unwrap()
|
||||||
|
.trim(),
|
||||||
|
"ok"
|
||||||
|
);
|
||||||
|
|
||||||
|
// Find the PTP device backed by virtio-rtc (clock_name starts with
|
||||||
|
// "Virtio PTP"), which may coexist with KVM's "KVM virtual PTP".
|
||||||
|
let ptp_dev = guest
|
||||||
|
.ssh_command(
|
||||||
|
"for d in /sys/class/ptp/ptp*; do \
|
||||||
|
if grep -q '^Virtio PTP' \"$d/clock_name\" 2>/dev/null; then \
|
||||||
|
basename \"$d\"; break; \
|
||||||
|
fi; \
|
||||||
|
done",
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
let ptp_dev = ptp_dev.trim();
|
||||||
|
assert!(ptp_dev.starts_with("ptp"), "No virtio-rtc PTP device found");
|
||||||
|
|
||||||
|
// Verify the device node exists
|
||||||
|
assert_eq!(
|
||||||
|
guest
|
||||||
|
.ssh_command(&format!("ls /dev/{ptp_dev} 2>/dev/null || echo missing"))
|
||||||
|
.unwrap()
|
||||||
|
.trim(),
|
||||||
|
format!("/dev/{ptp_dev}")
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
kill_child(&mut child);
|
||||||
|
let output = child.wait_with_output().unwrap();
|
||||||
|
|
||||||
|
handle_child_output(r, &output);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_virtio_pmem_discard_writes() {
|
fn test_virtio_pmem_discard_writes() {
|
||||||
test_virtio_pmem(true, false);
|
test_virtio_pmem(true, false);
|
||||||
|
|||||||
Reference in New Issue
Block a user