[ASAN] tests: Cleanup all current remaining leaks

We now run fully through ASAN here.

Closes: #609
Approved by: jlebon
This commit is contained in:
Colin Walters 2016-12-02 13:45:04 -05:00 committed by Atomic Bot
parent 7bb0ff46a4
commit e1c48c8adb
7 changed files with 32 additions and 17 deletions

View File

@ -89,7 +89,9 @@ test_bsdiff (void)
g_output_stream_close (out, NULL, NULL);
/* Now generate NEW_GENERATED from OLD and OUT. */
in = g_memory_input_stream_new_from_bytes (g_memory_output_stream_steal_as_bytes (G_MEMORY_OUTPUT_STREAM (out)));
{ g_autoptr(GBytes) bytes = g_memory_output_stream_steal_as_bytes (G_MEMORY_OUTPUT_STREAM (out));
in = g_memory_input_stream_new_from_bytes (bytes);
}
bspatch_stream.read = bzpatch_read;
bspatch_stream.opaque = in;

View File

@ -32,7 +32,7 @@
static void
helper_test_compress_decompress (const guint8 *data, gssize data_size)
{
GError *error = NULL;
g_autoptr(GError) error = NULL;
g_autoptr(GOutputStream) out_compress = g_memory_output_stream_new_resizable ();
g_autoptr(GOutputStream) out_decompress = NULL;
g_autoptr(GInputStream) in_compress = g_memory_input_stream_new_from_data (data, data_size, NULL);
@ -56,8 +56,9 @@ helper_test_compress_decompress (const guint8 *data, gssize data_size)
gssize n_bytes_written;
g_autoptr(GInputStream) convin = NULL;
g_autoptr(GConverter) decompressor = (GConverter*)_ostree_lzma_decompressor_new ();
g_autoptr(GBytes) bytes = g_memory_output_stream_steal_as_bytes (G_MEMORY_OUTPUT_STREAM (out_compress));
in_decompress = g_memory_input_stream_new_from_bytes (g_memory_output_stream_steal_as_bytes (G_MEMORY_OUTPUT_STREAM (out_compress)));
in_decompress = g_memory_input_stream_new_from_bytes (bytes);
convin = g_converter_input_stream_new ((GInputStream*) in_decompress, decompressor);
n_bytes_written = g_output_stream_splice (out_decompress, convin,
G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET | G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE,

View File

@ -84,7 +84,7 @@ test_ensure_parent_dirs (void)
glnx_unref_object OstreeMutableTree *tree = ostree_mutable_tree_new ();
glnx_unref_object OstreeMutableTree *parent = NULL;
g_autoptr(GPtrArray) split_path = NULL;
GError *error = NULL;
g_autoptr(GError) error = NULL;
const char *pathname = "/foo/bar/baz";
const char *checksum = "01234567890123456789012345678901";
g_autofree char *source_checksum = NULL;
@ -103,6 +103,7 @@ test_ensure_parent_dirs (void)
g_assert_false (ostree_mutable_tree_lookup (tree, "bar", &source_checksum2,
&source_subdir2, &error));
g_clear_error (&error);
}
static void
@ -110,7 +111,7 @@ test_ensure_dir (void)
{
glnx_unref_object OstreeMutableTree *tree = ostree_mutable_tree_new ();
glnx_unref_object OstreeMutableTree *parent = NULL;
GError *error = NULL;
g_autoptr(GError) error = NULL;
const char *dirname = "foo";
const char *filename = "bar";
const char *checksum = "01234567890123456789012345678901";
@ -122,13 +123,14 @@ test_ensure_dir (void)
g_assert (ostree_mutable_tree_replace_file (tree, filename, checksum, &error));
g_assert_false (ostree_mutable_tree_ensure_dir (tree, filename, &parent, &error));
g_clear_error (&error);
}
static void
test_replace_file (void)
{
glnx_unref_object OstreeMutableTree *tree = ostree_mutable_tree_new ();
GError *error = NULL;
g_autoptr(GError) error = NULL;
const char *filename = "bar";
const char *checksum = "01234567890123456789012345678901";
const char *checksum2 = "ABCDEF01234567890123456789012345";
@ -157,7 +159,7 @@ test_contents_checksum (void)
const char *subdir_checksum = "ABCD0123456789012345678901234567";
glnx_unref_object OstreeMutableTree *tree = ostree_mutable_tree_new ();
glnx_unref_object OstreeMutableTree *subdir = NULL;
GError *error = NULL;
g_autoptr(GError) error = NULL;
g_assert_null (ostree_mutable_tree_get_contents_checksum (tree));
ostree_mutable_tree_set_contents_checksum (tree, checksum);

View File

@ -40,19 +40,19 @@ util_usage_error_printerr (const gchar *string)
static void
test_ot_util_usage_error (void)
{
GError *error = NULL;
GOptionContext *context = g_option_context_new ("[TEST]");
g_autoptr(GError) error = NULL;
g_autoptr(GOptionContext) context = g_option_context_new ("[TEST]");
GPrintFunc old_printerr = g_set_printerr_handler (util_usage_error_printerr);
ot_util_usage_error (context, "find_me", &error);
g_assert_nonnull (strstr (printerr_str->str, "[TEST]"));
g_assert_nonnull (strstr (error->message, "find_me"));
g_clear_error (&error);
g_set_printerr_handler (old_printerr);
g_string_free (printerr_str, TRUE);
printerr_str = NULL;
g_option_context_free (context);
}
int main (int argc, char **argv)

View File

@ -43,7 +43,7 @@ ot_parse_keyvalue (const char *keyvalue,
static void
test_ot_parse_boolean (void)
{
GError *error = NULL;
g_autoptr(GError) error = NULL;
gboolean out = FALSE;
g_assert_true (ot_parse_boolean ("yes", &out, &error));
g_assert_true (out);
@ -70,15 +70,17 @@ test_ot_parse_boolean (void)
out = TRUE;
g_assert_true (ot_parse_boolean ("none", &out, &error));
g_assert_false (out);
g_clear_error (&error);
g_assert_false (ot_parse_boolean ("FOO", &out, &error));
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_FAILED);
g_clear_error (&error);
}
static void
test_ot_parse_keyvalue (void)
{
GError *error = NULL;
g_autoptr(GError) error = NULL;
char *keyvalue[] = {"foo=bar", "a=", "b=1231231"};
char *key[] = {"foo", "a", "b"};
char *value[] = {"bar", "", "1231231"};
@ -104,6 +106,7 @@ test_ot_parse_keyvalue (void)
&out_value,
&error));
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_FAILED);
g_clear_error (&error);
}
}

View File

@ -50,22 +50,29 @@ test_ot_util_path_split_validate (void)
static void
test_ot_util_filename_validate (void)
{
GError *error = NULL;
g_autoptr(GError) error = NULL;
/* Check for valid inputs. */
g_assert (ot_util_filename_validate ("valid", &error));
g_assert_no_error (error);
g_assert (ot_util_filename_validate ("valid_file_name", &error));
g_assert_no_error (error);
g_assert (ot_util_filename_validate ("file.name", &error));
g_assert_no_error (error);
g_assert (ot_util_filename_validate ("foo..", &error));
g_assert_no_error (error);
g_assert (ot_util_filename_validate ("..bar", &error));
g_assert_no_error (error);
g_assert (ot_util_filename_validate ("baz:", &error));
g_assert_no_error (error);
/* Check for invalid inputs. */
g_assert_false (ot_util_filename_validate ("not/valid/file/name", &error));
error = NULL;
g_clear_error (&error);
g_assert_false (ot_util_filename_validate (".", &error));
error = NULL;
g_clear_error (&error);
g_assert_false (ot_util_filename_validate ("..", &error));
g_clear_error (&error);
}
int main (int argc, char **argv)

View File

@ -27,7 +27,7 @@
static void
check_one_roundtrip (guint64 val)
{
GString *buf = g_string_new (NULL);
g_autoptr(GString) buf = g_string_new (NULL);
guint64 newval;
gsize bytes_read;