From 5d75298144eb0037e93e6ac6a81326a9cdb7fe0d Mon Sep 17 00:00:00 2001 From: Chen Chengjun Date: Thu, 2 Nov 2023 14:09:37 +0800 Subject: [PATCH] Make integration test runs in release mode --- .github/workflows/integration_test.yml | 6 +++--- Makefile | 13 ++++++++++++- runner/src/machine/qemu_grub_efi/mod.rs | 7 ++++++- runner/src/main.rs | 6 +++++- 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/.github/workflows/integration_test.yml b/.github/workflows/integration_test.yml index 1a353e006..86a307ec0 100644 --- a/.github/workflows/integration_test.yml +++ b/.github/workflows/integration_test.yml @@ -18,14 +18,14 @@ jobs: - name: Boot Test (Multiboot) id: boot_test_mb - run: RUSTFLAGS="-C opt-level=1" make run AUTO_TEST=boot ENABLE_KVM=0 BOOT_PROTOCOL=multiboot + run: make run AUTO_TEST=boot ENABLE_KVM=0 BOOT_PROTOCOL=multiboot RELEASE_MODE=1 - name: Boot Test (Multiboot2) id: boot_test_mb2 - run: RUSTFLAGS="-C opt-level=1" make run AUTO_TEST=boot ENABLE_KVM=0 BOOT_PROTOCOL=multiboot2 + run: make run AUTO_TEST=boot ENABLE_KVM=0 BOOT_PROTOCOL=multiboot2 RELEASE_MODE=1 - name: Syscall Test (Linux Boot Protocol) id: syscall_test_linux - run: RUSTFLAGS="-C opt-level=1" make run AUTO_TEST=syscall ENABLE_KVM=0 BOOT_PROTOCOL=linux + run: make run AUTO_TEST=syscall ENABLE_KVM=0 BOOT_PROTOCOL=linux RELEASE_MODE=1 # TODO: include the integration tests for MicroVM, which is not ready yet. diff --git a/Makefile b/Makefile index f6fb1d671..7ab0a9812 100644 --- a/Makefile +++ b/Makefile @@ -9,6 +9,7 @@ GDB_CLIENT ?= 0 GDB_SERVER ?= 0 INTEL_TDX ?= 0 SKIP_GRUB_MENU ?= 1 +RELEASE_MODE ?= 0 # End of setting up Make varaiables KERNEL_CMDLINE := SHELL="/bin/sh" LOGNAME="root" HOME="/" USER="root" PATH="/bin" init=/usr/bin/busybox -- sh -l @@ -22,11 +23,21 @@ endif CARGO_KBUILD_ARGS := -CARGO_KRUN_ARGS := -- '$(KERNEL_CMDLINE)' +CARGO_KRUN_ARGS := +ifeq ($(RELEASE_MODE), 1) +CARGO_KBUILD_ARGS += --release +CARGO_KRUN_ARGS += --release +endif + +CARGO_KRUN_ARGS += -- '$(KERNEL_CMDLINE)' CARGO_KRUN_ARGS += --boot-method="$(BOOT_METHOD)" CARGO_KRUN_ARGS += --boot-protocol="$(BOOT_PROTOCOL)" +ifeq ($(RELEASE_MODE), 1) +CARGO_KRUN_ARGS += --release-mode +endif + ifeq ($(EMULATE_IOMMU), 1) CARGO_KRUN_ARGS += --emulate-iommu endif diff --git a/runner/src/machine/qemu_grub_efi/mod.rs b/runner/src/machine/qemu_grub_efi/mod.rs index f1b798494..766029dcd 100644 --- a/runner/src/machine/qemu_grub_efi/mod.rs +++ b/runner/src/machine/qemu_grub_efi/mod.rs @@ -66,6 +66,7 @@ pub fn create_bootdev_image( initramfs_path: PathBuf, grub_cfg: String, protocol: BootProtocol, + release_mode: bool, ) -> PathBuf { let target_dir = jinux_path.parent().unwrap(); let iso_root = target_dir.join("iso_root"); @@ -86,7 +87,11 @@ pub fn create_bootdev_image( let target_path = match protocol { BootProtocol::Linux => { // Find the setup header in the build script output directory. - let bs_out_dir = glob("target/x86_64-custom/debug/build/jinux-frame-*").unwrap(); + let bs_out_dir = if release_mode { + glob("target/x86_64-custom/release/build/jinux-frame-*").unwrap() + } else { + glob("target/x86_64-custom/debug/build/jinux-frame-*").unwrap() + }; let header_path = Path::new(bs_out_dir.into_iter().next().unwrap().unwrap().as_path()) .join("out") .join("bin") diff --git a/runner/src/main.rs b/runner/src/main.rs index be90e6ecf..e57aa8190 100644 --- a/runner/src/main.rs +++ b/runner/src/main.rs @@ -80,6 +80,10 @@ struct Args { /// Run a GDB client instead of running the kernel. #[arg(long, default_value_t = false)] run_gdb_client: bool, + + /// Run in the release mode. + #[arg(long, default_value_t = false)] + release_mode: bool, } pub const COMMON_ARGS: &[&str] = &[ @@ -119,7 +123,6 @@ pub const GDB_ARGS: &[&str] = &[ fn main() { let args = Args::parse(); - if args.run_gdb_client { let gdb_grub = args.boot_method == BootMethod::QemuGrub; // You should comment out the next line if you want to debug grub instead @@ -195,6 +198,7 @@ fn main() { initramfs_path, grub_cfg, args.boot_protocol, + args.release_mode, ); qemu_cmd.arg("-cdrom"); qemu_cmd.arg(bootdev_image.as_os_str());