From d8cd403c5d3ad72d72242edd69bc0d638c07301e Mon Sep 17 00:00:00 2001 From: Stefan Nuernberger Date: Thu, 15 Feb 2024 15:08:31 +0100 Subject: [PATCH] arch: x86_64: integration test for bzImage boot Signed-off-by: Stefan Nuernberger --- scripts/test-util.sh | 1 + tests/integration.rs | 50 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/scripts/test-util.sh b/scripts/test-util.sh index ba93c26a3..53b6c5f1e 100644 --- a/scripts/test-util.sh +++ b/scripts/test-util.sh @@ -57,6 +57,7 @@ build_custom_linux() { make -j "$(nproc)" if [ "${ARCH}" == "x86_64" ]; then cp vmlinux "$WORKLOADS_DIR/" || exit 1 + cp arch/x86/boot/bzImage "$WORKLOADS_DIR/" || exit 1 elif [ "${ARCH}" == "aarch64" ]; then cp arch/arm64/boot/Image "$WORKLOADS_DIR/" || exit 1 cp arch/arm64/boot/Image.gz "$WORKLOADS_DIR/" || exit 1 diff --git a/tests/integration.rs b/tests/integration.rs index cea494055..d3783023f 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -3173,6 +3173,56 @@ mod common_parallel { handle_child_output(r, &output); } + #[test] + #[cfg(target_arch = "x86_64")] + fn test_direct_kernel_boot_bzimage() { + let focal = UbuntuDiskConfig::new(FOCAL_IMAGE_NAME.to_string()); + let guest = Guest::new(Box::new(focal)); + + let mut kernel_path = direct_kernel_boot_path(); + // Replace the default kernel with the bzImage. + kernel_path.pop(); + kernel_path.push("bzImage"); + + let mut child = GuestCommand::new(&guest) + .args(["--cpus", "boot=1"]) + .args(["--memory", "size=512M"]) + .args(["--kernel", kernel_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(); + + assert_eq!(guest.get_cpu_count().unwrap_or_default(), 1); + assert!(guest.get_total_memory().unwrap_or_default() > 480_000); + + let grep_cmd = if cfg!(target_arch = "x86_64") { + "grep -c PCI-MSI /proc/interrupts" + } else { + "grep -c ITS-MSI /proc/interrupts" + }; + assert_eq!( + guest + .ssh_command(grep_cmd) + .unwrap() + .trim() + .parse::() + .unwrap_or_default(), + 12 + ); + }); + + let _ = child.kill(); + let output = child.wait_with_output().unwrap(); + + handle_child_output(r, &output); + } + fn _test_virtio_block(image_name: &str, disable_io_uring: bool, disable_aio: bool) { let focal = UbuntuDiskConfig::new(image_name.to_string()); let guest = Guest::new(Box::new(focal));