From d0672e85ef120a4e3cd0dfcbdb717afbf9526f17 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Mon, 7 Apr 2008 10:42:57 +0100 Subject: [PATCH] [test/surface-source] Skip tests if we cannot create the source surface. Check that the test environment supports the desired source and avoid triggering asserts in the test routines. --- test/glitz-surface-source.c | 15 ++++++++++----- test/surface-source.c | 8 ++++++++ 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/test/glitz-surface-source.c b/test/glitz-surface-source.c index d70940a12..2dfa7355a 100644 --- a/test/glitz-surface-source.c +++ b/test/glitz-surface-source.c @@ -28,8 +28,6 @@ #include #include -#include - #define NAME "glitz" #include "surface-source.c" @@ -174,18 +172,25 @@ static cairo_surface_t * create_source_surface (int size) { struct closure *closure; - glitz_surface_t * glitz_surface; + glitz_surface_t *glitz_surface; cairo_surface_t *surface; closure = xcalloc (1, sizeof (struct closure)); closure->dpy = XOpenDisplay (getenv("CAIRO_TEST_GLITZ_DISPLAY")); - assert (closure->dpy); + if (closure->dpy == NULL) { + free (closure); + return NULL; + } glitz_surface = _glitz_glx_create_surface (GLITZ_STANDARD_ARGB32, size, size, closure); - assert (glitz_surface != NULL); + if (glitz_surface == NULL) { + XCloseDisplay (closure->dpy); + free (closure); + return NULL; + } surface = cairo_glitz_surface_create (glitz_surface); diff --git a/test/surface-source.c b/test/surface-source.c index c7f333469..5a034ad09 100644 --- a/test/surface-source.c +++ b/test/surface-source.c @@ -89,5 +89,13 @@ draw (cairo_t *cr, int width, int height) int main (void) { + cairo_surface_t *surface; + + surface = create_source_surface (SIZE); + if (surface == NULL) /* can't create the source so skip the test */ + return CAIRO_TEST_SUCCESS; + + cairo_surface_destroy (surface); + return cairo_test (&test); }