diff options
author | Matthias Clasen <mclasen@redhat.com> | 2015-09-23 22:56:32 -0400 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2015-10-13 02:56:47 +0200 |
commit | b1707e9a86937efeed974d7710c8d0b531306fc6 (patch) | |
tree | dcd1a9a69d5093f215178c870d0cbcc5e6182c50 /tests | |
parent | 13fa8aa57a1f76b246c2a5ffb769fb172dec90a1 (diff) | |
download | gdk-pixbuf-b1707e9a86937efeed974d7710c8d0b531306fc6.tar.gz |
pixbuf-randomly-modified: Use the new helper
Use the new helper function. This fixes the problem
that the test previously had with subdirectories in
test-images. The helper function will recurse into
any subdirectory it finds.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile.am | 8 | ||||
-rw-r--r-- | tests/pixbuf-randomly-modified.c | 18 |
2 files changed, 11 insertions, 15 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index 32a0a9a4e..4280e0fc9 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -58,9 +58,15 @@ dist_installed_test_data = \ cve-2015-4491.bmp \ large.png \ large.jpg \ - $(wildcard $(srcdir)/test-images/*) \ + $(filter-out tga,$(wildcard $(srcdir)/test-images/*)) \ $(wildcard $(srcdir)/test-images/tga/*) +pixbuf_randomly_modified_SOURCES = \ + pixbuf-randomly-modified.c \ + test-common.c \ + test-common.h \ + $(NULL) + cve_2015_4491_SOURCES = \ cve-2015-4491.c \ test-common.c \ diff --git a/tests/pixbuf-randomly-modified.c b/tests/pixbuf-randomly-modified.c index 554018708..69c90c4d3 100644 --- a/tests/pixbuf-randomly-modified.c +++ b/tests/pixbuf-randomly-modified.c @@ -29,6 +29,8 @@ #include <sys/resource.h> #endif +#include "test-common.h" + static void randomly_modify (const gchar *image, guint size) { @@ -64,15 +66,13 @@ static void test_randomly_modified (gconstpointer data) { const gchar *file = data; - const gchar *path; gchar *buffer; gsize size; gint iterations; gint i; GError *error = NULL; - path = g_test_get_filename (G_TEST_DIST, "test-images", file, NULL); - g_file_get_contents (path, &buffer, &size, &error); + g_file_get_contents (file, &buffer, &size, &error); g_assert_no_error (error); if (g_test_thorough ()) @@ -89,10 +89,7 @@ test_randomly_modified (gconstpointer data) int main (int argc, char **argv) { - const gchar *name; gchar *test_images_dir; - gchar *path; - GDir *dir; #ifdef HAVE_SETRLIMIT struct rlimit max_mem_size; @@ -107,14 +104,7 @@ main (int argc, char **argv) g_test_init (&argc, &argv, NULL); test_images_dir = g_build_filename (g_test_get_dir (G_TEST_DIST), "test-images", NULL); - dir = g_dir_open (test_images_dir, 0, NULL); - while ((name = g_dir_read_name (dir)) != NULL) - { - path = g_strconcat ("/pixbuf/randomly-modified/", name, NULL); - g_test_add_data_func_full (path, g_strdup (name), test_randomly_modified, g_free); - g_free (path); - } - g_dir_close (dir); + add_test_for_all_images ("/pixbuf/randomly-modified", test_images_dir, test_randomly_modified); g_free (test_images_dir); g_test_message ("Modified image is written to pixbuf-randomly-modified-image"); |