mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-23 10:42:11 +01:00
Merge branch 'main' into 'main'
Fix some test suite memory leaks See merge request GNOME/glib!2195
This commit is contained in:
commit
ef6a551739
@ -3639,6 +3639,8 @@ g_test_get_root
|
|||||||
g_test_suite_add
|
g_test_suite_add
|
||||||
g_test_suite_add_suite
|
g_test_suite_add_suite
|
||||||
g_test_run_suite
|
g_test_run_suite
|
||||||
|
g_test_case_free
|
||||||
|
g_test_suite_free
|
||||||
|
|
||||||
<SUBSECTION Private>
|
<SUBSECTION Private>
|
||||||
g_test_trap_assertions
|
g_test_trap_assertions
|
||||||
|
@ -63,6 +63,7 @@ test_copy_chunks_splice_cb (GObject *source,
|
|||||||
if (data->flags & TEST_CANCEL)
|
if (data->flags & TEST_CANCEL)
|
||||||
{
|
{
|
||||||
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_CANCELLED);
|
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_CANCELLED);
|
||||||
|
g_error_free (error);
|
||||||
g_main_loop_quit (data->main_loop);
|
g_main_loop_quit (data->main_loop);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -832,6 +832,7 @@ struct DestroyEntry
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* --- prototypes --- */
|
/* --- prototypes --- */
|
||||||
|
static void test_cleanup (void);
|
||||||
static void test_run_seed (const gchar *rseed);
|
static void test_run_seed (const gchar *rseed);
|
||||||
static void test_trap_clear (void);
|
static void test_trap_clear (void);
|
||||||
static guint8* g_test_log_dump (GTestLogMsg *msg,
|
static guint8* g_test_log_dump (GTestLogMsg *msg,
|
||||||
@ -1726,6 +1727,18 @@ void
|
|||||||
test_built_files_dir = test_argv0_dirname;
|
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
|
static void
|
||||||
test_run_seed (const gchar *rseed)
|
test_run_seed (const gchar *rseed)
|
||||||
{
|
{
|
||||||
@ -2178,8 +2191,15 @@ g_test_get_root (void)
|
|||||||
int
|
int
|
||||||
g_test_run (void)
|
g_test_run (void)
|
||||||
{
|
{
|
||||||
if (g_test_run_suite (g_test_get_root()) != 0)
|
int ret;
|
||||||
return 1;
|
GTestSuite *suite;
|
||||||
|
|
||||||
|
suite = g_test_get_root ();
|
||||||
|
if (g_test_run_suite (suite) != 0)
|
||||||
|
{
|
||||||
|
ret = 1;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
/* Clean up the temporary directory. */
|
/* Clean up the temporary directory. */
|
||||||
if (test_isolate_dirs_tmpdir != NULL)
|
if (test_isolate_dirs_tmpdir != NULL)
|
||||||
@ -2192,12 +2212,26 @@ g_test_run (void)
|
|||||||
/* 77 is special to Automake's default driver, but not Automake's TAP driver
|
/* 77 is special to Automake's default driver, but not Automake's TAP driver
|
||||||
* or Perl's prove(1) TAP driver. */
|
* or Perl's prove(1) TAP driver. */
|
||||||
if (test_tap_log)
|
if (test_tap_log)
|
||||||
return 0;
|
{
|
||||||
|
ret = 0;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
if (test_run_count > 0 && test_run_count == test_skipped_count)
|
if (test_run_count > 0 && test_run_count == test_skipped_count)
|
||||||
return 77;
|
{
|
||||||
|
ret = 77;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return 0;
|
{
|
||||||
|
ret = 0;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
out:
|
||||||
|
g_test_suite_free (suite);
|
||||||
|
test_cleanup ();
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2975,6 +3009,41 @@ g_test_run_suite (GTestSuite *suite)
|
|||||||
return n_bad;
|
return n_bad;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* g_test_case_free:
|
||||||
|
* @test_case: a #GTestCase
|
||||||
|
*
|
||||||
|
* Free the @test_case.
|
||||||
|
*
|
||||||
|
* Since: 2.70
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
g_test_case_free (GTestCase *test_case)
|
||||||
|
{
|
||||||
|
g_free (test_case->name);
|
||||||
|
g_slice_free (GTestCase, test_case);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* g_test_suite_free:
|
||||||
|
* @suite: a #GTestSuite
|
||||||
|
*
|
||||||
|
* Free the @suite and all nested #GTestSuites.
|
||||||
|
*
|
||||||
|
* Since: 2.70
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
g_test_suite_free (GTestSuite *suite)
|
||||||
|
{
|
||||||
|
g_slist_free_full (suite->cases, (GDestroyNotify)g_test_case_free);
|
||||||
|
|
||||||
|
g_free (suite->name);
|
||||||
|
|
||||||
|
g_slist_free_full (suite->suites, (GDestroyNotify)g_test_suite_free);
|
||||||
|
|
||||||
|
g_slice_free (GTestSuite, suite);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtest_default_log_handler (const gchar *log_domain,
|
gtest_default_log_handler (const gchar *log_domain,
|
||||||
GLogLevelFlags log_level,
|
GLogLevelFlags log_level,
|
||||||
|
@ -506,6 +506,12 @@ void g_test_suite_add_suite (GTestSuite *suite,
|
|||||||
GLIB_AVAILABLE_IN_ALL
|
GLIB_AVAILABLE_IN_ALL
|
||||||
int g_test_run_suite (GTestSuite *suite);
|
int g_test_run_suite (GTestSuite *suite);
|
||||||
|
|
||||||
|
GLIB_AVAILABLE_IN_2_70
|
||||||
|
void g_test_case_free (GTestCase *test_case);
|
||||||
|
|
||||||
|
GLIB_AVAILABLE_IN_2_70
|
||||||
|
void g_test_suite_free (GTestSuite *suite);
|
||||||
|
|
||||||
GLIB_AVAILABLE_IN_ALL
|
GLIB_AVAILABLE_IN_ALL
|
||||||
void g_test_trap_assertions (const char *domain,
|
void g_test_trap_assertions (const char *domain,
|
||||||
const char *file,
|
const char *file,
|
||||||
|
@ -1331,6 +1331,7 @@ g_system_thread_new (GThreadFunc proxy,
|
|||||||
{
|
{
|
||||||
g_set_error (error, G_THREAD_ERROR, G_THREAD_ERROR_AGAIN,
|
g_set_error (error, G_THREAD_ERROR, G_THREAD_ERROR_AGAIN,
|
||||||
"Error creating thread: %s", g_strerror (ret));
|
"Error creating thread: %s", g_strerror (ret));
|
||||||
|
g_free (thread->thread.name);
|
||||||
g_slice_free (GThreadPosix, thread);
|
g_slice_free (GThreadPosix, thread);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -389,6 +389,8 @@ test_search_path_heap_allocation (void)
|
|||||||
long_dir = g_test_build_filename (G_TEST_BUILT, "path-test-subdir", placeholder, NULL);
|
long_dir = g_test_build_filename (G_TEST_BUILT, "path-test-subdir", placeholder, NULL);
|
||||||
long_path = g_strjoin (G_SEARCHPATH_SEPARATOR_S, subdir, long_dir, NULL);
|
long_path = g_strjoin (G_SEARCHPATH_SEPARATOR_S, subdir, long_dir, NULL);
|
||||||
envp = g_environ_setenv (envp, "PATH", long_path, TRUE);
|
envp = g_environ_setenv (envp, "PATH", long_path, TRUE);
|
||||||
|
g_free (long_path);
|
||||||
|
g_free (long_dir);
|
||||||
|
|
||||||
g_ptr_array_add (argv,
|
g_ptr_array_add (argv,
|
||||||
g_test_build_filename (G_TEST_BUILT, "spawn-path-search-helper", NULL));
|
g_test_build_filename (G_TEST_BUILT, "spawn-path-search-helper", NULL));
|
||||||
|
@ -905,6 +905,7 @@ main (int argc, char *argv[])
|
|||||||
data.use_this_flag, data.use_this_type);
|
data.use_this_flag, data.use_this_type);
|
||||||
test_data = g_memdup2 (&data, sizeof (TestParamImplementData));
|
test_data = g_memdup2 (&data, sizeof (TestParamImplementData));
|
||||||
g_test_add_data_func_full (test_path, test_data, test_param_implement_child, g_free);
|
g_test_add_data_func_full (test_path, test_data, test_param_implement_child, g_free);
|
||||||
|
g_free (test_data);
|
||||||
g_free (test_path);
|
g_free (test_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user