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/font-matrix-translation.c | |
parent | c73b3e43e120065e40d8fc48c9bdbd88ebe8ab40 (diff) | |
download | cairo-436c0c8be28546813139f391a62303d4c1894fc3.tar.gz |
[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/font-matrix-translation.c')
-rw-r--r-- | test/font-matrix-translation.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/test/font-matrix-translation.c b/test/font-matrix-translation.c index 9ed12abb4..263a378d4 100644 --- a/test/font-matrix-translation.c +++ b/test/font-matrix-translation.c @@ -31,7 +31,7 @@ static cairo_test_draw_function_t draw; -cairo_test_t test = { +static const cairo_test_t test = { "font-matrix-translation", "Test that translation in a font matrix can be used to offset a string", 38, 34, @@ -51,7 +51,9 @@ text_extents_equal (const cairo_text_extents_t *A, } static cairo_test_status_t -box_text (cairo_t *cr, const char *utf8, double x, double y) +box_text (const cairo_test_context_t *ctx, cairo_t *cr, + const char *utf8, + double x, double y) { double line_width; cairo_text_extents_t extents = {0}, scaled_extents = {0}; @@ -64,7 +66,8 @@ box_text (cairo_t *cr, const char *utf8, double x, double y) scaled_font = cairo_get_scaled_font (cr); cairo_scaled_font_text_extents (scaled_font, TEXT, &scaled_extents); if (! text_extents_equal (&extents, &scaled_extents)) { - cairo_test_log ("Error: extents differ when they shouldn't:\n" + cairo_test_log (ctx, + "Error: extents differ when they shouldn't:\n" "cairo_text_extents(); extents (%g, %g, %g, %g, %g, %g)\n" "cairo_scaled_font_text_extents(); extents (%g, %g, %g, %g, %g, %g)\n", extents.x_bearing, extents.y_bearing, @@ -95,6 +98,7 @@ box_text (cairo_t *cr, const char *utf8, double x, double y) static cairo_test_status_t draw (cairo_t *cr, int width, int height) { + const cairo_test_context_t *ctx = cairo_test_get_context (cr); cairo_test_status_t status; cairo_text_extents_t extents; cairo_matrix_t matrix; @@ -114,7 +118,7 @@ draw (cairo_t *cr, int width, int height) /* Draw text and bounding box */ cairo_set_source_rgb (cr, 0, 0, 0); /* black */ - status = box_text (cr, TEXT, 0, - extents.y_bearing); + status = box_text (ctx, cr, TEXT, 0, - extents.y_bearing); if (status) return status; @@ -126,7 +130,7 @@ draw (cairo_t *cr, int width, int height) cairo_set_font_matrix (cr, &matrix); cairo_set_source_rgb (cr, 0, 0, 1); /* blue */ - status = box_text (cr, TEXT, 0, - extents.y_bearing); + status = box_text (ctx, cr, TEXT, 0, - extents.y_bearing); if (status) return status; |