From f1e12da7ef620de97cd9cd553465a271a883e5e6 Mon Sep 17 00:00:00 2001 From: Tobias Brunner Date: Mon, 2 Dec 2013 11:16:04 +0100 Subject: [PATCH] unit-tests: Don't use priority for destructor that unregisters testable functions This fixes coverage reports, at least if leak detective is disabled. If it is enabled the plugins are not unloaded so the destructor is not executed until the process is destroyed, which seems not to be covered by gcov. --- src/libstrongswan/utils/test.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/libstrongswan/utils/test.h b/src/libstrongswan/utils/test.h index d3c641674..5b7289244 100644 --- a/src/libstrongswan/utils/test.h +++ b/src/libstrongswan/utils/test.h @@ -42,6 +42,11 @@ void testable_function_register(char *name, void *fn); * Macro to automatically register/unregister a function that can be called * from tests. * + * @note The constructor has a priority set so that it runs after the + * constructor that creates the hashtable. The destructor, on the other hand, + * does not have a priority set, as test coverage would report that function as + * untested otherwise. + * * @param ns namespace * @param fn function to register */ @@ -51,7 +56,7 @@ static void testable_function_register_##fn() \ { \ testable_function_register(#ns "/" #fn, fn); \ } \ -static void testable_function_unregister_##fn() __attribute__ ((destructor(2000))); \ +static void testable_function_unregister_##fn() __attribute__ ((destructor)); \ static void testable_function_unregister_##fn() \ { \ testable_function_register(#ns "/" #fn, NULL); \