diff options
-rw-r--r-- | include/nm-test-utils.h | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/include/nm-test-utils.h b/include/nm-test-utils.h index dcfa46eba3..a26bffad26 100644 --- a/include/nm-test-utils.h +++ b/include/nm-test-utils.h @@ -75,7 +75,14 @@ struct __nmtst_internal extern struct __nmtst_internal __nmtst_internal; #define NMTST_DEFINE() \ - struct __nmtst_internal __nmtst_internal = { 0 }; +struct __nmtst_internal __nmtst_internal = { 0 }; \ +\ +__attribute__ ((destructor)) static void \ +_nmtst_exit (void) \ +{ \ + nmtst_free (); \ + g_test_assert_expected_messages (); \ +} inline static gboolean @@ -163,7 +170,6 @@ nmtst_free (void) inline static void __nmtst_init (int *argc, char ***argv, gboolean assert_logging, const char *log_level, const char *log_domains) { - static gsize atexit_registered = 0; const char *nmtst_debug; gboolean is_debug = FALSE; char *c_log_level = NULL, *c_log_domains = NULL; @@ -307,11 +313,6 @@ __nmtst_init (int *argc, char ***argv, gboolean assert_logging, const char *log_ g_free (c_log_level); g_free (c_log_domains); - if (g_once_init_enter (&atexit_registered)) { - atexit (nmtst_free); - g_once_init_leave (&atexit_registered, 1); - } - #ifdef __NETWORKMANAGER_UTILS_H__ /* ensure that monotonic timestamp is called (because it initially logs a line) */ nm_utils_get_monotonic_timestamp_s (); |