[cairo-commit] 3 commits - boilerplate/cairo-boilerplate-pdf.c boilerplate/cairo-boilerplate-ps.c boilerplate/cairo-boilerplate-svg.c configure.in test/font-options.c test/png.c test/user-data.c

Chris Wilson ickle at kemper.freedesktop.org
Mon Aug 18 10:02:01 PDT 2008


 boilerplate/cairo-boilerplate-pdf.c |   13 ++++++-
 boilerplate/cairo-boilerplate-ps.c  |   17 +++++++--
 boilerplate/cairo-boilerplate-svg.c |   13 ++++++-
 configure.in                        |    9 ++++-
 test/font-options.c                 |   19 +++-------
 test/png.c                          |   64 ++++++++++++++++++------------------
 test/user-data.c                    |   10 ++++-
 7 files changed, 92 insertions(+), 53 deletions(-)

New commits:
commit 4cd478b95f0ae803d1a0ab75197b1d389e2eba4c
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Aug 18 17:51:21 2008 +0100

    [test] Initialise test context.
    
    Fixup a couple more tests that do not initialise a test context for
    themselves.

diff --git a/test/font-options.c b/test/font-options.c
index 3e5194c..90c7441 100644
--- a/test/font-options.c
+++ b/test/font-options.c
@@ -23,21 +23,15 @@
  * Author: Chris Wilson <chris at chris-wilson.co.uk>
  */
 
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
+#include "cairo-test.h"
 
 #include <cairo.h>
 #include <assert.h>
-#include <stdlib.h>
-
-#if HAVE_FCFINI
-#include <fontconfig/fontconfig.h>
-#endif
 
 int
 main (void)
 {
+    cairo_test_context_t ctx;
     cairo_font_options_t *default_options;
     cairo_font_options_t *nil_options;
     cairo_surface_t *surface;
@@ -45,6 +39,8 @@ main (void)
     cairo_t *cr;
     cairo_scaled_font_t *scaled_font;
 
+    cairo_test_init (&ctx, "font-options");
+
     /* first check NULL handling of cairo_font_options_t */
     default_options = cairo_font_options_create ();
     assert (cairo_font_options_status (default_options) == CAIRO_STATUS_SUCCESS);
@@ -111,10 +107,7 @@ main (void)
 
     cairo_destroy (cr);
 
-    cairo_debug_reset_static_data ();
-#if HAVE_FCFINI
-    FcFini ();
-#endif
+    cairo_test_fini (&ctx);
 
-    return 0;
+    return CAIRO_TEST_SUCCESS;
 }
diff --git a/test/png.c b/test/png.c
index 65e465d..23fc9fe 100644
--- a/test/png.c
+++ b/test/png.c
@@ -23,15 +23,9 @@
  * Author: Chris Wilson <chris at chris-wilson.co.uk>
  */
 
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
 #include "cairo-test.h"
 
 #include <cairo.h>
-#include <stdio.h>
-#include <stdint.h>
 #include <assert.h>
 
 /* Test the idempotency of write_png->read_png */
@@ -69,20 +63,25 @@ format_to_string (cairo_format_t format)
 }
 
 static void
-print_surface (cairo_surface_t *surface)
+print_surface (cairo_test_context_t *ctx, cairo_surface_t *surface)
 {
-    printf ("%s (%dx%d)\n",
-	    format_to_string (cairo_image_surface_get_format (surface)),
-	    cairo_image_surface_get_width (surface),
-	    cairo_image_surface_get_height (surface));
+    cairo_test_log (ctx,
+		    "%s (%dx%d)\n",
+		    format_to_string (cairo_image_surface_get_format (surface)),
+		    cairo_image_surface_get_width (surface),
+		    cairo_image_surface_get_height (surface));
 }
 
 int
 main (void)
 {
+    cairo_test_context_t ctx;
     cairo_surface_t *surface0, *surface1;
     cairo_status_t status;
     uint32_t argb32 = 0xdeadbede;
+    cairo_test_status_t result = CAIRO_TEST_SUCCESS;
+
+    cairo_test_init (&ctx, "png");
 
     surface0 = cairo_image_surface_create_for_data ((unsigned char *) &argb32,
 						    CAIRO_FORMAT_ARGB32,
@@ -90,23 +89,23 @@ main (void)
     assert (cairo_surface_status (surface0) == CAIRO_STATUS_SUCCESS);
     status = cairo_surface_write_to_png (surface0, "png-test.png");
     if (status) {
-	printf ("Error writing 'png-test.png': %s\n",
-		cairo_status_to_string (status));
-	return CAIRO_TEST_FAILURE;
+	cairo_test_log (&ctx, "Error writing 'png-test.png': %s\n",
+			cairo_status_to_string (status));
+	result = CAIRO_TEST_FAILURE;
     }
     surface1 = cairo_image_surface_create_from_png ("png-test.png");
     status = cairo_surface_status (surface1);
     if (status) {
-	printf ("Error reading 'png-test.png': %s\n",
-		cairo_status_to_string (status));
-	return CAIRO_TEST_FAILURE;
+	cairo_test_log (&ctx, "Error reading 'png-test.png': %s\n",
+			cairo_status_to_string (status));
+	result = CAIRO_TEST_FAILURE;
     }
 
     if (! image_surface_equals (surface0, surface1)) {
-	printf ("Error surface mismatch.\n");
-	printf ("to png: "); print_surface (surface0);
-	printf ("from png: "); print_surface (surface1);
-	return CAIRO_TEST_FAILURE;
+	cairo_test_log (&ctx, "Error surface mismatch.\n");
+	cairo_test_log (&ctx, "to png: "); print_surface (&ctx, surface0);
+	cairo_test_log (&ctx, "from png: "); print_surface (&ctx, surface1);
+	result = CAIRO_TEST_FAILURE;
     }
     assert (*(uint32_t *) cairo_image_surface_get_data (surface1) == argb32);
 
@@ -120,23 +119,23 @@ main (void)
     assert (cairo_surface_status (surface0) == CAIRO_STATUS_SUCCESS);
     status = cairo_surface_write_to_png (surface0, "png-test.png");
     if (status) {
-	printf ("Error writing 'png-test.png': %s\n",
-		cairo_status_to_string (status));
-	return CAIRO_TEST_FAILURE;
+	cairo_test_log (&ctx, "Error writing 'png-test.png': %s\n",
+			cairo_status_to_string (status));
+	result = CAIRO_TEST_FAILURE;
     }
     surface1 = cairo_image_surface_create_from_png ("png-test.png");
     status = cairo_surface_status (surface1);
     if (status) {
-	printf ("Error reading 'png-test.png': %s\n",
-		cairo_status_to_string (status));
-	return CAIRO_TEST_FAILURE;
+	cairo_test_log (&ctx, "Error reading 'png-test.png': %s\n",
+			cairo_status_to_string (status));
+	result = CAIRO_TEST_FAILURE;
     }
 
     if (! image_surface_equals (surface0, surface1)) {
-	printf ("Error surface mismatch.\n");
-	printf ("to png: "); print_surface (surface0);
-	printf ("from png: "); print_surface (surface1);
-	return CAIRO_TEST_FAILURE;
+	cairo_test_log (&ctx, "Error surface mismatch.\n");
+	cairo_test_log (&ctx, "to png: "); print_surface (&ctx, surface0);
+	cairo_test_log (&ctx, "from png: "); print_surface (&ctx, surface1);
+	result = CAIRO_TEST_FAILURE;
     }
     assert ((*(uint32_t *) cairo_image_surface_get_data (surface1) & RGB_MASK)
 	    == (argb32 & RGB_MASK));
@@ -144,6 +143,7 @@ main (void)
     cairo_surface_destroy (surface0);
     cairo_surface_destroy (surface1);
 
+    cairo_test_fini (&ctx);
 
-    return CAIRO_TEST_SUCCESS;
+    return result;
 }
diff --git a/test/user-data.c b/test/user-data.c
index 187e765..c4e630c 100644
--- a/test/user-data.c
+++ b/test/user-data.c
@@ -23,9 +23,10 @@
  * Author: Kristian Høgsberg <krh at redhat.com>
  */
 
+#include "cairo-test.h"
+
 #include <cairo.h>
 #include <assert.h>
-#include <stdlib.h>
 
 static void
 destroy_data1 (void *p)
@@ -42,10 +43,13 @@ destroy_data2 (void *p)
 int
 main (void)
 {
+    cairo_test_context_t ctx;
     cairo_surface_t *surface;
     static const cairo_user_data_key_t key1, key2;
     int data1, data2;
 
+    cairo_test_init (&ctx, "user-data");
+
     data1 = 0;
     data2 = 0;
     surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 1, 1);
@@ -78,5 +82,7 @@ main (void)
     assert (data1 == 1);
     assert (data2 == 2);
 
-    return 0;
+    cairo_test_fini (&ctx);
+
+    return CAIRO_TEST_SUCCESS;
 }
commit cdd021b5fbeb53247e6e1aa7224a8faa60249dc7
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Aug 18 17:48:55 2008 +0100

    [boilerplate] Check exit code from system for trapped signals.
    
    If the external conversion utility was killed by a signal (e.g. the user
    sent SIGINT), raise that signal within our process as well. This means
    that a crash inside poppler or rsvg will be flagged as a crash inside the
    test suite, and makes interrupting the test suite far more responsive.

diff --git a/boilerplate/cairo-boilerplate-pdf.c b/boilerplate/cairo-boilerplate-pdf.c
index dc76435..791951b 100644
--- a/boilerplate/cairo-boilerplate-pdf.c
+++ b/boilerplate/cairo-boilerplate-pdf.c
@@ -32,6 +32,11 @@
 #include <cairo-pdf-surface-private.h>
 #include <cairo-paginated-surface-private.h>
 
+#if HAVE_SIGNAL_H
+#include <stdlib.h>
+#include <signal.h>
+#endif
+
 cairo_user_data_key_t pdf_closure_key;
 
 typedef struct _pdf_target_closure
@@ -108,6 +113,7 @@ _cairo_boilerplate_pdf_surface_write_to_png (cairo_surface_t *surface, const cha
     pdf_target_closure_t *ptc = cairo_surface_get_user_data (surface, &pdf_closure_key);
     char    command[4096];
     cairo_status_t status;
+    int exitstatus;
 
     /* Both surface and ptc->target were originally created at the
      * same dimensions. We want a 1:1 copy here, so we first clear any
@@ -146,7 +152,12 @@ _cairo_boilerplate_pdf_surface_write_to_png (cairo_surface_t *surface, const cha
     sprintf (command, "./pdf2png %s %s 1",
 	     ptc->filename, filename);
 
-    if (system (command) != 0)
+    exitstatus = system (command);
+#if _XOPEN_SOURCE && HAVE_SIGNAL_H
+    if (WIFSIGNALED (exitstatus))
+	raise (WTERMSIG (exitstatus));
+#endif
+    if (exitstatus)
 	return CAIRO_STATUS_WRITE_ERROR;
 
     return CAIRO_STATUS_SUCCESS;
diff --git a/boilerplate/cairo-boilerplate-ps.c b/boilerplate/cairo-boilerplate-ps.c
index f21d172..f1bd6e2 100644
--- a/boilerplate/cairo-boilerplate-ps.c
+++ b/boilerplate/cairo-boilerplate-ps.c
@@ -32,6 +32,11 @@
 #include <cairo-ps-surface-private.h>
 #include <cairo-paginated-surface-private.h>
 
+#if HAVE_SIGNAL_H
+#include <stdlib.h>
+#include <signal.h>
+#endif
+
 cairo_user_data_key_t	ps_closure_key;
 
 typedef struct _ps_target_closure
@@ -107,6 +112,7 @@ _cairo_boilerplate_ps_surface_write_to_png (cairo_surface_t *surface, const char
 							    &ps_closure_key);
     char    command[4096];
     cairo_status_t status;
+    int exitstatus;
 
     /* Both surface and ptc->target were originally created at the
      * same dimensions. We want a 1:1 copy here, so we first clear any
@@ -144,10 +150,15 @@ _cairo_boilerplate_ps_surface_write_to_png (cairo_surface_t *surface, const char
 
     sprintf (command, "gs -q -r72 -g%dx%d -dSAFER -dBATCH -dNOPAUSE -sDEVICE=pngalpha -sOutputFile=%s %s",
 	     ptc->width, ptc->height, filename, ptc->filename);
-    if (system (command) == 0)
-	return CAIRO_STATUS_SUCCESS;
+    exitstatus = system (command);
+#if _XOPEN_SOURCE && HAVE_SIGNAL_H
+    if (WIFSIGNALED (exitstatus))
+	raise (WTERMSIG (exitstatus));
+#endif
+    if (exitstatus)
+	return CAIRO_STATUS_WRITE_ERROR;
 
-    return CAIRO_STATUS_WRITE_ERROR;
+    return CAIRO_STATUS_SUCCESS;
 }
 
 cairo_surface_t *
diff --git a/boilerplate/cairo-boilerplate-svg.c b/boilerplate/cairo-boilerplate-svg.c
index d931847..afa5634 100644
--- a/boilerplate/cairo-boilerplate-svg.c
+++ b/boilerplate/cairo-boilerplate-svg.c
@@ -32,6 +32,11 @@
 #include <cairo-svg-surface-private.h>
 #include <cairo-paginated-surface-private.h>
 
+#if HAVE_SIGNAL_H
+#include <stdlib.h>
+#include <signal.h>
+#endif
+
 cairo_user_data_key_t	svg_closure_key;
 
 typedef struct _svg_target_closure
@@ -101,6 +106,7 @@ _cairo_boilerplate_svg_surface_write_to_png (cairo_surface_t *surface, const cha
     svg_target_closure_t *ptc = cairo_surface_get_user_data (surface, &svg_closure_key);
     char    command[4096];
     cairo_status_t status;
+    int exitstatus;
 
     /* Both surface and ptc->target were originally created at the
      * same dimensions. We want a 1:1 copy here, so we first clear any
@@ -139,7 +145,12 @@ _cairo_boilerplate_svg_surface_write_to_png (cairo_surface_t *surface, const cha
     sprintf (command, "./svg2png %s %s",
 	     ptc->filename, filename);
 
-    if (system (command) != 0)
+    exitstatus = system (command);
+#if _XOPEN_SOURCE && HAVE_SIGNAL_H
+    if (WIFSIGNALED (exitstatus))
+	raise (WTERMSIG (exitstatus));
+#endif
+    if (exitstatus)
 	return CAIRO_STATUS_WRITE_ERROR;
 
     return CAIRO_STATUS_SUCCESS;
commit 95575d7a6977a21960818f81aa267725edcd8d93
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Aug 18 17:13:25 2008 +0100

    [configure.in] Add release status
    
    Print out whether the current version represents a release, a development
    snapshot or is being compiled from git.

diff --git a/configure.in b/configure.in
index 37617bb..c8ab95c 100644
--- a/configure.in
+++ b/configure.in
@@ -9,6 +9,11 @@ m4_define(cairo_version_major, 1)
 m4_define(cairo_version_minor, 7)
 m4_define(cairo_version_micro, 5)
 
+m4_define([cairo_release_status],
+	  [m4_if(m4_eval(cairo_version_micro % 2), [1], [git],
+	         [m4_if(m4_eval(cairo_version_minor % 2), [1], [snapshot],
+		                                               [release])])])
+
 AC_INIT([cairo],
       cairo_version_major.cairo_version_minor.cairo_version_micro,
       [http://bugs.freedesktop.org/enter_bug.cgi?product=cairo])
@@ -49,9 +54,11 @@ AC_SUBST(LT_CURRENT_MINUS_AGE)
 CAIRO_VERSION_MAJOR=cairo_version_major()
 CAIRO_VERSION_MINOR=cairo_version_minor()
 CAIRO_VERSION_MICRO=cairo_version_micro()
+CAIRO_RELEASE_STATUS=cairo_release_status()
 AC_SUBST(CAIRO_VERSION_MAJOR)
 AC_SUBST(CAIRO_VERSION_MINOR)
 AC_SUBST(CAIRO_VERSION_MICRO)
+AC_SUBST(CAIRO_RELEASE_STATUS)
 
 dnl ===========================================================================
 
@@ -1096,7 +1103,7 @@ dnl ===========================================================================
 
 V="$CAIRO_VERSION_MAJOR.$CAIRO_VERSION_MINOR.$CAIRO_VERSION_MICRO"
 echo ""
-echo "cairo (version $V) will be compiled with the following surface backends:"
+echo "cairo (version $V [[$CAIRO_RELEASE_STATUS]]) will be compiled with the following surface backends:"
 echo "  image:         yes (always builtin)"
 echo "  Xlib:          $use_xlib"
 echo "  Xlib Xrender:  $use_xlib_xrender"


More information about the cairo-commit mailing list