[gdk-pixbuf] Install some pixbuf tests



commit 97c719eed2197625d4f9fe92907748dff876cc80
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed May 22 23:00:25 2013 -0400

    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.

 configure.ac                           |    7 +++++++
 tests/Makefile.am                      |   29 +++++++++++++++++++++++++++++
 tests/pixbuf-icon-serialize.test.in    |    3 +++
 tests/pixbuf-randomly-modified.c       |   20 ++++++++++++--------
 tests/pixbuf-randomly-modified.test.in |    3 +++
 tests/pixbuf-threads.c                 |   21 ++++++++++++++++++---
 tests/pixbuf-threads.test.in           |    3 +++
 7 files changed, 75 insertions(+), 11 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 9fe54ed..e653ea3 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 de12a12..f09904c 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 0000000..1e7babd
--- /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 9d3efe8..3367e24 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 0000000..0ab9a0c
--- /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 c0118fd..e9ae41a 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 0000000..dbe2a99
--- /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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]