[cairo-commit] 3 commits - build/configure.ac.system src/cairo-pattern.c test/cairo-test.c test/cairo-test.h util/cairo-script

Chris Wilson ickle at kemper.freedesktop.org
Sun Jun 28 13:13:57 PDT 2009


 build/configure.ac.system                |    3 +++
 src/cairo-pattern.c                      |    2 +-
 test/cairo-test.c                        |   18 ++++++++++++++++++
 test/cairo-test.h                        |    2 ++
 util/cairo-script/cairo-script-private.h |    1 +
 util/cairo-script/cairo-script-scanner.c |   15 ++++++++++++---
 6 files changed, 37 insertions(+), 4 deletions(-)

New commits:
commit d80f5580ef371a1d4b1746b4ad54d97274d2d6cd
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sun Jun 28 21:11:41 2009 +0100

    [pattern] Mark _cairo_pattern_nil as static
    
    Fixes check-def.sh failure.

diff --git a/src/cairo-pattern.c b/src/cairo-pattern.c
index 3e82650..9fe94ad 100644
--- a/src/cairo-pattern.c
+++ b/src/cairo-pattern.c
@@ -30,7 +30,7 @@
 
 #include "cairoint.h"
 
-const cairo_solid_pattern_t _cairo_pattern_nil = {
+static const cairo_solid_pattern_t _cairo_pattern_nil = {
     { CAIRO_PATTERN_TYPE_SOLID,		/* type */
       CAIRO_REFERENCE_COUNT_INVALID,	/* ref_count */
       CAIRO_STATUS_NO_MEMORY,		/* status */
commit 758a18b354cefca841536c7d91f8f5758456f72f
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sun Jun 28 20:56:33 2009 +0100

    [test] Timeout support for tests
    
    Enforce that each test must render within 60 seconds or be considered to
    have hit an infinite loop and be reported as a CRASH. The timeout value is
    adjustable via CAIRO_TEST_TIMEOUT -- a value of 0 will disable.

diff --git a/build/configure.ac.system b/build/configure.ac.system
index 30bcb8e..c75460d 100644
--- a/build/configure.ac.system
+++ b/build/configure.ac.system
@@ -74,6 +74,9 @@ AC_CHECK_TYPES([uint64_t, uint128_t])
 dnl Check for socket support for any2ppm daemon
 AC_CHECK_HEADERS([fcntl.h unistd.h signal.h sys/stat.h sys/socket.h sys/poll.h sys/un.h])
 
+dnl Check for infinite loops
+AC_CHECK_FUNCS([alarm])
+
 dnl check for CPU affinity support
 AC_CHECK_HEADERS([sched.h], [AC_CHECK_FUNCS([sched_getaffinity])])
 
diff --git a/test/cairo-test.c b/test/cairo-test.c
index 45b644b..3e2dc12 100644
--- a/test/cairo-test.c
+++ b/test/cairo-test.c
@@ -93,6 +93,7 @@ _xunlink (const cairo_test_context_t *ctx, const char *pathname);
 
 static const char *fail_face = "", *xfail_face="", *normal_face = "";
 static cairo_bool_t print_fail_on_stdout;
+static int cairo_test_timeout = 60;
 
 #define CAIRO_TEST_LOG_SUFFIX ".log"
 #define CAIRO_TEST_PNG_SUFFIX ".out.png"
@@ -149,6 +150,10 @@ _cairo_test_init (cairo_test_context_t *ctx,
 	ctx->malloc_failure = 0;
 #endif
 
+    ctx->timeout = cairo_test_timeout;
+    if (getenv ("CAIRO_TEST_TIMEOUT"))
+	ctx->timeout = atoi (getenv ("CAIRO_TEST_TIMEOUT"));
+
     xasprintf (&log_name, "%s%s", ctx->test_name, CAIRO_TEST_LOG_SUFFIX);
     _xunlink (NULL, log_name);
 
@@ -848,7 +853,13 @@ 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) {
@@ -1243,6 +1254,7 @@ _cairo_test_context_run_for_target (cairo_test_context_t *ctx,
 	void (* volatile old_segfault_handler)(int);
 	void (* volatile old_sigpipe_handler)(int);
 	void (* volatile old_sigabrt_handler)(int);
+	void (* volatile old_sigalrm_handler)(int);
 
 	/* Set up a checkpoint to get back to in case of segfaults. */
 #ifdef SIGSEGV
@@ -1254,6 +1266,9 @@ _cairo_test_context_run_for_target (cairo_test_context_t *ctx,
 #ifdef SIGABRT
 	old_sigabrt_handler = signal (SIGABRT, segfault_handler);
 #endif
+#ifdef SIGALRM
+	old_sigalrm_handler = signal (SIGALRM, segfault_handler);
+#endif
 	if (0 == setjmp (jmpbuf))
 	    status = cairo_test_for_target (ctx, target, dev_offset, similar);
 	else
@@ -1267,6 +1282,9 @@ _cairo_test_context_run_for_target (cairo_test_context_t *ctx,
 #ifdef SIGABRT
 	signal (SIGABRT, old_sigabrt_handler);
 #endif
+#ifdef SIGALRM
+	signal (SIGALRM, old_sigalrm_handler);
+#endif
     } else {
 	status = cairo_test_for_target (ctx, target, dev_offset, similar);
     }
diff --git a/test/cairo-test.h b/test/cairo-test.h
index d644d96..db02eef 100644
--- a/test/cairo-test.h
+++ b/test/cairo-test.h
@@ -179,6 +179,8 @@ struct _cairo_test_context {
     int malloc_failure;
     int last_fault_count;
 
+    int timeout;
+
     int thread;
 };
 
commit f7021d8f3e59d1f7fa77135366bbbd6845dff684
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sun Jun 28 20:41:04 2009 +0100

    [script] Enable error handling for recursive scanners
    
    It's conceivable that a script could execute another file and so we should
    only setjmp on the first invocation.

diff --git a/util/cairo-script/cairo-script-private.h b/util/cairo-script/cairo-script-private.h
index f09c69b..c5c3b59 100644
--- a/util/cairo-script/cairo-script-private.h
+++ b/util/cairo-script/cairo-script-private.h
@@ -424,6 +424,7 @@ union _csi_union_object {
 
 struct _csi_scanner {
     jmp_buf jmpbuf;
+    int depth;
 
     enum {
 	NONE,
diff --git a/util/cairo-script/cairo-script-scanner.c b/util/cairo-script/cairo-script-scanner.c
index 0c6a64d..9cc2ce9 100644
--- a/util/cairo-script/cairo-script-scanner.c
+++ b/util/cairo-script/cairo-script-scanner.c
@@ -1101,13 +1101,22 @@ _csi_scan_file (csi_t *ctx, csi_scanner_t *scan, csi_file_t *src)
     };
     csi_status_t status;
 
-    if ((status = setjmp (scan->jmpbuf)))
-	return status;
+    /* This function needs to be reentrant to handle recursive scanners.
+     * i.e. one script executes a second.
+     */
+
+    if (scan->depth++ == 0) {
+	if ((status = setjmp (scan->jmpbuf))) {
+	    scan->depth = 0;
+	    return status;
+	}
+    }
 
-    scan->line_number = 0;
+    scan->line_number = 0; /* XXX broken by recursive scanning */
     while (func[scan->state] (ctx, scan, src))
 	;
 
+    --scan->depth;
     return CSI_STATUS_SUCCESS;
 }
 


More information about the cairo-commit mailing list