mirror of
https://github.com/ostreedev/ostree.git
synced 2024-12-22 17:35:55 +03:00
[ASAN] tests: Fix leaks
Just for cleaner sanitizer output. Closes: #598 Approved by: jlebon
This commit is contained in:
parent
667b734c79
commit
62b94635bc
@ -73,7 +73,6 @@ test_raw_file_to_archive_z2_stream (gconstpointer data)
|
|||||||
&commit_checksum,
|
&commit_checksum,
|
||||||
&error);
|
&error);
|
||||||
g_assert_no_error (error);
|
g_assert_no_error (error);
|
||||||
reachable = ostree_repo_traverse_new_reachable ();
|
|
||||||
ostree_repo_traverse_commit (repo,
|
ostree_repo_traverse_commit (repo,
|
||||||
commit_checksum,
|
commit_checksum,
|
||||||
-1,
|
-1,
|
||||||
|
@ -31,7 +31,7 @@ static GKeyFile *g_keyfile;
|
|||||||
static void
|
static void
|
||||||
test_get_boolean_with_default (void)
|
test_get_boolean_with_default (void)
|
||||||
{
|
{
|
||||||
GError *error = NULL;
|
g_autoptr(GError) error = NULL;
|
||||||
gboolean out = FALSE;
|
gboolean out = FALSE;
|
||||||
|
|
||||||
GLogLevelFlags always_fatal_mask;
|
GLogLevelFlags always_fatal_mask;
|
||||||
@ -46,18 +46,21 @@ test_get_boolean_with_default (void)
|
|||||||
FALSE,
|
FALSE,
|
||||||
&out,
|
&out,
|
||||||
&error));
|
&error));
|
||||||
|
g_clear_error (&error);
|
||||||
g_assert_false (ot_keyfile_get_boolean_with_default (g_keyfile,
|
g_assert_false (ot_keyfile_get_boolean_with_default (g_keyfile,
|
||||||
NULL,
|
NULL,
|
||||||
"a_boolean_true",
|
"a_boolean_true",
|
||||||
FALSE,
|
FALSE,
|
||||||
&out,
|
&out,
|
||||||
&error));
|
&error));
|
||||||
|
g_clear_error (&error);
|
||||||
g_assert_false (ot_keyfile_get_boolean_with_default (g_keyfile,
|
g_assert_false (ot_keyfile_get_boolean_with_default (g_keyfile,
|
||||||
"section",
|
"section",
|
||||||
NULL,
|
NULL,
|
||||||
FALSE,
|
FALSE,
|
||||||
&out,
|
&out,
|
||||||
&error));
|
&error));
|
||||||
|
g_clear_error (&error);
|
||||||
|
|
||||||
/* Restore the old mask. */
|
/* Restore the old mask. */
|
||||||
g_log_set_always_fatal (always_fatal_mask);
|
g_log_set_always_fatal (always_fatal_mask);
|
||||||
@ -86,6 +89,7 @@ test_get_boolean_with_default (void)
|
|||||||
&error));
|
&error));
|
||||||
g_assert_true (out);
|
g_assert_true (out);
|
||||||
|
|
||||||
|
g_clear_error (&error);
|
||||||
g_assert_false (ot_keyfile_get_boolean_with_default (g_keyfile,
|
g_assert_false (ot_keyfile_get_boolean_with_default (g_keyfile,
|
||||||
"a_fake_section",
|
"a_fake_section",
|
||||||
"a_boolean_true",
|
"a_boolean_true",
|
||||||
@ -97,8 +101,8 @@ test_get_boolean_with_default (void)
|
|||||||
static void
|
static void
|
||||||
test_get_value_with_default (void)
|
test_get_value_with_default (void)
|
||||||
{
|
{
|
||||||
GError *error = NULL;
|
g_autoptr(GError) error = NULL;
|
||||||
char *out = NULL;
|
g_autofree char *out = NULL;
|
||||||
GLogLevelFlags always_fatal_mask;
|
GLogLevelFlags always_fatal_mask;
|
||||||
const char *section = "section";
|
const char *section = "section";
|
||||||
|
|
||||||
@ -112,18 +116,21 @@ test_get_value_with_default (void)
|
|||||||
"none",
|
"none",
|
||||||
&out,
|
&out,
|
||||||
&error));
|
&error));
|
||||||
|
g_clear_pointer (&out, g_free);
|
||||||
g_assert_false (ot_keyfile_get_value_with_default (g_keyfile,
|
g_assert_false (ot_keyfile_get_value_with_default (g_keyfile,
|
||||||
section,
|
section,
|
||||||
NULL,
|
NULL,
|
||||||
"none",
|
"none",
|
||||||
&out,
|
&out,
|
||||||
&error));
|
&error));
|
||||||
|
g_clear_pointer (&out, g_free);
|
||||||
g_assert_false (ot_keyfile_get_value_with_default (g_keyfile,
|
g_assert_false (ot_keyfile_get_value_with_default (g_keyfile,
|
||||||
section,
|
section,
|
||||||
NULL,
|
NULL,
|
||||||
"something",
|
"something",
|
||||||
&out,
|
&out,
|
||||||
&error));
|
&error));
|
||||||
|
g_clear_pointer (&out, g_free);
|
||||||
|
|
||||||
/* Restore the old mask. */
|
/* Restore the old mask. */
|
||||||
g_log_set_always_fatal (always_fatal_mask);
|
g_log_set_always_fatal (always_fatal_mask);
|
||||||
@ -135,6 +142,7 @@ test_get_value_with_default (void)
|
|||||||
&out,
|
&out,
|
||||||
&error));
|
&error));
|
||||||
g_assert_cmpstr (out, ==, "foo");
|
g_assert_cmpstr (out, ==, "foo");
|
||||||
|
g_clear_pointer (&out, g_free);
|
||||||
|
|
||||||
g_assert (ot_keyfile_get_value_with_default (g_keyfile,
|
g_assert (ot_keyfile_get_value_with_default (g_keyfile,
|
||||||
section,
|
section,
|
||||||
@ -143,6 +151,7 @@ test_get_value_with_default (void)
|
|||||||
&out,
|
&out,
|
||||||
&error));
|
&error));
|
||||||
g_assert_cmpstr (out, ==, "correct");
|
g_assert_cmpstr (out, ==, "correct");
|
||||||
|
g_clear_pointer (&out, g_free);
|
||||||
|
|
||||||
g_assert_false (ot_keyfile_get_value_with_default (g_keyfile,
|
g_assert_false (ot_keyfile_get_value_with_default (g_keyfile,
|
||||||
"a_fake_section",
|
"a_fake_section",
|
||||||
@ -150,6 +159,8 @@ test_get_value_with_default (void)
|
|||||||
"no value",
|
"no value",
|
||||||
&out,
|
&out,
|
||||||
&error));
|
&error));
|
||||||
|
g_clear_error (&error);
|
||||||
|
g_clear_pointer (&out, g_free);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -180,7 +180,7 @@ static void
|
|||||||
test_libarchive_autocreate_empty (gconstpointer data)
|
test_libarchive_autocreate_empty (gconstpointer data)
|
||||||
{
|
{
|
||||||
TestData *td = (void*)data;
|
TestData *td = (void*)data;
|
||||||
GError *error = NULL;
|
g_autoptr(GError) error = NULL;
|
||||||
struct archive *a = archive_read_new ();
|
struct archive *a = archive_read_new ();
|
||||||
OstreeRepoImportArchiveOptions opts = { 0, };
|
OstreeRepoImportArchiveOptions opts = { 0, };
|
||||||
glnx_unref_object OstreeMutableTree *mtree = ostree_mutable_tree_new ();
|
glnx_unref_object OstreeMutableTree *mtree = ostree_mutable_tree_new ();
|
||||||
@ -198,7 +198,7 @@ static void
|
|||||||
test_libarchive_error_device_file (gconstpointer data)
|
test_libarchive_error_device_file (gconstpointer data)
|
||||||
{
|
{
|
||||||
TestData *td = (void*)data;
|
TestData *td = (void*)data;
|
||||||
GError *error = NULL;
|
g_autoptr(GError) error = NULL;
|
||||||
struct archive *a = archive_read_new ();
|
struct archive *a = archive_read_new ();
|
||||||
OstreeRepoImportArchiveOptions opts = { 0, };
|
OstreeRepoImportArchiveOptions opts = { 0, };
|
||||||
glnx_unref_object OstreeMutableTree *mtree = ostree_mutable_tree_new ();
|
glnx_unref_object OstreeMutableTree *mtree = ostree_mutable_tree_new ();
|
||||||
@ -563,6 +563,7 @@ int main (int argc, char **argv)
|
|||||||
|
|
||||||
r = g_test_run();
|
r = g_test_run();
|
||||||
|
|
||||||
|
g_clear_object (&td.repo);
|
||||||
if (td.tmpd && g_getenv ("TEST_SKIP_CLEANUP") == NULL)
|
if (td.tmpd && g_getenv ("TEST_SKIP_CLEANUP") == NULL)
|
||||||
(void) glnx_shutil_rm_rf_at (AT_FDCWD, td.tmpd, NULL, NULL);
|
(void) glnx_shutil_rm_rf_at (AT_FDCWD, td.tmpd, NULL, NULL);
|
||||||
g_free (td.tmpd);
|
g_free (td.tmpd);
|
||||||
|
@ -127,6 +127,7 @@ int main (int argc, char **argv)
|
|||||||
g_test_add_data_func ("/test-pull-c/multi-ok-error-repeat", &td, test_pull_multi_error_then_ok);
|
g_test_add_data_func ("/test-pull-c/multi-ok-error-repeat", &td, test_pull_multi_error_then_ok);
|
||||||
|
|
||||||
r = g_test_run();
|
r = g_test_run();
|
||||||
|
g_clear_object (&td.repo);
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
@ -74,8 +74,8 @@ test_rollsum (void)
|
|||||||
#define MAX_BUFFER_SIZE 1000000
|
#define MAX_BUFFER_SIZE 1000000
|
||||||
gsize i;
|
gsize i;
|
||||||
int len;
|
int len;
|
||||||
unsigned char *a = malloc (MAX_BUFFER_SIZE);
|
g_autofree unsigned char *a = malloc (MAX_BUFFER_SIZE);
|
||||||
unsigned char *b = malloc (MAX_BUFFER_SIZE);
|
g_autofree unsigned char *b = malloc (MAX_BUFFER_SIZE);
|
||||||
g_autoptr(GRand) rand = g_rand_new ();
|
g_autoptr(GRand) rand = g_rand_new ();
|
||||||
|
|
||||||
/* These two buffers produce the same crc32. */
|
/* These two buffers produce the same crc32. */
|
||||||
|
Loading…
Reference in New Issue
Block a user