mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-27 20:52:12 +01:00
testutils: Defer global cleanup until we really exit
Some test suites try to call g_test_build_filename() after g_test_run() has returned. In the installed-tests use-case where G_TEST_BUILDDIR and G_TEST_SRCDIR are unset, that call uses test_argv0_dirname, which is freed in test_cleanup(). Defer test_cleanup() using atexit() so it isn't freed until after we return from main(). Resolves: https://gitlab.gnome.org/GNOME/glib/-/issues/2563 Signed-off-by: Simon McVittie <smcv@collabora.com>
This commit is contained in:
parent
2c958470d2
commit
c651ea0453
@ -890,10 +890,10 @@ static gboolean test_debug_log = FALSE;
|
||||
static gboolean test_tap_log = TRUE; /* default to TAP as of GLib 2.62; see #1619; the non-TAP output mode is deprecated */
|
||||
static gboolean test_nonfatal_assertions = FALSE;
|
||||
static DestroyEntry *test_destroy_queue = NULL;
|
||||
static char *test_argv0 = NULL;
|
||||
static char *test_argv0_dirname;
|
||||
static const char *test_disted_files_dir;
|
||||
static const char *test_built_files_dir;
|
||||
static char *test_argv0 = NULL; /* points into global argv */
|
||||
static char *test_argv0_dirname = NULL; /* owned by GLib */
|
||||
static const char *test_disted_files_dir; /* points into test_argv0_dirname or an environment variable */
|
||||
static const char *test_built_files_dir; /* points into test_argv0_dirname or an environment variable */
|
||||
static char *test_initial_cwd = NULL;
|
||||
static gboolean test_in_forked_child = FALSE;
|
||||
static gboolean test_in_subprocess = FALSE;
|
||||
@ -2219,6 +2219,13 @@ g_test_run (void)
|
||||
int ret;
|
||||
GTestSuite *suite;
|
||||
|
||||
if (atexit (test_cleanup) != 0)
|
||||
{
|
||||
int errsv = errno;
|
||||
g_error ("Unable to register test cleanup to be run at exit: %s",
|
||||
g_strerror (errsv));
|
||||
}
|
||||
|
||||
suite = g_test_get_root ();
|
||||
if (g_test_run_suite (suite) != 0)
|
||||
{
|
||||
@ -2255,7 +2262,6 @@ g_test_run (void)
|
||||
|
||||
out:
|
||||
g_test_suite_free (suite);
|
||||
test_cleanup ();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user