2024-01-03 06:40:54 +00:00
|
|
|
# SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
|
2024-02-21 08:58:40 +00:00
|
|
|
# The Makefile provides a way to run arbitrary tests in the kernel
|
|
|
|
|
# mode using the kernel command line.
|
|
|
|
|
# Here are the options for the auto test feature.
|
2023-10-26 03:27:35 +00:00
|
|
|
AUTO_TEST ?= none
|
2024-02-21 08:58:40 +00:00
|
|
|
BOOT_LOADER ?= grub
|
2023-10-08 09:38:24 +00:00
|
|
|
BOOT_PROTOCOL ?= multiboot2
|
2024-02-21 08:58:40 +00:00
|
|
|
QEMU_MACHINE ?= q35
|
2023-08-02 11:08:02 +00:00
|
|
|
BUILD_SYSCALL_TEST ?= 0
|
|
|
|
|
EMULATE_IOMMU ?= 0
|
|
|
|
|
ENABLE_KVM ?= 1
|
2023-09-10 11:23:53 +00:00
|
|
|
INTEL_TDX ?= 0
|
2023-10-23 10:58:40 +00:00
|
|
|
SKIP_GRUB_MENU ?= 1
|
2023-11-28 04:17:42 +00:00
|
|
|
SYSCALL_TEST_DIR ?= /tmp
|
2023-11-02 06:09:37 +00:00
|
|
|
RELEASE_MODE ?= 0
|
2024-02-21 08:58:40 +00:00
|
|
|
# End of auto test features.
|
|
|
|
|
|
|
|
|
|
CARGO_OSDK_ARGS :=
|
2023-08-02 11:08:02 +00:00
|
|
|
|
2023-10-23 10:58:40 +00:00
|
|
|
ifeq ($(AUTO_TEST), syscall)
|
|
|
|
|
BUILD_SYSCALL_TEST := 1
|
2024-02-21 08:58:40 +00:00
|
|
|
CARGO_OSDK_ARGS += --kcmd_args="SYSCALL_TEST_DIR=$(SYSCALL_TEST_DIR)"
|
|
|
|
|
CARGO_OSDK_ARGS += --init_args="/opt/syscall_test/run_syscall_test.sh"
|
2023-08-02 11:08:02 +00:00
|
|
|
endif
|
2023-11-02 09:37:21 +00:00
|
|
|
ifeq ($(AUTO_TEST), regression)
|
2024-02-21 08:58:40 +00:00
|
|
|
CARGO_OSDK_ARGS += --init_args="/regression/run_regression_test.sh"
|
2023-11-02 09:37:21 +00:00
|
|
|
endif
|
2023-10-26 03:27:35 +00:00
|
|
|
ifeq ($(AUTO_TEST), boot)
|
2024-02-21 08:58:40 +00:00
|
|
|
CARGO_OSDK_ARGS += --init_args="-c exit 0"
|
2023-10-23 10:58:40 +00:00
|
|
|
endif
|
2023-08-02 11:08:02 +00:00
|
|
|
|
2023-11-02 06:09:37 +00:00
|
|
|
ifeq ($(RELEASE_MODE), 1)
|
2024-02-21 08:58:40 +00:00
|
|
|
CARGO_OSDK_ARGS += --profile release
|
2023-11-02 06:09:37 +00:00
|
|
|
endif
|
|
|
|
|
|
2024-01-28 06:54:38 +00:00
|
|
|
ifeq ($(INTEL_TDX), 1)
|
2024-02-21 08:58:40 +00:00
|
|
|
CARGO_OSDK_ARGS += --features intel_tdx
|
2023-09-10 11:23:53 +00:00
|
|
|
endif
|
|
|
|
|
|
2024-02-21 08:58:40 +00:00
|
|
|
CARGO_OSDK_ARGS += --boot.loader="$(BOOT_LOADER)"
|
|
|
|
|
CARGO_OSDK_ARGS += --boot.protocol="$(BOOT_PROTOCOL)"
|
|
|
|
|
CARGO_OSDK_ARGS += --qemu.machine="$(QEMU_MACHINE)"
|
2023-08-02 11:08:02 +00:00
|
|
|
|
2024-02-21 08:58:40 +00:00
|
|
|
ifeq ($(QEMU_MACHINE), microvm)
|
|
|
|
|
CARGO_OSDK_ARGS += --select microvm
|
2023-08-02 11:08:02 +00:00
|
|
|
endif
|
|
|
|
|
|
2024-02-21 08:58:40 +00:00
|
|
|
# To test the linux-efi-handover64 boot protocol, we need to use Debian's
|
|
|
|
|
# GRUB release, which is installed in /usr/bin in our Docker image.
|
|
|
|
|
ifeq ($(BOOT_PROTOCOL), linux-efi-handover64)
|
|
|
|
|
CARGO_OSDK_ARGS += --boot.grub-mkrescue=/usr/bin/grub-mkrescue
|
2023-08-09 03:40:00 +00:00
|
|
|
endif
|
|
|
|
|
|
2024-02-21 08:58:40 +00:00
|
|
|
ifeq ($(EMULATE_IOMMU), 1)
|
|
|
|
|
CARGO_OSDK_ARGS += --select iommu
|
2023-11-04 08:41:30 +00:00
|
|
|
endif
|
|
|
|
|
|
2024-02-21 08:58:40 +00:00
|
|
|
ifeq ($(ENABLE_KVM), 1)
|
|
|
|
|
CARGO_OSDK_ARGS += --qemu.args="--enable-kvm"
|
2023-08-02 11:08:02 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
# Pass make variables to all subdirectory makes
|
|
|
|
|
export
|
|
|
|
|
|
2023-11-06 07:42:26 +00:00
|
|
|
# Maintain a list of usermode crates that can be tested with `cargo test`
|
|
|
|
|
USERMODE_TESTABLE := \
|
|
|
|
|
framework/libs/align_ext \
|
2024-02-21 08:58:40 +00:00
|
|
|
framework/libs/aster-main \
|
2023-12-29 07:32:06 +00:00
|
|
|
framework/libs/linux-bzimage/builder \
|
|
|
|
|
framework/libs/linux-bzimage/boot-params \
|
2023-11-06 07:42:26 +00:00
|
|
|
framework/libs/ktest \
|
2023-11-08 15:59:23 +00:00
|
|
|
framework/libs/ktest-proc-macro \
|
2024-02-27 08:40:16 +00:00
|
|
|
kernel/libs/cpio-decoder \
|
|
|
|
|
kernel/libs/int-to-c-enum \
|
|
|
|
|
kernel/libs/int-to-c-enum/derive \
|
|
|
|
|
kernel/libs/aster-rights \
|
|
|
|
|
kernel/libs/aster-rights-proc \
|
|
|
|
|
kernel/libs/keyable-arc \
|
|
|
|
|
kernel/libs/typeflags \
|
|
|
|
|
kernel/libs/typeflags-util
|
2023-11-06 07:42:26 +00:00
|
|
|
|
2024-02-21 08:58:40 +00:00
|
|
|
# Maintain a list of kernel crates that can be tested with `cargo osdk test`
|
2024-02-27 03:23:06 +00:00
|
|
|
# The framework is tested independently, thus not included here
|
2024-02-21 08:58:40 +00:00
|
|
|
KTEST_TESTABLE := \
|
2024-02-27 08:40:16 +00:00
|
|
|
"kernel/aster-nix" \
|
|
|
|
|
"kernel/comps/block" \
|
|
|
|
|
"kernel/comps/console" \
|
|
|
|
|
"kernel/comps/framebuffer" \
|
|
|
|
|
"kernel/comps/input" \
|
|
|
|
|
"kernel/comps/network" \
|
|
|
|
|
"kernel/comps/time" \
|
|
|
|
|
"kernel/comps/virtio"
|
2024-02-21 08:58:40 +00:00
|
|
|
|
|
|
|
|
.PHONY: all install_osdk build tools run test docs check clean update_initramfs
|
2022-08-08 22:43:47 +00:00
|
|
|
|
2023-04-10 03:12:42 +00:00
|
|
|
all: build
|
2022-08-08 22:43:47 +00:00
|
|
|
|
2024-02-21 08:58:40 +00:00
|
|
|
install_osdk:
|
2024-02-26 13:32:39 +00:00
|
|
|
@cargo install cargo-osdk --path osdk
|
2022-08-17 03:22:49 +00:00
|
|
|
|
2022-08-08 22:43:47 +00:00
|
|
|
build:
|
2023-05-29 05:29:53 +00:00
|
|
|
@make --no-print-directory -C regression
|
2024-02-27 08:40:16 +00:00
|
|
|
@cd kernel && cargo osdk build $(CARGO_OSDK_ARGS)
|
2023-08-07 02:56:03 +00:00
|
|
|
|
2023-02-07 08:05:21 +00:00
|
|
|
tools:
|
2024-02-27 08:40:16 +00:00
|
|
|
@cd kernel/libs/comp-sys && cargo install --path cargo-component
|
2023-02-07 08:05:21 +00:00
|
|
|
|
2022-08-17 03:22:49 +00:00
|
|
|
run: build
|
2024-02-27 08:40:16 +00:00
|
|
|
@cd kernel && cargo osdk run $(CARGO_OSDK_ARGS)
|
2023-07-26 07:36:40 +00:00
|
|
|
|
2023-11-04 08:41:30 +00:00
|
|
|
test:
|
2023-11-06 07:42:26 +00:00
|
|
|
@for dir in $(USERMODE_TESTABLE); do \
|
|
|
|
|
(cd $$dir && cargo test) || exit 1; \
|
|
|
|
|
done
|
2022-08-08 22:43:47 +00:00
|
|
|
|
2024-02-21 08:58:40 +00:00
|
|
|
ktest:
|
|
|
|
|
@for dir in $(KTEST_TESTABLE); do \
|
|
|
|
|
(cd $$dir && cargo osdk test) || exit 1; \
|
|
|
|
|
done
|
|
|
|
|
|
2022-08-08 22:43:47 +00:00
|
|
|
docs:
|
2023-04-10 03:12:42 +00:00
|
|
|
@cargo doc # Build Rust docs
|
2022-08-08 22:43:47 +00:00
|
|
|
@echo "" # Add a blank line
|
2022-08-08 23:02:55 +00:00
|
|
|
@cd docs && mdbook build # Build mdBook
|
2022-08-08 22:43:47 +00:00
|
|
|
|
2024-02-25 14:03:54 +00:00
|
|
|
format:
|
2024-02-27 12:28:43 +00:00
|
|
|
@./tools/format_all.sh
|
2024-02-25 14:03:54 +00:00
|
|
|
|
2022-08-08 23:02:55 +00:00
|
|
|
check:
|
2024-02-27 12:28:43 +00:00
|
|
|
@./tools/format_all.sh --check # Check Rust format issues
|
2024-02-21 08:58:40 +00:00
|
|
|
@cargo osdk clippy
|
2022-08-08 22:43:47 +00:00
|
|
|
|
|
|
|
|
clean:
|
2023-04-10 03:12:42 +00:00
|
|
|
@cargo clean
|
2022-08-17 03:22:49 +00:00
|
|
|
@cd docs && mdbook clean
|
2023-05-29 05:29:53 +00:00
|
|
|
@make --no-print-directory -C regression clean
|
2023-12-28 09:24:23 +00:00
|
|
|
|
|
|
|
|
update_initramfs:
|
|
|
|
|
@make --no-print-directory -C regression clean
|
2024-02-21 08:58:40 +00:00
|
|
|
@make --no-print-directory -C regression
|