summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2009-07-28 08:05:22 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2009-07-28 08:41:50 +0100
commit24b5ac6377f0e4b76b73460a497b9861fc01a889 (patch)
treed0e65b1b24c35e7856c98b6336e64c163cc35aa5 /test
parentdacc380dd9ea23fe060d0397104ecd4b2a6d0eae (diff)
[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().
Diffstat (limited to 'test')
-rw-r--r--test/cairo-test.c14
1 files 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) {