asterinas/Makefile

142 lines
3.6 KiB
Makefile
Raw Normal View History

# SPDX-License-Identifier: MPL-2.0
# 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.
AUTO_TEST ?= none
BOOT_LOADER ?= grub
BOOT_PROTOCOL ?= multiboot2
QEMU_MACHINE ?= q35
BUILD_SYSCALL_TEST ?= 0
EMULATE_IOMMU ?= 0
ENABLE_KVM ?= 1
INTEL_TDX ?= 0
SKIP_GRUB_MENU ?= 1
2023-11-28 04:17:42 +00:00
SYSCALL_TEST_DIR ?= /tmp
RELEASE_MODE ?= 0
# End of auto test features.
CARGO_OSDK_ARGS :=
ifeq ($(AUTO_TEST), syscall)
BUILD_SYSCALL_TEST := 1
CARGO_OSDK_ARGS += --kcmd_args="SYSCALL_TEST_DIR=$(SYSCALL_TEST_DIR)"
CARGO_OSDK_ARGS += --init_args="/opt/syscall_test/run_syscall_test.sh"
endif
2023-11-02 09:37:21 +00:00
ifeq ($(AUTO_TEST), regression)
CARGO_OSDK_ARGS += --init_args="/regression/run_regression_test.sh"
2023-11-02 09:37:21 +00:00
endif
ifeq ($(AUTO_TEST), boot)
CARGO_OSDK_ARGS += --init_args="-c exit 0"
endif
ifeq ($(RELEASE_MODE), 1)
CARGO_OSDK_ARGS += --profile release
endif
ifeq ($(INTEL_TDX), 1)
CARGO_OSDK_ARGS += --features intel_tdx
endif
CARGO_OSDK_ARGS += --boot.loader="$(BOOT_LOADER)"
CARGO_OSDK_ARGS += --boot.protocol="$(BOOT_PROTOCOL)"
CARGO_OSDK_ARGS += --qemu.machine="$(QEMU_MACHINE)"
ifeq ($(QEMU_MACHINE), microvm)
CARGO_OSDK_ARGS += --select microvm
endif
# 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
endif
ifeq ($(EMULATE_IOMMU), 1)
CARGO_OSDK_ARGS += --select iommu
2023-11-04 08:41:30 +00:00
endif
ifeq ($(ENABLE_KVM), 1)
CARGO_OSDK_ARGS += --qemu.args="--enable-kvm"
endif
# Pass make variables to all subdirectory makes
export
# Maintain a list of usermode crates that can be tested with `cargo test`
USERMODE_TESTABLE := \
framework/libs/align_ext \
framework/libs/aster-main \
2023-12-29 07:32:06 +00:00
framework/libs/linux-bzimage/builder \
framework/libs/linux-bzimage/boot-params \
framework/libs/ktest \
2023-11-08 15:59:23 +00:00
framework/libs/ktest-proc-macro \
services/libs/cpio-decoder \
services/libs/int-to-c-enum \
services/libs/int-to-c-enum/derive \
2023-12-25 03:12:25 +00:00
services/libs/aster-rights \
services/libs/aster-rights-proc \
services/libs/keyable-arc \
services/libs/typeflags \
services/libs/typeflags-util
# Maintain a list of kernel crates that can be tested with `cargo osdk test`
# The framework is tested independently, thus not included here
KTEST_TESTABLE := \
"services/aster-nix" \
"services/comps/block" \
"services/comps/console" \
"services/comps/framebuffer" \
"services/comps/input" \
"services/comps/network" \
"services/comps/time" \
"services/comps/virtio"
.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
install_osdk:
@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
@cargo osdk build $(CARGO_OSDK_ARGS)
2023-08-07 02:56:03 +00:00
2023-02-07 08:05:21 +00:00
tools:
2023-04-10 03:12:42 +00:00
@cd services/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
@cargo osdk run $(CARGO_OSDK_ARGS)
2023-11-04 08:41:30 +00:00
test:
@for dir in $(USERMODE_TESTABLE); do \
(cd $$dir && cargo test) || exit 1; \
done
2022-08-08 22:43:47 +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
format:
./tools/format_all.sh
2022-08-08 23:02:55 +00:00
check:
./tools/format_all.sh --check # Check Rust format issues
@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
@make --no-print-directory -C regression