diff --git a/test/cairo-test.c b/test/cairo-test.c index 8e70f9508..9d245ad12 100644 --- a/test/cairo-test.c +++ b/test/cairo-test.c @@ -1031,3 +1031,22 @@ cairo_test_paint_checkered (cairo_t *cr) return status; } + +cairo_bool_t +cairo_test_is_target_enabled (const cairo_test_context_t *ctx, const char *target) +{ + size_t i; + + for (i = 0; i < ctx->num_targets; i++) { + const cairo_boilerplate_target_t *t = ctx->targets_to_test[i]; + if (strcmp (t->name, target) == 0) { + /* XXX ask the target whether is it possible to run? + * e.g. the xlib backend could check whether it is able to connect + * to the Display. + */ + return TRUE; + } + } + + return FALSE; +} diff --git a/test/cairo-test.h b/test/cairo-test.h index 09f5fd875..4c3cbced1 100644 --- a/test/cairo-test.h +++ b/test/cairo-test.h @@ -176,6 +176,10 @@ cairo_test_paint_checkered (cairo_t *cr); #define CAIRO_TEST_DOUBLE_EQUALS(a,b) (fabs((a)-(b)) < 0.00001) +cairo_bool_t +cairo_test_is_target_enabled (const cairo_test_context_t *ctx, + const char *target); + CAIRO_END_DECLS #endif diff --git a/test/create-for-stream.c b/test/create-for-stream.c index 9d90cf4ef..211d2c4a3 100644 --- a/test/create-for-stream.c +++ b/test/create-for-stream.c @@ -243,36 +243,42 @@ main (void) cairo_test_init (&ctx, test_name); #if CAIRO_HAS_PS_SURFACE - test_status = test_surface (&ctx, "ps", "create-for-stream.ps", - cairo_ps_surface_create, - cairo_ps_surface_create_for_stream); - cairo_test_log (&ctx, "TEST: %s TARGET: %s RESULT: %s\n", - test_name, "ps", - test_status ? "FAIL" : "PASS"); - if (status == CAIRO_TEST_SUCCESS) - status = test_status; + if (cairo_test_is_target_enabled (&ctx, "ps")) { + test_status = test_surface (&ctx, "ps", "create-for-stream.ps", + cairo_ps_surface_create, + cairo_ps_surface_create_for_stream); + cairo_test_log (&ctx, "TEST: %s TARGET: %s RESULT: %s\n", + test_name, "ps", + test_status ? "FAIL" : "PASS"); + if (status == CAIRO_TEST_SUCCESS) + status = test_status; + } #endif #if CAIRO_HAS_PDF_SURFACE - test_status = test_surface (&ctx, "pdf", "create-for-stream.pdf", - cairo_pdf_surface_create, - cairo_pdf_surface_create_for_stream); - cairo_test_log (&ctx, "TEST: %s TARGET: %s RESULT: %s\n", - test_name, "pdf", - test_status ? "FAIL" : "PASS"); - if (status == CAIRO_TEST_SUCCESS) - status = test_status; + if (cairo_test_is_target_enabled (&ctx, "pdf")) { + test_status = test_surface (&ctx, "pdf", "create-for-stream.pdf", + cairo_pdf_surface_create, + cairo_pdf_surface_create_for_stream); + cairo_test_log (&ctx, "TEST: %s TARGET: %s RESULT: %s\n", + test_name, "pdf", + test_status ? "FAIL" : "PASS"); + if (status == CAIRO_TEST_SUCCESS) + status = test_status; + } #endif #if CAIRO_HAS_SVG_SURFACE - test_status = test_surface (&ctx, "svg", "create-for-stream.svg", - cairo_svg_surface_create, - cairo_svg_surface_create_for_stream); - cairo_test_log (&ctx, "TEST: %s TARGET: %s RESULT: %s\n", - test_name, "svg", - test_status ? "FAIL" : "PASS"); - if (status == CAIRO_TEST_SUCCESS) - status = test_status; + if (cairo_test_is_target_enabled (&ctx, "svg")) { + test_status = test_surface (&ctx, "svg", "create-for-stream.svg", + cairo_svg_surface_create, + cairo_svg_surface_create_for_stream); + cairo_test_log (&ctx, "TEST: %s TARGET: %s RESULT: %s\n", + test_name, "svg", + test_status ? "FAIL" : "PASS"); + if (status == CAIRO_TEST_SUCCESS) + status = test_status; + } #endif cairo_test_fini (&ctx); diff --git a/test/fallback-resolution.c b/test/fallback-resolution.c index aa1be92a7..44b467b96 100644 --- a/test/fallback-resolution.c +++ b/test/fallback-resolution.c @@ -89,7 +89,6 @@ int main (void) { cairo_test_context_t ctx; - cairo_surface_t *surface = NULL; cairo_t *cr; cairo_status_t status; cairo_test_status_t ret = CAIRO_TEST_SUCCESS; @@ -102,27 +101,37 @@ main (void) cairo_test_init (&ctx, "fallback-resolution"); for (backend=0; backend < NUM_BACKENDS; backend++) { + cairo_surface_t *surface = NULL; /* Create backend-specific surface and force image fallbacks. */ switch (backend) { case PDF: - surface = cairo_pdf_surface_create (backend_filename[backend], - SIZE, SIZE); - cairo_boilerplate_pdf_surface_force_fallbacks (surface); + if (cairo_test_is_target_enabled (&ctx, "pdf")) { + surface = cairo_pdf_surface_create (backend_filename[backend], + SIZE, SIZE); + cairo_boilerplate_pdf_surface_force_fallbacks (surface); + } break; case PS: - surface = cairo_ps_surface_create (backend_filename[backend], - SIZE, SIZE); - cairo_boilerplate_ps_surface_force_fallbacks (surface); + if (cairo_test_is_target_enabled (&ctx, "ps")) { + surface = cairo_ps_surface_create (backend_filename[backend], + SIZE, SIZE); + cairo_boilerplate_ps_surface_force_fallbacks (surface); + } break; case SVG: - surface = cairo_svg_surface_create (backend_filename[backend], - SIZE, SIZE); - cairo_boilerplate_svg_surface_force_fallbacks (surface); - cairo_svg_surface_restrict_to_version (surface, CAIRO_SVG_VERSION_1_2); + if (cairo_test_is_target_enabled (&ctx, "svg")) { + surface = cairo_svg_surface_create (backend_filename[backend], + SIZE, SIZE); + cairo_boilerplate_svg_surface_force_fallbacks (surface); + cairo_svg_surface_restrict_to_version (surface, CAIRO_SVG_VERSION_1_2); + } break; } + if (surface == NULL) + continue; + cr = cairo_create (surface); cairo_set_tolerance (cr, 3.0); diff --git a/test/get-xrender-format.c b/test/get-xrender-format.c index fbb7d0c92..e14728247 100644 --- a/test/get-xrender-format.c +++ b/test/get-xrender-format.c @@ -42,6 +42,10 @@ main (void) int screen; cairo_test_init (&ctx, "get-xrender-format"); + if (! cairo_test_is_target_enabled (&ctx, "xlib")) { + cairo_test_fini (&ctx); + return CAIRO_TEST_UNTESTED; + } dpy = XOpenDisplay (NULL); if (! dpy) { diff --git a/test/multi-page.c b/test/multi-page.c index 4e0749afe..bf33dad8b 100644 --- a/test/multi-page.c +++ b/test/multi-page.c @@ -139,41 +139,45 @@ main (void) cairo_test_init (&ctx, "multi-page"); #if CAIRO_HAS_PS_SURFACE - filename = "multi-page.ps"; + if (cairo_test_is_target_enabled (&ctx, "ps")) { + filename = "multi-page.ps"; - surface = cairo_ps_surface_create (filename, - WIDTH_IN_POINTS, HEIGHT_IN_POINTS); - status = cairo_surface_status (surface); - if (status) { - cairo_test_log (&ctx, "Failed to create ps surface for file %s: %s\n", - filename, cairo_status_to_string (status)); - result = CAIRO_TEST_FAILURE; + surface = cairo_ps_surface_create (filename, + WIDTH_IN_POINTS, HEIGHT_IN_POINTS); + status = cairo_surface_status (surface); + if (status) { + cairo_test_log (&ctx, "Failed to create ps surface for file %s: %s\n", + filename, cairo_status_to_string (status)); + result = CAIRO_TEST_FAILURE; + } + + draw_some_pages (surface); + + cairo_surface_destroy (surface); + + printf ("multi-page: Please check %s to ensure it looks happy.\n", filename); } - - draw_some_pages (surface); - - cairo_surface_destroy (surface); - - printf ("multi-page: Please check %s to ensure it looks happy.\n", filename); #endif #if CAIRO_HAS_PDF_SURFACE - filename = "multi-page.pdf"; + if (cairo_test_is_target_enabled (&ctx, "pdf")) { + filename = "multi-page.pdf"; - surface = cairo_pdf_surface_create (filename, - WIDTH_IN_POINTS, HEIGHT_IN_POINTS); - status = cairo_surface_status (surface); - if (status) { - cairo_test_log (&ctx, "Failed to create pdf surface for file %s: %s\n", - filename, cairo_status_to_string (status)); - result = CAIRO_TEST_FAILURE; + surface = cairo_pdf_surface_create (filename, + WIDTH_IN_POINTS, HEIGHT_IN_POINTS); + status = cairo_surface_status (surface); + if (status) { + cairo_test_log (&ctx, "Failed to create pdf surface for file %s: %s\n", + filename, cairo_status_to_string (status)); + result = CAIRO_TEST_FAILURE; + } + + draw_some_pages (surface); + + cairo_surface_destroy (surface); + + printf ("multi-page: Please check %s to ensure it looks happy.\n", filename); } - - draw_some_pages (surface); - - cairo_surface_destroy (surface); - - printf ("multi-page: Please check %s to ensure it looks happy.\n", filename); #endif cairo_test_fini (&ctx); diff --git a/test/pdf-features.c b/test/pdf-features.c index 74804cd84..e8616850d 100644 --- a/test/pdf-features.c +++ b/test/pdf-features.c @@ -94,6 +94,10 @@ main (void) size_t i; cairo_test_init (&ctx, "pdf-features"); + if (! cairo_test_is_target_enabled (&ctx, "pdf")) { + cairo_test_fini (&ctx); + return CAIRO_TEST_UNTESTED; + } filename = "pdf-features.pdf"; diff --git a/test/ps-features.c b/test/ps-features.c index b3ac50d10..43c358736 100644 --- a/test/ps-features.c +++ b/test/ps-features.c @@ -98,6 +98,10 @@ main (void) char dsc[255]; cairo_test_init (&ctx, "ps-features"); + if (! cairo_test_is_target_enabled (&ctx, "ps")) { + cairo_test_fini (&ctx); + return CAIRO_TEST_UNTESTED; + } filename = "ps-features.ps"; diff --git a/test/svg-clip.c b/test/svg-clip.c index 0dfab4d87..0286677f3 100644 --- a/test/svg-clip.c +++ b/test/svg-clip.c @@ -112,6 +112,10 @@ main (void) cairo_surface_t *surface; cairo_test_init (&ctx, "svg-clip"); + if (! cairo_test_is_target_enabled (&ctx, "svg")) { + cairo_test_fini (&ctx); + return CAIRO_TEST_UNTESTED; + } surface = cairo_svg_surface_create (filename, WIDTH_IN_POINTS, HEIGHT_IN_POINTS); diff --git a/test/svg-surface.c b/test/svg-surface.c index f6b843ac9..9a626337d 100644 --- a/test/svg-surface.c +++ b/test/svg-surface.c @@ -95,6 +95,10 @@ main (void) cairo_surface_t *surface; cairo_test_init (&ctx, "svg-surface"); + if (! cairo_test_is_target_enabled (&ctx, "svg")) { + cairo_test_fini (&ctx); + return CAIRO_TEST_UNTESTED; + } surface = cairo_svg_surface_create (filename, WIDTH_IN_POINTS, HEIGHT_IN_POINTS); diff --git a/test/xlib-expose-event.c b/test/xlib-expose-event.c index c872047bc..0dbddac1f 100644 --- a/test/xlib-expose-event.c +++ b/test/xlib-expose-event.c @@ -213,6 +213,10 @@ main (void) cairo_test_status_t result = CAIRO_TEST_SUCCESS; cairo_test_init (&ctx, "xlib-expose-event"); + if (! cairo_test_is_target_enabled (&ctx, "xlib")) { + cairo_test_fini (&ctx); + return CAIRO_TEST_UNTESTED; + } dpy = XOpenDisplay (NULL); if (dpy == NULL) { diff --git a/test/xlib-surface.c b/test/xlib-surface.c index 20c2bc95a..71bbeab1d 100644 --- a/test/xlib-surface.c +++ b/test/xlib-surface.c @@ -303,6 +303,10 @@ main (void) int stride; cairo_test_init (&ctx, "xlib-surface"); + if (! cairo_test_is_target_enabled (&ctx, "xlib")) { + cairo_test_fini (&ctx); + return CAIRO_TEST_UNTESTED; + } dpy = XOpenDisplay (NULL); if (!dpy) {