summaryrefslogtreecommitdiff
path: root/tests/pixbuf-threads.c
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2013-06-24 16:37:57 +0100
committerColin Walters <walters@verbum.org>2013-06-24 16:37:57 +0100
commit67b5737712ea43c54ac31a19f349cef74aa2287f (patch)
tree2d436be0eea7c950e3cfb17f914fdfdc4d1a5213 /tests/pixbuf-threads.c
parentb4049c42255086280404ab95d44e64b19d6650a9 (diff)
downloadgdk-pixbuf-67b5737712ea43c54ac31a19f349cef74aa2287f.tar.gz
tests: Fix up pixbuf tests to know how to find data files
These tests were broken by: 8ec55ff29e0626a05a3aa9d92060e28767ee142f Previously we were relying on hand-written .test files which used sh -c and wildcard expansion, but with modern GLib we can just use g_test_get_dir() to find the datadir relative to our binary path.
Diffstat (limited to 'tests/pixbuf-threads.c')
-rw-r--r--tests/pixbuf-threads.c49
1 files changed, 25 insertions, 24 deletions
diff --git a/tests/pixbuf-threads.c b/tests/pixbuf-threads.c
index 268b01fb8..8af6acfda 100644
--- a/tests/pixbuf-threads.c
+++ b/tests/pixbuf-threads.c
@@ -78,20 +78,16 @@ load_image (gpointer data,
g_object_unref (loader);
}
-static void
-usage (void)
-{
- g_print ("usage: pixbuf-threads [--verbose] <files>\n");
- exit (EXIT_FAILURE);
-}
-
int
main (int argc, char **argv)
{
int i, start;
GThreadPool *pool;
+ GPtrArray *files = g_ptr_array_new_with_free_func ((GDestroyNotify)g_free);
int l, iterations;
+ g_test_init (&argc, &argv, NULL);
+
#if !GLIB_CHECK_VERSION (2, 35, 3)
g_type_init ();
#endif
@@ -108,11 +104,8 @@ main (int argc, char **argv)
g_log_set_always_fatal (G_LOG_LEVEL_WARNING | G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL);
- if (argc == 1)
- usage();
-
start = 1;
- if (strcmp (argv[1], "--verbose") == 0)
+ if (argc > 1 && strcmp (argv[1], "--verbose") == 0)
{
verbose = TRUE;
start = 2;
@@ -121,19 +114,27 @@ main (int argc, char **argv)
pool = g_thread_pool_new (load_image, NULL, 20, FALSE, NULL);
l = 0;
- i = start;
- while (1) {
- i++;
- if (i == argc)
- {
- i = start;
- l++;
- }
- g_thread_pool_push (pool, argv[i], NULL);
- if (verbose) g_print ("now %d items pending\n", g_thread_pool_unprocessed (pool));
- if (l == iterations)
- break;
- }
+
+ for (i = start; i < argc; i++)
+ g_ptr_array_add (files, argv[i]);
+
+ if (files->len == 0)
+ {
+ const gchar *distdir = g_test_get_dir (G_TEST_DIST);
+ g_ptr_array_add (files, g_build_filename (distdir, "test-images", "valid_jpeg_progressive_test", NULL));
+ g_ptr_array_add (files, g_build_filename (distdir, "test-images", "valid_png_test", NULL));
+ }
+
+ g_assert_cmpint (files->len, >, 0);
+
+ for (l = 0; l < iterations; l++)
+ {
+ for (i = 0; i < files->len; i++)
+ {
+ g_thread_pool_push (pool, files->pdata[i], NULL);
+ if (verbose) g_print ("now %d items pending\n", g_thread_pool_unprocessed (pool));
+ }
+ }
g_thread_pool_free (pool, FALSE, TRUE);