]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
add and use TEST_FINI for acutest
authorAlan T. DeKok <aland@freeradius.org>
Tue, 30 Jan 2024 21:03:43 +0000 (16:03 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 30 Jan 2024 21:03:43 +0000 (16:03 -0500)
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

src/lib/server/pair_server_tests.c
src/lib/server/tmpl_dcursor_tests.c

index f1925ac57e8dbff053b72a5d791e6d24454eb231..07f28ec9fd853acb690108e7c4bc3949304a2eef 100644 (file)
  * @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 <freeradius-devel/util/acutest.h>
 #include <freeradius-devel/util/acutest_helpers.h>
index ec8191d55dd382504872e10c56d99530ed5b3b8c..7018c56d7dfc7941592090d1f8adc7864a445b50 100644 (file)
@@ -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 <freeradius-devel/util/acutest.h>
 #include <freeradius-devel/util/acutest_helpers.h>