diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2008-08-11 21:12:45 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2008-08-13 21:54:59 +0100 |
commit | 436c0c8be28546813139f391a62303d4c1894fc3 (patch) | |
tree | 7134b42ba4af4da886f8bd7906f4d6a144d1a134 /test/get-xrender-format.c | |
parent | c73b3e43e120065e40d8fc48c9bdbd88ebe8ab40 (diff) |
[test] Preparatory work for running under memfault.
In order to run under memfault, the framework is first extended to handle
running concurrent tests - i.e. multi-threading. (Not that this is a
requirement for memfault, instead it shares a common goal of storing
per-test data). To that end all the global data is moved into a per-test
context and the targets are adjusted to avoid overlap on shared, global
resources (such as output files and frame buffers). In order to preserve
the simplicity of the standard draw routines, the context is not passed
explicitly as a parameter to the routines, but is instead attached to the
cairo_t via the user_data.
For the masochist, to enable the tests to be run across multiple threads
simply set the environment variable CAIRO_TEST_NUM_THREADS to the desired
number.
In the long run, we can hope the need for memfault (runtime testing of
error paths) will be mitigated by static analysis. A promising candidate
for this task would appear to be http://hal.cs.berkeley.edu/cil/.
Diffstat (limited to 'test/get-xrender-format.c')
-rw-r--r-- | test/get-xrender-format.c | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/test/get-xrender-format.c b/test/get-xrender-format.c index 9dec1d99..fbb7d0c9 100644 --- a/test/get-xrender-format.c +++ b/test/get-xrender-format.c @@ -34,37 +34,39 @@ int main (void) { + cairo_test_context_t ctx; Display *dpy; XRenderPictFormat *orig_format, *format; cairo_surface_t *surface; Pixmap pixmap; int screen; - cairo_test_init ("get-xrender-format"); + cairo_test_init (&ctx, "get-xrender-format"); dpy = XOpenDisplay (NULL); if (! dpy) { - cairo_test_log ("Error: Cannot open display: %s.\n", + cairo_test_log (&ctx, "Error: Cannot open display: %s.\n", XDisplayName (NULL)); - cairo_test_fini (); + cairo_test_fini (&ctx); return CAIRO_TEST_SUCCESS; } screen = DefaultScreen (dpy); - cairo_test_log ("Testing with image surface.\n"); + cairo_test_log (&ctx, "Testing with image surface.\n"); surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 1, 1); format = cairo_xlib_surface_get_xrender_format (surface); if (format != NULL) { - cairo_test_log ("Error: expected NULL for image surface\n"); + cairo_test_log (&ctx, "Error: expected NULL for image surface\n"); + cairo_test_fini (&ctx); return CAIRO_TEST_FAILURE; } cairo_surface_destroy (surface); - cairo_test_log ("Testing with non-xrender xlib surface.\n"); + cairo_test_log (&ctx, "Testing with non-xrender xlib surface.\n"); pixmap = XCreatePixmap (dpy, DefaultRootWindow (dpy), 1, 1, DefaultDepth (dpy, screen)); @@ -74,13 +76,14 @@ main (void) orig_format = XRenderFindVisualFormat (dpy, DefaultVisual (dpy, screen)); format = cairo_xlib_surface_get_xrender_format (surface); if (format != orig_format) { - cairo_test_log ("Error: did not receive the same format as XRenderFindVisualFormat\n"); + cairo_test_log (&ctx, "Error: did not receive the same format as XRenderFindVisualFormat\n"); + cairo_test_fini (&ctx); return CAIRO_TEST_FAILURE; } cairo_surface_destroy (surface); XFreePixmap (dpy, pixmap); - cairo_test_log ("Testing with xlib xrender surface.\n"); + cairo_test_log (&ctx, "Testing with xlib xrender surface.\n"); orig_format = XRenderFindStandardFormat (dpy, PictStandardARGB32); pixmap = XCreatePixmap (dpy, DefaultRootWindow (dpy), @@ -92,17 +95,18 @@ main (void) 1, 1); format = cairo_xlib_surface_get_xrender_format (surface); if (format != orig_format) { - cairo_test_log ("Error: did not receive the same format originally set\n"); + cairo_test_log (&ctx, "Error: did not receive the same format originally set\n"); return CAIRO_TEST_FAILURE; } - cairo_test_log ("Testing without the X Render extension.\n"); + cairo_test_log (&ctx, "Testing without the X Render extension.\n"); cairo_boilerplate_xlib_surface_disable_render (surface); format = cairo_xlib_surface_get_xrender_format (surface); if (format != NULL) { - cairo_test_log ("Error: did not receive a NULL format as expected\n"); + cairo_test_log (&ctx, "Error: did not receive a NULL format as expected\n"); + cairo_test_fini (&ctx); return CAIRO_TEST_FAILURE; } @@ -110,9 +114,7 @@ main (void) XCloseDisplay (dpy); - cairo_debug_reset_static_data (); - - cairo_test_fini (); + cairo_test_fini (&ctx); return CAIRO_TEST_SUCCESS; } |