From 353d92b1dfb6b3cb154c70e98b403d155ff0261b Mon Sep 17 00:00:00 2001 From: Andre Richter Date: Tue, 19 Apr 2022 09:10:06 +0200 Subject: [PATCH] Revert "Move test-features activation to Cargo.toml" This reverts commit 0b449706f3a0c3bbd115f1a3e6844e5fc0459ee0. Also moves the feature addition before the if/else --- 12_integrated_testing/Cargo.lock | 1 - 12_integrated_testing/Cargo.toml | 7 ------- 12_integrated_testing/Makefile | 2 ++ 12_integrated_testing/README.md | 19 +++++++------------ .../Cargo.lock | 1 - .../Cargo.toml | 7 ------- 13_exceptions_part2_peripheral_IRQs/Makefile | 2 ++ 14_virtual_mem_part2_mmio_remap/Cargo.lock | 1 - 14_virtual_mem_part2_mmio_remap/Cargo.toml | 7 ------- 14_virtual_mem_part2_mmio_remap/Makefile | 2 ++ .../Cargo.lock | 1 - .../Cargo.toml | 7 ------- .../Makefile | 2 ++ .../README.md | 2 +- .../Cargo.lock | 1 - .../Cargo.toml | 7 ------- .../Makefile | 2 ++ 17 files changed, 18 insertions(+), 53 deletions(-) diff --git a/12_integrated_testing/Cargo.lock b/12_integrated_testing/Cargo.lock index d34ce134..5834e9f3 100644 --- a/12_integrated_testing/Cargo.lock +++ b/12_integrated_testing/Cargo.lock @@ -16,7 +16,6 @@ name = "mingo" version = "0.12.0" dependencies = [ "cortex-a", - "mingo", "qemu-exit", "test-macros", "test-types", diff --git a/12_integrated_testing/Cargo.toml b/12_integrated_testing/Cargo.toml index 3e4b2a8a..e768e678 100644 --- a/12_integrated_testing/Cargo.toml +++ b/12_integrated_testing/Cargo.toml @@ -35,13 +35,6 @@ cortex-a = { version = "7.x.x" } [dev-dependencies] test-macros = { path = "test-macros" } -# The following line is a workaround, as suggested in [1], to enable a feature in test-builds only. -# This allows building the library part of the kernel with specialized code for testing. -# -# -# [1] https://github.com/rust-lang/cargo/issues/2911#issuecomment-749580481 -mingo = { path = ".", features = ["test_build"] } - # Unit tests are done in the library part of the kernel. [lib] name = "libkernel" diff --git a/12_integrated_testing/Makefile b/12_integrated_testing/Makefile index 925ac45f..6adb1aca 100644 --- a/12_integrated_testing/Makefile +++ b/12_integrated_testing/Makefile @@ -277,6 +277,8 @@ gdb gdb-opt0: $(KERNEL_ELF) ##-------------------------------------------------------------------------------------------------- .PHONY: test test_boot test_unit test_integration +test_unit test_integration: FEATURES += --features test_build + ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. test_boot test_unit test_integration test: diff --git a/12_integrated_testing/README.md b/12_integrated_testing/README.md index 05029ca1..3bd88c96 100644 --- a/12_integrated_testing/README.md +++ b/12_integrated_testing/README.md @@ -324,7 +324,7 @@ pub fn qemu_exit_success() -> ! { [Click here] in case you are interested in the implementation. Note that for the functions to work, the `-semihosting` flag must be added to the `QEMU` invocation. -You might have also noted the `#[cfg(feature = "test_build")]`. In `Cargo.toml`, we ensure that +You might have also noted the `#[cfg(feature = "test_build")]`. In the `Makefile`, we ensure that this feature is only enabled when `cargo test` runs. This way, it is ensured that testing-specific code is conditionally compiled only for testing. @@ -417,7 +417,7 @@ endef test_unit: $(call color_header, "Compiling unit test(s) - $(BSP)") $(call test_prepare) - @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(TEST_CMD) --lib + RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(TEST_CMD) --lib ``` It first does the standard `objcopy` step to strip the `ELF` down to a raw binary. Just like in all @@ -910,7 +910,7 @@ diff -uNr 11_exceptions_part1_groundwork/Cargo.toml 12_integrated_testing/Cargo. authors = ["Andre Richter "] edition = "2021" -@@ -11,20 +11,57 @@ +@@ -11,20 +11,50 @@ default = [] bsp_rpi3 = ["tock-registers"] bsp_rpi4 = ["tock-registers"] @@ -942,13 +942,6 @@ diff -uNr 11_exceptions_part1_groundwork/Cargo.toml 12_integrated_testing/Cargo. +[dev-dependencies] +test-macros = { path = "test-macros" } + -+# The following line is a workaround, as suggested in [1], to enable a feature in test-builds only. -+# This allows building the library part of the kernel with specialized code for testing. -+# -+# -+# [1] https://github.com/rust-lang/cargo/issues/2911#issuecomment-749580481 -+mingo = { path = ".", features = ["test_build"] } -+ +# Unit tests are done in the library part of the kernel. +[lib] +name = "libkernel" @@ -1014,12 +1007,14 @@ diff -uNr 11_exceptions_part1_groundwork/Makefile 12_integrated_testing/Makefile OBJCOPY_CMD = rust-objcopy \ --strip-all \ -O binary -@@ -265,11 +275,11 @@ +@@ -265,11 +275,13 @@ ##-------------------------------------------------------------------------------------------------- ## Testing targets ##-------------------------------------------------------------------------------------------------- -.PHONY: test test_boot +.PHONY: test test_boot test_unit test_integration ++ ++test_unit test_integration: FEATURES += --features test_build ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. @@ -1028,7 +1023,7 @@ diff -uNr 11_exceptions_part1_groundwork/Makefile 12_integrated_testing/Makefile $(call color_header, "$(QEMU_MISSING_STRING)") else # QEMU is supported. -@@ -281,6 +291,43 @@ +@@ -281,6 +293,43 @@ $(call color_header, "Boot test - $(BSP)") @$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN) diff --git a/13_exceptions_part2_peripheral_IRQs/Cargo.lock b/13_exceptions_part2_peripheral_IRQs/Cargo.lock index ba1b9013..8fde49ef 100644 --- a/13_exceptions_part2_peripheral_IRQs/Cargo.lock +++ b/13_exceptions_part2_peripheral_IRQs/Cargo.lock @@ -16,7 +16,6 @@ name = "mingo" version = "0.13.0" dependencies = [ "cortex-a", - "mingo", "qemu-exit", "test-macros", "test-types", diff --git a/13_exceptions_part2_peripheral_IRQs/Cargo.toml b/13_exceptions_part2_peripheral_IRQs/Cargo.toml index a1a3bfbf..7ef55831 100644 --- a/13_exceptions_part2_peripheral_IRQs/Cargo.toml +++ b/13_exceptions_part2_peripheral_IRQs/Cargo.toml @@ -35,13 +35,6 @@ cortex-a = { version = "7.x.x" } [dev-dependencies] test-macros = { path = "test-macros" } -# The following line is a workaround, as suggested in [1], to enable a feature in test-builds only. -# This allows building the library part of the kernel with specialized code for testing. -# -# -# [1] https://github.com/rust-lang/cargo/issues/2911#issuecomment-749580481 -mingo = { path = ".", features = ["test_build"] } - # Unit tests are done in the library part of the kernel. [lib] name = "libkernel" diff --git a/13_exceptions_part2_peripheral_IRQs/Makefile b/13_exceptions_part2_peripheral_IRQs/Makefile index 925ac45f..6adb1aca 100644 --- a/13_exceptions_part2_peripheral_IRQs/Makefile +++ b/13_exceptions_part2_peripheral_IRQs/Makefile @@ -277,6 +277,8 @@ gdb gdb-opt0: $(KERNEL_ELF) ##-------------------------------------------------------------------------------------------------- .PHONY: test test_boot test_unit test_integration +test_unit test_integration: FEATURES += --features test_build + ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. test_boot test_unit test_integration test: diff --git a/14_virtual_mem_part2_mmio_remap/Cargo.lock b/14_virtual_mem_part2_mmio_remap/Cargo.lock index ab4eda71..6526767a 100644 --- a/14_virtual_mem_part2_mmio_remap/Cargo.lock +++ b/14_virtual_mem_part2_mmio_remap/Cargo.lock @@ -16,7 +16,6 @@ name = "mingo" version = "0.14.0" dependencies = [ "cortex-a", - "mingo", "qemu-exit", "test-macros", "test-types", diff --git a/14_virtual_mem_part2_mmio_remap/Cargo.toml b/14_virtual_mem_part2_mmio_remap/Cargo.toml index 130d80f7..3146ad05 100644 --- a/14_virtual_mem_part2_mmio_remap/Cargo.toml +++ b/14_virtual_mem_part2_mmio_remap/Cargo.toml @@ -35,13 +35,6 @@ cortex-a = { version = "7.x.x" } [dev-dependencies] test-macros = { path = "test-macros" } -# The following line is a workaround, as suggested in [1], to enable a feature in test-builds only. -# This allows building the library part of the kernel with specialized code for testing. -# -# -# [1] https://github.com/rust-lang/cargo/issues/2911#issuecomment-749580481 -mingo = { path = ".", features = ["test_build"] } - # Unit tests are done in the library part of the kernel. [lib] name = "libkernel" diff --git a/14_virtual_mem_part2_mmio_remap/Makefile b/14_virtual_mem_part2_mmio_remap/Makefile index 925ac45f..6adb1aca 100644 --- a/14_virtual_mem_part2_mmio_remap/Makefile +++ b/14_virtual_mem_part2_mmio_remap/Makefile @@ -277,6 +277,8 @@ gdb gdb-opt0: $(KERNEL_ELF) ##-------------------------------------------------------------------------------------------------- .PHONY: test test_boot test_unit test_integration +test_unit test_integration: FEATURES += --features test_build + ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. test_boot test_unit test_integration test: diff --git a/15_virtual_mem_part3_precomputed_tables/Cargo.lock b/15_virtual_mem_part3_precomputed_tables/Cargo.lock index 29683180..9ce8fc76 100644 --- a/15_virtual_mem_part3_precomputed_tables/Cargo.lock +++ b/15_virtual_mem_part3_precomputed_tables/Cargo.lock @@ -16,7 +16,6 @@ name = "mingo" version = "0.15.0" dependencies = [ "cortex-a", - "mingo", "qemu-exit", "test-macros", "test-types", diff --git a/15_virtual_mem_part3_precomputed_tables/Cargo.toml b/15_virtual_mem_part3_precomputed_tables/Cargo.toml index 1c39f36f..6a41bd03 100644 --- a/15_virtual_mem_part3_precomputed_tables/Cargo.toml +++ b/15_virtual_mem_part3_precomputed_tables/Cargo.toml @@ -35,13 +35,6 @@ cortex-a = { version = "7.x.x" } [dev-dependencies] test-macros = { path = "test-macros" } -# The following line is a workaround, as suggested in [1], to enable a feature in test-builds only. -# This allows building the library part of the kernel with specialized code for testing. -# -# -# [1] https://github.com/rust-lang/cargo/issues/2911#issuecomment-749580481 -mingo = { path = ".", features = ["test_build"] } - # Unit tests are done in the library part of the kernel. [lib] name = "libkernel" diff --git a/15_virtual_mem_part3_precomputed_tables/Makefile b/15_virtual_mem_part3_precomputed_tables/Makefile index 56a77692..a695185d 100644 --- a/15_virtual_mem_part3_precomputed_tables/Makefile +++ b/15_virtual_mem_part3_precomputed_tables/Makefile @@ -293,6 +293,8 @@ gdb gdb-opt0: $(KERNEL_ELF) ##-------------------------------------------------------------------------------------------------- .PHONY: test test_boot test_unit test_integration +test_unit test_integration: FEATURES += --features test_build + ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. test_boot test_unit test_integration test: diff --git a/15_virtual_mem_part3_precomputed_tables/README.md b/15_virtual_mem_part3_precomputed_tables/README.md index 39881214..bc666db8 100644 --- a/15_virtual_mem_part3_precomputed_tables/README.md +++ b/15_virtual_mem_part3_precomputed_tables/README.md @@ -869,7 +869,7 @@ diff -uNr 14_virtual_mem_part2_mmio_remap/Makefile 15_virtual_mem_part3_precompu $(call color_progress_prefix, "Name") @echo $(KERNEL_BIN) $(call color_progress_prefix, "Size") -@@ -300,6 +316,7 @@ +@@ -302,6 +318,7 @@ TEST_ELF=$$(echo $$1 | sed -e 's/.*target/target/g') TEST_BINARY=$$(echo $$1.img | sed -e 's/.*target/target/g') diff --git a/16_virtual_mem_part4_higher_half_kernel/Cargo.lock b/16_virtual_mem_part4_higher_half_kernel/Cargo.lock index a1766828..af4081af 100644 --- a/16_virtual_mem_part4_higher_half_kernel/Cargo.lock +++ b/16_virtual_mem_part4_higher_half_kernel/Cargo.lock @@ -16,7 +16,6 @@ name = "mingo" version = "0.16.0" dependencies = [ "cortex-a", - "mingo", "qemu-exit", "test-macros", "test-types", diff --git a/16_virtual_mem_part4_higher_half_kernel/Cargo.toml b/16_virtual_mem_part4_higher_half_kernel/Cargo.toml index 34f5090d..4964df47 100644 --- a/16_virtual_mem_part4_higher_half_kernel/Cargo.toml +++ b/16_virtual_mem_part4_higher_half_kernel/Cargo.toml @@ -35,13 +35,6 @@ cortex-a = { version = "7.x.x" } [dev-dependencies] test-macros = { path = "test-macros" } -# The following line is a workaround, as suggested in [1], to enable a feature in test-builds only. -# This allows building the library part of the kernel with specialized code for testing. -# -# -# [1] https://github.com/rust-lang/cargo/issues/2911#issuecomment-749580481 -mingo = { path = ".", features = ["test_build"] } - # Unit tests are done in the library part of the kernel. [lib] name = "libkernel" diff --git a/16_virtual_mem_part4_higher_half_kernel/Makefile b/16_virtual_mem_part4_higher_half_kernel/Makefile index 56a77692..a695185d 100644 --- a/16_virtual_mem_part4_higher_half_kernel/Makefile +++ b/16_virtual_mem_part4_higher_half_kernel/Makefile @@ -293,6 +293,8 @@ gdb gdb-opt0: $(KERNEL_ELF) ##-------------------------------------------------------------------------------------------------- .PHONY: test test_boot test_unit test_integration +test_unit test_integration: FEATURES += --features test_build + ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. test_boot test_unit test_integration test: