mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-05 08:48:07 +02:00
tests: check for no pending expected_messages on exit of tests
On the end of the test there should be no unchecked expected
messages. Register a destructor function in nmtst to assert
against that.
Also call nmtst_free() in the destructor. That way, we always release
the allocated data without requiring the test to do it explicitly.
(cherry picked from commit bb90127c2a)
This commit is contained in:
parent
0074bf032b
commit
fec4e68f4d
1 changed files with 8 additions and 7 deletions
|
|
@ -130,7 +130,14 @@ struct __nmtst_internal
|
||||||
extern struct __nmtst_internal __nmtst_internal;
|
extern struct __nmtst_internal __nmtst_internal;
|
||||||
|
|
||||||
#define NMTST_DEFINE() \
|
#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
|
inline static gboolean
|
||||||
|
|
@ -218,7 +225,6 @@ nmtst_free (void)
|
||||||
inline static void
|
inline static void
|
||||||
__nmtst_init (int *argc, char ***argv, gboolean assert_logging, const char *log_level, const char *log_domains, gboolean *out_set_logging)
|
__nmtst_init (int *argc, char ***argv, gboolean assert_logging, const char *log_level, const char *log_domains, gboolean *out_set_logging)
|
||||||
{
|
{
|
||||||
static gsize atexit_registered = 0;
|
|
||||||
const char *nmtst_debug;
|
const char *nmtst_debug;
|
||||||
gboolean is_debug = FALSE;
|
gboolean is_debug = FALSE;
|
||||||
char *c_log_level = NULL, *c_log_domains = NULL;
|
char *c_log_level = NULL, *c_log_domains = NULL;
|
||||||
|
|
@ -381,11 +387,6 @@ __nmtst_init (int *argc, char ***argv, gboolean assert_logging, const char *log_
|
||||||
g_free (c_log_level);
|
g_free (c_log_level);
|
||||||
g_free (c_log_domains);
|
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__
|
#ifdef __NETWORKMANAGER_UTILS_H__
|
||||||
/* ensure that monotonic timestamp is called (because it initially logs a line) */
|
/* ensure that monotonic timestamp is called (because it initially logs a line) */
|
||||||
nm_utils_get_monotonic_timestamp_s ();
|
nm_utils_get_monotonic_timestamp_s ();
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue