Enable arch-aware make check
This commit is contained in:
parent
1452aab69c
commit
bf5360d721
|
|
@ -70,7 +70,7 @@ runs:
|
||||||
[[ "${{ matrix.id }}" == "compile" ]] && CMD+="make build FEATURES=all"
|
[[ "${{ matrix.id }}" == "compile" ]] && CMD+="make build FEATURES=all"
|
||||||
[[ "${{ matrix.id }}" == "usermode_test" ]] && CMD+="make test"
|
[[ "${{ matrix.id }}" == "usermode_test" ]] && CMD+="make test"
|
||||||
[[ "${{ matrix.id }}" == "ktest" ]] && CMD+="make ktest NETDEV=tap"
|
[[ "${{ matrix.id }}" == "ktest" ]] && CMD+="make ktest NETDEV=tap"
|
||||||
[[ -n "${{ inputs.arch }}" ]] && CMD+=" ARCH=${{ inputs.arch }}"
|
[[ -n "${{ inputs.arch }}" ]] && CMD+=" OSDK_TARGET_ARCH=${{ inputs.arch }}"
|
||||||
|
|
||||||
echo "Executing: $CMD"
|
echo "Executing: $CMD"
|
||||||
eval $CMD
|
eval $CMD
|
||||||
|
|
@ -86,7 +86,7 @@ runs:
|
||||||
[[ -n "${{ inputs.smp }}" ]] && CMD+=" SMP=${{ inputs.smp }}"
|
[[ -n "${{ inputs.smp }}" ]] && CMD+=" SMP=${{ inputs.smp }}"
|
||||||
[[ -n "${{ inputs.netdev }}" ]] && CMD+=" NETDEV=${{ inputs.netdev }}"
|
[[ -n "${{ inputs.netdev }}" ]] && CMD+=" NETDEV=${{ inputs.netdev }}"
|
||||||
[[ -n "${{ inputs.scheme }}" ]] && CMD+=" SCHEME=${{ inputs.scheme }}"
|
[[ -n "${{ inputs.scheme }}" ]] && CMD+=" SCHEME=${{ inputs.scheme }}"
|
||||||
[[ -n "${{ inputs.arch }}" ]] && CMD+=" ARCH=${{ inputs.arch }}"
|
[[ -n "${{ inputs.arch }}" ]] && CMD+=" OSDK_TARGET_ARCH=${{ inputs.arch }}"
|
||||||
[[ -n "${{ inputs.extra_blocklists }}" ]] && CMD+=" EXTRA_BLOCKLISTS_DIRS=${{ inputs.extra_blocklists }}"
|
[[ -n "${{ inputs.extra_blocklists }}" ]] && CMD+=" EXTRA_BLOCKLISTS_DIRS=${{ inputs.extra_blocklists }}"
|
||||||
[[ -n "${{ inputs.syscall_test_suite }}" ]] && CMD+=" SYSCALL_TEST_SUITE=${{ inputs.syscall_test_suite }}"
|
[[ -n "${{ inputs.syscall_test_suite }}" ]] && CMD+=" SYSCALL_TEST_SUITE=${{ inputs.syscall_test_suite }}"
|
||||||
[[ -n "${{ inputs.syscall_test_workdir }}" ]] && CMD+=" SYSCALL_TEST_WORKDIR=${{ inputs.syscall_test_workdir }}"
|
[[ -n "${{ inputs.syscall_test_workdir }}" ]] && CMD+=" SYSCALL_TEST_WORKDIR=${{ inputs.syscall_test_workdir }}"
|
||||||
|
|
|
||||||
14
Makefile
14
Makefile
|
|
@ -3,7 +3,7 @@
|
||||||
# =========================== Makefile options. ===============================
|
# =========================== Makefile options. ===============================
|
||||||
|
|
||||||
# Global build options.
|
# Global build options.
|
||||||
ARCH ?= x86_64
|
OSDK_TARGET_ARCH ?= x86_64
|
||||||
BENCHMARK ?= none
|
BENCHMARK ?= none
|
||||||
BOOT_METHOD ?= grub-rescue-iso
|
BOOT_METHOD ?= grub-rescue-iso
|
||||||
BOOT_PROTOCOL ?= multiboot2
|
BOOT_PROTOCOL ?= multiboot2
|
||||||
|
|
@ -52,7 +52,7 @@ SHELL := /bin/bash
|
||||||
CARGO_OSDK := ~/.cargo/bin/cargo-osdk
|
CARGO_OSDK := ~/.cargo/bin/cargo-osdk
|
||||||
|
|
||||||
# Common arguments for `cargo osdk` `build`, `run` and `test` commands.
|
# Common arguments for `cargo osdk` `build`, `run` and `test` commands.
|
||||||
CARGO_OSDK_COMMON_ARGS := --target-arch=$(ARCH)
|
CARGO_OSDK_COMMON_ARGS := --target-arch=$(OSDK_TARGET_ARCH)
|
||||||
# The build arguments also apply to the `cargo osdk run` command.
|
# The build arguments also apply to the `cargo osdk run` command.
|
||||||
CARGO_OSDK_BUILD_ARGS := --kcmd-args="ostd.log_level=$(LOG_LEVEL)"
|
CARGO_OSDK_BUILD_ARGS := --kcmd-args="ostd.log_level=$(LOG_LEVEL)"
|
||||||
CARGO_OSDK_TEST_ARGS :=
|
CARGO_OSDK_TEST_ARGS :=
|
||||||
|
|
@ -105,9 +105,9 @@ BOOT_METHOD = qemu-direct
|
||||||
OVMF = off
|
OVMF = off
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(ARCH), riscv64)
|
ifeq ($(OSDK_TARGET_ARCH), riscv64)
|
||||||
SCHEME = riscv
|
SCHEME = riscv
|
||||||
else ifeq ($(ARCH), loongarch64)
|
else ifeq ($(OSDK_TARGET_ARCH), loongarch64)
|
||||||
SCHEME = loongarch
|
SCHEME = loongarch
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
@ -141,7 +141,7 @@ CARGO_OSDK_COMMON_ARGS += --grub-boot-protocol=$(BOOT_PROTOCOL)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(ENABLE_KVM), 1)
|
ifeq ($(ENABLE_KVM), 1)
|
||||||
ifeq ($(ARCH), x86_64)
|
ifeq ($(OSDK_TARGET_ARCH), x86_64)
|
||||||
CARGO_OSDK_COMMON_ARGS += --qemu-args="-accel kvm"
|
CARGO_OSDK_COMMON_ARGS += --qemu-args="-accel kvm"
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
@ -314,7 +314,6 @@ format:
|
||||||
@$(MAKE) --no-print-directory -C test format
|
@$(MAKE) --no-print-directory -C test format
|
||||||
|
|
||||||
.PHONY: check
|
.PHONY: check
|
||||||
# FIXME: Make `make check` arch-aware.
|
|
||||||
check: initramfs $(CARGO_OSDK)
|
check: initramfs $(CARGO_OSDK)
|
||||||
@# Check formatting issues of the Rust code
|
@# Check formatting issues of the Rust code
|
||||||
@./tools/format_all.sh --check
|
@./tools/format_all.sh --check
|
||||||
|
|
@ -345,6 +344,9 @@ check: initramfs $(CARGO_OSDK)
|
||||||
done
|
done
|
||||||
@for dir in $(OSDK_CRATES); do \
|
@for dir in $(OSDK_CRATES); do \
|
||||||
echo "Checking $$dir"; \
|
echo "Checking $$dir"; \
|
||||||
|
# Exclude linux-bzimage-setup since it only supports x86-64 currently and will panic \
|
||||||
|
# in other architectures. \
|
||||||
|
[ "$$dir" = "ostd/libs/linux-bzimage/setup" ] && [ "$(OSDK_TARGET_ARCH)" != "x86_64" ] && continue; \
|
||||||
(cd $$dir && cargo osdk clippy -- -- -D warnings) || exit 1; \
|
(cd $$dir && cargo osdk clippy -- -- -D warnings) || exit 1; \
|
||||||
done
|
done
|
||||||
@
|
@
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,22 @@ impl Display for Arch {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the default architecture implied by the host rustc's default architecture.
|
/// Get the default architecture implied by the host rustc's default architecture.
|
||||||
|
///
|
||||||
|
/// If the environment variable `OSDK_TARGET_ARCH` is set, use it to determine the default
|
||||||
|
/// architecture directly.
|
||||||
pub fn get_default_arch() -> Arch {
|
pub fn get_default_arch() -> Arch {
|
||||||
|
if let Ok(arch) = std::env::var("OSDK_TARGET_ARCH") {
|
||||||
|
return match arch.as_str() {
|
||||||
|
"aarch64" => Arch::Aarch64,
|
||||||
|
"riscv64" => Arch::RiscV64,
|
||||||
|
"x86_64" => Arch::X86_64,
|
||||||
|
"loongarch64" => Arch::LoongArch64,
|
||||||
|
_ => panic!(
|
||||||
|
"The environment variable `OSDK_TARGET_ARCH` specifies an unsupported native architecture"
|
||||||
|
),
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
let output = crate::util::new_command_checked_exists("rustc")
|
let output = crate::util::new_command_checked_exists("rustc")
|
||||||
.arg("-vV")
|
.arg("-vV")
|
||||||
.output()
|
.output()
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
# SPDX-License-Identifier: MPL-2.0
|
# SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
ARCH ?= x86_64
|
OSDK_TARGET_ARCH ?= x86_64
|
||||||
SMP ?= 1
|
SMP ?= 1
|
||||||
VERBOSE ?= 1
|
VERBOSE ?= 1
|
||||||
SYSCALL_TEST_SUITE ?= ltp
|
SYSCALL_TEST_SUITE ?= ltp
|
||||||
|
|
@ -47,7 +47,7 @@ endif
|
||||||
all: build
|
all: build
|
||||||
|
|
||||||
.PHONY: build
|
.PHONY: build
|
||||||
ifeq ($(ARCH), loongarch64)
|
ifeq ($(OSDK_TARGET_ARCH), loongarch64)
|
||||||
build: $(EXT2_IMAGE) $(EXFAT_IMAGE)
|
build: $(EXT2_IMAGE) $(EXFAT_IMAGE)
|
||||||
@echo "For loongarch, we generate a fake initramfs to successfully test or build."
|
@echo "For loongarch, we generate a fake initramfs to successfully test or build."
|
||||||
@touch $(INITRAMFS_IMAGE)
|
@touch $(INITRAMFS_IMAGE)
|
||||||
|
|
@ -59,7 +59,7 @@ endif
|
||||||
$(INITRAMFS_IMAGE): $(INITRAMFS)
|
$(INITRAMFS_IMAGE): $(INITRAMFS)
|
||||||
@nix-build \
|
@nix-build \
|
||||||
--tarball-ttl $(NIXPKGS_CACHE_TTL) \
|
--tarball-ttl $(NIXPKGS_CACHE_TTL) \
|
||||||
--argstr target $(ARCH) \
|
--argstr target $(OSDK_TARGET_ARCH) \
|
||||||
--arg enableBasicTest $(ENABLE_BASIC_TEST) \
|
--arg enableBasicTest $(ENABLE_BASIC_TEST) \
|
||||||
--arg enableBenchmark $(ENABLE_BENCHMARK) \
|
--arg enableBenchmark $(ENABLE_BENCHMARK) \
|
||||||
--arg enableSyscallTest $(ENABLE_SYSCALL_TEST) \
|
--arg enableSyscallTest $(ENABLE_SYSCALL_TEST) \
|
||||||
|
|
@ -74,7 +74,7 @@ $(INITRAMFS_IMAGE): $(INITRAMFS)
|
||||||
$(INITRAMFS):
|
$(INITRAMFS):
|
||||||
@nix-build \
|
@nix-build \
|
||||||
--tarball-ttl $(NIXPKGS_CACHE_TTL) \
|
--tarball-ttl $(NIXPKGS_CACHE_TTL) \
|
||||||
--argstr target $(ARCH) \
|
--argstr target $(OSDK_TARGET_ARCH) \
|
||||||
--arg enableBasicTest $(ENABLE_BASIC_TEST) \
|
--arg enableBasicTest $(ENABLE_BASIC_TEST) \
|
||||||
--arg enableBenchmark $(ENABLE_BENCHMARK) \
|
--arg enableBenchmark $(ENABLE_BENCHMARK) \
|
||||||
--arg enableSyscallTest $(ENABLE_SYSCALL_TEST) \
|
--arg enableSyscallTest $(ENABLE_SYSCALL_TEST) \
|
||||||
|
|
|
||||||
|
|
@ -38,9 +38,9 @@ While most tests rely on `Nix` for compilation, the `gvisor` syscall test suite
|
||||||
The test suite supports building for multiple architectures, including `x86_64` and `riscv64`. You can specify the desired architecture by running:
|
The test suite supports building for multiple architectures, including `x86_64` and `riscv64`. You can specify the desired architecture by running:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
make build ARCH=x86_64
|
make build OSDK_TARGET_ARCH=x86_64
|
||||||
# or
|
# or
|
||||||
make build ARCH=riscv64
|
make build OSDK_TARGET_ARCH=riscv64
|
||||||
```
|
```
|
||||||
|
|
||||||
The build artifacts (initramfs) can be found in the `test/build` directory after the compilation.
|
The build artifacts (initramfs) can be found in the `test/build` directory after the compilation.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue