diff options
| author | Dimitri Staessens <dimitri@ouroboros.rocks> | 2026-01-23 18:54:27 +0100 |
|---|---|---|
| committer | Sander Vrijders <sander@ouroboros.rocks> | 2026-01-26 07:48:26 +0100 |
| commit | 1775201647a10923b9f73addf2304c3124350836 (patch) | |
| tree | 194645b0e6c6531e824bc8a34c9dda27db0cbb35 | |
| parent | f60b67a6fcbed7329f7d27511e8c572dc252934e (diff) | |
| download | ouroboros-1775201647a10923b9f73addf2304c3124350836.tar.gz ouroboros-1775201647a10923b9f73addf2304c3124350836.zip | |
build: Add DISABLE_TESTS_CORE_DUMPS option
We have a few that test that assertions are triggered. This adds a
DISABLE_TESTS_CORE_DUMPS CMake build option (default ON) that disables
core dumps for tests so they don't pollute the core cache.
Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks>
Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
| -rw-r--r-- | cmake/utils/DisableTestLogging.cmake | 10 | ||||
| -rw-r--r-- | include/test/test.h | 8 |
2 files changed, 17 insertions, 1 deletions
diff --git a/cmake/utils/DisableTestLogging.cmake b/cmake/utils/DisableTestLogging.cmake index 730b0bc0..a7e90b38 100644 --- a/cmake/utils/DisableTestLogging.cmake +++ b/cmake/utils/DisableTestLogging.cmake @@ -5,8 +5,18 @@ else () message(STATUS "Ouroboros logging in test output enabled") endif () +set(DISABLE_TESTS_CORE_DUMPS TRUE CACHE BOOL "Enable core dumps for tests (useful for debugging)") +if (DISABLE_TESTS_CORE_DUMPS) + message(STATUS "Core dumps in tests enabled") +else () + message(STATUS "Core dumps in tests disabled") +endif () + macro(disable_test_logging_for_target target) if (DISABLE_TESTS_LOGGING) target_compile_definitions(${target} PRIVATE OUROBOROS_DISABLE_LOGGING) endif () + if (DISABLE_TESTS_CORE_DUMPS) + target_compile_definitions(${target} PRIVATE DISABLE_TESTS_CORE_DUMPS) + endif () endmacro() diff --git a/include/test/test.h b/include/test/test.h index b524d8ec..306e737a 100644 --- a/include/test/test.h +++ b/include/test/test.h @@ -29,6 +29,7 @@ #include <unistd.h> #include <sys/wait.h> #include <sys/types.h> +#include <sys/resource.h> #define TEST_RC_SUCCESS 0 #define TEST_RC_SKIP 1 @@ -81,8 +82,13 @@ static int __attribute__((unused)) test_assert_fail(int(* testfunc)(void)) return TEST_RC_FAIL; } - if (pid == 0) + if (pid == 0) { +#ifdef DISABLE_TESTS_CORE_DUMPS + struct rlimit rl = { .rlim_cur = 0, .rlim_max = 0 }; + setrlimit(RLIMIT_CORE, &rl); +#endif return testfunc(); /* should abort */ + } waitpid(pid, &wstatus, 0); #ifdef CONFIG_OUROBOROS_DEBUG |
