summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2013-05-22 23:00:25 -0400
committerMatthias Clasen <mclasen@redhat.com>2013-05-22 23:00:25 -0400
commit97c719eed2197625d4f9fe92907748dff876cc80 (patch)
treee7dd66fb94553c8d26c80ca8e9b865b47463c465
parent90bbdc77039b24f30362264936fdb025283f64fe (diff)
downloadgdk-pixbuf-97c719eed2197625d4f9fe92907748dff876cc80.tar.gz
Install some pixbuf tests
Make it possible to limit the iterations of the pixbuf-threads and pixbuf-randomly-modified tests, and run them installed on some of the test images in tests/test-images.
-rw-r--r--configure.ac7
-rw-r--r--tests/Makefile.am29
-rw-r--r--tests/pixbuf-icon-serialize.test.in3
-rw-r--r--tests/pixbuf-randomly-modified.c20
-rw-r--r--tests/pixbuf-randomly-modified.test.in3
-rw-r--r--tests/pixbuf-threads.c21
-rw-r--r--tests/pixbuf-threads.test.in3
7 files changed, 75 insertions, 11 deletions
diff --git a/configure.ac b/configure.ac
index 9fe54ed7c..e653ea397 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1026,6 +1026,13 @@ fi
AC_SUBST(GDK_PIXBUF_LINK_FLAGS)
+AC_ARG_ENABLE(installed_tests,
+ AS_HELP_STRING([--enable-installed-tests],
+ [Install test programs (default: no)]),,
+ [enable_installed_tests=no])
+AM_CONDITIONAL(BUILDOPT_INSTALL_TESTS, test x$enable_installed_tests = xyes)
+
+
##################################################
# Output commands
##################################################
diff --git a/tests/Makefile.am b/tests/Makefile.am
index de12a12e3..f09904caa 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,5 +1,7 @@
include $(top_srcdir)/Makefile.decl
+NULL =
+
INCLUDES = \
-I$(top_srcdir) \
-I$(top_srcdir)/gdk-pixbuf \
@@ -30,5 +32,32 @@ pixbuf_random_LDADD = $(LDADDS)
pixbuf_threads_LDADD = $(LDADDS) $(GLIB_LIBS)
pixbuf_icon_serialize_LDADD = $(LDADDS) $(GLIB_LIBS)
+if BUILDOPT_INSTALL_TESTS
+insttestdir = $(pkglibexecdir)/installed-tests
+insttest_PROGRAMS = \
+ pixbuf-icon-serialize \
+ pixbuf-randomly-modified \
+ pixbuf-threads \
+ $(NULL)
+
+testimagedir = $(insttestdir)/test-images
+testimage_DATA = $(wildcard test-images/*)
+
+substitutions = \
+ -e s,@pkglibexecdir\@,$(pkglibexecdir),g \
+ $(NULL)
+
+test_in_files = $(insttest_PROGRAMS:=.test.in)
+test_files = $(test_in_files:.test.in=.test)
+
+$(test_files): %.test: %.test.in
+ $(AM_V_GEN) sed $(substitutions) $< > $@.tmp && mv $@.tmp $@
+
+EXTRA_DIST += $(test_in_files)
+
+testmetadir = $(datadir)/installed-tests/$(PACKAGE)
+testmeta_DATA = $(test_files)
+
+endif
-include $(top_srcdir)/git.mk
diff --git a/tests/pixbuf-icon-serialize.test.in b/tests/pixbuf-icon-serialize.test.in
new file mode 100644
index 000000000..1e7babde8
--- /dev/null
+++ b/tests/pixbuf-icon-serialize.test.in
@@ -0,0 +1,3 @@
+[Test]
+Exec=/bin/sh -c "@pkglibexecdir@/installed-tests/pixbuf-icon-serialize"
+Type=session
diff --git a/tests/pixbuf-randomly-modified.c b/tests/pixbuf-randomly-modified.c
index 9d3efe8fc..3367e24af 100644
--- a/tests/pixbuf-randomly-modified.c
+++ b/tests/pixbuf-randomly-modified.c
@@ -98,18 +98,22 @@ main (int argc, char **argv)
int seed, i;
gboolean got_seed = FALSE;
GPtrArray *files = g_ptr_array_new ();
+ int l, iterations;
+
+ if (g_getenv ("ITERATIONS"))
+ iterations = atoi (g_getenv ("ITERATIONS"));
+ else
+ iterations = 1000;
if (argc == 1)
usage ();
-
+
seed = time (NULL);
for (i = 1; i < argc; ++i)
{
- if (strncmp (argv[i], "-s", 2) == 0)
+ if (strcmp (argv[i], "-s") == 0)
{
- if (strlen (argv[i]) > 2)
- usage();
if (i+1 < argc)
{
seed = atoi (argv[i+1]);
@@ -135,13 +139,13 @@ main (int argc, char **argv)
#endif
g_log_set_always_fatal (G_LOG_LEVEL_WARNING | G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL);
- for (;;)
+ for (l = 0; l < iterations; l++)
for (i = 0; i < files->len; ++i)
{
gchar *contents;
gsize size;
GError *err = NULL;
-
+
fflush (stdout);
if (!g_file_get_contents (files->pdata[i], &contents, &size, &err))
{
@@ -152,10 +156,10 @@ main (int argc, char **argv)
g_print ("%s\t\t", (char *)files->pdata[i]);
randomly_modify (contents, size);
g_print ("done\n");
-
+
g_free (contents);
}
}
-
+
return 0;
}
diff --git a/tests/pixbuf-randomly-modified.test.in b/tests/pixbuf-randomly-modified.test.in
new file mode 100644
index 000000000..0ab9a0c61
--- /dev/null
+++ b/tests/pixbuf-randomly-modified.test.in
@@ -0,0 +1,3 @@
+[Test]
+Exec=sh -c "env ITERATIONS=50 @pkglibexecdir@/installed-tests/pixbuf-randomly-modified @pkglibexecdir@/installed-tests/test-images/*"
+Type=session
diff --git a/tests/pixbuf-threads.c b/tests/pixbuf-threads.c
index c0118fd85..e9ae41a6f 100644
--- a/tests/pixbuf-threads.c
+++ b/tests/pixbuf-threads.c
@@ -86,6 +86,7 @@ main (int argc, char **argv)
{
int i, start;
GThreadPool *pool;
+ int l, iterations;
#if !GLIB_CHECK_VERSION (2, 35, 3)
g_type_init ();
@@ -96,6 +97,11 @@ main (int argc, char **argv)
g_thread_init (NULL);
#endif
+ if (g_getenv ("ITERATIONS"))
+ iterations = atoi (g_getenv ("ITERATIONS"));
+ else
+ iterations = 1000;
+
g_log_set_always_fatal (G_LOG_LEVEL_WARNING | G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL);
if (argc == 1)
@@ -107,16 +113,25 @@ main (int argc, char **argv)
verbose = TRUE;
start = 2;
}
-
+
pool = g_thread_pool_new (load_image, NULL, 20, FALSE, NULL);
+ l = 0;
i = start;
while (1) {
i++;
if (i == argc)
- i = start;
+ {
+ 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;
}
-
+
+ g_thread_pool_free (pool, FALSE, TRUE);
+
return 0;
}
diff --git a/tests/pixbuf-threads.test.in b/tests/pixbuf-threads.test.in
new file mode 100644
index 000000000..dbe2a99b2
--- /dev/null
+++ b/tests/pixbuf-threads.test.in
@@ -0,0 +1,3 @@
+[Test]
+Exec=sh -c "env ITERATIONS=50 @pkglibexecdir@/installed-tests/pixbuf-threads @pkglibexecdir@/installed-tests/test-images/{valid_jpeg_progressive_test,valid_png_test}"
+Type=session