From 84d13508d59db724770e18af89a9033643a7f991 Mon Sep 17 00:00:00 2001 From: David Gibson Date: Tue, 26 May 2026 20:47:02 +1000 Subject: [PATCH] tests: Remove unused cleanup() mechanism from tests The cleanup() function is defined as a weak symbol in testutils.c, and called from the various helpers which exit a test. The idea is that each test can override it to perform test specific cleanup. However, nothing actually uses it. Furthermore the use of ((weak)) means we can't run the tests on Windows / mingw. Just remove it for now. Assisted-by: Claude:claude-opus-4-6 Signed-off-by: David Gibson --- tests/tests.h | 9 --------- tests/testutils.c | 5 ----- 2 files changed, 14 deletions(-) diff --git a/tests/tests.h b/tests/tests.h index 7c1b6c0..578d8c1 100644 --- a/tests/tests.h +++ b/tests/tests.h @@ -25,9 +25,6 @@ void test_init(int argc, char *argv[]); #define streq(s1, s2) (strcmp((s1),(s2)) == 0) -/* Each test case must define this function */ -void cleanup(void); - #define verbose_printf(...) \ if (verbose_test) { \ printf(__VA_ARGS__); \ @@ -39,21 +36,18 @@ void cleanup(void); #define PASS() \ do { \ - cleanup(); \ printf("PASS\n"); \ exit(RC_PASS); \ } while (0) #define PASS_INCONCLUSIVE() \ do { \ - cleanup(); \ printf("PASS (inconclusive)\n"); \ exit(RC_PASS); \ } while (0) #define IRRELEVANT() \ do { \ - cleanup(); \ printf("PASS (irrelevant)\n"); \ exit(RC_PASS); \ } while (0) @@ -61,21 +55,18 @@ void cleanup(void); /* Look out, gcc extension below... */ #define FAIL(fmt, ...) \ do { \ - cleanup(); \ printf("FAIL\t" fmt "\n", ##__VA_ARGS__); \ exit(RC_FAIL); \ } while (0) #define CONFIG(fmt, ...) \ do { \ - cleanup(); \ printf("Bad configuration: " fmt "\n", ##__VA_ARGS__); \ exit(RC_CONFIG); \ } while (0) #define TEST_BUG(fmt, ...) \ do { \ - cleanup(); \ printf("BUG in testsuite: " fmt "\n", ##__VA_ARGS__); \ exit(RC_BUG); \ } while (0) diff --git a/tests/testutils.c b/tests/testutils.c index 54da2e4..5ab4324 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -42,13 +42,8 @@ static inline void VALGRIND_MAKE_MEM_DEFINED(void *p, size_t len) int verbose_test = 1; char *test_name; -void __attribute__((weak)) cleanup(void) -{ -} - static void sigint_handler(int signum, siginfo_t *si, void *uc) { - cleanup(); fprintf(stderr, "%s: %s (pid=%d)\n", test_name, strsignal(signum), getpid()); exit(RC_BUG);