Skip to content

Commit

Permalink
kernel/Cargo.toml: Add default-test cargo feature
Browse files Browse the repository at this point in the history
Add the default-test cargo feature to control what features we want to enable in
the tests. The vtpm/mstpm/wrappers.rs, for example, can't run in the test
environment because its malloc() etc functions conflict with the libc standard
libraries.

This was working before, but now it is not working as expected.
"cargo test --workspace" is not honoring --no-default-features for workspace members.
rust-lang/cargo#7160

Signed-off-by: Claudio Carvalho <[email protected]>
  • Loading branch information
cclaudio committed Feb 20, 2024
1 parent 47ac6cb commit 818bf1c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
FEATURES ?= "default"
SVSM_ARGS = --features ${FEATURES}

FEATURES_TEST ?= "default-test"
CARGO_ARGS_TEST = --no-default-features --features ${FEATURES_TEST}

ifdef RELEASE
TARGET_PATH=release
CARGO_ARGS += --release
Expand All @@ -14,8 +17,10 @@ endif

ifeq ($(V), 1)
CARGO_ARGS += -v
CARGO_ARGS_TEST += -v
else ifeq ($(V), 2)
CARGO_ARGS += -vv
CARGO_ARGS_TEST += -vv
endif

STAGE2_ELF = "target/x86_64-unknown-none/${TARGET_PATH}/stage2"
Expand Down Expand Up @@ -62,7 +67,7 @@ bin/coconut-test-qemu.igvm: $(IGVMBUILDER) bin/test-kernel.elf bin/stage2.bin
$(IGVMBUILDER) --sort --output $@ --stage2 bin/stage2.bin --kernel bin/test-kernel.elf qemu

test:
cargo test --workspace --target=x86_64-unknown-linux-gnu
cargo test --workspace ${CARGO_ARGS_TEST} --target=x86_64-unknown-linux-gnu

test-in-svsm: utils/cbit bin/coconut-test-qemu.igvm
./scripts/test-in-svsm.sh
Expand Down
1 change: 1 addition & 0 deletions kernel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ test.workspace = true

[features]
default = ["mstpm"]
default-test = []
enable-gdb = ["dep:gdbstub", "dep:gdbstub_arch"]
fuzzing-hooks = []
mstpm = ["dep:libmstpm"]
Expand Down

0 comments on commit 818bf1c

Please sign in to comment.