gio/tests: fix leaks

https://bugzilla.gnome.org/show_bug.cgi?id=682560
This commit is contained in:
Dan Winship
2012-08-24 20:43:54 -04:00
parent 17bb9d542c
commit beb0f9c150
11 changed files with 94 additions and 16 deletions

View File

@@ -431,6 +431,7 @@ test_initial_structure (gconstpointer test_data)
test_attributes (item, info);
g_object_unref (child);
g_object_unref (info);
}
/* read and test the pattern file */
@@ -447,6 +448,7 @@ test_initial_structure (gconstpointer test_data)
g_assert (info != NULL);
size = g_file_info_get_size (info);
g_assert_cmpint (size, ==, PATTERN_FILE_SIZE);
g_object_unref (info);
error = NULL;
ins = g_file_read (child, NULL, &error);
@@ -538,6 +540,9 @@ traverse_recurse_dirs (GFile * parent, GFile * root)
g_object_unref (descend);
error = NULL;
g_object_unref (info);
g_free (relative_path);
info = g_file_enumerator_next_file (enumerator, NULL, &error);
}
g_assert_no_error (error);
@@ -891,6 +896,7 @@ test_create (gconstpointer test_data)
error->code, error->message);
g_assert_cmpint (res, ==, TRUE);
g_assert_no_error (error);
g_object_unref (os);
}
g_object_unref (child);
}
@@ -961,6 +967,7 @@ test_open (gconstpointer test_data)
&error);
g_assert_cmpint (res, ==, TRUE);
g_assert_no_error (error);
g_object_unref (input_stream);
}
g_object_unref (child);
}
@@ -977,6 +984,7 @@ test_delete (gconstpointer test_data)
GError *error;
guint i;
struct StructureItem item;
gchar *path;
g_assert (test_data != NULL);
log ("\n");
@@ -1000,8 +1008,10 @@ test_delete (gconstpointer test_data)
g_assert (child != NULL);
/* we don't care about result here */
log (" Deleting %s, path = %s\n", item.filename,
g_file_get_path (child));
path = g_file_get_path (child);
log (" Deleting %s, path = %s\n", item.filename, path);
g_free (path);
error = NULL;
if ((item.extra_flags & TEST_DELETE_NORMAL) == TEST_DELETE_NORMAL)
res = g_file_delete (child, NULL, &error);
@@ -1138,11 +1148,10 @@ cleanup_dir_recurse (GFile *parent, GFile *root)
g_assert (root != NULL);
error = NULL;
enumerator =
g_file_enumerate_children (parent, "*",
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, NULL,
&error);
NULL);
if (! enumerator)
return;
@@ -1154,6 +1163,7 @@ cleanup_dir_recurse (GFile *parent, GFile *root)
g_assert (descend != NULL);
relative_path = g_file_get_relative_path (root, descend);
g_assert (relative_path != NULL);
g_free (relative_path);
log (" deleting '%s'\n", g_file_info_get_display_name (info));
@@ -1166,6 +1176,8 @@ cleanup_dir_recurse (GFile *parent, GFile *root)
g_object_unref (descend);
error = NULL;
g_object_unref (info);
info = g_file_enumerator_next_file (enumerator, NULL, &error);
}
g_assert_no_error (error);
@@ -1263,6 +1275,7 @@ main (int argc, char *argv[])
return g_test_run ();
}
g_option_context_free (context);
/* Write test - clean target directory first */
/* this can be also considered as a test - enumerate + delete */