From 79284b25994d90149f4a9a5286ec739770db94ea Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Tue, 17 Dec 2024 19:18:21 -0700 Subject: libmisc: Rework how test-intercepts work --- libmisc/tests/test_assert.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'libmisc/tests/test_assert.c') diff --git a/libmisc/tests/test_assert.c b/libmisc/tests/test_assert.c index 189f6de..0c51bbd 100644 --- a/libmisc/tests/test_assert.c +++ b/libmisc/tests/test_assert.c @@ -5,12 +5,14 @@ */ #include +#include /* for va_list, va_start(), va_end() */ #include -#include #include +#include #include #include +#include #include "test.h" @@ -28,17 +30,21 @@ jmp_buf global_env; setjmp(global_env) == 0; \ }) -[[noreturn]] void abort(void) { +void __lm_abort(void) { global_failed = true; longjmp(global_env, 1); } -#define __builtin_unreachable() test_assert(0) - -int vprintf(const char *format, va_list ap) { - return vasprintf(&global_log, format, ap); +int __lm_printf(const char *format, ...) { + va_list va; + va_start(va, format); + int ret = vasprintf(&global_log, format, va); + va_end(va); + return ret; } +#define __builtin_unreachable() test_assert(0) + /* Utilities ******************************************************************/ #define test_should_succeed(test) do { \ -- cgit v1.2.3-2-g168b From 1aecc70750ee6ce9c96ebf3e6b4a7fb322ff8ca3 Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Tue, 17 Dec 2024 19:18:21 -0700 Subject: Build the full matrix of CMAKE_BUILD_TYPE --- libmisc/tests/test_assert.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'libmisc/tests/test_assert.c') diff --git a/libmisc/tests/test_assert.c b/libmisc/tests/test_assert.c index 0c51bbd..3c2d6b6 100644 --- a/libmisc/tests/test_assert.c +++ b/libmisc/tests/test_assert.c @@ -74,6 +74,7 @@ int __lm_printf(const char *format, ...) { static_assert(sizeof(char) == 1); int main() { +#ifndef NDEBUG test_should_succeed(assert(true)); test_should_fail(assert(false), "error: ASSERT: "__FILE__":"LM_STR_(__LINE__)":main(): assertion \"false\" failed\n"); @@ -88,5 +89,6 @@ int main() { free(global_log); global_log = NULL; } +#endif return 0; } -- cgit v1.2.3-2-g168b