diff options
author | Matthias Clasen <mclasen@redhat.com> | 2015-09-23 22:55:26 -0400 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2015-10-13 02:56:47 +0200 |
commit | 13fa8aa57a1f76b246c2a5ffb769fb172dec90a1 (patch) | |
tree | 45fa6be99886337bee5368e68ed854dc9f8a0336 /tests/test-common.c | |
parent | 118bdf49b7c9c4239f9a6cb3bbeb40fccdbaaf33 (diff) | |
download | gdk-pixbuf-13fa8aa57a1f76b246c2a5ffb769fb172dec90a1.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.
Diffstat (limited to 'tests/test-common.c')
-rw-r--r-- | tests/test-common.c | 26 |
1 files changed, 26 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); +} |