From: Alan T. DeKok Date: Tue, 30 Jan 2024 21:03:43 +0000 (-0500) Subject: add and use TEST_FINI for acutest X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c70337589a9aa501e84d7ae76714069b014d7aaf;p=thirdparty%2Ffreeradius-server.git add and use TEST_FINI for acutest so that the dictionaries are cleaned up when we exit. This commit also removes the use of constructors. While this change makes the tests slower, we do need everything to be cleaned up on exit, to avoid errors --- diff --git a/src/lib/server/pair_server_tests.c b/src/lib/server/pair_server_tests.c index f1925ac57e8..07f28ec9fd8 100644 --- a/src/lib/server/pair_server_tests.c +++ b/src/lib/server/pair_server_tests.c @@ -21,25 +21,10 @@ * @copyright 2020 Network RADIUS SAS (legal@networkradius.com) */ -/** - * The 'TEST_INIT' macro provided by 'acutest.h' allowing to register a function to be called - * before call the unit tests. Therefore, It calls the function ALL THE TIME causing an overhead. - * That is why we are initializing test_init() by "__attribute__((constructor));" reducing the - * test execution by 50% of the time. - */ -#define USE_CONSTRUCTOR - -/* - * It should be declared before include the "acutest.h" - */ -#ifdef USE_CONSTRUCTOR -static void test_init(void) __attribute__((constructor)); -static void test_free(void) __attribute__((destructor)); -#else static void test_init(void); +static void test_free(void); # define TEST_INIT test_init() # define TEST_FINI test_free() -#endif #include #include diff --git a/src/lib/server/tmpl_dcursor_tests.c b/src/lib/server/tmpl_dcursor_tests.c index ec8191d55dd..7018c56d7df 100644 --- a/src/lib/server/tmpl_dcursor_tests.c +++ b/src/lib/server/tmpl_dcursor_tests.c @@ -1,13 +1,7 @@ -#define USE_CONSTRUCTOR - -#ifdef USE_CONSTRUCTOR -static void test_init(void) __attribute__((constructor)); -static void test_free(void) __attribute__((destructor)); -#else static void test_init(void); +static void test_free(void); # define TEST_INIT test_init() # define TEST_FINI test_free() -#endif #include #include