summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2015-09-23 22:55:26 -0400
committerBenjamin Otte <otte@redhat.com>2015-09-24 12:49:27 +0200
commit98c63e553970e19cfaa42ea72c994a9d480b32cf (patch)
tree1667debcffd1ed4df3f2154b2375b5dda25d32b8
parente93cd6e1369f5fc90e38903c1858ef905264137b (diff)
downloadgdk-pixbuf-98c63e553970e19cfaa42ea72c994a9d480b32cf.tar.gz
Add a helper to run tests over directories
This helper function recursively runs over a directory and adds a test function for each file in the tree.
-rw-r--r--tests/test-common.c26
-rw-r--r--tests/test-common.h4
2 files changed, 30 insertions, 0 deletions
diff --git a/tests/test-common.c b/tests/test-common.c
index 0f70a8bfa..01a0c3877 100644
--- a/tests/test-common.c
+++ b/tests/test-common.c
@@ -113,3 +113,29 @@ pixdata_equal (GdkPixbuf *p1, GdkPixbuf *p2, GError **error)
return TRUE;
}
+
+void
+add_test_for_all_images (const gchar *prefix,
+ const gchar *path,
+ GTestDataFunc test_func)
+{
+ GDir *dir;
+ const gchar *name;
+
+ dir = g_dir_open (path, 0, NULL);
+ while ((name = g_dir_read_name (dir)) != NULL)
+ {
+ gchar *test_path;
+ gchar *dir_path;
+
+ test_path = g_strconcat (prefix, "/", name, NULL);
+ dir_path = g_strconcat (path, "/", name, NULL);
+ if (g_file_test (dir_path, G_FILE_TEST_IS_DIR))
+ add_test_for_all_images (test_path, dir_path, test_func);
+ else
+ g_test_add_data_func_full (test_path, g_strdup (dir_path), test_func, g_free);
+ g_free (test_path);
+ g_free (dir_path);
+ }
+ g_dir_close (dir);
+}
diff --git a/tests/test-common.h b/tests/test-common.h
index 0514cd757..5c8e3e7a4 100644
--- a/tests/test-common.h
+++ b/tests/test-common.h
@@ -30,6 +30,10 @@ G_BEGIN_DECLS
gboolean format_supported (const gchar *filename);
gboolean skip_if_insufficient_memory (GError **err);
gboolean pixdata_equal (GdkPixbuf *p1, GdkPixbuf *p2, GError **error);
+void add_test_for_all_images (const gchar *prefix,
+ const gchar *dir,
+ GTestDataFunc test_func);
+
G_END_DECLS