diff --git a/12_integrated_testing/Cargo.lock b/12_integrated_testing/Cargo.lock index 5834e9f3..d34ce134 100644 --- a/12_integrated_testing/Cargo.lock +++ b/12_integrated_testing/Cargo.lock @@ -16,6 +16,7 @@ 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 e768e678..3e4b2a8a 100644 --- a/12_integrated_testing/Cargo.toml +++ b/12_integrated_testing/Cargo.toml @@ -35,6 +35,13 @@ 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 872de5a5..e9ed2d27 100644 --- a/12_integrated_testing/Makefile +++ b/12_integrated_testing/Makefile @@ -284,15 +284,13 @@ define test_prepare @chmod +x target/kernel_test_runner.sh endef -test_unit test_integration: FEATURES += --features test_build - ##------------------------------------------------------------------------------ ## Run unit test(s) ##------------------------------------------------------------------------------ test_unit: $(call colorecho, "\nCompiling unit test(s) - $(BSP)") $(call test_prepare) - RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(TEST_CMD) --lib + @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(TEST_CMD) --lib ##------------------------------------------------------------------------------ ## Run integration test(s) diff --git a/12_integrated_testing/README.md b/12_integrated_testing/README.md index fddd4be5..698ad1b0 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 the `Makefile`, we ensure that +You might have also noted the `#[cfg(feature = "test_build")]`. In `Cargo.toml`, 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. @@ -411,8 +411,6 @@ define test_prepare @chmod +x target/kernel_test_runner.sh endef -test_unit test_integration: FEATURES += --features test_build - ##------------------------------------------------------------------------------ ## Run unit test(s) ##------------------------------------------------------------------------------ @@ -912,7 +910,7 @@ diff -uNr 11_exceptions_part1_groundwork/Cargo.toml 12_integrated_testing/Cargo. authors = ["Andre Richter "] edition = "2021" -@@ -11,20 +11,50 @@ +@@ -11,20 +11,57 @@ default = [] bsp_rpi3 = ["tock-registers"] bsp_rpi4 = ["tock-registers"] @@ -944,6 +942,13 @@ 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" @@ -1023,7 +1028,7 @@ diff -uNr 11_exceptions_part1_groundwork/Makefile 12_integrated_testing/Makefile $(call colorecho, "\n$(QEMU_MISSING_STRING)") else # QEMU is supported. -@@ -253,6 +263,45 @@ +@@ -253,6 +263,43 @@ $(call colorecho, "\nBoot test - $(BSP)") @$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN) @@ -1049,15 +1054,13 @@ diff -uNr 11_exceptions_part1_groundwork/Makefile 12_integrated_testing/Makefile + @chmod +x target/kernel_test_runner.sh +endef + -+test_unit test_integration: FEATURES += --features test_build -+ +##------------------------------------------------------------------------------ +## Run unit test(s) +##------------------------------------------------------------------------------ +test_unit: + $(call colorecho, "\nCompiling unit test(s) - $(BSP)") + $(call test_prepare) -+ RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(TEST_CMD) --lib ++ @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(TEST_CMD) --lib + +##------------------------------------------------------------------------------ +## Run integration test(s) diff --git a/13_exceptions_part2_peripheral_IRQs/Cargo.lock b/13_exceptions_part2_peripheral_IRQs/Cargo.lock index 8fde49ef..ba1b9013 100644 --- a/13_exceptions_part2_peripheral_IRQs/Cargo.lock +++ b/13_exceptions_part2_peripheral_IRQs/Cargo.lock @@ -16,6 +16,7 @@ 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 7ef55831..a1a3bfbf 100644 --- a/13_exceptions_part2_peripheral_IRQs/Cargo.toml +++ b/13_exceptions_part2_peripheral_IRQs/Cargo.toml @@ -35,6 +35,13 @@ 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 72ae3c36..e9ed2d27 100644 --- a/13_exceptions_part2_peripheral_IRQs/Makefile +++ b/13_exceptions_part2_peripheral_IRQs/Makefile @@ -284,8 +284,6 @@ define test_prepare @chmod +x target/kernel_test_runner.sh endef -test_unit test_integration: FEATURES += --features test_build - ##------------------------------------------------------------------------------ ## Run unit test(s) ##------------------------------------------------------------------------------ diff --git a/13_exceptions_part2_peripheral_IRQs/README.md b/13_exceptions_part2_peripheral_IRQs/README.md index 4224d8b9..eefe4b7e 100644 --- a/13_exceptions_part2_peripheral_IRQs/README.md +++ b/13_exceptions_part2_peripheral_IRQs/README.md @@ -758,19 +758,6 @@ diff -uNr 12_integrated_testing/Cargo.toml 13_exceptions_part2_peripheral_IRQs/C edition = "2021" -diff -uNr 12_integrated_testing/Makefile 13_exceptions_part2_peripheral_IRQs/Makefile ---- 12_integrated_testing/Makefile -+++ 13_exceptions_part2_peripheral_IRQs/Makefile -@@ -292,7 +292,7 @@ - test_unit: - $(call colorecho, "\nCompiling unit test(s) - $(BSP)") - $(call test_prepare) -- RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(TEST_CMD) --lib -+ @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(TEST_CMD) --lib - - ##------------------------------------------------------------------------------ - ## Run integration test(s) - diff -uNr 12_integrated_testing/src/_arch/aarch64/cpu/smp.rs 13_exceptions_part2_peripheral_IRQs/src/_arch/aarch64/cpu/smp.rs --- 12_integrated_testing/src/_arch/aarch64/cpu/smp.rs +++ 13_exceptions_part2_peripheral_IRQs/src/_arch/aarch64/cpu/smp.rs diff --git a/14_virtual_mem_part2_mmio_remap/Cargo.lock b/14_virtual_mem_part2_mmio_remap/Cargo.lock index 6526767a..ab4eda71 100644 --- a/14_virtual_mem_part2_mmio_remap/Cargo.lock +++ b/14_virtual_mem_part2_mmio_remap/Cargo.lock @@ -16,6 +16,7 @@ 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 3146ad05..130d80f7 100644 --- a/14_virtual_mem_part2_mmio_remap/Cargo.toml +++ b/14_virtual_mem_part2_mmio_remap/Cargo.toml @@ -35,6 +35,13 @@ 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 72ae3c36..e9ed2d27 100644 --- a/14_virtual_mem_part2_mmio_remap/Makefile +++ b/14_virtual_mem_part2_mmio_remap/Makefile @@ -284,8 +284,6 @@ define test_prepare @chmod +x target/kernel_test_runner.sh endef -test_unit test_integration: FEATURES += --features test_build - ##------------------------------------------------------------------------------ ## Run unit test(s) ##------------------------------------------------------------------------------ diff --git a/15_virtual_mem_part3_precomputed_tables/Cargo.lock b/15_virtual_mem_part3_precomputed_tables/Cargo.lock index 9ce8fc76..29683180 100644 --- a/15_virtual_mem_part3_precomputed_tables/Cargo.lock +++ b/15_virtual_mem_part3_precomputed_tables/Cargo.lock @@ -16,6 +16,7 @@ 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 6a41bd03..1c39f36f 100644 --- a/15_virtual_mem_part3_precomputed_tables/Cargo.toml +++ b/15_virtual_mem_part3_precomputed_tables/Cargo.toml @@ -35,6 +35,13 @@ 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 385c003c..513f3dc1 100644 --- a/15_virtual_mem_part3_precomputed_tables/Makefile +++ b/15_virtual_mem_part3_precomputed_tables/Makefile @@ -287,8 +287,6 @@ define test_prepare @chmod +x target/kernel_test_runner.sh endef -test_unit test_integration: FEATURES += --features test_build - ##------------------------------------------------------------------------------ ## Run unit test(s) ##------------------------------------------------------------------------------ diff --git a/16_virtual_mem_part4_higher_half_kernel/Cargo.lock b/16_virtual_mem_part4_higher_half_kernel/Cargo.lock index af4081af..a1766828 100644 --- a/16_virtual_mem_part4_higher_half_kernel/Cargo.lock +++ b/16_virtual_mem_part4_higher_half_kernel/Cargo.lock @@ -16,6 +16,7 @@ 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 4964df47..34f5090d 100644 --- a/16_virtual_mem_part4_higher_half_kernel/Cargo.toml +++ b/16_virtual_mem_part4_higher_half_kernel/Cargo.toml @@ -35,6 +35,13 @@ 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 385c003c..513f3dc1 100644 --- a/16_virtual_mem_part4_higher_half_kernel/Makefile +++ b/16_virtual_mem_part4_higher_half_kernel/Makefile @@ -287,8 +287,6 @@ define test_prepare @chmod +x target/kernel_test_runner.sh endef -test_unit test_integration: FEATURES += --features test_build - ##------------------------------------------------------------------------------ ## Run unit test(s) ##------------------------------------------------------------------------------