glib/gtestutils: Introduce and use a test_cleanup function

This commit is contained in:
GOUJON Évan 2021-07-23 22:20:54 +02:00
parent 353f0b5235
commit bd779c96e9

View File

@ -832,6 +832,7 @@ struct DestroyEntry
};
/* --- prototypes --- */
static void test_cleanup (void);
static void test_run_seed (const gchar *rseed);
static void test_trap_clear (void);
static guint8* g_test_log_dump (GTestLogMsg *msg,
@ -1726,6 +1727,18 @@ void
test_built_files_dir = test_argv0_dirname;
}
static void
test_cleanup (void)
{
/* Free statically allocated variables */
g_clear_pointer (&test_run_rand, g_rand_free);
g_clear_pointer (&test_argv0_dirname, g_free);
g_clear_pointer (&test_initial_cwd, g_free);
}
static void
test_run_seed (const gchar *rseed)
{
@ -2217,6 +2230,7 @@ g_test_run (void)
out:
g_test_suite_free (suite);
test_cleanup ();
return ret;
}