diff options
| author | Felix Morgner <felix.morgner@ost.ch> | 2026-07-26 23:15:47 +0200 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@ost.ch> | 2026-07-26 23:15:47 +0200 |
| commit | a7700e8a8fd649be43150f67c94fd02cf72b03a1 (patch) | |
| tree | 1d50976f7bdeeddafa6f7f0fab00490c59b7250a | |
| parent | 0092b0f0750e85e1a6e97a00ae21d3d1572b17ef (diff) | |
| download | kernel-a7700e8a8fd649be43150f67c94fd02cf72b03a1.tar.xz kernel-a7700e8a8fd649be43150f67c94fd02cf72b03a1.zip | |
build: separate normal from stress tests
| -rw-r--r-- | CMakeLists.txt | 4 | ||||
| -rw-r--r-- | CMakePresets.json | 3 | ||||
| -rw-r--r-- | cmake/Modules/BuildHostTests.cmake | 51 | ||||
| -rw-r--r-- | kernel/CMakeLists.txt | 18 | ||||
| -rw-r--r-- | libs/acpi/CMakeLists.txt | 8 | ||||
| -rw-r--r-- | libs/kstd/CMakeLists.txt | 8 |
6 files changed, 73 insertions, 19 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 8ac8dc04..45cdbb0b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,8 +41,12 @@ endif() option(TEACHOS_ENABLE_LINTING "Enable linting during build" ON) option(TEACHOS_GENERATE_DOCS "Generate documentation during build" ON) option(TEACHOS_ENABLE_TEST_SANITIZERS "Enable sanitizers for test executables" ON) +option(TEACHOS_ENABLE_TEST_COVERAGE "Enable generation of test coverage" ON) option(TEACHOS_ENABLE_TEST_TSAN "Enable TSan for the test executable" OFF) +set(ACPI_ENABLE_TEST_COVERAGE ${TEACHOS_ENABLE_TEST_COVERAGE}) +set(KSTD_ENABLE_TEST_COVERAGE ${TEACHOS_ENABLE_TEST_COVERAGE}) + #[============================================================================[ # Global Build System Configuration #]============================================================================] diff --git a/CMakePresets.json b/CMakePresets.json index 1d75402d..dd85260c 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -32,6 +32,7 @@ "description": "Build-host Testing with ThreadSanitizer", "cacheVariables": { "TEACHOS_ENABLE_TEST_SANITIZERS": false, + "TEACHOS_ENABLE_TEST_COVERAGE": false, "TEACHOS_ENABLE_TEST_TSAN": true } } @@ -76,7 +77,7 @@ "outputOnFailure": true }, "execution": { - "jobs": 1 + "jobs": 0 } } ] diff --git a/cmake/Modules/BuildHostTests.cmake b/cmake/Modules/BuildHostTests.cmake index 70038b46..d92c3308 100644 --- a/cmake/Modules/BuildHostTests.cmake +++ b/cmake/Modules/BuildHostTests.cmake @@ -1,36 +1,67 @@ include_guard(GLOBAL) function("teachos_add_tests" NAME) - add_executable("${NAME}_tests") - add_executable("${NAME}::tests" ALIAS "${NAME}_tests") + add_executable("${NAME}_tests") + add_executable("${NAME}::tests" ALIAS "${NAME}_tests") - file(GLOB_RECURSE + file(GLOB_RECURSE TEST_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS - "*.stress.cpp" "*.tests.cpp" ) - target_sources("${NAME}_tests" PRIVATE + target_sources("${NAME}_tests" PRIVATE ${TEST_SOURCES} ) - target_link_libraries("${NAME}_tests" PRIVATE + target_link_libraries("${NAME}_tests" PRIVATE "Catch2::Catch2WithMain" "${NAME}::lib" ) - set_target_properties("${NAME}_tests" PROPERTIES + set_target_properties("${NAME}_tests" PROPERTIES EXCLUDE_FROM_ALL NO ) + file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bht_results") + + catch_discover_tests("${NAME}::tests" + REPORTER junit + OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/bht_results" + OUTPUT_SUFFIX ".xml" + ) +endfunction() + +function("teachos_add_stress_tests" NAME) + add_executable("${NAME}_stress_tests") + add_executable("${NAME}::stress_tests" ALIAS "${NAME}_stress_tests") + + file(GLOB_RECURSE + TEST_SOURCES + RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + CONFIGURE_DEPENDS + "*.stress.cpp" + ) + + target_sources("${NAME}_stress_tests" PRIVATE + ${TEST_SOURCES} + ) + + target_link_libraries("${NAME}_stress_tests" PRIVATE + "Catch2::Catch2WithMain" + "${NAME}::lib" + ) + + set_target_properties("${NAME}_stress_tests" PROPERTIES + EXCLUDE_FROM_ALL NO + ) - file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bht_results") + file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bht_results") - catch_discover_tests("${NAME}::tests" + catch_discover_tests("${NAME}::stress_tests" REPORTER junit OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/bht_results" OUTPUT_SUFFIX ".xml" ) -endfunction()
\ No newline at end of file +endfunction() diff --git a/kernel/CMakeLists.txt b/kernel/CMakeLists.txt index c93fe9c9..7bae7b07 100644 --- a/kernel/CMakeLists.txt +++ b/kernel/CMakeLists.txt @@ -154,9 +154,15 @@ if(BUILD_TESTING) include("Catch") include("BuildHostTests") - teachos_add_tests("kernel") + if(TEACHOS_ENABLE_TEST_SANITIZERS) + teachos_add_tests("kernel") + set(TEST_TARGET "kernel_tests") + elseif(TEACHOS_ENABLE_TEST_TSAN) + teachos_add_stress_tests("kernel") + set(TEST_TARGET "kernel_stress_tests") + endif() - target_sources("kernel_tests" PRIVATE + target_sources("${TEST_TARGET}" PRIVATE "kernel/test_support/kapi/boot_modules.cpp" "kernel/test_support/kapi/cpu.cpp" "kernel/test_support/kapi/cio.cpp" @@ -182,17 +188,17 @@ if(BUILD_TESTING) "kernel/test_support/state_reset_listener.cpp" ) - target_compile_definitions("kernel_tests" PRIVATE + target_compile_definitions("${TEST_TARGET}" PRIVATE KERNEL_TEST_ASSETS_DIR="${CMAKE_CURRENT_SOURCE_DIR}/kernel/test_support/filesystem/test_assets" ) - set_target_properties("kernel_tests" PROPERTIES + set_target_properties("${TEST_TARGET}" PROPERTIES C_CLANG_TIDY "" CXX_CLANG_TIDY "" ) - if(COMMAND "enable_coverage" AND NOT TEACHOS_ENABLE_TEST_TSAN) + if(COMMAND "enable_coverage" AND TEACHOS_ENABLE_TEST_COVERAGE) enable_coverage("kernel_lib") - enable_coverage("kernel_tests") + enable_coverage("${TEST_TARGET}") endif() endif() diff --git a/libs/acpi/CMakeLists.txt b/libs/acpi/CMakeLists.txt index 4bd23d47..77992695 100644 --- a/libs/acpi/CMakeLists.txt +++ b/libs/acpi/CMakeLists.txt @@ -9,6 +9,12 @@ project("acpi" include("CTest") #[============================================================================[ +# Global Build System Options +#]============================================================================] + +option(ACPI_ENABLE_TEST_COVERAGE "Enable generation of test coverage" ON) + +#[============================================================================[ # Library #]============================================================================] @@ -85,7 +91,7 @@ if(BUILD_TESTING) set_source_files_properties("acpi/test_data/tables.S" PROPERTIES OBJECT_DEPENDS "${GENERATED_TABLE_BLOBS}") - if(COMMAND "enable_coverage" AND NOT TEACHOS_ENABLE_TEST_TSAN) + if(COMMAND "enable_coverage" AND ACPI_ENABLE_TEST_COVERAGE) enable_coverage("acpi") endif() diff --git a/libs/kstd/CMakeLists.txt b/libs/kstd/CMakeLists.txt index 379ca7d0..d8d5ea2a 100644 --- a/libs/kstd/CMakeLists.txt +++ b/libs/kstd/CMakeLists.txt @@ -9,6 +9,12 @@ project("kstd" include("CTest") #[============================================================================[ +# Global Build System Options +#]============================================================================] + +option(KSTD_ENABLE_TEST_COVERAGE "Enable generation of test coverage" ON) + +#[============================================================================[ # Library #]============================================================================] @@ -74,7 +80,7 @@ if(BUILD_TESTING) teachos_add_tests("kstd") - if(COMMAND "enable_coverage" AND NOT TEACHOS_ENABLE_TEST_TSAN) + if(COMMAND "enable_coverage" AND KSTD_ENABLE_TEST_COVERAGE) enable_coverage("kstd") enable_coverage("kstd_tests") endif() |
