mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-22 08:53:29 +00:00
Specify ktest osdk args in Makefile
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
6d687fef32
commit
00e6905d93
78
Makefile
78
Makefile
@ -49,43 +49,47 @@ SHELL := /bin/bash
|
|||||||
|
|
||||||
CARGO_OSDK := ~/.cargo/bin/cargo-osdk
|
CARGO_OSDK := ~/.cargo/bin/cargo-osdk
|
||||||
|
|
||||||
CARGO_OSDK_ARGS := --target-arch=$(ARCH) --kcmd-args="ostd.log_level=$(LOG_LEVEL)"
|
# Common arguments for `cargo osdk` `build`, `run` and `test` commands.
|
||||||
|
CARGO_OSDK_COMMON_ARGS := --target-arch=$(ARCH)
|
||||||
|
# The build arguments also apply to the `cargo osdk run` command.
|
||||||
|
CARGO_OSDK_BUILD_ARGS := --kcmd-args="ostd.log_level=$(LOG_LEVEL)"
|
||||||
|
CARGO_OSDK_TEST_ARGS :=
|
||||||
|
|
||||||
ifeq ($(AUTO_TEST), syscall)
|
ifeq ($(AUTO_TEST), syscall)
|
||||||
BUILD_SYSCALL_TEST := 1
|
BUILD_SYSCALL_TEST := 1
|
||||||
CARGO_OSDK_ARGS += --kcmd-args="SYSCALL_TEST_SUITE=$(SYSCALL_TEST_SUITE)"
|
CARGO_OSDK_BUILD_ARGS += --kcmd-args="SYSCALL_TEST_SUITE=$(SYSCALL_TEST_SUITE)"
|
||||||
CARGO_OSDK_ARGS += --kcmd-args="SYSCALL_TEST_WORKDIR=$(SYSCALL_TEST_WORKDIR)"
|
CARGO_OSDK_BUILD_ARGS += --kcmd-args="SYSCALL_TEST_WORKDIR=$(SYSCALL_TEST_WORKDIR)"
|
||||||
CARGO_OSDK_ARGS += --kcmd-args="EXTRA_BLOCKLISTS_DIRS=$(EXTRA_BLOCKLISTS_DIRS)"
|
CARGO_OSDK_BUILD_ARGS += --kcmd-args="EXTRA_BLOCKLISTS_DIRS=$(EXTRA_BLOCKLISTS_DIRS)"
|
||||||
CARGO_OSDK_ARGS += --init-args="/opt/syscall_test/run_syscall_test.sh"
|
CARGO_OSDK_BUILD_ARGS += --init-args="/opt/syscall_test/run_syscall_test.sh"
|
||||||
else ifeq ($(AUTO_TEST), test)
|
else ifeq ($(AUTO_TEST), test)
|
||||||
ifneq ($(SMP), 1)
|
ifneq ($(SMP), 1)
|
||||||
CARGO_OSDK_ARGS += --kcmd-args="BLOCK_UNSUPPORTED_SMP_TESTS=1"
|
CARGO_OSDK_BUILD_ARGS += --kcmd-args="BLOCK_UNSUPPORTED_SMP_TESTS=1"
|
||||||
endif
|
endif
|
||||||
CARGO_OSDK_ARGS += --init-args="/test/run_general_test.sh"
|
CARGO_OSDK_BUILD_ARGS += --init-args="/test/run_general_test.sh"
|
||||||
else ifeq ($(AUTO_TEST), boot)
|
else ifeq ($(AUTO_TEST), boot)
|
||||||
CARGO_OSDK_ARGS += --init-args="/test/boot_hello.sh"
|
CARGO_OSDK_BUILD_ARGS += --init-args="/test/boot_hello.sh"
|
||||||
else ifeq ($(AUTO_TEST), vsock)
|
else ifeq ($(AUTO_TEST), vsock)
|
||||||
export VSOCK=on
|
export VSOCK=on
|
||||||
CARGO_OSDK_ARGS += --init-args="/test/run_vsock_test.sh"
|
CARGO_OSDK_BUILD_ARGS += --init-args="/test/run_vsock_test.sh"
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(RELEASE_LTO), 1)
|
ifeq ($(RELEASE_LTO), 1)
|
||||||
CARGO_OSDK_ARGS += --profile release-lto
|
CARGO_OSDK_COMMON_ARGS += --profile release-lto
|
||||||
OSTD_TASK_STACK_SIZE_IN_PAGES = 8
|
OSTD_TASK_STACK_SIZE_IN_PAGES = 8
|
||||||
else ifeq ($(RELEASE), 1)
|
else ifeq ($(RELEASE), 1)
|
||||||
CARGO_OSDK_ARGS += --release
|
CARGO_OSDK_COMMON_ARGS += --release
|
||||||
OSTD_TASK_STACK_SIZE_IN_PAGES = 8
|
OSTD_TASK_STACK_SIZE_IN_PAGES = 8
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# If the BENCHMARK is set, we will run the benchmark in the kernel mode.
|
# If the BENCHMARK is set, we will run the benchmark in the kernel mode.
|
||||||
ifneq ($(BENCHMARK), none)
|
ifneq ($(BENCHMARK), none)
|
||||||
CARGO_OSDK_ARGS += --init-args="/benchmark/common/bench_runner.sh $(BENCHMARK) asterinas"
|
CARGO_OSDK_BUILD_ARGS += --init-args="/benchmark/common/bench_runner.sh $(BENCHMARK) asterinas"
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(INTEL_TDX), 1)
|
ifeq ($(INTEL_TDX), 1)
|
||||||
BOOT_METHOD = grub-qcow2
|
BOOT_METHOD = grub-qcow2
|
||||||
BOOT_PROTOCOL = linux-efi-handover64
|
BOOT_PROTOCOL = linux-efi-handover64
|
||||||
CARGO_OSDK_ARGS += --scheme tdx
|
CARGO_OSDK_COMMON_ARGS += --scheme tdx
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(BOOT_PROTOCOL), linux-legacy32)
|
ifeq ($(BOOT_PROTOCOL), linux-legacy32)
|
||||||
@ -96,46 +100,50 @@ BOOT_METHOD = qemu-direct
|
|||||||
OVMF = off
|
OVMF = off
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(ARCH), riscv64)
|
||||||
|
SCHEME = riscv
|
||||||
|
endif
|
||||||
|
|
||||||
ifneq ($(SCHEME), "")
|
ifneq ($(SCHEME), "")
|
||||||
CARGO_OSDK_ARGS += --scheme $(SCHEME)
|
CARGO_OSDK_COMMON_ARGS += --scheme $(SCHEME)
|
||||||
else
|
else
|
||||||
CARGO_OSDK_ARGS += --boot-method="$(BOOT_METHOD)"
|
CARGO_OSDK_COMMON_ARGS += --boot-method="$(BOOT_METHOD)"
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifdef FEATURES
|
ifdef FEATURES
|
||||||
CARGO_OSDK_ARGS += --features="$(FEATURES)"
|
CARGO_OSDK_COMMON_ARGS += --features="$(FEATURES)"
|
||||||
endif
|
endif
|
||||||
ifeq ($(NO_DEFAULT_FEATURES), 1)
|
ifeq ($(NO_DEFAULT_FEATURES), 1)
|
||||||
CARGO_OSDK_ARGS += --no-default-features
|
CARGO_OSDK_COMMON_ARGS += --no-default-features
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# To test the linux-efi-handover64 boot protocol, we need to use Debian's
|
# 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.
|
# GRUB release, which is installed in /usr/bin in our Docker image.
|
||||||
ifeq ($(BOOT_PROTOCOL), linux-efi-handover64)
|
ifeq ($(BOOT_PROTOCOL), linux-efi-handover64)
|
||||||
CARGO_OSDK_ARGS += --grub-mkrescue=/usr/bin/grub-mkrescue
|
CARGO_OSDK_COMMON_ARGS += --grub-mkrescue=/usr/bin/grub-mkrescue --grub-boot-protocol="linux"
|
||||||
CARGO_OSDK_ARGS += --grub-boot-protocol="linux"
|
|
||||||
# FIXME: GZIP self-decompression (--encoding gzip) triggers CPU faults
|
|
||||||
CARGO_OSDK_ARGS += --encoding raw
|
|
||||||
else ifeq ($(BOOT_PROTOCOL), linux-efi-pe64)
|
else ifeq ($(BOOT_PROTOCOL), linux-efi-pe64)
|
||||||
CARGO_OSDK_ARGS += --grub-boot-protocol="linux"
|
CARGO_OSDK_COMMON_ARGS += --grub-boot-protocol="linux"
|
||||||
CARGO_OSDK_ARGS += --encoding raw
|
|
||||||
else ifeq ($(BOOT_PROTOCOL), linux-legacy32)
|
else ifeq ($(BOOT_PROTOCOL), linux-legacy32)
|
||||||
CARGO_OSDK_ARGS += --linux-x86-legacy-boot
|
CARGO_OSDK_COMMON_ARGS += --linux-x86-legacy-boot --grub-boot-protocol="linux"
|
||||||
CARGO_OSDK_ARGS += --grub-boot-protocol="linux"
|
|
||||||
else
|
else
|
||||||
CARGO_OSDK_ARGS += --grub-boot-protocol=$(BOOT_PROTOCOL)
|
CARGO_OSDK_COMMON_ARGS += --grub-boot-protocol=$(BOOT_PROTOCOL)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(ENABLE_KVM), 1)
|
ifeq ($(ENABLE_KVM), 1)
|
||||||
CARGO_OSDK_ARGS += --qemu-args="-accel kvm"
|
ifeq ($(ARCH), x86_64)
|
||||||
|
CARGO_OSDK_COMMON_ARGS += --qemu-args="-accel kvm"
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Skip GZIP to make encoding and decoding of initramfs faster
|
# Skip GZIP to make encoding and decoding of initramfs faster
|
||||||
ifeq ($(INITRAMFS_SKIP_GZIP),1)
|
ifeq ($(INITRAMFS_SKIP_GZIP),1)
|
||||||
CARGO_OSDK_INITRAMFS_OPTION := --initramfs=$(realpath test/build/initramfs.cpio)
|
CARGO_OSDK_INITRAMFS_OPTION := --initramfs=$(realpath test/build/initramfs.cpio)
|
||||||
CARGO_OSDK_ARGS += $(CARGO_OSDK_INITRAMFS_OPTION)
|
CARGO_OSDK_COMMON_ARGS += $(CARGO_OSDK_INITRAMFS_OPTION)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
CARGO_OSDK_BUILD_ARGS += $(CARGO_OSDK_COMMON_ARGS)
|
||||||
|
CARGO_OSDK_TEST_ARGS += $(CARGO_OSDK_COMMON_ARGS)
|
||||||
|
|
||||||
# Pass make variables to all subdirectory makes
|
# Pass make variables to all subdirectory makes
|
||||||
export
|
export
|
||||||
|
|
||||||
@ -219,7 +227,7 @@ initramfs:
|
|||||||
|
|
||||||
.PHONY: build
|
.PHONY: build
|
||||||
build: initramfs $(CARGO_OSDK)
|
build: initramfs $(CARGO_OSDK)
|
||||||
@cd kernel && cargo osdk build $(CARGO_OSDK_ARGS)
|
@cd kernel && cargo osdk build $(CARGO_OSDK_BUILD_ARGS)
|
||||||
|
|
||||||
.PHONY: tools
|
.PHONY: tools
|
||||||
tools:
|
tools:
|
||||||
@ -227,7 +235,7 @@ tools:
|
|||||||
|
|
||||||
.PHONY: run
|
.PHONY: run
|
||||||
run: initramfs $(CARGO_OSDK)
|
run: initramfs $(CARGO_OSDK)
|
||||||
@cd kernel && cargo osdk run $(CARGO_OSDK_ARGS)
|
@cd kernel && cargo osdk run $(CARGO_OSDK_BUILD_ARGS)
|
||||||
# Check the running status of auto tests from the QEMU log
|
# Check the running status of auto tests from the QEMU log
|
||||||
ifeq ($(AUTO_TEST), syscall)
|
ifeq ($(AUTO_TEST), syscall)
|
||||||
@tail --lines 100 qemu.log | grep -q "^All syscall tests passed." \
|
@tail --lines 100 qemu.log | grep -q "^All syscall tests passed." \
|
||||||
@ -245,19 +253,19 @@ endif
|
|||||||
|
|
||||||
.PHONY: gdb_server
|
.PHONY: gdb_server
|
||||||
gdb_server: initramfs $(CARGO_OSDK)
|
gdb_server: initramfs $(CARGO_OSDK)
|
||||||
@cd kernel && cargo osdk run $(CARGO_OSDK_ARGS) --gdb-server wait-client,vscode,addr=:$(GDB_TCP_PORT)
|
@cd kernel && cargo osdk run $(CARGO_OSDK_BUILD_ARGS) --gdb-server wait-client,vscode,addr=:$(GDB_TCP_PORT)
|
||||||
|
|
||||||
.PHONY: gdb_client
|
.PHONY: gdb_client
|
||||||
gdb_client: initramfs $(CARGO_OSDK)
|
gdb_client: initramfs $(CARGO_OSDK)
|
||||||
@cd kernel && cargo osdk debug $(CARGO_OSDK_ARGS) --remote :$(GDB_TCP_PORT)
|
@cd kernel && cargo osdk debug $(CARGO_OSDK_BUILD_ARGS) --remote :$(GDB_TCP_PORT)
|
||||||
|
|
||||||
.PHONY: profile_server
|
.PHONY: profile_server
|
||||||
profile_server: initramfs $(CARGO_OSDK)
|
profile_server: initramfs $(CARGO_OSDK)
|
||||||
@cd kernel && cargo osdk run $(CARGO_OSDK_ARGS) --gdb-server addr=:$(GDB_TCP_PORT)
|
@cd kernel && cargo osdk run $(CARGO_OSDK_BUILD_ARGS) --gdb-server addr=:$(GDB_TCP_PORT)
|
||||||
|
|
||||||
.PHONY: profile_client
|
.PHONY: profile_client
|
||||||
profile_client: initramfs $(CARGO_OSDK)
|
profile_client: initramfs $(CARGO_OSDK)
|
||||||
@cd kernel && cargo osdk profile $(CARGO_OSDK_ARGS) --remote :$(GDB_TCP_PORT) \
|
@cd kernel && cargo osdk profile $(CARGO_OSDK_BUILD_ARGS) --remote :$(GDB_TCP_PORT) \
|
||||||
--samples $(GDB_PROFILE_COUNT) --interval $(GDB_PROFILE_INTERVAL) --format $(GDB_PROFILE_FORMAT)
|
--samples $(GDB_PROFILE_COUNT) --interval $(GDB_PROFILE_INTERVAL) --format $(GDB_PROFILE_FORMAT)
|
||||||
|
|
||||||
.PHONY: test
|
.PHONY: test
|
||||||
@ -272,7 +280,7 @@ ktest: initramfs $(CARGO_OSDK)
|
|||||||
@for dir in $(OSDK_CRATES); do \
|
@for dir in $(OSDK_CRATES); do \
|
||||||
[ $$dir = "ostd/libs/linux-bzimage/setup" ] && continue; \
|
[ $$dir = "ostd/libs/linux-bzimage/setup" ] && continue; \
|
||||||
echo "[make] Testing $$dir"; \
|
echo "[make] Testing $$dir"; \
|
||||||
(cd $$dir && OVMF=off cargo osdk test $(CARGO_OSDK_INITRAMFS_OPTION)) || exit 1; \
|
(cd $$dir && cargo osdk test $(CARGO_OSDK_TEST_ARGS)) || exit 1; \
|
||||||
tail --lines 10 qemu.log | grep -q "^\\[ktest runner\\] All crates tested." \
|
tail --lines 10 qemu.log | grep -q "^\\[ktest runner\\] All crates tested." \
|
||||||
|| (echo "Test failed" && exit 1); \
|
|| (echo "Test failed" && exit 1); \
|
||||||
done
|
done
|
||||||
|
@ -25,9 +25,6 @@ init_args = ["sh", "-l"]
|
|||||||
initramfs = "test/build/initramfs.cpio.gz"
|
initramfs = "test/build/initramfs.cpio.gz"
|
||||||
|
|
||||||
# Special options for testing
|
# Special options for testing
|
||||||
[test.boot]
|
|
||||||
method = "qemu-direct"
|
|
||||||
|
|
||||||
[test.qemu]
|
[test.qemu]
|
||||||
args = "$(./tools/qemu_args.sh test)"
|
args = "$(./tools/qemu_args.sh test)"
|
||||||
|
|
||||||
|
@ -4,14 +4,15 @@
|
|||||||
|
|
||||||
# This script is used to generate QEMU arguments for OSDK.
|
# This script is used to generate QEMU arguments for OSDK.
|
||||||
# Usage: `qemu_args.sh [scheme]`
|
# Usage: `qemu_args.sh [scheme]`
|
||||||
# - scheme: "normal", "microvm" or "iommu";
|
# - scheme: "normal", "test", "microvm" or "iommu";
|
||||||
# Other arguments are configured via environmental variables:
|
# Other arguments are configured via environmental variables:
|
||||||
# - OVMF: "on" or "off";
|
# - OVMF: "on" or "off";
|
||||||
|
# - BOOT_METHOD: "qemu-direct", "grub-rescue-iso", "linux-efi-pe64" or "linux-efi-handover64";
|
||||||
# - NETDEV: "user" or "tap";
|
# - NETDEV: "user" or "tap";
|
||||||
# - VHOST: "off" or "on";
|
# - VHOST: "off" or "on";
|
||||||
# - VSOCK: "off" or "on";
|
# - VSOCK: "off" or "on";
|
||||||
# - SMP: number of CPUs;
|
# - SMP: number of CPUs;
|
||||||
# - MEM: amount of memory, e.g. "8G".
|
# - MEM: amount of memory, e.g. "8G";
|
||||||
# - VNC_PORT: VNC port, default is "42".
|
# - VNC_PORT: VNC port, default is "42".
|
||||||
|
|
||||||
OVMF=${OVMF:-"on"}
|
OVMF=${OVMF:-"on"}
|
||||||
@ -153,8 +154,8 @@ if [ "$1" = "microvm" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$OVMF" = "on" ]; then
|
if [ "$OVMF" = "on" ]; then
|
||||||
if [ "$1" = "test" ]; then
|
if [ "$BOOT_METHOD" = "qemu-direct" ]; then
|
||||||
echo "We use QEMU direct boot for testing, which does not support OVMF, ignoring OVMF" 1>&2
|
echo "QEMU direct boot is not compatible with OVMF, ignoring OVMF" 1>&2
|
||||||
else
|
else
|
||||||
OVMF_PATH="/root/ovmf/release"
|
OVMF_PATH="/root/ovmf/release"
|
||||||
QEMU_ARGS="${QEMU_ARGS} \
|
QEMU_ARGS="${QEMU_ARGS} \
|
||||||
|
Reference in New Issue
Block a user