From 24b5ac6377f0e4b76b73460a497b9861fc01a889 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Tue, 28 Jul 2009 08:05:22 +0100 Subject: [PATCH] [test] Add timeouts around finishing and converting surfaces to images. In order to catch infinite loops whilst replaying and converting vector surfaces to images (via external renderers) we need to also install alarms around the calls to finish() and get_image(). --- test/cairo-test.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/test/cairo-test.c b/test/cairo-test.c index 430acc17c..67323b5cf 100644 --- a/test/cairo-test.c +++ b/test/cairo-test.c @@ -90,6 +90,10 @@ #define ARRAY_SIZE(A) (sizeof(A) / sizeof (A[0])) #endif +#if ! HAVE_ALARM +#define alarm(X); +#endif + static const cairo_user_data_key_t _cairo_test_context_key; static void @@ -955,13 +959,9 @@ REPEAT: cairo_font_options_destroy (font_options); cairo_save (cr); -#if HAVE_ALARM alarm (ctx->timeout); -#endif status = (ctx->test->draw) (cr, ctx->test->width, ctx->test->height); -#if HAVE_ALARM alarm (0); -#endif cairo_restore (cr); if (similar) { @@ -1040,7 +1040,10 @@ REPEAT: MEMFAULT_ENABLE_FAULTS (); #endif + /* also check for infinite loops whilst replaying */ + alarm (ctx->timeout); diff_status = target->finish_surface (surface); + alarm (0); #if HAVE_MEMFAULT MEMFAULT_DISABLE_FAULTS (); @@ -1081,9 +1084,12 @@ REPEAT: /* we may be running this test to generate reference images */ _xunlink (ctx, out_png_path); + /* be more generous as we may need to use external renderers */ + alarm (4 * ctx->timeout); test_image = target->get_image_surface (surface, 0, ctx->test->width, ctx->test->height); + alarm (0); diff_status = cairo_surface_write_to_png (test_image, out_png_path); cairo_surface_destroy (test_image); if (diff_status) {