summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2008-08-11 21:12:45 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2008-08-13 21:54:59 +0100
commit436c0c8be28546813139f391a62303d4c1894fc3 (patch)
tree7134b42ba4af4da886f8bd7906f4d6a144d1a134 /test
parentc73b3e43e120065e40d8fc48c9bdbd88ebe8ab40 (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')
-rw-r--r--test/Makefile.am3
-rw-r--r--test/a1-image-sample.c2
-rw-r--r--test/a1-mask.c36
-rw-r--r--test/a1-traps-sample.c2
-rw-r--r--test/a8-mask.c36
-rw-r--r--test/big-line.c2
-rw-r--r--test/big-trap.c2
-rw-r--r--test/bilevel-image.c4
-rw-r--r--test/bitmap-font.c23
-rw-r--r--test/buffer-diff.c122
-rw-r--r--test/buffer-diff.h9
-rw-r--r--test/cairo-test.c692
-rw-r--r--test/cairo-test.h56
-rw-r--r--test/caps-joins-alpha.c2
-rw-r--r--test/caps-joins.c2
-rw-r--r--test/caps-sub-paths.c2
-rw-r--r--test/clip-all.c2
-rw-r--r--test/clip-empty.c2
-rw-r--r--test/clip-fill-rule-pixel-aligned.c2
-rw-r--r--test/clip-fill-rule.c2
-rw-r--r--test/clip-nesting.c2
-rw-r--r--test/clip-operator.c9
-rw-r--r--test/clip-push-group.c2
-rw-r--r--test/clip-twice.c2
-rw-r--r--test/clip-zero.c2
-rw-r--r--test/clipped-group.c2
-rw-r--r--test/close-path.c2
-rw-r--r--test/composite-integer-translate-over-repeat.c2
-rw-r--r--test/composite-integer-translate-over.c5
-rw-r--r--test/composite-integer-translate-source.c5
-rw-r--r--test/copy-path.c81
-rw-r--r--test/create-for-stream.c42
-rw-r--r--test/create-from-png-stream.c12
-rw-r--r--test/create-from-png.c190
-rw-r--r--test/dash-caps-joins.c2
-rw-r--r--test/dash-curve.c2
-rw-r--r--test/dash-no-dash.c2
-rw-r--r--test/dash-offset-negative.c2
-rw-r--r--test/dash-scale.c2
-rw-r--r--test/dash-state.c2
-rw-r--r--test/dash-zero-length.c2
-rw-r--r--test/degenerate-arc.c2
-rw-r--r--test/degenerate-path.c2
-rw-r--r--test/degenerate-pen.c2
-rw-r--r--test/device-offset-positive.c2
-rw-r--r--test/device-offset-scale.c2
-rw-r--r--test/device-offset.c2
-rw-r--r--test/extend-pad.c2
-rw-r--r--test/extend-reflect-similar.c7
-rw-r--r--test/extend-reflect.c5
-rw-r--r--test/extend-repeat-similar.c7
-rw-r--r--test/extend-repeat.c5
-rw-r--r--test/fallback-resolution.c7
-rw-r--r--test/fill-and-stroke-alpha-add.c2
-rw-r--r--test/fill-and-stroke-alpha.c2
-rw-r--r--test/fill-and-stroke.c2
-rw-r--r--test/fill-degenerate-sort-order.c2
-rw-r--r--test/fill-missed-stop.c2
-rw-r--r--test/fill-rule.c2
-rw-r--r--test/filter-bilinear-extents.c2
-rw-r--r--test/filter-nearest-offset.c4
-rw-r--r--test/finer-grained-fallbacks.c2
-rw-r--r--test/font-face-get-type.c17
-rw-r--r--test/font-matrix-translation.c14
-rw-r--r--test/ft-font-create-for-ft-face.c13
-rw-r--r--test/ft-show-glyphs-positioning.c2
-rw-r--r--test/ft-show-glyphs-table.c2
-rw-r--r--test/ft-text-antialias-none.c4
-rw-r--r--test/ft-text-vertical-layout-type1.c4
-rw-r--r--test/ft-text-vertical-layout-type3.c4
-rw-r--r--test/get-and-set.c8
-rw-r--r--test/get-clip.c66
-rw-r--r--test/get-group-target.c2
-rw-r--r--test/get-path-extents.c126
-rw-r--r--test/get-xrender-format.c30
-rw-r--r--test/glyph-cache-pressure.c2
-rw-r--r--test/gradient-alpha.c2
-rw-r--r--test/gradient-zero-stops.c2
-rw-r--r--test/group-paint.c5
-rw-r--r--test/imagediff.c2
-rw-r--r--test/in-fill-empty-trapezoid.c20
-rw-r--r--test/in-fill-trapezoid.c11
-rw-r--r--test/infinite-join.c2
-rw-r--r--test/invalid-matrix.c7
-rw-r--r--test/large-clip.c2
-rw-r--r--test/large-font.c4
-rw-r--r--test/large-source.c2
-rw-r--r--test/leaky-dash.c2
-rw-r--r--test/leaky-dashed-rectangle.c2
-rw-r--r--test/leaky-polygon.c2
-rw-r--r--test/line-width-scale.c5
-rw-r--r--test/line-width-zero.c2
-rw-r--r--test/line-width.c2
-rw-r--r--test/linear-gradient-reflect.c2
-rw-r--r--test/linear-gradient.c4
-rw-r--r--test/long-dashed-lines.c3
-rw-r--r--test/long-lines.c21
-rw-r--r--test/mask-alpha.c2
-rw-r--r--test/mask-ctm.c4
-rw-r--r--test/mask-surface-ctm.c4
-rw-r--r--test/mask.c23
-rw-r--r--test/meta-surface-pattern.c3
-rw-r--r--test/miter-precision.c6
-rw-r--r--test/move-to-show-surface.c2
-rw-r--r--test/multi-page.c16
-rw-r--r--test/new-sub-path.c2
-rw-r--r--test/nil-surface.c13
-rw-r--r--test/operator-clear.c11
-rw-r--r--test/operator-source.c11
-rw-r--r--test/over-above-source.c2
-rw-r--r--test/over-around-source.c2
-rw-r--r--test/over-below-source.c2
-rw-r--r--test/over-between-source.c2
-rw-r--r--test/paint-repeat.c4
-rw-r--r--test/paint-source-alpha.c4
-rw-r--r--test/paint-with-alpha.c4
-rw-r--r--test/paint.c2
-rw-r--r--test/pattern-get-type.c25
-rw-r--r--test/pattern-getters.c13
-rw-r--r--test/pdf-features.c7
-rw-r--r--test/pixman-rotate.c2
-rw-r--r--test/ps-features.c7
-rw-r--r--test/pthread-show-text.c11
-rw-r--r--test/push-group.c2
-rw-r--r--test/radial-gradient.c2
-rw-r--r--test/random-intersections.c2
-rw-r--r--test/rectangle-rounding-error.c2
-rw-r--r--test/rectilinear-miter-limit.c2
-rw-r--r--test/rectilinear-stroke.c2
-rw-r--r--test/reflected-stroke.c2
-rw-r--r--test/rel-path.c9
-rw-r--r--test/rgb24-ignore-alpha.c2
-rw-r--r--test/rotate-image-surface-paint.c2
-rw-r--r--test/scale-down-source-surface-paint.c4
-rw-r--r--test/scale-source-surface-paint.c4
-rw-r--r--test/select-font-face.c2
-rw-r--r--test/select-font-no-show-text.c2
-rw-r--r--test/self-copy.c2
-rw-r--r--test/self-intersecting.c2
-rw-r--r--test/set-source.c2
-rw-r--r--test/show-text-current-point.c2
-rw-r--r--test/skew-extreme.c2
-rw-r--r--test/smask-fill.c3
-rw-r--r--test/smask-image-mask.c5
-rw-r--r--test/smask-mask.c3
-rw-r--r--test/smask-paint.c3
-rw-r--r--test/smask-stroke.c3
-rw-r--r--test/smask-text.c3
-rw-r--r--test/smask.c5
-rw-r--r--test/solid-pattern-cache-stress.c2
-rw-r--r--test/source-clip-scale.c2
-rw-r--r--test/source-clip.c2
-rw-r--r--test/source-surface-scale-paint.c4
-rw-r--r--test/stroke-ctm-caps.c2
-rw-r--r--test/stroke-image.c2
-rw-r--r--test/surface-finish-twice.c2
-rw-r--r--test/surface-pattern-big-scale-down.c2
-rw-r--r--test/surface-pattern-scale-down.c2
-rw-r--r--test/surface-pattern-scale-up.c2
-rw-r--r--test/surface-pattern.c2
-rw-r--r--test/surface-source.c2
-rw-r--r--test/svg-clip.c14
-rw-r--r--test/svg-surface.c15
-rw-r--r--test/text-antialias-gray.c4
-rw-r--r--test/text-antialias-none.c4
-rw-r--r--test/text-antialias-subpixel.c4
-rw-r--r--test/text-cache-crash.c4
-rw-r--r--test/text-lcd-filter-fir3.c4
-rw-r--r--test/text-lcd-filter-fir5.c4
-rw-r--r--test/text-lcd-filter-intra-pixel.c4
-rw-r--r--test/text-lcd-filter-none.c4
-rw-r--r--test/text-pattern.c2
-rw-r--r--test/text-rotate.c4
-rw-r--r--test/text-transform.c7
-rw-r--r--test/text-zero-len.c21
-rw-r--r--test/transforms.c2
-rw-r--r--test/translate-show-surface.c2
-rw-r--r--test/trap-clip.c27
-rw-r--r--test/truetype-tables.c10
-rw-r--r--test/unantialiased-shapes.c2
-rw-r--r--test/unbounded-operator.c9
-rw-r--r--test/user-font-proxy.c2
-rw-r--r--test/user-font.c2
-rw-r--r--test/xlib-expose-event.c32
-rw-r--r--test/xlib-surface.c40
-rw-r--r--test/zero-alpha.c2
186 files changed, 1385 insertions, 962 deletions
diff --git a/test/Makefile.am b/test/Makefile.am
index d80e8a6c8..555279cd4 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -886,11 +886,12 @@ EXTRA_PROGRAMS += $(TESTS) $(DISABLED_TESTS)
# and TARGETS make var on the command line. Same for the rest.
TARGETS = $(CAIRO_TEST_TARGET)
TARGETS_EXCLUDE = $(CAIRO_TEST_TARGET_EXCLUDE)
+NUM_THREADS = $(CAIRO_TEST_NUM_THREADS)
# Same about ENV vs CAIRO_TEST_ENV. ENV is used with "make run" only
ENV = $(CAIRO_TEST_ENV)
-TESTS_ENVIRONMENT = CAIRO_XFAIL_TESTS="$(XFAIL_TESTS:$(EXEEXT)=)" CAIRO_TEST_TARGET="$(TARGETS)" CAIRO_TEST_TARGET_EXCLUDE="$(TARGETS_EXCLUDE)" $(ENV)
+TESTS_ENVIRONMENT = CAIRO_XFAIL_TESTS="$(XFAIL_TESTS:$(EXEEXT)=)" CAIRO_TEST_TARGET="$(TARGETS)" CAIRO_TEST_TARGET_EXCLUDE="$(TARGETS_EXCLUDE)" CAIRO_TEST_NUM_THREADS="$(NUM_THREADS)" $(ENV)
EXTRA_VALGRIND_FLAGS = $(CAIRO_EXTRA_VALGRIND_FLAGS)
VALGRIND_FLAGS = \
diff --git a/test/a1-image-sample.c b/test/a1-image-sample.c
index a95c57750..809078c45 100644
--- a/test/a1-image-sample.c
+++ b/test/a1-image-sample.c
@@ -34,7 +34,7 @@ static cairo_test_draw_function_t draw;
#define WIDTH (PAD + POINTS * 2 + PAD)
#define HEIGHT (WIDTH)
-cairo_test_t test = {
+static const cairo_test_t test = {
"a1-image-sample",
"Test sample position when drawing images with FILTER_NEAREST",
WIDTH, HEIGHT,
diff --git a/test/a1-mask.c b/test/a1-mask.c
index 946b62209..e4638fee3 100644
--- a/test/a1-mask.c
+++ b/test/a1-mask.c
@@ -48,7 +48,7 @@ static unsigned char mask[(MASK_WIDTH + 7) / 8 * MASK_HEIGHT] = {
MASK,
};
-cairo_test_t test = {
+static const cairo_test_t test = {
"a1-mask",
"test masks of CAIRO_FORMAT_A1",
MASK_WIDTH, MASK_HEIGHT,
@@ -57,12 +57,15 @@ cairo_test_t test = {
static cairo_test_status_t
-check_status (cairo_status_t status, cairo_status_t expected)
+check_status (const cairo_test_context_t *ctx,
+ cairo_status_t status,
+ cairo_status_t expected)
{
if (status == expected)
return CAIRO_TEST_SUCCESS;
- cairo_test_log ("Error: Expected status value %d (%s), received %d (%s)\n",
+ cairo_test_log (ctx,
+ "Error: Expected status value %d (%s), received %d (%s)\n",
expected,
cairo_status_to_string (expected),
status,
@@ -71,7 +74,8 @@ check_status (cairo_status_t status, cairo_status_t expected)
}
static cairo_test_status_t
-test_surface_with_width_and_stride (int width, int stride,
+test_surface_with_width_and_stride (const cairo_test_context_t *ctx,
+ int width, int stride,
cairo_status_t expected)
{
cairo_test_status_t status;
@@ -80,7 +84,8 @@ test_surface_with_width_and_stride (int width, int stride,
int len;
unsigned char *data;
- cairo_test_log ("Creating surface with width %d and stride %d\n",
+ cairo_test_log (ctx,
+ "Creating surface with width %d and stride %d\n",
width, stride);
len = stride;
@@ -94,11 +99,11 @@ test_surface_with_width_and_stride (int width, int stride,
cairo_paint (cr);
- status = check_status (cairo_surface_status (surface), expected);
+ status = check_status (ctx, cairo_surface_status (surface), expected);
if (status)
goto BAIL;
- status = check_status (cairo_status (cr), expected);
+ status = check_status (ctx, cairo_status (cr), expected);
if (status)
goto BAIL;
@@ -146,9 +151,10 @@ draw (cairo_t *cr, int dst_width, int dst_height)
int
main (void)
{
+ cairo_test_context_t ctx;
int test_width;
- cairo_test_init ("a1-mask");
+ cairo_test_init (&ctx, "a1-mask");
/* first check the API strictness */
for (test_width = 0; test_width < 40; test_width++) {
@@ -164,13 +170,15 @@ main (void)
expected = (stride == test_stride) ?
CAIRO_STATUS_SUCCESS : CAIRO_STATUS_INVALID_STRIDE;
- status = test_surface_with_width_and_stride (test_width,
+ status = test_surface_with_width_and_stride (&ctx,
+ test_width,
test_stride,
expected);
if (status)
return status;
- status = test_surface_with_width_and_stride (test_width,
+ status = test_surface_with_width_and_stride (&ctx,
+ test_width,
-test_stride,
expected);
if (status)
@@ -180,20 +188,22 @@ main (void)
/* Then create a surface using the correct stride,
* (should always succeed).
*/
- status = test_surface_with_width_and_stride (test_width,
+ status = test_surface_with_width_and_stride (&ctx,
+ test_width,
stride,
CAIRO_STATUS_SUCCESS);
if (status)
return status;
- status = test_surface_with_width_and_stride (test_width,
+ status = test_surface_with_width_and_stride (&ctx,
+ test_width,
-stride,
CAIRO_STATUS_SUCCESS);
if (status)
return status;
}
- cairo_test_fini ();
+ cairo_test_fini (&ctx);
return cairo_test (&test);
}
diff --git a/test/a1-traps-sample.c b/test/a1-traps-sample.c
index 1148a8bf3..956d6a796 100644
--- a/test/a1-traps-sample.c
+++ b/test/a1-traps-sample.c
@@ -34,7 +34,7 @@ static cairo_test_draw_function_t draw;
#define WIDTH (PAD + POINTS * 2 + PAD)
#define HEIGHT (WIDTH)
-cairo_test_t test = {
+static const cairo_test_t test = {
"a1-traps-sample",
"Test sample position when drawing trapezoids with ANTIALIAS_NONE",
WIDTH, HEIGHT,
diff --git a/test/a8-mask.c b/test/a8-mask.c
index fdf4fef07..47f9f5be9 100644
--- a/test/a8-mask.c
+++ b/test/a8-mask.c
@@ -28,7 +28,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"a8-mask",
"test masks of CAIRO_FORMAT_A8",
8, 8,
@@ -50,12 +50,15 @@ static unsigned char mask[MASK_WIDTH * MASK_HEIGHT] = {
};
static cairo_test_status_t
-check_status (cairo_status_t status, cairo_status_t expected)
+check_status (const cairo_test_context_t *ctx,
+ cairo_status_t status,
+ cairo_status_t expected)
{
if (status == expected)
return CAIRO_TEST_SUCCESS;
- cairo_test_log ("Error: Expected status value %d (%s), received %d (%s)\n",
+ cairo_test_log (ctx,
+ "Error: Expected status value %d (%s), received %d (%s)\n",
expected,
cairo_status_to_string (expected),
status,
@@ -64,7 +67,8 @@ check_status (cairo_status_t status, cairo_status_t expected)
}
static cairo_test_status_t
-test_surface_with_width_and_stride (int width, int stride,
+test_surface_with_width_and_stride (const cairo_test_context_t *ctx,
+ int width, int stride,
cairo_status_t expected)
{
cairo_test_status_t status;
@@ -73,7 +77,8 @@ test_surface_with_width_and_stride (int width, int stride,
int len;
unsigned char *data;
- cairo_test_log ("Creating surface with width %d and stride %d\n",
+ cairo_test_log (ctx,
+ "Creating surface with width %d and stride %d\n",
width, stride);
len = stride;
@@ -87,11 +92,11 @@ test_surface_with_width_and_stride (int width, int stride,
cairo_paint (cr);
- status = check_status (cairo_surface_status (surface), expected);
+ status = check_status (ctx, cairo_surface_status (surface), expected);
if (status)
goto BAIL;
- status = check_status (cairo_status (cr), expected);
+ status = check_status (ctx, cairo_status (cr), expected);
if (status)
goto BAIL;
@@ -147,9 +152,10 @@ draw (cairo_t *cr, int dst_width, int dst_height)
int
main (void)
{
+ cairo_test_context_t ctx;
int test_width;
- cairo_test_init ("a8-mask");
+ cairo_test_init (&ctx, "a8-mask");
for (test_width = 0; test_width < 40; test_width++) {
int stride = cairo_format_stride_for_width (CAIRO_FORMAT_A8,
@@ -163,13 +169,15 @@ main (void)
expected = (stride == test_width) ?
CAIRO_STATUS_SUCCESS : CAIRO_STATUS_INVALID_STRIDE;
- status = test_surface_with_width_and_stride (test_width,
+ status = test_surface_with_width_and_stride (&ctx,
+ test_width,
test_width,
expected);
if (status)
return status;
- status = test_surface_with_width_and_stride (test_width,
+ status = test_surface_with_width_and_stride (&ctx,
+ test_width,
-test_width,
expected);
if (status)
@@ -179,20 +187,22 @@ main (void)
/* Then create a surface using the correct stride,
* (should always succeed).
*/
- status = test_surface_with_width_and_stride (test_width,
+ status = test_surface_with_width_and_stride (&ctx,
+ test_width,
stride,
CAIRO_STATUS_SUCCESS);
if (status)
return status;
- status = test_surface_with_width_and_stride (test_width,
+ status = test_surface_with_width_and_stride (&ctx,
+ test_width,
-stride,
CAIRO_STATUS_SUCCESS);
if (status)
return status;
}
- cairo_test_fini ();
+ cairo_test_fini (&ctx);
return cairo_test (&test);
}
diff --git a/test/big-line.c b/test/big-line.c
index cb1d84e0d..253be3a2e 100644
--- a/test/big-line.c
+++ b/test/big-line.c
@@ -27,7 +27,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"big-line",
"Test drawing of simple lines with positive and negative coordinates > 2^16\n"
"This currently fails because of 16-bit limitations in pixman.",
diff --git a/test/big-trap.c b/test/big-trap.c
index e201b9898..400705e79 100644
--- a/test/big-trap.c
+++ b/test/big-trap.c
@@ -60,7 +60,7 @@ static cairo_test_draw_function_t draw;
* will prevent the hiding of internal library symbols.
*/
-cairo_test_t test = {
+static const cairo_test_t test = {
"big-trap",
"Test oversize trapezoid with a clip region"
"\nTest needs to be adjusted to trigger the original bug",
diff --git a/test/bilevel-image.c b/test/bilevel-image.c
index 7898a5f2b..7a75edb74 100644
--- a/test/bilevel-image.c
+++ b/test/bilevel-image.c
@@ -27,7 +27,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"bilevel-image",
"Test that PS can embed an RGB image with a bilevel alpha channel.",
12, 4,
@@ -39,7 +39,7 @@ cairo_test_t test = {
static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
- static uint32_t data[] = {
+ uint32_t data[] = {
RGBx, RGBx, RGBx,
RGBx, RGBx, RGBx,
RGBx, RGBx, RGBx,
diff --git a/test/bitmap-font.c b/test/bitmap-font.c
index 7bebb6c9c..42bf7071b 100644
--- a/test/bitmap-font.c
+++ b/test/bitmap-font.c
@@ -38,7 +38,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"bitmap-font",
"Test drawing with a font consisting only of bitmaps",
246 + 1, 2 * TEXT_SIZE,
@@ -58,14 +58,14 @@ font_extents_equal (const cairo_font_extents_t *A,
}
static cairo_test_status_t
-check_font_extents (cairo_t *cr, const char *comment)
+check_font_extents (const cairo_test_context_t *ctx, cairo_t *cr, const char *comment)
{
cairo_font_extents_t font_extents, ref_font_extents = {11, 2, 13, 6, 0};
memset (&font_extents, 0xff, sizeof (cairo_font_extents_t));
cairo_font_extents (cr, &font_extents);
if (! font_extents_equal (&font_extents, &ref_font_extents)) {
- cairo_test_log ("Error: %s: cairo_font_extents(); extents (%g, %g, %g, %g, %g)\n",
+ cairo_test_log (ctx, "Error: %s: cairo_font_extents(); extents (%g, %g, %g, %g, %g)\n",
comment,
font_extents.ascent, font_extents.descent,
font_extents.height,
@@ -79,30 +79,27 @@ check_font_extents (cairo_t *cr, const char *comment)
static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
+ const cairo_test_context_t *ctx = cairo_test_get_context (cr);
FcPattern *pattern;
cairo_font_face_t *font_face;
cairo_font_extents_t font_extents;
cairo_font_options_t *font_options;
cairo_status_t status;
- const char *srcdir = getenv ("srcdir");
char *filename;
int face_count;
struct stat stat_buf;
- if (! srcdir)
- srcdir = ".";
-
- xasprintf (&filename, "%s/%s", srcdir, FONT);
+ xasprintf (&filename, "%s/%s", ctx->srcdir, FONT);
if (stat (filename, &stat_buf) || ! S_ISREG (stat_buf.st_mode)) {
- cairo_test_log ("Error finding font: %s: file not found?\n", filename);
+ cairo_test_log (ctx, "Error finding font: %s: file not found?\n", filename);
return CAIRO_TEST_FAILURE;
}
pattern = FcFreeTypeQuery ((unsigned char *)filename, 0, NULL, &face_count);
free (filename);
if (! pattern) {
- cairo_test_log ("FcFreeTypeQuery failed.\n");
+ cairo_test_log (ctx, "FcFreeTypeQuery failed.\n");
return CAIRO_TEST_FAILURE;
}
@@ -110,14 +107,14 @@ draw (cairo_t *cr, int width, int height)
status = cairo_font_face_status (font_face);
if (status) {
- cairo_test_log ("Error creating font face for %s: %s\n",
+ cairo_test_log (ctx, "Error creating font face for %s: %s\n",
filename,
cairo_status_to_string (status));
return CAIRO_TEST_FAILURE;
}
if (cairo_font_face_get_type (font_face) != CAIRO_FONT_TYPE_FT) {
- cairo_test_log ("Unexpected value from cairo_font_face_get_type: %d (expected %d)\n",
+ cairo_test_log (ctx, "Unexpected value from cairo_font_face_get_type: %d (expected %d)\n",
cairo_font_face_get_type (font_face), CAIRO_FONT_TYPE_FT);
cairo_font_face_destroy (font_face);
return CAIRO_TEST_FAILURE;
@@ -125,7 +122,7 @@ draw (cairo_t *cr, int width, int height)
cairo_set_font_face (cr, font_face);
-#define CHECK_FONT_EXTENTS(comment) if (check_font_extents (cr, (comment)) != CAIRO_TEST_SUCCESS) return CAIRO_TEST_FAILURE
+#define CHECK_FONT_EXTENTS(comment) if (check_font_extents (ctx, cr, (comment)) != CAIRO_TEST_SUCCESS) return CAIRO_TEST_FAILURE
cairo_font_extents (cr, &font_extents);
CHECK_FONT_EXTENTS ("default");
diff --git a/test/buffer-diff.c b/test/buffer-diff.c
index d1b586376..ef708761c 100644
--- a/test/buffer-diff.c
+++ b/test/buffer-diff.c
@@ -47,12 +47,12 @@
#define PERCEPTUAL_DIFF_THRESHOLD 25
static void
-xunlink (const char *pathname)
+xunlink (const cairo_test_context_t *ctx, const char *pathname)
{
if (unlink (pathname) < 0 && errno != ENOENT) {
- cairo_test_log (" Error: Cannot remove %s: %s\n",
+ cairo_test_log (ctx, " Error: Cannot remove %s: %s\n",
pathname, strerror (errno));
- exit (1);
+ exit (CAIRO_TEST_FAILURE);
}
}
@@ -122,7 +122,8 @@ buffer_diff_core (unsigned char *_buf_a,
}
void
-compare_surfaces (cairo_surface_t *surface_a,
+compare_surfaces (const cairo_test_context_t *ctx,
+ cairo_surface_t *surface_a,
cairo_surface_t *surface_b,
cairo_surface_t *surface_diff,
buffer_diff_result_t *result)
@@ -150,14 +151,15 @@ compare_surfaces (cairo_surface_t *surface_a,
if (result->pixels_changed == 0)
return;
- cairo_test_log ("%d pixels differ (with maximum difference of %d) from reference image\n",
+ cairo_test_log (ctx,
+ "%d pixels differ (with maximum difference of %d) from reference image\n",
result->pixels_changed, result->max_diff);
/* Then, if there are any different pixels, we give the pdiff code
* a crack at the images. If it decides that there are no visually
* discernible differences in any pixels, then we accept this
* result as good enough.
- *
+ *
* Only let pdiff have a crack at the comparison if the max difference
* is lower than a threshold, otherwise some problems could be masked.
*/
@@ -166,7 +168,8 @@ compare_surfaces (cairo_surface_t *surface_a,
gamma, luminance, field_of_view);
if (discernible_pixels_changed == 0) {
result->pixels_changed = 0;
- cairo_test_log ("But perceptual diff finds no visually discernible difference.\n"
+ cairo_test_log (ctx,
+ "But perceptual diff finds no visually discernible difference.\n"
"Accepting result.\n");
}
}
@@ -208,7 +211,9 @@ stdio_write_func (void *closure, const unsigned char *data, unsigned int length)
* extending from (x,y) to (width,height).
*/
static void
-flatten_surface (cairo_surface_t **surface, int x, int y)
+flatten_surface (const cairo_test_context_t *ctx,
+ cairo_surface_t **surface,
+ int x, int y)
{
cairo_surface_t *flat;
cairo_t *cr;
@@ -219,14 +224,17 @@ flatten_surface (cairo_surface_t **surface, int x, int y)
cairo_surface_set_device_offset (flat, -x, -y);
cr = cairo_create (flat);
+ cairo_surface_destroy (flat);
+
cairo_set_source_rgb (cr, 1, 1, 1);
cairo_paint (cr);
+
cairo_set_source_surface (cr, *surface, 0, 0);
+ cairo_surface_destroy (*surface);
cairo_paint (cr);
- cairo_destroy (cr);
- cairo_surface_destroy (*surface);
- *surface = flat;
+ *surface = cairo_surface_reference (cairo_get_target (cr));
+ cairo_destroy (cr);
}
/* Given an image surface, create a new surface that has the same
@@ -235,7 +243,9 @@ flatten_surface (cairo_surface_t **surface, int x, int y)
* The original surface will be destroyed.
*/
static void
-extract_sub_surface (cairo_surface_t **surface, int x, int y)
+extract_sub_surface (const cairo_test_context_t *ctx,
+ cairo_surface_t **surface,
+ int x, int y)
{
cairo_surface_t *sub;
cairo_t *cr;
@@ -250,13 +260,15 @@ extract_sub_surface (cairo_surface_t **surface, int x, int y)
* time, so I'm leaving both here so I can look at both to see
* which I like better. */
cr = cairo_create (sub);
+ cairo_surface_destroy (sub);
+
cairo_set_source_surface (cr, *surface, -x, -y);
+ cairo_surface_destroy (*surface);
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
cairo_paint (cr);
- cairo_destroy (cr);
- cairo_surface_destroy (*surface);
- *surface = sub;
+ *surface = cairo_surface_reference (cairo_get_target (cr));
+ cairo_destroy (cr);
}
/* Image comparison code courtesy of Richard Worth <richard@theworths.org>
@@ -275,7 +287,8 @@ extract_sub_surface (cairo_surface_t **surface, int x, int y)
* oh well).
*/
static cairo_status_t
-image_diff_core (const char *filename_a,
+image_diff_core (const cairo_test_context_t *ctx,
+ const char *filename_a,
const char *filename_b,
const char *filename_diff,
int ax,
@@ -293,7 +306,7 @@ image_diff_core (const char *filename_a,
surface_a = cairo_image_surface_create_from_png (filename_a);
status = cairo_surface_status (surface_a);
if (status) {
- cairo_test_log ("Error: Failed to create surface from %s: %s\n",
+ cairo_test_log (ctx, "Error: Failed to create surface from %s: %s\n",
filename_a, cairo_status_to_string (status));
return status;
}
@@ -301,28 +314,45 @@ image_diff_core (const char *filename_a,
surface_b = cairo_image_surface_create_from_png (filename_b);
status = cairo_surface_status (surface_b);
if (status) {
- cairo_test_log ("Error: Failed to create surface from %s: %s\n",
+ cairo_test_log (ctx, "Error: Failed to create surface from %s: %s\n",
filename_b, cairo_status_to_string (status));
cairo_surface_destroy (surface_a);
return status;
}
if (flatten) {
- flatten_surface (&surface_a, ax, ay);
- flatten_surface (&surface_b, bx, by);
+ flatten_surface (ctx, &surface_a, ax, ay);
+ flatten_surface (ctx, &surface_b, bx, by);
ax = ay = bx = by = 0;
}
if (ax || ay) {
- extract_sub_surface (&surface_a, ax, ay);
+ extract_sub_surface (ctx, &surface_a, ax, ay);
ax = ay = 0;
}
if (bx || by) {
- extract_sub_surface (&surface_b, bx, by);
+ extract_sub_surface (ctx, &surface_b, bx, by);
bx = by = 0;
}
+ status = cairo_surface_status (surface_a);
+ if (status) {
+ cairo_test_log (ctx, "Error: Failed to extract surface from %s: %s\n",
+ filename_a, cairo_status_to_string (status));
+ cairo_surface_destroy (surface_a);
+ cairo_surface_destroy (surface_b);
+ return status;
+ }
+ status = cairo_surface_status (surface_b);
+ if (status) {
+ cairo_test_log (ctx, "Error: Failed to extract surface from %s: %s\n",
+ filename_b, cairo_status_to_string (status));
+ cairo_surface_destroy (surface_a);
+ cairo_surface_destroy (surface_b);
+ return status;
+ }
+
width_a = cairo_image_surface_get_width (surface_a);
height_a = cairo_image_surface_get_height (surface_a);
stride_a = cairo_image_surface_get_stride (surface_a);
@@ -334,7 +364,7 @@ image_diff_core (const char *filename_a,
height_a != height_b ||
stride_a != stride_b)
{
- cairo_test_log ("Error: Image size mismatch: (%dx%d) vs. (%dx%d)\n"
+ cairo_test_log (ctx, "Error: Image size mismatch: (%dx%d) vs. (%dx%d)\n"
" for %s vs. %s\n",
width_a, height_a,
width_b, height_b,
@@ -346,25 +376,49 @@ image_diff_core (const char *filename_a,
surface_diff = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
width_a, height_a);
+ status = cairo_surface_status (surface_diff);
+ if (status) {
+ cairo_test_log (ctx, "Error: Failed to allocate surface to hold differences\n");
+ cairo_surface_destroy (surface_a);
+ cairo_surface_destroy (surface_b);
+ return CAIRO_STATUS_NO_MEMORY;
+ }
- compare_surfaces (surface_a, surface_b, surface_diff, result);
+
+ compare_surfaces (ctx, surface_a, surface_b, surface_diff, result);
status = CAIRO_STATUS_SUCCESS;
if (result->pixels_changed) {
FILE *png_file;
- if (filename_diff)
+ if (filename_diff) {
png_file = fopen (filename_diff, "wb");
- else
+ if (png_file == NULL) {
+ int err = errno;
+
+ cairo_surface_destroy (surface_a);
+ cairo_surface_destroy (surface_b);
+ cairo_surface_destroy (surface_diff);
+
+ switch (err) {
+ case ENOMEM:
+ return CAIRO_STATUS_NO_MEMORY;
+ default:
+ return CAIRO_STATUS_WRITE_ERROR;
+ }
+ }
+ } else
png_file = stdout;
- status = cairo_surface_write_to_png_stream (surface_diff, stdio_write_func, png_file);
+ status = cairo_surface_write_to_png_stream (surface_diff,
+ stdio_write_func,
+ png_file);
if (png_file != stdout)
fclose (png_file);
} else {
if (filename_diff)
- xunlink (filename_diff);
+ xunlink (ctx, filename_diff);
}
cairo_surface_destroy (surface_a);
@@ -375,7 +429,8 @@ image_diff_core (const char *filename_a,
}
cairo_status_t
-image_diff (const char *filename_a,
+image_diff (const cairo_test_context_t *ctx,
+ const char *filename_a,
const char *filename_b,
const char *filename_diff,
int ax,
@@ -384,13 +439,15 @@ image_diff (const char *filename_a,
int by,
buffer_diff_result_t *result)
{
- return image_diff_core (filename_a, filename_b, filename_diff,
+ return image_diff_core (ctx,
+ filename_a, filename_b, filename_diff,
ax, ay, bx, by,
result, FALSE);
}
cairo_status_t
-image_diff_flattened (const char *filename_a,
+image_diff_flattened (const cairo_test_context_t *ctx,
+ const char *filename_a,
const char *filename_b,
const char *filename_diff,
int ax,
@@ -399,7 +456,8 @@ image_diff_flattened (const char *filename_a,
int by,
buffer_diff_result_t *result)
{
- return image_diff_core (filename_a, filename_b, filename_diff,
+ return image_diff_core (ctx,
+ filename_a, filename_b, filename_diff,
ax, ay, bx, by,
result, TRUE);
}
diff --git a/test/buffer-diff.h b/test/buffer-diff.h
index cd3534508..61daa897d 100644
--- a/test/buffer-diff.h
+++ b/test/buffer-diff.h
@@ -45,7 +45,8 @@ typedef struct _buffer_diff_result {
* images differ.
*/
void
-compare_surfaces (cairo_surface_t *surface_a,
+compare_surfaces (const cairo_test_context_t *ctx,
+ cairo_surface_t *surface_a,
cairo_surface_t *surface_b,
cairo_surface_t *surface_diff,
buffer_diff_result_t *result);
@@ -81,7 +82,8 @@ buffer_diff_noalpha (unsigned char *buf_a,
* images differ.
*/
cairo_status_t
-image_diff (const char *filename_a,
+image_diff (const cairo_test_context_t *ctx,
+ const char *filename_a,
const char *filename_b,
const char *filename_diff,
int ax,
@@ -92,7 +94,8 @@ image_diff (const char *filename_a,
/* Like image_diff, but blending the contents of b over white first. */
cairo_status_t
-image_diff_flattened (const char *filename_a,
+image_diff_flattened (const cairo_test_context_t *ctx,
+ const char *filename_a,
const char *filename_b,
const char *filename_diff,
int ax,
diff --git a/test/cairo-test.c b/test/cairo-test.c
index 4fd817f08..8e70f9508 100644
--- a/test/cairo-test.c
+++ b/test/cairo-test.c
@@ -31,10 +31,6 @@
#include <stdlib.h>
#include <stdarg.h>
#include <ctype.h>
-#include <setjmp.h>
-#ifdef HAVE_SIGNAL_H
-#include <signal.h>
-#endif
#if HAVE_FEENABLEEXCEPT
#include <fenv.h>
#endif
@@ -47,6 +43,9 @@
#if HAVE_FCFINI
#include <fontconfig/fontconfig.h>
#endif
+#ifdef HAVE_PTHREAD_H
+#include <pthread.h>
+#endif
#include "cairo-test.h"
@@ -66,8 +65,10 @@
#define TRUE !FALSE
#endif
+static cairo_user_data_key_t _cairo_test_context_key;
+
static void
-xunlink (const char *pathname);
+xunlink (const cairo_test_context_t *ctx, const char *pathname);
static const char *fail_face = "", *normal_face = "";
@@ -101,20 +102,11 @@ static const char *vector_ignored_tests[] = {
NULL
};
-/* Static data is messy, but we're coding for tests here, not a
- * general-purpose library, and it keeps the tests cleaner to avoid a
- * context object there, (though not a whole lot). */
-FILE *cairo_test_log_file = NULL;
-const char *srcdir;
-const char *refdir;
-
-/* Used to catch crashes in a test, such that we report it as such and
- * continue testing, although one crasher may already have corrupted memory in
- * an nonrecoverable fashion. */
-jmp_buf jmpbuf;
-
-void
-cairo_test_init (const char *test_name)
+static void
+_cairo_test_init (cairo_test_context_t *ctx,
+ const cairo_test_t *test,
+ const char *test_name,
+ cairo_test_status_t expectation)
{
char *log_name;
@@ -122,23 +114,68 @@ cairo_test_init (const char *test_name)
feenableexcept (FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW);
#endif
+ ctx->test = test;
+ ctx->test_name = test_name;
+ ctx->expectation = expectation;
+
xasprintf (&log_name, "%s%s", test_name, CAIRO_TEST_LOG_SUFFIX);
- xunlink (log_name);
+ xunlink (NULL, log_name);
- cairo_test_log_file = fopen (log_name, "a");
- if (cairo_test_log_file == NULL) {
+ ctx->log_file = fopen (log_name, "a");
+ if (ctx->log_file == NULL) {
fprintf (stderr, "Error opening log file: %s\n", log_name);
- cairo_test_log_file = stderr;
+ ctx->log_file = stderr;
}
free (log_name);
+ ctx->srcdir = getenv ("srcdir");
+ if (ctx->srcdir == NULL)
+ ctx->srcdir = ".";
+
+ ctx->refdir = getenv ("CAIRO_REF_DIR");
+
+ ctx->thread = 0;
+
+ {
+ int tmp_num_targets;
+ cairo_bool_t tmp_limited_targets;
+ ctx->targets_to_test = cairo_boilerplate_get_targets (&tmp_num_targets, &tmp_limited_targets);
+ ctx->num_targets = tmp_num_targets;
+ ctx->limited_targets = tmp_limited_targets;
+ }
+
printf ("\nTESTING %s\n", test_name);
}
void
-cairo_test_fini (void)
+cairo_test_init (cairo_test_context_t *ctx,
+ const char *test_name)
{
- fclose (cairo_test_log_file);
+ _cairo_test_init (ctx, NULL, test_name, CAIRO_TEST_SUCCESS);
+}
+
+static void
+cairo_test_init_thread (cairo_test_context_t *ctx, cairo_test_context_t *master, int thread)
+{
+ *ctx = *master;
+ ctx->thread = thread;
+}
+
+void
+cairo_test_fini (cairo_test_context_t *ctx)
+{
+ if (ctx->thread != 0)
+ return;
+
+ if (ctx->log_file == NULL)
+ return;
+
+ if (ctx->log_file != stderr)
+ fclose (ctx->log_file);
+ ctx->log_file = NULL;
+
+ cairo_boilerplate_free_targets (ctx->targets_to_test);
+
cairo_debug_reset_static_data ();
#if HAVE_FCFINI
FcFini ();
@@ -146,10 +183,10 @@ cairo_test_fini (void)
}
void
-cairo_test_log (const char *fmt, ...)
+cairo_test_log (const cairo_test_context_t *ctx, const char *fmt, ...)
{
va_list va;
- FILE *file = cairo_test_log_file ? cairo_test_log_file : stderr;
+ FILE *file = ctx && ctx->log_file ? ctx->log_file : stderr;
va_start (va, fmt);
vfprintf (file, fmt, va);
@@ -157,7 +194,8 @@ cairo_test_log (const char *fmt, ...)
}
void
-cairo_test_log_path (const cairo_path_t *path)
+cairo_test_log_path (const cairo_test_context_t *ctx,
+ const cairo_path_t *path)
{
int i;
@@ -165,21 +203,25 @@ cairo_test_log_path (const cairo_path_t *path)
cairo_path_data_t *data = &path->data[i];
switch (data->header.type) {
case CAIRO_PATH_MOVE_TO:
- cairo_test_log (" cairo_move_to (cr, %g, %g);\n",
+ cairo_test_log (ctx,
+ " cairo_move_to (cr, %g, %g);\n",
data[1].point.x, data[1].point.y);
break;
case CAIRO_PATH_LINE_TO:
- cairo_test_log (" cairo_line_to (cr, %g, %g);\n",
+ cairo_test_log (ctx,
+ " cairo_line_to (cr, %g, %g);\n",
data[1].point.x, data[1].point.y);
break;
case CAIRO_PATH_CURVE_TO:
- cairo_test_log (" cairo_curve_to (cr, %g, %g, %g, %g, %g, %g);\n",
+ cairo_test_log (ctx,
+ " cairo_curve_to (cr, %g, %g, %g, %g, %g, %g);\n",
data[1].point.x, data[1].point.y,
data[2].point.x, data[2].point.y,
data[3].point.x, data[3].point.y);
break;
case CAIRO_PATH_CLOSE_PATH:
- cairo_test_log (" cairo_close_path (cr);\n\n");
+ cairo_test_log (ctx,
+ " cairo_close_path (cr);\n\n");
break;
default:
assert (0);
@@ -188,25 +230,26 @@ cairo_test_log_path (const cairo_path_t *path)
}
static void
-xunlink (const char *pathname)
+xunlink (const cairo_test_context_t *ctx, const char *pathname)
{
if (unlink (pathname) < 0 && errno != ENOENT) {
- cairo_test_log ("Error: Cannot remove %s: %s\n",
+ cairo_test_log (ctx, "Error: Cannot remove %s: %s\n",
pathname, strerror (errno));
exit (1);
}
}
static char *
-cairo_ref_name_for_test_target_format (const char *test_name,
+cairo_ref_name_for_test_target_format (const cairo_test_context_t *ctx,
+ const char *test_name,
const char *target_name,
const char *format)
{
char *ref_name = NULL;
/* First look for a previous build for comparison. */
- if (refdir) {
- xasprintf (&ref_name, "%s/%s-%s-%s%s", refdir,
+ if (ctx->refdir != NULL) {
+ xasprintf (&ref_name, "%s/%s-%s-%s%s", ctx->refdir,
test_name,
target_name,
format,
@@ -218,7 +261,7 @@ cairo_ref_name_for_test_target_format (const char *test_name,
}
/* Next look for a target/format-specific reference image. */
- xasprintf (&ref_name, "%s/%s-%s-%s%s", srcdir,
+ xasprintf (&ref_name, "%s/%s-%s-%s%s", ctx->srcdir,
test_name,
target_name,
format,
@@ -229,7 +272,7 @@ cairo_ref_name_for_test_target_format (const char *test_name,
goto done;
/* Next, look for target-specific reference image. */
- xasprintf (&ref_name, "%s/%s-%s%s", srcdir,
+ xasprintf (&ref_name, "%s/%s-%s%s", ctx->srcdir,
test_name,
target_name,
CAIRO_TEST_REF_SUFFIX);
@@ -239,7 +282,7 @@ cairo_ref_name_for_test_target_format (const char *test_name,
goto done;
/* Next, look for format-specific reference image. */
- xasprintf (&ref_name, "%s/%s-%s%s", srcdir,
+ xasprintf (&ref_name, "%s/%s-%s%s", ctx->srcdir,
test_name,
format,
CAIRO_TEST_REF_SUFFIX);
@@ -249,7 +292,7 @@ cairo_ref_name_for_test_target_format (const char *test_name,
goto done;
/* Finally, look for the standard reference image. */
- xasprintf (&ref_name, "%s/%s%s", srcdir,
+ xasprintf (&ref_name, "%s/%s%s", ctx->srcdir,
test_name,
CAIRO_TEST_REF_SUFFIX);
if (access (ref_name, F_OK) != 0)
@@ -264,10 +307,14 @@ done:
}
static cairo_bool_t
-cairo_test_target_has_similar (const cairo_test_t *test, cairo_boilerplate_target_t *target)
+cairo_test_target_has_similar (const cairo_test_context_t *ctx,
+ const cairo_boilerplate_target_t *target)
{
cairo_surface_t *surface;
- cairo_bool_t has_similar = FALSE;
+ cairo_bool_t has_similar;
+ cairo_t * cr;
+ cairo_surface_t *similar;
+ void *closure;
/* ignore image intermediate targets */
if (target->expected_type == CAIRO_SURFACE_TYPE_IMAGE)
@@ -276,106 +323,140 @@ cairo_test_target_has_similar (const cairo_test_t *test, cairo_boilerplate_targe
if (getenv ("CAIRO_TEST_IGNORE_SIMILAR"))
return FALSE;
- surface = (target->create_surface) (test->name,
+ surface = (target->create_surface) (ctx->test->name,
target->content,
- test->width,
- test->height,
+ ctx->test->width,
+ ctx->test->height,
+ ctx->test->width + 25 * NUM_DEVICE_OFFSETS,
+ ctx->test->height + 25 * NUM_DEVICE_OFFSETS,
CAIRO_BOILERPLATE_MODE_TEST,
- &target->closure);
- if (surface != NULL) {
- cairo_t * cr = cairo_create (surface);
- cairo_surface_t *similar;
- cairo_push_group_with_content (cr, cairo_boilerplate_content (target->content));
- similar = cairo_get_group_target (cr);
- has_similar = cairo_surface_get_type (similar) == cairo_surface_get_type (surface);
-
- cairo_destroy (cr);
- cairo_surface_destroy (surface);
-
- if (target->cleanup)
- target->cleanup (target->closure);
- }
+ 0,
+ &closure);
+ if (surface == NULL)
+ return FALSE;
+
+ cr = cairo_create (surface);
+ cairo_push_group_with_content (cr,
+ cairo_boilerplate_content (target->content));
+ similar = cairo_get_group_target (cr);
+
+ has_similar = cairo_surface_get_type (similar) == cairo_surface_get_type (surface);
+
+ cairo_destroy (cr);
+ cairo_surface_destroy (surface);
+
+ if (target->cleanup)
+ target->cleanup (closure);
return has_similar;
}
static cairo_test_status_t
-cairo_test_for_target (cairo_test_t *test,
- cairo_boilerplate_target_t *target,
+cairo_test_for_target (const cairo_test_context_t *ctx,
+ const cairo_boilerplate_target_t *target,
int dev_offset,
cairo_bool_t similar)
{
cairo_test_status_t status;
cairo_surface_t *surface = NULL;
cairo_t *cr;
+ const char *no_offset_str = "";
char *png_name, *ref_name, *diff_name, *offset_str;
- cairo_test_status_t ret = CAIRO_TEST_SUCCESS;
+ cairo_test_status_t ret;
cairo_content_t expected_content;
cairo_font_options_t *font_options;
const char *format;
+ cairo_bool_t have_output = FALSE;
+ cairo_bool_t have_result = FALSE;
+ void *closure;
+ int width, height;
/* Get the strings ready that we'll need. */
format = cairo_boilerplate_content_name (target->content);
if (dev_offset)
xasprintf (&offset_str, "-%d", dev_offset);
else
- offset_str = strdup("");
+ offset_str = (char *) no_offset_str;
- xasprintf (&png_name, "%s-%s-%s%s%s%s",
- test->name,
- target->name,
- format,
- similar ? "-similar" : "",
- offset_str, CAIRO_TEST_PNG_SUFFIX);
- ref_name = cairo_ref_name_for_test_target_format (test->name, target->name, format);
- xasprintf (&diff_name, "%s-%s-%s%s%s%s",
- test->name,
- target->name,
- format,
- similar ? "-similar" : "",
- offset_str, CAIRO_TEST_DIFF_SUFFIX);
+ ref_name = cairo_ref_name_for_test_target_format (ctx, ctx->test->name, target->name, format);
+ if (ctx->thread == 0) {
+ xasprintf (&png_name, "%s-%s-%s%s%s%s",
+ ctx->test->name,
+ target->name,
+ format,
+ similar ? "-similar" : "",
+ offset_str, CAIRO_TEST_PNG_SUFFIX);
+ xasprintf (&diff_name, "%s-%s-%s%s%s%s",
+ ctx->test->name,
+ target->name,
+ format,
+ similar ? "-similar" : "",
+ offset_str, CAIRO_TEST_DIFF_SUFFIX);
+ } else {
+ xasprintf (&png_name, "%s-%s-%s%s%s-%d%s",
+ ctx->test->name,
+ target->name,
+ format,
+ similar ? "-similar" : "",
+ offset_str,
+ ctx->thread,
+ CAIRO_TEST_PNG_SUFFIX);
+ xasprintf (&diff_name, "%s-%s-%s%s%s-%d%s",
+ ctx->test->name,
+ target->name,
+ format,
+ similar ? "-similar" : "",
+ offset_str,
+ ctx->thread,
+ CAIRO_TEST_DIFF_SUFFIX);
+ }
if (target->is_vector) {
int i;
for (i = 0; vector_ignored_tests[i] != NULL; i++)
- if (strcmp (test->name, vector_ignored_tests[i]) == 0) {
- cairo_test_log ("Error: Skipping for vector target %s\n", target->name);
+ if (strcmp (ctx->test->name, vector_ignored_tests[i]) == 0) {
+ cairo_test_log (ctx, "Error: Skipping for vector target %s\n", target->name);
ret = CAIRO_TEST_UNTESTED;
goto UNWIND_STRINGS;
}
}
- if (ret == CAIRO_TEST_SUCCESS) {
- /* Run the actual drawing code. */
-
- if (test->width && test->height) {
- test->width += dev_offset;
- test->height += dev_offset;
- }
-
- surface = (target->create_surface) (test->name,
- target->content,
- test->width,
- test->height,
- CAIRO_BOILERPLATE_MODE_TEST,
- &target->closure);
-
- if (test->width && test->height) {
- test->width -= dev_offset;
- test->height -= dev_offset;;
- }
+ width = ctx->test->width;
+ height = ctx->test->height;
+ if (width && height) {
+ width += dev_offset;
+ height += dev_offset;
}
+ have_output = FALSE;
+ have_result = FALSE;
+
+ /* Run the actual drawing code. */
+ ret = CAIRO_TEST_SUCCESS;
+ surface = (target->create_surface) (ctx->test->name,
+ target->content,
+ width, height,
+ ctx->test->width + 25 * NUM_DEVICE_OFFSETS,
+ ctx->test->height + 25 * NUM_DEVICE_OFFSETS,
+ CAIRO_BOILERPLATE_MODE_TEST,
+ ctx->thread,
+ &closure);
if (surface == NULL) {
- cairo_test_log ("Error: Failed to set %s target\n", target->name);
+ cairo_test_log (ctx, "Error: Failed to set %s target\n", target->name);
ret = CAIRO_TEST_UNTESTED;
goto UNWIND_STRINGS;
}
+ if (cairo_surface_status (surface)) {
+ cairo_test_log (ctx, "Error: Created an error surface\n");
+ ret = CAIRO_TEST_FAILURE;
+ goto UNWIND_STRINGS;
+ }
+
/* Check that we created a surface of the expected type. */
if (cairo_surface_get_type (surface) != target->expected_type) {
- cairo_test_log ("Error: Created surface is of type %d (expected %d)\n",
+ cairo_test_log (ctx, "Error: Created surface is of type %d (expected %d)\n",
cairo_surface_get_type (surface), target->expected_type);
ret = CAIRO_TEST_FAILURE;
goto UNWIND_SURFACE;
@@ -387,7 +468,7 @@ cairo_test_for_target (cairo_test_t *test,
expected_content = cairo_boilerplate_content (target->content);
if (cairo_surface_get_content (surface) != expected_content) {
- cairo_test_log ("Error: Created surface has content %d (expected %d)\n",
+ cairo_test_log (ctx, "Error: Created surface has content %d (expected %d)\n",
cairo_surface_get_content (surface), expected_content);
ret = CAIRO_TEST_FAILURE;
goto UNWIND_SURFACE;
@@ -396,6 +477,11 @@ cairo_test_for_target (cairo_test_t *test,
cairo_surface_set_device_offset (surface, dev_offset, dev_offset);
cr = cairo_create (surface);
+ if (cairo_set_user_data (cr, &_cairo_test_context_key, (void*) ctx, NULL)) {
+ ret = CAIRO_TEST_FAILURE;
+ goto UNWIND_CAIRO;
+ }
+
if (similar)
cairo_push_group_with_content (cr, expected_content);
@@ -416,40 +502,49 @@ cairo_test_for_target (cairo_test_t *test,
cairo_font_options_destroy (font_options);
cairo_save (cr);
- status = (test->draw) (cr, test->width, test->height);
+ status = (ctx->test->draw) (cr, ctx->test->width, ctx->test->height);
cairo_restore (cr);
- /* Then, check all the different ways it could fail. */
- if (status) {
- cairo_test_log ("Error: Function under test failed\n");
- ret = status;
- goto UNWIND_CAIRO;
- }
-
if (similar) {
cairo_pop_group_to_source (cr);
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
cairo_paint (cr);
}
+ /* Then, check all the different ways it could fail. */
+ if (status) {
+ cairo_test_log (ctx, "Error: Function under test failed\n");
+ ret = status;
+ goto UNWIND_CAIRO;
+ }
+
if (cairo_status (cr) != CAIRO_STATUS_SUCCESS) {
- cairo_test_log ("Error: Function under test left cairo status in an error state: %s\n",
+ cairo_test_log (ctx, "Error: Function under test left cairo status in an error state: %s\n",
cairo_status_to_string (cairo_status (cr)));
ret = CAIRO_TEST_FAILURE;
goto UNWIND_CAIRO;
}
/* Skip image check for tests with no image (width,height == 0,0) */
- if (test->width != 0 && test->height != 0) {
+ if (ctx->test->width != 0 && ctx->test->height != 0) {
buffer_diff_result_t result;
cairo_status_t diff_status;
- xunlink (png_name);
- (target->write_to_png) (surface, png_name);
- cairo_test_log ("OUTPUT: %s\n", png_name);
+ xunlink (ctx, png_name);
+
+ diff_status = (target->write_to_png) (surface, png_name);
+ if (diff_status) {
+ cairo_test_log (ctx, "Error: Failed to compare images: %s\n",
+ cairo_status_to_string (diff_status));
+ ret = CAIRO_TEST_FAILURE;
+ goto UNWIND_CAIRO;
+ }
+ have_output = TRUE;
+
if (!ref_name) {
- cairo_test_log ("Error: Cannot find reference image for %s/%s-%s-%s%s\n",srcdir,
- test->name,
+ cairo_test_log (ctx, "Error: Cannot find reference image for %s/%s-%s-%s%s\n",
+ ctx->srcdir,
+ ctx->test->name,
target->name,
format,
CAIRO_TEST_REF_SUFFIX);
@@ -457,22 +552,23 @@ cairo_test_for_target (cairo_test_t *test,
goto UNWIND_CAIRO;
}
- cairo_test_log ("REFERENCE: %s\n", ref_name);
- cairo_test_log ("DIFFERENCE: %s\n", diff_name);
-
if (target->content == CAIRO_TEST_CONTENT_COLOR_ALPHA_FLATTENED) {
- diff_status= image_diff_flattened (png_name, ref_name, diff_name,
+ diff_status = image_diff_flattened (ctx,
+ png_name, ref_name, diff_name,
dev_offset, dev_offset, 0, 0, &result);
} else {
- diff_status = image_diff (png_name, ref_name, diff_name,
+ diff_status = image_diff (ctx,
+ png_name, ref_name, diff_name,
dev_offset, dev_offset, 0, 0, &result);
}
if (diff_status) {
- cairo_test_log ("Error: Failed to compare images: %s\n",
+ cairo_test_log (ctx, "Error: Failed to compare images: %s\n",
cairo_status_to_string (diff_status));
ret = CAIRO_TEST_FAILURE;
goto UNWIND_CAIRO;
}
+
+ have_result = TRUE;
if (result.pixels_changed && result.max_diff > target->error_tolerance) {
ret = CAIRO_TEST_FAILURE;
goto UNWIND_CAIRO;
@@ -484,10 +580,19 @@ UNWIND_CAIRO:
UNWIND_SURFACE:
cairo_surface_destroy (surface);
- cairo_debug_reset_static_data ();
-
if (target->cleanup)
- target->cleanup (target->closure);
+ target->cleanup (closure);
+
+ if (ctx->thread == 0) {
+ if (have_output)
+ cairo_test_log (ctx, "OUTPUT: %s\n", png_name);
+
+ if (have_result) {
+ cairo_test_log (ctx,
+ "REFERENCE: %s\nDIFFERENCE: %s\n",
+ ref_name, diff_name);
+ }
+ }
UNWIND_STRINGS:
if (png_name)
@@ -496,13 +601,20 @@ UNWIND_STRINGS:
free (ref_name);
if (diff_name)
free (diff_name);
- if (offset_str)
+ if (offset_str != no_offset_str)
free (offset_str);
return ret;
}
-#ifdef HAVE_SIGNAL_H
+#if defined(HAVE_SIGNAL_H) && defined(HAVE_SETJMP_H)
+#include <signal.h>
+#include <setjmp.h>
+/* Used to catch crashes in a test, so that we report it as such and
+ * continue testing, although one crasher may already have corrupted memory in
+ * an nonrecoverable fashion. */
+static jmp_buf jmpbuf;
+
static void
segfault_handler (int signal)
{
@@ -511,21 +623,16 @@ segfault_handler (int signal)
#endif
static cairo_test_status_t
-cairo_test_expecting (cairo_test_t *test,
- cairo_test_status_t expectation)
+cairo_test_run (cairo_test_context_t *ctx)
{
/* we use volatile here to make sure values are not clobbered
* by longjmp */
- volatile size_t i, j, num_targets, similar, has_similar;
- volatile cairo_bool_t limited_targets = FALSE, print_fail_on_stdout = TRUE;
-#ifdef HAVE_SIGNAL_H
- void (*old_segfault_handler)(int);
-#endif
+ volatile size_t i, j;
+ volatile cairo_bool_t print_fail_on_stdout = ctx->thread == 0;
volatile cairo_test_status_t status, ret;
- cairo_boilerplate_target_t ** volatile targets_to_test;
#ifdef HAVE_UNISTD_H
- if (isatty (2)) {
+ if (ctx->thread == 0 && isatty (2)) {
fail_face = "\033[41m\033[37m\033[1m";
normal_face = "\033[m";
if (isatty (1))
@@ -533,25 +640,6 @@ cairo_test_expecting (cairo_test_t *test,
}
#endif
- srcdir = getenv ("srcdir");
- if (!srcdir)
- srcdir = ".";
- refdir = getenv ("CAIRO_REF_DIR");
-
- cairo_test_init (test->name);
- printf ("%s\n", test->description);
-
- if (expectation == CAIRO_TEST_FAILURE)
- printf ("Expecting failure\n");
-
- {
- int tmp_num_targets;
- cairo_bool_t tmp_limited_targets;
- targets_to_test = cairo_boilerplate_get_targets (&tmp_num_targets, &tmp_limited_targets);
- num_targets = tmp_num_targets;
- limited_targets = tmp_limited_targets;
- }
-
/* The intended logic here is that we return overall SUCCESS
* iff. there is at least one tested backend and that all tested
* backends return SUCCESS, OR, there's backends were manually
@@ -570,90 +658,217 @@ cairo_test_expecting (cairo_test_t *test,
* Also, on a crash, run no further tests.
*/
status = ret = CAIRO_TEST_UNTESTED;
- for (i = 0; i < num_targets; i++) {
+ for (i = 0; i < ctx->num_targets && status != CAIRO_TEST_CRASHED; i++) {
+ const cairo_boilerplate_target_t * volatile target = ctx->targets_to_test[(i + ctx->thread) % ctx->num_targets];
+
for (j = 0; j < NUM_DEVICE_OFFSETS; j++) {
- cairo_boilerplate_target_t * volatile target = targets_to_test[i];
- volatile int dev_offset = j * 25;
- has_similar = cairo_test_target_has_similar (test, target);
+ volatile int dev_offset = ((j + ctx->thread) % NUM_DEVICE_OFFSETS) * 25;
+ volatile int similar, has_similar;
+
+ has_similar = cairo_test_target_has_similar (ctx, target);
for (similar = 0; similar <= has_similar ; similar++) {
- cairo_test_log ("Testing %s with %s%s target (dev offset %d)\n", test->name, similar ? " (similar)" : "", target->name, dev_offset);
- printf ("%s-%s-%s [%d]%s:\t", test->name, target->name,
- cairo_boilerplate_content_name (target->content),
- dev_offset,
- similar ? " (similar)": "");
-
-#ifdef HAVE_SIGNAL_H
- /* Set up a checkpoint to get back to in case of segfaults. */
- old_segfault_handler = signal (SIGSEGV, segfault_handler);
- if (0 == setjmp (jmpbuf))
+ cairo_test_log (ctx, "Testing %s with %s%s target (dev offset %d)\n", ctx->test_name, similar ? " (similar)" : "", target->name, dev_offset);
+ if (ctx->thread == 0) {
+ printf ("%s-%s-%s [%d]%s:\t", ctx->test->name, target->name,
+ cairo_boilerplate_content_name (target->content),
+ dev_offset,
+ similar ? " (similar)": "");
+ fflush (stdout);
+ }
+
+#if defined(HAVE_SIGNAL_H) && defined(HAVE_SETJMP_H)
+ if (ctx->thread == 0) {
+ void (* volatile old_segfault_handler)(int);
+ void (* volatile old_sigpipe_handler)(int);
+
+ /* Set up a checkpoint to get back to in case of segfaults. */
+#ifdef SIGSEGV
+ old_segfault_handler = signal (SIGSEGV, segfault_handler);
+#endif
+#ifdef SIGPIPE
+ old_sigpipe_handler = signal (SIGPIPE, segfault_handler);
+#endif
+ if (0 == setjmp (jmpbuf))
+ status = cairo_test_for_target (ctx, target, dev_offset, similar);
+ else
+ status = CAIRO_TEST_CRASHED;
+#ifdef SIGSEGV
+ signal (SIGSEGV, old_segfault_handler);
#endif
- status = cairo_test_for_target (test, target, dev_offset, similar);
-#ifdef HAVE_SIGNAL_H
- else
- status = CAIRO_TEST_CRASHED;
- signal (SIGSEGV, old_segfault_handler);
+#ifdef SIGPIPE
+ signal (SIGPIPE, old_sigpipe_handler);
+#endif
+ } else {
+ status = cairo_test_for_target (ctx, target, dev_offset, similar);
+ }
+#else
+ status = cairo_test_for_target (ctx, target, dev_offset, similar);
#endif
- cairo_test_log ("TEST: %s TARGET: %s FORMAT: %s OFFSET: %d SIMILAR: %d RESULT: ",
- test->name, target->name,
- cairo_boilerplate_content_name (target->content),
- dev_offset, similar);
-
- switch (status) {
- case CAIRO_TEST_SUCCESS:
- printf ("PASS\n");
- cairo_test_log ("PASS\n");
- if (ret == CAIRO_TEST_UNTESTED)
- ret = CAIRO_TEST_SUCCESS;
- break;
- case CAIRO_TEST_UNTESTED:
- printf ("UNTESTED\n");
- cairo_test_log ("UNTESTED\n");
- break;
- case CAIRO_TEST_CRASHED:
- if (print_fail_on_stdout) {
- printf ("!!!CRASHED!!!\n");
- } else {
+ if (ctx->thread == 0) {
+ cairo_test_log (ctx,
+ "TEST: %s TARGET: %s FORMAT: %s OFFSET: %d SIMILAR: %d RESULT: ",
+ ctx->test->name, target->name,
+ cairo_boilerplate_content_name (target->content),
+ dev_offset, similar);
+ switch (status) {
+ case CAIRO_TEST_SUCCESS:
+ printf ("PASS\n");
+ cairo_test_log (ctx, "PASS\n");
+ if (ret == CAIRO_TEST_UNTESTED)
+ ret = CAIRO_TEST_SUCCESS;
+ break;
+ case CAIRO_TEST_UNTESTED:
+ printf ("UNTESTED\n");
+ cairo_test_log (ctx, "UNTESTED\n");
+ break;
+ case CAIRO_TEST_CRASHED:
+ if (print_fail_on_stdout) {
+ printf ("!!!CRASHED!!!\n");
+ } else {
/* eat the test name */
printf ("\r");
fflush (stdout);
- }
- cairo_test_log ("CRASHED\n");
- fprintf (stderr, "%s-%s-%s [%d]%s:\t%s!!!CRASHED!!!%s\n",
- test->name, target->name,
- cairo_boilerplate_content_name (target->content), dev_offset, similar ? " (similar)" : "",
- fail_face, normal_face);
- ret = CAIRO_TEST_FAILURE;
- break;
- default:
- case CAIRO_TEST_FAILURE:
- if (expectation == CAIRO_TEST_FAILURE) {
- printf ("XFAIL\n");
- cairo_test_log ("XFAIL\n");
- } else {
- if (print_fail_on_stdout) {
- printf ("FAIL\n");
- } else {
- /* eat the test name */
- printf ("\r");
- fflush (stdout);
}
- fprintf (stderr, "%s-%s-%s [%d]%s:\t%sFAIL%s\n",
- test->name, target->name,
+ cairo_test_log (ctx, "CRASHED\n");
+ fprintf (stderr, "%s-%s-%s [%d]%s:\t%s!!!CRASHED!!!%s\n",
+ ctx->test->name, target->name,
cairo_boilerplate_content_name (target->content), dev_offset, similar ? " (similar)" : "",
fail_face, normal_face);
- cairo_test_log ("FAIL\n");
+ ret = CAIRO_TEST_FAILURE;
+ break;
+ default:
+ case CAIRO_TEST_FAILURE:
+ if (ctx->expectation == CAIRO_TEST_FAILURE) {
+ printf ("XFAIL\n");
+ cairo_test_log (ctx, "XFAIL\n");
+ } else {
+ if (print_fail_on_stdout) {
+ printf ("FAIL\n");
+ } else {
+ /* eat the test name */
+ printf ("\r");
+ fflush (stdout);
+ }
+ fprintf (stderr, "%s-%s-%s [%d]%s:\t%sFAIL%s\n",
+ ctx->test->name, target->name,
+ cairo_boilerplate_content_name (target->content), dev_offset, similar ? " (similar)" : "",
+ fail_face, normal_face);
+ cairo_test_log (ctx, "FAIL\n");
+ }
+ ret = CAIRO_TEST_FAILURE;
+ break;
+ }
+ fflush (stdout);
+ } else {
+#ifdef HAVE_FLOCKFILE
+ flockfile (stdout);
+#endif
+ printf ("%s-%s-%s %d [%d]:\t",
+ ctx->test->name, target->name,
+ cairo_boilerplate_content_name (target->content),
+ ctx->thread,
+ dev_offset);
+ switch (status) {
+ case CAIRO_TEST_SUCCESS:
+ printf ("PASS\n");
+ break;
+ case CAIRO_TEST_UNTESTED:
+ printf ("UNTESTED\n");
+ break;
+ case CAIRO_TEST_CRASHED:
+ printf ("!!!CRASHED!!!\n");
+ ret = CAIRO_TEST_FAILURE;
+ break;
+ default:
+ case CAIRO_TEST_FAILURE:
+ if (ctx->expectation == CAIRO_TEST_FAILURE) {
+ printf ("XFAIL\n");
+ } else {
+ printf ("FAIL\n");
+ }
+ ret = CAIRO_TEST_FAILURE;
+ break;
}
- ret = status;
- break;
- }
- if (status == CAIRO_TEST_CRASHED)
- goto out;
+ fflush (stdout);
+#ifdef HAVE_FLOCKFILE
+ funlockfile (stdout);
+#endif
+ }
}
}
}
-out:
+
+ return ret;
+}
+
+#ifdef HAVE_PTHREAD_H
+typedef struct _cairo_test_thread {
+ pthread_t thread;
+ cairo_test_context_t *ctx;
+ size_t id;
+} cairo_test_thread_t;
+
+static void *
+cairo_test_run_threaded (void *closure)
+{
+ cairo_test_thread_t *arg = closure;
+ cairo_test_context_t ctx;
+ cairo_test_status_t ret;
+
+ cairo_test_init_thread (&ctx, arg->ctx, arg->id);
+
+ ret = cairo_test_run (&ctx);
+
+ cairo_test_fini (&ctx);
+
+ return (void *) ret;
+}
+#endif
+
+
+static cairo_test_status_t
+cairo_test_expecting (const cairo_test_t *test,
+ cairo_test_status_t expectation)
+{
+ cairo_test_context_t ctx;
+ cairo_test_status_t ret = CAIRO_TEST_SUCCESS;
+ size_t num_threads;
+
+ _cairo_test_init (&ctx, test, test->name, expectation);
+ printf ("%s\n", test->description);
+
+ if (expectation == CAIRO_TEST_FAILURE)
+ printf ("Expecting failure\n");
+
+#ifdef HAVE_PTHREAD_H
+ num_threads = 0;
+ if (getenv ("CAIRO_TEST_NUM_THREADS"))
+ num_threads = atoi (getenv ("CAIRO_TEST_NUM_THREADS"));
+ if (num_threads > 1) {
+ cairo_test_thread_t *threads;
+ size_t n;
+
+ threads = xmalloc (sizeof (cairo_test_thread_t) * num_threads);
+ for (n = 0; n < num_threads; n++) {
+ threads[n].ctx = &ctx;
+ threads[n].id = n + 1;
+ pthread_create (&threads[n].thread, NULL,
+ cairo_test_run_threaded, &threads[n]);
+ }
+ for (n = 0; n < num_threads; n++) {
+ void *tmp;
+ pthread_join (threads[n].thread, &tmp);
+ if (ret == CAIRO_TEST_SUCCESS)
+ ret = (cairo_test_status_t) tmp;
+ }
+ free (threads);
+ }
+
+ if (ret == CAIRO_TEST_SUCCESS)
+#endif
+ ret = cairo_test_run (&ctx);
if (ret != CAIRO_TEST_SUCCESS)
printf ("Check %s%s out for more information.\n", test->name, CAIRO_TEST_LOG_SUFFIX);
@@ -661,7 +876,7 @@ out:
/* if the set of targets to test was limited using CAIRO_TEST_TARGET, we
* behave slightly differently, to ensure that limiting the targets does
* not increase the number of tests failing. */
- if (limited_targets) {
+ if (ctx.limited_targets) {
/* if all untested, success */
if (ret == CAIRO_TEST_UNTESTED) {
@@ -680,21 +895,18 @@ out:
}
} else {
-
if (ret == CAIRO_TEST_UNTESTED)
ret = CAIRO_TEST_FAILURE;
}
- cairo_test_fini ();
-
- cairo_boilerplate_free_targets (targets_to_test);
+ cairo_test_fini (&ctx);
return ret;
}
cairo_test_status_t
-cairo_test (cairo_test_t *test)
+cairo_test (const cairo_test_t *test)
{
cairo_test_status_t expectation = CAIRO_TEST_SUCCESS;
const char *xfails;
@@ -726,20 +938,26 @@ cairo_test (cairo_test_t *test)
return cairo_test_expecting (test, expectation);
}
+const cairo_test_context_t *
+cairo_test_get_context (cairo_t *cr)
+{
+ return cairo_get_user_data (cr, &_cairo_test_context_key);
+}
+
cairo_surface_t *
-cairo_test_create_surface_from_png (const char *filename)
+cairo_test_create_surface_from_png (const cairo_test_context_t *ctx,
+ const char *filename)
{
cairo_surface_t *image;
- char *srcdir = getenv ("srcdir");
image = cairo_image_surface_create_from_png (filename);
if (cairo_surface_status(image)) {
/* expect not found when running with srcdir != builddir
* such as when 'make distcheck' is run
*/
- if (srcdir) {
+ if (ctx->srcdir) {
char *srcdir_filename;
- xasprintf (&srcdir_filename, "%s/%s", srcdir, filename);
+ xasprintf (&srcdir_filename, "%s/%s", ctx->srcdir, filename);
image = cairo_image_surface_create_from_png (srcdir_filename);
free (srcdir_filename);
}
@@ -749,12 +967,13 @@ cairo_test_create_surface_from_png (const char *filename)
}
cairo_pattern_t *
-cairo_test_create_pattern_from_png (const char *filename)
+cairo_test_create_pattern_from_png (const cairo_test_context_t *ctx,
+ const char *filename)
{
cairo_surface_t *image;
cairo_pattern_t *pattern;
- image = cairo_test_create_surface_from_png (filename);
+ image = cairo_test_create_surface_from_png (ctx, filename);
pattern = cairo_pattern_create_for_surface (image);
@@ -807,7 +1026,8 @@ cairo_test_paint_checkered (cairo_t *cr)
cairo_paint (cr);
cairo_restore (cr);
+ status = cairo_surface_status (check);
cairo_surface_destroy (check);
- return CAIRO_STATUS_SUCCESS;
+ return status;
}
diff --git a/test/cairo-test.h b/test/cairo-test.h
index 381fd4c8d..09f5fd875 100644
--- a/test/cairo-test.h
+++ b/test/cairo-test.h
@@ -66,15 +66,18 @@ typedef enum cairo_test_status {
CAIRO_TEST_CRASHED
} cairo_test_status_t;
+typedef struct _cairo_test_context cairo_test_context_t;
+typedef struct _cairo_test cairo_test_t;
+
typedef cairo_test_status_t (cairo_test_draw_function_t) (cairo_t *cr, int width, int height);
-typedef struct _cairo_test {
+struct _cairo_test {
const char *name;
const char *description;
int width;
int height;
cairo_test_draw_function_t *draw;
-} cairo_test_t;
+};
/* The standard test interface which works by examining result image.
*
@@ -99,7 +102,35 @@ typedef struct _cairo_test {
* to the four criteria above.
*/
cairo_test_status_t
-cairo_test (cairo_test_t *test);
+cairo_test (const cairo_test_t *test);
+
+/* The full context for the test.
+ * For ordinary tests (using cairo_test()) the context is passed to the draw
+ * routine via user_data on the cairo_t. The reason why the context is not
+ * passed as an explicit parameter is that it is rarely required by the test
+ * itself and by removing the parameter we can keep the draw routines simple
+ * and serve as example code.
+ */
+struct _cairo_test_context {
+ const cairo_test_t *test;
+ const char *test_name;
+ cairo_test_status_t expectation;
+
+ FILE *log_file;
+ const char *srcdir; /* directory containing sources and input data */
+ const char *refdir; /* directory containing reference images */
+
+ size_t num_targets;
+ cairo_bool_t limited_targets;
+ cairo_boilerplate_target_t **targets_to_test;
+
+ int thread;
+};
+
+/* Retrieve the test context from the cairo_t, used for logging, paths etc */
+const cairo_test_context_t *
+cairo_test_get_context (cairo_t *cr);
+
/* cairo_test_init(), cairo_test_log(), and cairo_test_fini() exist to
* help in writing tests for which cairo_test() is not appropriate for
@@ -108,30 +139,37 @@ cairo_test (cairo_test_t *test);
* than be handed one by cairo_test.
*/
+
/* Initialize test-specific resources, (log files, etc.) */
void
-cairo_test_init (const char *test_name);
+cairo_test_init (cairo_test_context_t *ctx,
+ const char *test_name);
/* Finalize test-specific resource. */
void
-cairo_test_fini (void);
+cairo_test_fini (cairo_test_context_t *ctx);
+
/* Print a message to the log file, ala printf. */
void
-cairo_test_log (const char *fmt, ...) CAIRO_BOILERPLATE_PRINTF_FORMAT(1, 2);
+cairo_test_log (const cairo_test_context_t *ctx,
+ const char *fmt, ...) CAIRO_BOILERPLATE_PRINTF_FORMAT(2, 3);
void
-cairo_test_log_path (const cairo_path_t *path);
+cairo_test_log_path (const cairo_test_context_t *ctx,
+ const cairo_path_t *path);
/* Helper functions that take care of finding source images even when
* building in a non-srcdir manner, (ie. the tests will be run in a
* directory that is different from the one where the source image
* exists). */
cairo_surface_t *
-cairo_test_create_surface_from_png (const char *filename);
+cairo_test_create_surface_from_png (const cairo_test_context_t *ctx,
+ const char *filename);
cairo_pattern_t *
-cairo_test_create_pattern_from_png (const char *filename);
+cairo_test_create_pattern_from_png (const cairo_test_context_t *ctx,
+ const char *filename);
cairo_status_t
cairo_test_paint_checkered (cairo_t *cr);
diff --git a/test/caps-joins-alpha.c b/test/caps-joins-alpha.c
index cdf608613..7595095e0 100644
--- a/test/caps-joins-alpha.c
+++ b/test/caps-joins-alpha.c
@@ -32,7 +32,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"caps-joins-alpha",
"Test caps and joins with some source alpha",
3 * (PAD + SIZE) + PAD,
diff --git a/test/caps-joins.c b/test/caps-joins.c
index c7306a01b..bbda0478d 100644
--- a/test/caps-joins.c
+++ b/test/caps-joins.c
@@ -31,7 +31,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"caps-joins",
"Test caps and joins",
3 * (PAD + SIZE) + PAD,
diff --git a/test/caps-sub-paths.c b/test/caps-sub-paths.c
index 73af8aa7e..e431576d1 100644
--- a/test/caps-sub-paths.c
+++ b/test/caps-sub-paths.c
@@ -32,7 +32,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"caps-sub-paths",
"Test that sub-paths receive caps.",
20, 20,
diff --git a/test/clip-all.c b/test/clip-all.c
index b38e7b9b9..7e08b8e58 100644
--- a/test/clip-all.c
+++ b/test/clip-all.c
@@ -30,7 +30,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"clip-all",
"Test clipping with everything clipped out",
SIZE, SIZE,
diff --git a/test/clip-empty.c b/test/clip-empty.c
index 90491536f..2635042df 100644
--- a/test/clip-empty.c
+++ b/test/clip-empty.c
@@ -29,7 +29,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"clip-empty",
"Test clipping with an empty clip path",
SIZE, SIZE,
diff --git a/test/clip-fill-rule-pixel-aligned.c b/test/clip-fill-rule-pixel-aligned.c
index c2bb08b3b..db7f66ffe 100644
--- a/test/clip-fill-rule-pixel-aligned.c
+++ b/test/clip-fill-rule-pixel-aligned.c
@@ -30,7 +30,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"clip-fill-rule-pixel-aligned",
"Tests interaction of clipping and cairo_set_fill_rule with a pixel-aligned path",
PAD + (SIZE*4) + PAD + (SIZE*4) + PAD,
diff --git a/test/clip-fill-rule.c b/test/clip-fill-rule.c
index 5012b3b1f..7140bc5b2 100644
--- a/test/clip-fill-rule.c
+++ b/test/clip-fill-rule.c
@@ -29,7 +29,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"clip-fill-rule",
"Tests interaction of clipping with cairo_set_fill_rule",
STAR_SIZE * 2 + 2, STAR_SIZE + 2,
diff --git a/test/clip-nesting.c b/test/clip-nesting.c
index 09f77fda8..e82e81762 100644
--- a/test/clip-nesting.c
+++ b/test/clip-nesting.c
@@ -33,7 +33,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"clip-nesting",
"Test clipping with multiple contexts for the same surface",
SIZE, SIZE,
diff --git a/test/clip-operator.c b/test/clip-operator.c
index 3bfb5ba49..d6e20c879 100644
--- a/test/clip-operator.c
+++ b/test/clip-operator.c
@@ -115,7 +115,7 @@ draw_rects (cairo_t *cr, int x, int y)
cairo_fill (cr);
}
-static void (*draw_funcs[])(cairo_t *cr, int x, int y) = {
+static void (* const draw_funcs[])(cairo_t *cr, int x, int y) = {
draw_mask,
draw_glyphs,
draw_polygon,
@@ -130,7 +130,7 @@ static void (*draw_funcs[])(cairo_t *cr, int x, int y) = {
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"clip-operator",
"Surface clipping with different operators",
IMAGE_WIDTH, IMAGE_HEIGHT,
@@ -140,6 +140,7 @@ cairo_test_t test = {
static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
+ const cairo_test_context_t *ctx = cairo_test_get_context (cr);
size_t j, x, y;
cairo_operator_t op;
cairo_pattern_t *pattern;
@@ -178,14 +179,14 @@ draw (cairo_t *cr, int width, int height)
draw_funcs[j] (cr, x, y);
if (cairo_status (cr))
- cairo_test_log ("%d %d HERE!\n", op, (int)j);
+ cairo_test_log (ctx, "%d %d HERE!\n", op, (int)j);
cairo_restore (cr);
}
}
if (cairo_status (cr) != CAIRO_STATUS_SUCCESS)
- cairo_test_log ("%d %d .HERE!\n", op, (int)j);
+ cairo_test_log (ctx, "%d %d .HERE!\n", op, (int)j);
return CAIRO_TEST_SUCCESS;
}
diff --git a/test/clip-push-group.c b/test/clip-push-group.c
index 8274e85d4..66027b43b 100644
--- a/test/clip-push-group.c
+++ b/test/clip-push-group.c
@@ -38,7 +38,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"clip-push-group",
"Test that push_group doesn't crash after setting a surface-based clip",
SIZE, SIZE,
diff --git a/test/clip-twice.c b/test/clip-twice.c
index 71a3c148b..435b0c55b 100644
--- a/test/clip-twice.c
+++ b/test/clip-twice.c
@@ -30,7 +30,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"clip-twice",
"Verifies that the clip mask is updated correctly when it constructed by setting the clip path twice.",
WIDTH, HEIGHT,
diff --git a/test/clip-zero.c b/test/clip-zero.c
index bf96d8c91..4482c163b 100644
--- a/test/clip-zero.c
+++ b/test/clip-zero.c
@@ -28,7 +28,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"clip-zero",
"Verifies that 0x0 surfaces or clips don't cause problems.",
0, 0,
diff --git a/test/clipped-group.c b/test/clipped-group.c
index 724e6cf5a..e1f68bec0 100644
--- a/test/clipped-group.c
+++ b/test/clipped-group.c
@@ -30,7 +30,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"clipped-group",
"Test that a clipped group ends up in the right place",
WIDTH, HEIGHT,
diff --git a/test/close-path.c b/test/close-path.c
index 04658b2a2..999fb3760 100644
--- a/test/close-path.c
+++ b/test/close-path.c
@@ -28,7 +28,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"close-path",
"Test some corner cases related to cairo_close_path",
32, 16,
diff --git a/test/composite-integer-translate-over-repeat.c b/test/composite-integer-translate-over-repeat.c
index 2d79ee682..c691acb35 100644
--- a/test/composite-integer-translate-over-repeat.c
+++ b/test/composite-integer-translate-over-repeat.c
@@ -34,7 +34,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"composite-integer-translate-over-repeat",
"Test simple compositing: integer-translation 32->32 OVER, with repeat",
SIZE, SIZE,
diff --git a/test/composite-integer-translate-over.c b/test/composite-integer-translate-over.c
index 2eac588e4..835a4dcb5 100644
--- a/test/composite-integer-translate-over.c
+++ b/test/composite-integer-translate-over.c
@@ -32,7 +32,7 @@ const char png_filename[] = "romedalen.png";
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"composite-integer-translate-over",
"Test simple compositing: integer-translation 32->32 OVER",
SIZE, SIZE,
@@ -42,9 +42,10 @@ cairo_test_t test = {
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_surface_t *image;
- image = cairo_test_create_surface_from_png (png_filename);
+ image = cairo_test_create_surface_from_png (ctx, png_filename);
cairo_set_source_rgba (cr, 0, 0, 0, 1);
cairo_rectangle (cr, 0, 0, SIZE, SIZE);
diff --git a/test/composite-integer-translate-source.c b/test/composite-integer-translate-source.c
index 67813b71b..0945cc1d8 100644
--- a/test/composite-integer-translate-source.c
+++ b/test/composite-integer-translate-source.c
@@ -35,7 +35,7 @@ const char png_filename[] = "romedalen.png";
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"composite-integer-translate-source",
"Test simple compositing: integer-translation 32->32 SOURCE",
SIZE, SIZE,
@@ -45,9 +45,10 @@ cairo_test_t test = {
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_surface_t *image;
- image = cairo_test_create_surface_from_png (png_filename);
+ image = cairo_test_create_surface_from_png (ctx, png_filename);
cairo_set_source_rgba (cr, 0, 0, 0, 1);
cairo_rectangle (cr, 0, 0, SIZE, SIZE);
diff --git a/test/copy-path.c b/test/copy-path.c
index 362bb34d3..dfc671dce 100644
--- a/test/copy-path.c
+++ b/test/copy-path.c
@@ -28,7 +28,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"copy-path",
"Tests calls to path_data functions: cairo_copy_path, cairo_copy_path_flat, and cairo_append_path",
45, 53,
@@ -96,6 +96,7 @@ make_path (cairo_t *cr)
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_path_t *path;
cairo_t *cr_error;
@@ -105,7 +106,8 @@ draw (cairo_t *cr, int width, int height)
path = cairo_copy_path (cr_error);
if (path->status == CAIRO_STATUS_SUCCESS ||
path->status != cairo_status (cr_error)) {
- cairo_test_log ("Error: cairo_copy_path returned status of %s rather than propagating %s\n",
+ cairo_test_log (ctx,
+ "Error: cairo_copy_path returned status of %s rather than propagating %s\n",
cairo_status_to_string (path->status),
cairo_status_to_string (cairo_status (cr_error)));
cairo_path_destroy (path);
@@ -116,7 +118,8 @@ draw (cairo_t *cr, int width, int height)
path = cairo_copy_path_flat (cr_error);
if (path->status == CAIRO_STATUS_SUCCESS ||
path->status != cairo_status (cr_error)) {
- cairo_test_log ("Error: cairo_copy_path_flat returned status of %s rather than propagating %s\n",
+ cairo_test_log (ctx,
+ "Error: cairo_copy_path_flat returned status of %s rather than propagating %s\n",
cairo_status_to_string (path->status),
cairo_status_to_string (cairo_status (cr_error)));
cairo_path_destroy (path);
@@ -125,18 +128,20 @@ draw (cairo_t *cr, int width, int height)
cairo_path_destroy (path);
cairo_destroy (cr_error);
-
+
/* first check that we can copy an empty path */
cairo_new_path (cr);
path = cairo_copy_path (cr);
if (path->status != CAIRO_STATUS_SUCCESS) {
- cairo_test_log ("Error: cairo_copy_path returned status of %s\n",
+ cairo_test_log (ctx,
+ "Error: cairo_copy_path returned status of %s\n",
cairo_status_to_string (path->status));
cairo_path_destroy (path);
return CAIRO_TEST_FAILURE;
}
if (path->num_data != 0) {
- cairo_test_log ("Error: cairo_copy_path did not copy an empty path, returned path contains %d elements\n",
+ cairo_test_log (ctx,
+ "Error: cairo_copy_path did not copy an empty path, returned path contains %d elements\n",
path->num_data);
cairo_path_destroy (path);
return CAIRO_TEST_FAILURE;
@@ -144,7 +149,8 @@ draw (cairo_t *cr, int width, int height)
cairo_append_path (cr, path);
cairo_path_destroy (path);
if (cairo_status (cr) != CAIRO_STATUS_SUCCESS) {
- cairo_test_log ("Error: cairo_append_path failed with a copy of an empty path, returned status of %s\n",
+ cairo_test_log (ctx,
+ "Error: cairo_append_path failed with a copy of an empty path, returned status of %s\n",
cairo_status_to_string (cairo_status (cr)));
return CAIRO_TEST_FAILURE;
}
@@ -197,51 +203,75 @@ draw (cairo_t *cr, int width, int height)
int
main (void)
{
+ cairo_test_context_t ctx;
cairo_t *cr;
cairo_path_data_t data;
cairo_path_t path;
cairo_surface_t *surface;
+ cairo_status_t status;
+
+ cairo_test_init (&ctx, "copy-path");
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 1, 1);
/* Test a few error cases for cairo_append_path_data */
cr = cairo_create (surface);
cairo_append_path (cr, NULL);
- if (cairo_status (cr) != CAIRO_STATUS_NULL_POINTER)
- return 1;
+ status = cairo_status (cr);
cairo_destroy (cr);
+ if (status != CAIRO_STATUS_NULL_POINTER) {
+ cairo_surface_destroy (surface);
+ cairo_test_fini (&ctx);
+ return CAIRO_TEST_FAILURE;
+ }
cr = cairo_create (surface);
path.status = -1;
cairo_append_path (cr, &path);
- if (cairo_status (cr) != CAIRO_STATUS_INVALID_STATUS)
- return 1;
+ status = cairo_status (cr);
cairo_destroy (cr);
+ if (status != CAIRO_STATUS_INVALID_STATUS) {
+ cairo_surface_destroy (surface);
+ cairo_test_fini (&ctx);
+ return CAIRO_TEST_FAILURE;
+ }
cr = cairo_create (surface);
path.status = CAIRO_STATUS_NO_MEMORY;
cairo_append_path (cr, &path);
- if (cairo_status (cr) != CAIRO_STATUS_NO_MEMORY)
- return 1;
+ status = cairo_status (cr);
cairo_destroy (cr);
+ if (status != CAIRO_STATUS_NO_MEMORY) {
+ cairo_surface_destroy (surface);
+ cairo_test_fini (&ctx);
+ return CAIRO_TEST_FAILURE;
+ }
cr = cairo_create (surface);
path.data = NULL;
path.num_data = 0;
path.status = CAIRO_STATUS_SUCCESS;
cairo_append_path (cr, &path);
- if (cairo_status (cr) != CAIRO_STATUS_SUCCESS)
- return 1;
+ status = cairo_status (cr);
cairo_destroy (cr);
+ if (status != CAIRO_STATUS_SUCCESS) {
+ cairo_surface_destroy (surface);
+ cairo_test_fini (&ctx);
+ return CAIRO_TEST_FAILURE;
+ }
cr = cairo_create (surface);
path.data = NULL;
path.num_data = 1;
path.status = CAIRO_STATUS_SUCCESS;
cairo_append_path (cr, &path);
- if (cairo_status (cr) != CAIRO_STATUS_NULL_POINTER)
- return 1;
+ status = cairo_status (cr);
cairo_destroy (cr);
+ if (status != CAIRO_STATUS_NULL_POINTER) {
+ cairo_surface_destroy (surface);
+ cairo_test_fini (&ctx);
+ return CAIRO_TEST_FAILURE;
+ }
cr = cairo_create (surface);
/* Intentionally insert bogus header.length value (otherwise would be 2) */
@@ -250,19 +280,28 @@ main (void)
path.data = &data;
path.num_data = 1;
cairo_append_path (cr, &path);
- if (cairo_status (cr) != CAIRO_STATUS_INVALID_PATH_DATA)
- return 1;
+ status = cairo_status (cr);
cairo_destroy (cr);
+ if (status != CAIRO_STATUS_INVALID_PATH_DATA) {
+ cairo_surface_destroy (surface);
+ cairo_test_fini (&ctx);
+ return CAIRO_TEST_FAILURE;
+ }
/* And test the degnerate case */
cr = cairo_create (surface);
path.num_data = 0;
cairo_append_path (cr, &path);
- if (cairo_status (cr) != CAIRO_STATUS_SUCCESS)
- return 1;
+ status = cairo_status (cr);
cairo_destroy (cr);
+ if (status != CAIRO_STATUS_SUCCESS) {
+ cairo_surface_destroy (surface);
+ cairo_test_fini (&ctx);
+ return CAIRO_TEST_FAILURE;
+ }
cairo_surface_destroy (surface);
+ cairo_test_fini (&ctx);
return cairo_test (&test);
}
diff --git a/test/create-for-stream.c b/test/create-for-stream.c
index 379412fc5..9d90cf4ef 100644
--- a/test/create-for-stream.c
+++ b/test/create-for-stream.c
@@ -85,6 +85,7 @@ draw_to (cairo_surface_t *surface)
}
typedef struct _write_closure {
+ const cairo_test_context_t *ctx;
char buffer[MAX_OUTPUT_SIZE];
size_t index;
cairo_test_status_t status;
@@ -106,7 +107,7 @@ test_write (void *closure,
write_closure_t *wc = closure;
if (wc->index + length >= sizeof wc->buffer) {
- cairo_test_log ("Error: out of bounds in write callback\n");
+ cairo_test_log (wc->ctx, "Error: out of bounds in write callback\n");
wc->status = CAIRO_TEST_FAILURE;
return CAIRO_STATUS_SUCCESS;
}
@@ -130,7 +131,8 @@ typedef cairo_surface_t *
double height_in_points);
static cairo_test_status_t
-test_surface (const char *backend,
+test_surface (const cairo_test_context_t *ctx,
+ const char *backend,
const char *filename,
file_constructor_t file_constructor,
stream_constructor_t stream_constructor)
@@ -147,7 +149,9 @@ test_surface (const char *backend,
status = cairo_surface_status (surface);
if (status) {
- cairo_test_log ("%s: Failed to create surface for stream.\n", backend);
+ cairo_test_log (ctx,
+ "%s: Failed to create surface for stream.\n",
+ backend);
return CAIRO_TEST_FAILURE;
}
@@ -158,12 +162,14 @@ test_surface (const char *backend,
cairo_surface_destroy (surface);
if (status != CAIRO_STATUS_WRITE_ERROR) {
- cairo_test_log ("%s: Error: expected \"write error\", but received \"%s\".\n",
+ cairo_test_log (ctx,
+ "%s: Error: expected \"write error\", but received \"%s\".\n",
backend, cairo_status_to_string (status));
return CAIRO_TEST_FAILURE;
}
/* construct the real surface */
+ wc.ctx = ctx;
wc.status = CAIRO_TEST_SUCCESS;
wc.index = 0;
@@ -172,7 +178,8 @@ test_surface (const char *backend,
status = cairo_surface_status (surface);
if (status) {
- cairo_test_log ("%s: Failed to create surface for stream.\n", backend);
+ cairo_test_log (ctx,
+ "%s: Failed to create surface for stream.\n", backend);
return CAIRO_TEST_FAILURE;
}
@@ -190,7 +197,7 @@ test_surface (const char *backend,
status = cairo_surface_status (surface);
if (status) {
- cairo_test_log ("%s: Failed to create surface for file %s: %s.\n",
+ cairo_test_log (ctx, "%s: Failed to create surface for file %s: %s.\n",
backend, filename, cairo_status_to_string (status));
return CAIRO_TEST_FAILURE;
}
@@ -201,20 +208,20 @@ test_surface (const char *backend,
fp = fopen (filename, "r");
if (fp == NULL) {
- cairo_test_log ("%s: Failed to open %s for reading: %s.\n",
+ cairo_test_log (ctx, "%s: Failed to open %s for reading: %s.\n",
backend, filename, strerror (errno));
return CAIRO_TEST_FAILURE;
}
if (fread (file_contents, 1, wc.index, fp) != wc.index) {
- cairo_test_log ("%s: Failed to read %s: %s.\n",
+ cairo_test_log (ctx, "%s: Failed to read %s: %s.\n",
backend, filename, strerror (errno));
fclose (fp);
return CAIRO_TEST_FAILURE;
}
if (memcmp (file_contents, wc.buffer, wc.index) != 0) {
- cairo_test_log ("%s: Stream based output differ from file output for %s.\n",
+ cairo_test_log (ctx, "%s: Stream based output differ from file output for %s.\n",
backend, filename);
fclose (fp);
return CAIRO_TEST_FAILURE;
@@ -228,17 +235,18 @@ test_surface (const char *backend,
int
main (void)
{
+ cairo_test_context_t ctx;
cairo_test_status_t status = CAIRO_TEST_SUCCESS;
cairo_test_status_t test_status;
const char test_name[] = "create-for-stream";
- cairo_test_init (test_name);
+ cairo_test_init (&ctx, test_name);
#if CAIRO_HAS_PS_SURFACE
- test_status = test_surface ("ps", "create-for-stream.ps",
+ test_status = test_surface (&ctx, "ps", "create-for-stream.ps",
cairo_ps_surface_create,
cairo_ps_surface_create_for_stream);
- cairo_test_log ("TEST: %s TARGET: %s RESULT: %s\n",
+ cairo_test_log (&ctx, "TEST: %s TARGET: %s RESULT: %s\n",
test_name, "ps",
test_status ? "FAIL" : "PASS");
if (status == CAIRO_TEST_SUCCESS)
@@ -246,10 +254,10 @@ main (void)
#endif
#if CAIRO_HAS_PDF_SURFACE
- test_status = test_surface ("pdf", "create-for-stream.pdf",
+ test_status = test_surface (&ctx, "pdf", "create-for-stream.pdf",
cairo_pdf_surface_create,
cairo_pdf_surface_create_for_stream);
- cairo_test_log ("TEST: %s TARGET: %s RESULT: %s\n",
+ cairo_test_log (&ctx, "TEST: %s TARGET: %s RESULT: %s\n",
test_name, "pdf",
test_status ? "FAIL" : "PASS");
if (status == CAIRO_TEST_SUCCESS)
@@ -257,17 +265,17 @@ main (void)
#endif
#if CAIRO_HAS_SVG_SURFACE
- test_status = test_surface ("svg", "create-for-stream.svg",
+ test_status = test_surface (&ctx, "svg", "create-for-stream.svg",
cairo_svg_surface_create,
cairo_svg_surface_create_for_stream);
- cairo_test_log ("TEST: %s TARGET: %s RESULT: %s\n",
+ cairo_test_log (&ctx, "TEST: %s TARGET: %s RESULT: %s\n",
test_name, "svg",
test_status ? "FAIL" : "PASS");
if (status == CAIRO_TEST_SUCCESS)
status = test_status;
#endif
- cairo_test_fini ();
+ cairo_test_fini (&ctx);
return status;
}
diff --git a/test/create-from-png-stream.c b/test/create-from-png-stream.c
index 4e8a29d8a..4fe05794d 100644
--- a/test/create-from-png-stream.c
+++ b/test/create-from-png-stream.c
@@ -33,7 +33,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"create-from-png-stream",
"Tests the creation of an image surface from a PNG using a FILE *",
WIDTH, HEIGHT,
@@ -56,17 +56,17 @@ read_png_from_file (void *closure, unsigned char *data, unsigned int length)
static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
- char *srcdir = getenv ("srcdir");
+ const cairo_test_context_t *ctx = cairo_test_get_context (cr);
char *filename;
FILE *file;
cairo_surface_t *surface;
- xasprintf (&filename, "%s/%s", srcdir ? srcdir : ".",
+ xasprintf (&filename, "%s/%s", ctx->srcdir,
"create-from-png-stream-ref.png");
file = fopen (filename, "rb");
if (file == NULL) {
- cairo_test_log ("Error: failed to open file: %s\n", filename);
+ cairo_test_log (ctx, "Error: failed to open file: %s\n", filename);
return CAIRO_TEST_FAILURE;
}
@@ -76,7 +76,9 @@ draw (cairo_t *cr, int width, int height)
fclose (file);
if (surface == NULL) {
- cairo_test_log ("Error: failed to create surface from PNG: %s\n", filename);
+ cairo_test_log (ctx,
+ "Error: failed to create surface from PNG: %s\n",
+ filename);
free (filename);
return CAIRO_TEST_FAILURE;
}
diff --git a/test/create-from-png.c b/test/create-from-png.c
index 0707680cb..52831f06c 100644
--- a/test/create-from-png.c
+++ b/test/create-from-png.c
@@ -32,7 +32,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"create-from-png",
"Tests the creation of an image surface from a PNG file",
WIDTH, HEIGHT,
@@ -54,16 +54,16 @@ read_error (void *closure, unsigned char *data, unsigned int size)
static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
- char *srcdir = getenv ("srcdir");
+ const cairo_test_context_t *ctx = cairo_test_get_context (cr);
char *filename;
cairo_surface_t *surface;
- xasprintf (&filename, "%s/%s", srcdir ? srcdir : ".",
+ xasprintf (&filename, "%s/%s", ctx->srcdir,
"create-from-png-ref.png");
surface = cairo_image_surface_create_from_png (filename);
if (cairo_surface_status (surface)) {
- cairo_test_log ("Error reading PNG image %s: %s\n",
+ cairo_test_log (ctx, "Error reading PNG image %s: %s\n",
filename,
cairo_status_to_string (cairo_surface_status (surface)));
free (filename);
@@ -82,189 +82,177 @@ draw (cairo_t *cr, int width, int height)
int
main (void)
{
- char *srcdir = getenv ("srcdir");
+ cairo_test_context_t ctx;
char *filename;
cairo_surface_t *surface;
cairo_status_t status;
+ cairo_test_status_t result = CAIRO_TEST_SUCCESS;
+
+ cairo_test_init (&ctx, "create-from-png");
surface = cairo_image_surface_create_from_png ("___THIS_FILE_DOES_NOT_EXIST___");
if (cairo_surface_status (surface) != CAIRO_STATUS_FILE_NOT_FOUND) {
- cairo_test_log ("Error: expected \"file not found\", but got: %s\n",
+ cairo_test_log (&ctx, "Error: expected \"file not found\", but got: %s\n",
cairo_status_to_string (cairo_surface_status (surface)));
- cairo_surface_destroy (surface);
- return CAIRO_TEST_FAILURE;
+ result = CAIRO_TEST_FAILURE;
}
+ cairo_surface_destroy (surface);
surface = cairo_image_surface_create_from_png_stream (no_memory_error, NULL);
if (cairo_surface_status (surface) != CAIRO_STATUS_NO_MEMORY) {
- cairo_test_log ("Error: expected \"out of memory\", but got: %s\n",
+ cairo_test_log (&ctx, "Error: expected \"out of memory\", but got: %s\n",
cairo_status_to_string (cairo_surface_status (surface)));
- cairo_surface_destroy (surface);
- return CAIRO_TEST_FAILURE;
+ result = CAIRO_TEST_FAILURE;
}
+ cairo_surface_destroy (surface);
surface = cairo_image_surface_create_from_png_stream (read_error, NULL);
if (cairo_surface_status (surface) != CAIRO_STATUS_READ_ERROR) {
- cairo_test_log ("Error: expected \"read error\", but got: %s\n",
+ cairo_test_log (&ctx, "Error: expected \"read error\", but got: %s\n",
cairo_status_to_string (cairo_surface_status (surface)));
- cairo_surface_destroy (surface);
- return CAIRO_TEST_FAILURE;
+ result = CAIRO_TEST_FAILURE;
}
+ cairo_surface_destroy (surface);
/* cheekily test error propagation from the user write funcs as well ... */
- xasprintf (&filename, "%s/%s", srcdir ? srcdir : ".",
+ xasprintf (&filename, "%s/%s", ctx.srcdir,
"create-from-png-ref.png");
surface = cairo_image_surface_create_from_png (filename);
if (cairo_surface_status (surface)) {
- cairo_test_log ("Error reading PNG image %s: %s\n",
+ cairo_test_log (&ctx, "Error reading PNG image %s: %s\n",
filename,
cairo_status_to_string (cairo_surface_status (surface)));
- free (filename);
- return CAIRO_TEST_FAILURE;
- }
- free (filename);
+ result = CAIRO_TEST_FAILURE;
+ } else {
+ status = cairo_surface_write_to_png_stream (surface,
+ (cairo_write_func_t) no_memory_error,
+ NULL);
+ if (status != CAIRO_STATUS_NO_MEMORY) {
+ cairo_test_log (&ctx, "Error: expected \"out of memory\", but got: %s\n",
+ cairo_status_to_string (status));
+ result = CAIRO_TEST_FAILURE;
+ }
- status = cairo_surface_write_to_png_stream (surface,
- (cairo_write_func_t) no_memory_error,
- NULL);
- if (status != CAIRO_STATUS_NO_MEMORY) {
- cairo_test_log ("Error: expected \"out of memory\", but got: %s\n",
- cairo_status_to_string (status));
- cairo_surface_destroy (surface);
- return CAIRO_TEST_FAILURE;
- }
- status = cairo_surface_write_to_png_stream (surface,
- (cairo_write_func_t) read_error,
- NULL);
- if (status != CAIRO_STATUS_READ_ERROR) {
- cairo_test_log ("Error: expected \"read error\", but got: %s\n",
- cairo_status_to_string (status));
- cairo_surface_destroy (surface);
- return CAIRO_TEST_FAILURE;
+ status = cairo_surface_write_to_png_stream (surface,
+ (cairo_write_func_t) read_error,
+ NULL);
+ if (status != CAIRO_STATUS_READ_ERROR) {
+ cairo_test_log (&ctx, "Error: expected \"read error\", but got: %s\n",
+ cairo_status_to_string (status));
+ result = CAIRO_TEST_FAILURE;
+ }
+
+ /* and check that error has not propagated to the surface */
+ if (cairo_surface_status (surface)) {
+ cairo_test_log (&ctx, "Error: user write error propagated to surface: %s",
+ cairo_status_to_string (cairo_surface_status (surface)));
+ result = CAIRO_TEST_FAILURE;
+ }
}
cairo_surface_destroy (surface);
+ free (filename);
/* check that loading alpha/opaque PNGs generate the correct surfaces */
- xasprintf (&filename, "%s/%s", srcdir ? srcdir : ".",
+ xasprintf (&filename, "%s/%s", ctx.srcdir,
"create-from-png-alpha-ref.png");
surface = cairo_image_surface_create_from_png (filename);
if (cairo_surface_status (surface)) {
- cairo_test_log ("Error reading PNG image %s: %s\n",
+ cairo_test_log (&ctx, "Error reading PNG image %s: %s\n",
filename,
cairo_status_to_string (cairo_surface_status (surface)));
- free (filename);
- return CAIRO_TEST_FAILURE;
- }
- if (cairo_image_surface_get_format (surface) != CAIRO_FORMAT_ARGB32) {
- cairo_test_log ("Error reading PNG image %s: did not create an ARGB32 image\n",
- filename);
- cairo_surface_destroy (surface);
- return CAIRO_TEST_FAILURE;
+ result = CAIRO_TEST_FAILURE;
+ } else if (cairo_image_surface_get_format (surface) != CAIRO_FORMAT_ARGB32) {
+ cairo_test_log (&ctx, "Error reading PNG image %s: did not create an ARGB32 image\n",
+ filename);
+ result = CAIRO_TEST_FAILURE;
}
free (filename);
cairo_surface_destroy (surface);
- xasprintf (&filename, "%s/%s", srcdir ? srcdir : ".",
+ xasprintf (&filename, "%s/%s", ctx.srcdir,
"create-from-png-ref.png");
surface = cairo_image_surface_create_from_png (filename);
if (cairo_surface_status (surface)) {
- cairo_test_log ("Error reading PNG image %s: %s\n",
+ cairo_test_log (&ctx, "Error reading PNG image %s: %s\n",
filename,
cairo_status_to_string (cairo_surface_status (surface)));
- free (filename);
- return CAIRO_TEST_FAILURE;
- }
- if (cairo_image_surface_get_format (surface) != CAIRO_FORMAT_RGB24) {
- cairo_test_log ("Error reading PNG image %s: did not create an RGB24 image\n",
- filename);
- cairo_surface_destroy (surface);
- return CAIRO_TEST_FAILURE;
+ result = CAIRO_TEST_FAILURE;
+ } else if (cairo_image_surface_get_format (surface) != CAIRO_FORMAT_RGB24) {
+ cairo_test_log (&ctx, "Error reading PNG image %s: did not create an RGB24 image\n",
+ filename);
+ result = CAIRO_TEST_FAILURE;
}
free (filename);
cairo_surface_destroy (surface);
/* check paletted PNGs */
- xasprintf (&filename, "%s/%s", srcdir ? srcdir : ".",
+ xasprintf (&filename, "%s/%s", ctx.srcdir,
"create-from-png-indexed-alpha-ref.png");
surface = cairo_image_surface_create_from_png (filename);
if (cairo_surface_status (surface)) {
- cairo_test_log ("Error reading PNG image %s: %s\n",
+ cairo_test_log (&ctx, "Error reading PNG image %s: %s\n",
filename,
cairo_status_to_string (cairo_surface_status (surface)));
- free (filename);
- return CAIRO_TEST_FAILURE;
- }
- if (cairo_image_surface_get_format (surface) != CAIRO_FORMAT_ARGB32) {
- cairo_test_log ("Error reading PNG image %s: did not create an ARGB32 image\n",
- filename);
- free (filename);
- cairo_surface_destroy (surface);
- return CAIRO_TEST_FAILURE;
+ result = CAIRO_TEST_FAILURE;
+ } else if (cairo_image_surface_get_format (surface) != CAIRO_FORMAT_ARGB32) {
+ cairo_test_log (&ctx, "Error reading PNG image %s: did not create an ARGB32 image\n",
+ filename);
+ result = CAIRO_TEST_FAILURE;
}
free (filename);
cairo_surface_destroy (surface);
- xasprintf (&filename, "%s/%s", srcdir ? srcdir : ".",
+ xasprintf (&filename, "%s/%s", ctx.srcdir,
"create-from-png-indexed-ref.png");
surface = cairo_image_surface_create_from_png (filename);
if (cairo_surface_status (surface)) {
- cairo_test_log ("Error reading PNG image %s: %s\n",
+ cairo_test_log (&ctx, "Error reading PNG image %s: %s\n",
filename,
cairo_status_to_string (cairo_surface_status (surface)));
- free (filename);
- return CAIRO_TEST_FAILURE;
- }
- if (cairo_image_surface_get_format (surface) != CAIRO_FORMAT_RGB24) {
- cairo_test_log ("Error reading PNG image %s: did not create an RGB24 image\n",
- filename);
- free (filename);
- cairo_surface_destroy (surface);
- return CAIRO_TEST_FAILURE;
+ result = CAIRO_TEST_FAILURE;
+ } else if (cairo_image_surface_get_format (surface) != CAIRO_FORMAT_RGB24) {
+ cairo_test_log (&ctx, "Error reading PNG image %s: did not create an RGB24 image\n",
+ filename);
+ result = CAIRO_TEST_FAILURE;
}
free (filename);
cairo_surface_destroy (surface);
/* check grayscale PNGs */
- xasprintf (&filename, "%s/%s", srcdir ? srcdir : ".",
+ xasprintf (&filename, "%s/%s", ctx.srcdir,
"create-from-png-gray-alpha-ref.png");
surface = cairo_image_surface_create_from_png (filename);
if (cairo_surface_status (surface)) {
- cairo_test_log ("Error reading PNG image %s: %s\n",
+ cairo_test_log (&ctx, "Error reading PNG image %s: %s\n",
filename,
cairo_status_to_string (cairo_surface_status (surface)));
- free (filename);
- return CAIRO_TEST_FAILURE;
- }
- if (cairo_image_surface_get_format (surface) != CAIRO_FORMAT_ARGB32) {
- cairo_test_log ("Error reading PNG image %s: did not create an ARGB32 image\n",
- filename);
- free (filename);
- cairo_surface_destroy (surface);
- return CAIRO_TEST_FAILURE;
+ result = CAIRO_TEST_FAILURE;
+ } else if (cairo_image_surface_get_format (surface) != CAIRO_FORMAT_ARGB32) {
+ cairo_test_log (&ctx, "Error reading PNG image %s: did not create an ARGB32 image\n",
+ filename);
+ result = CAIRO_TEST_FAILURE;
}
free (filename);
cairo_surface_destroy (surface);
- xasprintf (&filename, "%s/%s", srcdir ? srcdir : ".",
+ xasprintf (&filename, "%s/%s", ctx.srcdir,
"create-from-png-gray-ref.png");
surface = cairo_image_surface_create_from_png (filename);
if (cairo_surface_status (surface)) {
- cairo_test_log ("Error reading PNG image %s: %s\n",
+ cairo_test_log (&ctx, "Error reading PNG image %s: %s\n",
filename,
cairo_status_to_string (cairo_surface_status (surface)));
- free (filename);
- return CAIRO_TEST_FAILURE;
- }
- if (cairo_image_surface_get_format (surface) != CAIRO_FORMAT_RGB24) {
- cairo_test_log ("Error reading PNG image %s: did not create an RGB24 image\n",
- filename);
- free (filename);
- cairo_surface_destroy (surface);
- return CAIRO_TEST_FAILURE;
+ result = CAIRO_TEST_FAILURE;
+ } else if (cairo_image_surface_get_format (surface) != CAIRO_FORMAT_RGB24) {
+ cairo_test_log (&ctx, "Error reading PNG image %s: did not create an RGB24 image\n",
+ filename);
+ result = CAIRO_TEST_FAILURE;
}
free (filename);
cairo_surface_destroy (surface);
+ cairo_test_fini (&ctx);
+
return cairo_test (&test);
}
diff --git a/test/dash-caps-joins.c b/test/dash-caps-joins.c
index 370d05dd5..680a7fbea 100644
--- a/test/dash-caps-joins.c
+++ b/test/dash-caps-joins.c
@@ -37,7 +37,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"dash-caps-joins",
"Test caps and joins when dashing",
3 * (PAD + SIZE) + PAD,
diff --git a/test/dash-curve.c b/test/dash-curve.c
index 48f5c12cb..b98f4f145 100644
--- a/test/dash-curve.c
+++ b/test/dash-curve.c
@@ -27,7 +27,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"dash-curve",
"Tries to explore the state space of the dashing code along curves",
25*60, 4*60,
diff --git a/test/dash-no-dash.c b/test/dash-no-dash.c
index 21235b964..e9e9c5df8 100644
--- a/test/dash-no-dash.c
+++ b/test/dash-no-dash.c
@@ -33,7 +33,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"dash-no-dash",
"Tests that we can actually turn dashing on and off again",
WIDTH, HEIGHT,
diff --git a/test/dash-offset-negative.c b/test/dash-offset-negative.c
index 539e3cde5..adfe26557 100644
--- a/test/dash-offset-negative.c
+++ b/test/dash-offset-negative.c
@@ -36,7 +36,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"dash-offset-negative",
"Tests cairo_set_dash with a negative offset",
IMAGE_WIDTH, IMAGE_HEIGHT,
diff --git a/test/dash-scale.c b/test/dash-scale.c
index b845dcf8c..b00b0f194 100644
--- a/test/dash-scale.c
+++ b/test/dash-scale.c
@@ -31,7 +31,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"dash-scale",
"Test interactions of cairo_set_dash and cairo_scale, (in particular with a non-uniformly scaled pen)",
3 * (PAD + SIZE) + PAD,
diff --git a/test/dash-state.c b/test/dash-state.c
index a59a3e8f9..f74e59864 100644
--- a/test/dash-state.c
+++ b/test/dash-state.c
@@ -27,7 +27,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"dash-state",
"Tries to explore the state space of the dashing code",
25*60, 4*60,
diff --git a/test/dash-zero-length.c b/test/dash-zero-length.c
index 6e9854adc..e6f2da61d 100644
--- a/test/dash-zero-length.c
+++ b/test/dash-zero-length.c
@@ -35,7 +35,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"dash-zero-length",
"Tests cairo_set_dash with zero length",
IMAGE_WIDTH, IMAGE_HEIGHT,
diff --git a/test/degenerate-arc.c b/test/degenerate-arc.c
index f01b666ba..d030598b2 100644
--- a/test/degenerate-arc.c
+++ b/test/degenerate-arc.c
@@ -32,7 +32,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"degenerate-arc",
"Tests the behaviour of degenerate arcs",
40, 40,
diff --git a/test/degenerate-path.c b/test/degenerate-path.c
index c861cd2ce..67cc9a072 100644
--- a/test/degenerate-path.c
+++ b/test/degenerate-path.c
@@ -32,7 +32,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"degenerate-path",
"Tests the behaviour of degenerate paths with different cap types",
3*(PAD+LINE_WIDTH+PAD), 8*(LINE_WIDTH+PAD) + PAD,
diff --git a/test/degenerate-pen.c b/test/degenerate-pen.c
index 4ff50f82a..deb7b2a3b 100644
--- a/test/degenerate-pen.c
+++ b/test/degenerate-pen.c
@@ -50,7 +50,7 @@ static cairo_test_draw_function_t draw;
* pen doing slope comparisons.
*/
-cairo_test_t test = {
+static const cairo_test_t test = {
"degenerate-pen",
"Test round joins with a pen that's transformed to a line",
WIDTH, HEIGHT,
diff --git a/test/device-offset-positive.c b/test/device-offset-positive.c
index ab1adcfff..4b49b1006 100644
--- a/test/device-offset-positive.c
+++ b/test/device-offset-positive.c
@@ -31,7 +31,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"device-offset-positive",
"Simple test using a surface with a positive device-offset as a source.",
SIZE, SIZE,
diff --git a/test/device-offset-scale.c b/test/device-offset-scale.c
index 5134589be..1c2537d62 100644
--- a/test/device-offset-scale.c
+++ b/test/device-offset-scale.c
@@ -30,7 +30,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"device-offset-scale",
"Test that the device-offset transform is transformed by the ctm.",
WIDTH, HEIGHT,
diff --git a/test/device-offset.c b/test/device-offset.c
index cee603f3c..dfeb50815 100644
--- a/test/device-offset.c
+++ b/test/device-offset.c
@@ -31,7 +31,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"device-offset",
"Simple test using a surface with a negative device-offset as a source.",
SIZE, SIZE,
diff --git a/test/extend-pad.c b/test/extend-pad.c
index fdd887f6b..8c3c09c30 100644
--- a/test/extend-pad.c
+++ b/test/extend-pad.c
@@ -32,7 +32,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"extend-pad",
"Test CAIRO_EXTEND_PAD for surface patterns",
SIZE, SIZE,
diff --git a/test/extend-reflect-similar.c b/test/extend-reflect-similar.c
index 1ff4039ec..c1914b316 100644
--- a/test/extend-reflect-similar.c
+++ b/test/extend-reflect-similar.c
@@ -4,7 +4,7 @@ const char png_filename[] = "romedalen.png";
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"extend-reflect-similar",
"Test CAIRO_EXTEND_REFLECT for surface patterns",
256 + 32*2, 192 + 32*2,
@@ -22,9 +22,11 @@ clone_similar_surface (cairo_surface_t * target, cairo_surface_t *surface)
cairo_image_surface_get_width (surface),
cairo_image_surface_get_height (surface));
cr = cairo_create (similar);
+ cairo_surface_destroy (similar);
cairo_set_source_surface (cr, surface, 0, 0);
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
cairo_paint (cr);
+ similar = cairo_surface_reference (cairo_get_target (cr));
cairo_destroy (cr);
return similar;
@@ -33,10 +35,11 @@ clone_similar_surface (cairo_surface_t * target, cairo_surface_t *surface)
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_surface_t *surface;
cairo_surface_t *similar;
- surface = cairo_test_create_surface_from_png (png_filename);
+ surface = cairo_test_create_surface_from_png (ctx, png_filename);
similar = clone_similar_surface (cairo_get_group_target (cr), surface);
cairo_set_source_surface (cr, similar, 32, 32);
cairo_pattern_set_extend (cairo_get_source (cr), CAIRO_EXTEND_REFLECT);
diff --git a/test/extend-reflect.c b/test/extend-reflect.c
index e9d07cc0c..6175657b5 100644
--- a/test/extend-reflect.c
+++ b/test/extend-reflect.c
@@ -6,7 +6,7 @@ const char png_filename[] = "romedalen.png";
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"extend-reflect",
"Test CAIRO_EXTEND_REFLECT for surface patterns",
256 + 32*2, 192 + 32*2,
@@ -16,9 +16,10 @@ cairo_test_t test = {
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_surface_t *surface;
- surface = cairo_test_create_surface_from_png (png_filename);
+ surface = cairo_test_create_surface_from_png (ctx, png_filename);
cairo_set_source_surface (cr, surface, 32, 32);
cairo_pattern_set_extend (cairo_get_source (cr), CAIRO_EXTEND_REFLECT);
diff --git a/test/extend-repeat-similar.c b/test/extend-repeat-similar.c
index 1a1412561..88d4a2b78 100644
--- a/test/extend-repeat-similar.c
+++ b/test/extend-repeat-similar.c
@@ -4,7 +4,7 @@ const char png_filename[] = "romedalen.png";
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"extend-repeat-similar",
"Test CAIRO_EXTEND_REPEAT for surface patterns",
256 + 32*2, 192 + 32*2,
@@ -22,9 +22,11 @@ clone_similar_surface (cairo_surface_t * target, cairo_surface_t *surface)
cairo_image_surface_get_width (surface),
cairo_image_surface_get_height (surface));
cr = cairo_create (similar);
+ cairo_surface_destroy (similar);
cairo_set_source_surface (cr, surface, 0, 0);
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
cairo_paint (cr);
+ similar = cairo_surface_reference (cairo_get_target (cr));
cairo_destroy (cr);
return similar;
@@ -33,10 +35,11 @@ clone_similar_surface (cairo_surface_t * target, cairo_surface_t *surface)
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_surface_t *surface;
cairo_surface_t *similar;
- surface = cairo_test_create_surface_from_png (png_filename);
+ surface = cairo_test_create_surface_from_png (ctx, png_filename);
similar = clone_similar_surface (cairo_get_group_target (cr), surface);
cairo_set_source_surface (cr, similar, 32, 32);
cairo_pattern_set_extend (cairo_get_source (cr), CAIRO_EXTEND_REPEAT);
diff --git a/test/extend-repeat.c b/test/extend-repeat.c
index 351b63b86..32c43a539 100644
--- a/test/extend-repeat.c
+++ b/test/extend-repeat.c
@@ -4,7 +4,7 @@ const char png_filename[] = "romedalen.png";
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"extend-repeat",
"Test CAIRO_EXTEND_REPEAT for surface patterns",
256 + 32*2, 192 + 32*2,
@@ -14,9 +14,10 @@ cairo_test_t test = {
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_surface_t *surface;
- surface = cairo_test_create_surface_from_png (png_filename);
+ surface = cairo_test_create_surface_from_png (ctx, png_filename);
cairo_set_source_surface (cr, surface, 32, 32);
cairo_pattern_set_extend (cairo_get_source (cr), CAIRO_EXTEND_REPEAT);
diff --git a/test/fallback-resolution.c b/test/fallback-resolution.c
index 2fcf1ac16..aa1be92a7 100644
--- a/test/fallback-resolution.c
+++ b/test/fallback-resolution.c
@@ -88,6 +88,7 @@ static const char *backend_filename[NUM_BACKENDS] = {
int
main (void)
{
+ cairo_test_context_t ctx;
cairo_surface_t *surface = NULL;
cairo_t *cr;
cairo_status_t status;
@@ -98,7 +99,7 @@ main (void)
num_pages = sizeof (ppi) / sizeof (ppi[0]);
- cairo_test_init ("fallback-resolution");
+ cairo_test_init (&ctx, "fallback-resolution");
for (backend=0; backend < NUM_BACKENDS; backend++) {
@@ -166,7 +167,7 @@ main (void)
cairo_surface_destroy (surface);
if (status) {
- cairo_test_log ("Failed to create pdf surface for file %s: %s\n",
+ cairo_test_log (&ctx, "Failed to create pdf surface for file %s: %s\n",
backend_filename[backend],
cairo_status_to_string (status));
ret = CAIRO_TEST_FAILURE;
@@ -177,7 +178,7 @@ main (void)
backend_filename[backend]);
}
- cairo_test_fini ();
+ cairo_test_fini (&ctx);
return ret;
}
diff --git a/test/fill-and-stroke-alpha-add.c b/test/fill-and-stroke-alpha-add.c
index 0a3ebbc7b..3575c82d8 100644
--- a/test/fill-and-stroke-alpha-add.c
+++ b/test/fill-and-stroke-alpha-add.c
@@ -31,7 +31,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"fill-and-stroke-alpha-add",
"Use a group to fill/stroke a path (each with different alpha) using DEST_OUT and ADD to combine",
2 * SIZE + 4 * PAD, SIZE + 2 * PAD,
diff --git a/test/fill-and-stroke-alpha.c b/test/fill-and-stroke-alpha.c
index 1d01151e3..fe02c7575 100644
--- a/test/fill-and-stroke-alpha.c
+++ b/test/fill-and-stroke-alpha.c
@@ -31,7 +31,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"fill-and-stroke-alpha",
"Use a group to fill/stroke a path then blend the result with alpha onto the destination",
2 * SIZE + 4 * PAD, SIZE + 2 * PAD,
diff --git a/test/fill-and-stroke.c b/test/fill-and-stroke.c
index 345b51d00..8bbb26110 100644
--- a/test/fill-and-stroke.c
+++ b/test/fill-and-stroke.c
@@ -30,7 +30,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"fill-and-stroke",
"Tests using cairo_fill_preserve/cairo_stroke to fill/stroke the same path",
2 * SIZE + 4 * PAD, SIZE + 2 * PAD,
diff --git a/test/fill-degenerate-sort-order.c b/test/fill-degenerate-sort-order.c
index 570b37319..b35f42ed8 100644
--- a/test/fill-degenerate-sort-order.c
+++ b/test/fill-degenerate-sort-order.c
@@ -38,7 +38,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"fill-degenerate-sort-order",
"Tests the tessellator's event comparator with degenerate input",
190, 120,
diff --git a/test/fill-missed-stop.c b/test/fill-missed-stop.c
index f05b1aadb..cb551c498 100644
--- a/test/fill-missed-stop.c
+++ b/test/fill-missed-stop.c
@@ -40,7 +40,7 @@
static cairo_test_draw_function_t draw;
#define SIZE 50
-cairo_test_t test = {
+static const cairo_test_t test = {
"fill-missed-stop",
"Tests that the tessellator doesn't miss stop events when generating trapezoids",
SIZE+3, SIZE+3,
diff --git a/test/fill-rule.c b/test/fill-rule.c
index a9ce29560..8f787ff7b 100644
--- a/test/fill-rule.c
+++ b/test/fill-rule.c
@@ -68,7 +68,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"fill-rule",
"Tests cairo_set_fill_rule with some star shapes",
BIG_STAR_SIZE * 2 + 3, BIG_STAR_SIZE + LITTLE_STAR_SIZE + 3,
diff --git a/test/filter-bilinear-extents.c b/test/filter-bilinear-extents.c
index 0a9555664..666b7b33a 100644
--- a/test/filter-bilinear-extents.c
+++ b/test/filter-bilinear-extents.c
@@ -44,7 +44,7 @@ static cairo_test_draw_function_t draw;
#define WIDTH (PAD + 3 * SCALE + PAD)
#define HEIGHT WIDTH
-cairo_test_t test = {
+static const cairo_test_t test = {
"filter-bilinear-extents",
"Test that pattern extents are properly computed for CAIRO_FILTER_BILINEAR",
WIDTH, HEIGHT,
diff --git a/test/filter-nearest-offset.c b/test/filter-nearest-offset.c
index 2727f56ea..a4cb5139d 100644
--- a/test/filter-nearest-offset.c
+++ b/test/filter-nearest-offset.c
@@ -36,7 +36,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"filter-nearest-offset",
"Test sampling offset of CAIRO_FILTER_NEAREST"
"\nwrong sampling location for nearest-neighbor filter in libpixman and Render",
@@ -48,7 +48,7 @@ static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
cairo_surface_t *surface;
- static uint32_t data[STAMP_WIDTH * STAMP_HEIGHT] = {
+ uint32_t data[STAMP_WIDTH * STAMP_HEIGHT] = {
0xffffffff, 0xffffffff, 0xffff0000, 0xffff0000,
0xffffffff, 0xffffffff, 0xffff0000, 0xffff0000,
diff --git a/test/finer-grained-fallbacks.c b/test/finer-grained-fallbacks.c
index 2dd006ccc..f7cd5f366 100644
--- a/test/finer-grained-fallbacks.c
+++ b/test/finer-grained-fallbacks.c
@@ -33,7 +33,7 @@ static cairo_test_draw_function_t draw;
#define WIDTH (CIRCLE_SIZE*6.5 + PAD)
#define HEIGHT (CIRCLE_SIZE*3.5 + PAD)
-cairo_test_t test = {
+static const cairo_test_t test = {
"finer-grained-fallbacks",
"Test that multiple PS/PDF fallback images in various locations are correct",
WIDTH, HEIGHT,
diff --git a/test/font-face-get-type.c b/test/font-face-get-type.c
index a3298fa45..32ebc47c2 100644
--- a/test/font-face-get-type.c
+++ b/test/font-face-get-type.c
@@ -28,14 +28,15 @@
int
main (void)
{
+ cairo_test_context_t ctx;
cairo_surface_t *surface;
cairo_t *cr;
cairo_font_face_t *font_face;
cairo_scaled_font_t *scaled_font;
- cairo_test_init ("font-face-get-type");
+ cairo_test_init (&ctx, "font-face-get-type");
- cairo_test_log ("Creating cairo context and obtaining a font face\n");
+ cairo_test_log (&ctx, "Creating cairo context and obtaining a font face\n");
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 1, 1);
cr = cairo_create (surface);
@@ -44,29 +45,31 @@ main (void)
CAIRO_FONT_SLANT_NORMAL,
CAIRO_FONT_WEIGHT_NORMAL);
- cairo_test_log ("Testing return value of cairo_font_face_get_type\n");
+ cairo_test_log (&ctx, "Testing return value of cairo_font_face_get_type\n");
font_face = cairo_get_font_face (cr);
if (cairo_font_face_get_type (font_face) != CAIRO_FONT_TYPE_TOY) {
- cairo_test_log ("Unexpected value %d from cairo_font_face_get_type (expected %d)\n",
+ cairo_test_log (&ctx, "Unexpected value %d from cairo_font_face_get_type (expected %d)\n",
cairo_font_face_get_type (font_face), CAIRO_FONT_TYPE_TOY);
+ cairo_test_fini (&ctx);
return CAIRO_TEST_FAILURE;
}
- cairo_test_log ("Testing return value of cairo_get_scaled_font\n");
+ cairo_test_log (&ctx, "Testing return value of cairo_get_scaled_font\n");
scaled_font = cairo_get_scaled_font (cr);
if (cairo_scaled_font_get_font_face (scaled_font) != font_face) {
- cairo_test_log ("Font face returned from the scaled font is different from that returned by the context\n");
+ cairo_test_log (&ctx, "Font face returned from the scaled font is different from that returned by the context\n");
+ cairo_test_fini (&ctx);
return CAIRO_TEST_FAILURE;
}
cairo_destroy (cr);
cairo_surface_destroy (surface);
- cairo_test_fini ();
+ cairo_test_fini (&ctx);
return CAIRO_TEST_SUCCESS;
}
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;
diff --git a/test/ft-font-create-for-ft-face.c b/test/ft-font-create-for-ft-face.c
index 35cb77d48..6b3c5119d 100644
--- a/test/ft-font-create-for-ft-face.c
+++ b/test/ft-font-create-for-ft-face.c
@@ -28,7 +28,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"ft-font-create-for-ft-face",
"Simple test to verify that cairo_ft_font_create_for_ft_face doesn't crash.",
0, 0,
@@ -38,6 +38,7 @@ cairo_test_t test = {
static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
+ const cairo_test_context_t *ctx = cairo_test_get_context (cr);
FcPattern *pattern, *resolved;
FcResult result;
cairo_font_face_t *font_face;
@@ -55,7 +56,7 @@ draw (cairo_t *cr, int width, int height)
* Do not use this in production code! */
pattern = FcPatternCreate ();
if (! pattern) {
- cairo_test_log ("FcPatternCreate failed.\n");
+ cairo_test_log (ctx, "FcPatternCreate failed.\n");
return CAIRO_TEST_FAILURE;
}
@@ -63,14 +64,14 @@ draw (cairo_t *cr, int width, int height)
FcDefaultSubstitute (pattern);
resolved = FcFontMatch (NULL, pattern, &result);
if (! resolved) {
- cairo_test_log ("FcFontMatch failed.\n");
+ cairo_test_log (ctx, "FcFontMatch failed.\n");
return CAIRO_TEST_FAILURE;
}
font_face = cairo_ft_font_face_create_for_pattern (resolved);
if (cairo_font_face_get_type (font_face) != CAIRO_FONT_TYPE_FT) {
- cairo_test_log ("Unexpected value from cairo_font_face_get_type: %d (expected %d)\n",
+ cairo_test_log (ctx, "Unexpected value from cairo_font_face_get_type: %d (expected %d)\n",
cairo_font_face_get_type (font_face), CAIRO_FONT_TYPE_FT);
cairo_font_face_destroy (font_face);
return CAIRO_TEST_FAILURE;
@@ -97,14 +98,14 @@ draw (cairo_t *cr, int width, int height)
FcPatternDestroy (resolved);
if (cairo_scaled_font_get_type (scaled_font) != CAIRO_FONT_TYPE_FT) {
- cairo_test_log ("Unexpected value from cairo_scaled_font_get_type: %d (expected %d)\n",
+ cairo_test_log (ctx, "Unexpected value from cairo_scaled_font_get_type: %d (expected %d)\n",
cairo_scaled_font_get_type (scaled_font), CAIRO_FONT_TYPE_FT);
cairo_scaled_font_destroy (scaled_font);
return CAIRO_TEST_FAILURE;
}
if (!ft_face) {
- cairo_test_log ("Failed to get an ft_face with cairo_ft_scaled_font_lock_face\n");
+ cairo_test_log (ctx, "Failed to get an ft_face with cairo_ft_scaled_font_lock_face\n");
cairo_scaled_font_destroy (scaled_font);
return CAIRO_TEST_FAILURE;
}
diff --git a/test/ft-show-glyphs-positioning.c b/test/ft-show-glyphs-positioning.c
index d23c53181..33e50554f 100644
--- a/test/ft-show-glyphs-positioning.c
+++ b/test/ft-show-glyphs-positioning.c
@@ -31,7 +31,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"ft-show-glyphs-positioning",
"Test that the PS/PDF glyph positioning optimizations are correct",
235, (TEXT_SIZE + 4)*2,
diff --git a/test/ft-show-glyphs-table.c b/test/ft-show-glyphs-table.c
index a7654bc81..cc34c6d29 100644
--- a/test/ft-show-glyphs-table.c
+++ b/test/ft-show-glyphs-table.c
@@ -56,7 +56,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"ft-show-glyphs-table",
"Test cairo_show_glyphs with cairo-ft backend and glyphs laid out in a table",
WIDTH, HEIGHT,
diff --git a/test/ft-text-antialias-none.c b/test/ft-text-antialias-none.c
index e4a34e968..5d0326919 100644
--- a/test/ft-text-antialias-none.c
+++ b/test/ft-text-antialias-none.c
@@ -35,7 +35,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"ft-text-antialias-none",
"Tests text rendering with no antialiasing",
WIDTH, HEIGHT,
@@ -99,7 +99,7 @@ draw (cairo_t *cr, int width, int height)
{
cairo_text_extents_t extents;
cairo_scaled_font_t * scaled_font;
- static char black[] = "black", blue[] = "blue";
+ const char black[] = "black", blue[] = "blue";
/* We draw in the default black, so paint white first. */
cairo_save (cr);
diff --git a/test/ft-text-vertical-layout-type1.c b/test/ft-text-vertical-layout-type1.c
index c52c28d6b..3cfb15302 100644
--- a/test/ft-text-vertical-layout-type1.c
+++ b/test/ft-text-vertical-layout-type1.c
@@ -35,7 +35,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"ft-text-vertical-layout-type1",
"Tests text rendering for vertical layout with Type1 fonts"
"\nCan fail if an incorrect font is loaded---need to bundle the desired font",
@@ -101,7 +101,7 @@ draw (cairo_t *cr, int width, int height)
{
cairo_text_extents_t extents;
cairo_scaled_font_t * scaled_font;
- static char text[] = "i-W";
+ const char text[] = "i-W";
double line_width, x, y;
line_width = cairo_get_line_width (cr);
diff --git a/test/ft-text-vertical-layout-type3.c b/test/ft-text-vertical-layout-type3.c
index 4d1394aed..c1a8bbf31 100644
--- a/test/ft-text-vertical-layout-type3.c
+++ b/test/ft-text-vertical-layout-type3.c
@@ -35,7 +35,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"ft-text-vertical-layout-type3",
"Tests text rendering for vertical layout with TrueType fonts",
WIDTH, HEIGHT,
@@ -100,7 +100,7 @@ draw (cairo_t *cr, int width, int height)
{
cairo_text_extents_t extents;
cairo_scaled_font_t * scaled_font;
- static char text[] = "i-W";
+ const char text[] = "i-W";
double line_width, x, y;
line_width = cairo_get_line_width (cr);
diff --git a/test/get-and-set.c b/test/get-and-set.c
index c23707e4c..90c394a89 100644
--- a/test/get-and-set.c
+++ b/test/get-and-set.c
@@ -28,7 +28,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"get-and-set",
"Tests calls to the most trivial cairo_get and cairo_set functions",
0, 0,
@@ -49,7 +49,7 @@ typedef struct {
} settings_t;
/* Two sets of settings, no defaults */
-settings_t settings[] = {
+static const settings_t settings[] = {
{
CAIRO_OPERATOR_IN,
2.0,
@@ -77,7 +77,7 @@ settings_t settings[] = {
};
static void
-settings_set (cairo_t *cr, settings_t *settings)
+settings_set (cairo_t *cr, const settings_t *settings)
{
cairo_set_operator (cr, settings->op);
cairo_set_tolerance (cr, settings->tolerance);
@@ -114,7 +114,7 @@ settings_get (cairo_t *cr, settings_t *settings)
}
static int
-settings_equal (settings_t *a, settings_t *b)
+settings_equal (const settings_t *a, const settings_t *b)
{
return (a->op == b->op &&
a->tolerance == b->tolerance &&
diff --git a/test/get-clip.c b/test/get-clip.c
index bd92e1e1e..bd7f8a1c6 100644
--- a/test/get-clip.c
+++ b/test/get-clip.c
@@ -28,7 +28,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"get-clip",
"Test cairo_copy_clip_rectangle_list and cairo_clip_extents",
0, 0,
@@ -36,7 +36,8 @@ cairo_test_t test = {
};
static cairo_bool_t
-check_count (const char *message, cairo_bool_t uses_clip_rects,
+check_count (const cairo_test_context_t *ctx,
+ const char *message, cairo_bool_t uses_clip_rects,
cairo_rectangle_list_t *list, int expected)
{
if (!uses_clip_rects) {
@@ -46,29 +47,29 @@ check_count (const char *message, cairo_bool_t uses_clip_rects,
return 1;
if (list->status == CAIRO_STATUS_CLIP_NOT_REPRESENTABLE)
return 1;
- cairo_test_log ("Error: %s; cairo_copy_clip_rectangle_list unexpectedly got %d rectangles\n",
+ cairo_test_log (ctx, "Error: %s; cairo_copy_clip_rectangle_list unexpectedly got %d rectangles\n",
message, list->num_rectangles);
return 0;
}
if (list->status != CAIRO_STATUS_SUCCESS) {
- cairo_test_log ("Error: %s; cairo_copy_clip_rectangle_list failed with \"%s\"\n",
+ cairo_test_log (ctx, "Error: %s; cairo_copy_clip_rectangle_list failed with \"%s\"\n",
message, cairo_status_to_string(list->status));
return 0;
}
if (list->num_rectangles == expected)
return 1;
- cairo_test_log ("Error: %s; expected %d rectangles, got %d\n", message,
+ cairo_test_log (ctx, "Error: %s; expected %d rectangles, got %d\n", message,
expected, list->num_rectangles);
return 0;
}
static cairo_bool_t
-check_unrepresentable (const char *message, cairo_rectangle_list_t *list)
+check_unrepresentable (const cairo_test_context_t *ctx, const char *message, cairo_rectangle_list_t *list)
{
if (list->status != CAIRO_STATUS_CLIP_NOT_REPRESENTABLE) {
- cairo_test_log ("Error: %s; cairo_copy_clip_rectangle_list got unexpected result \"%s\"\n"
+ cairo_test_log (ctx, "Error: %s; cairo_copy_clip_rectangle_list got unexpected result \"%s\"\n"
" (we expected CAIRO_STATUS_CLIP_NOT_REPRESENTABLE)",
message, cairo_status_to_string(list->status));
return 0;
@@ -77,7 +78,8 @@ check_unrepresentable (const char *message, cairo_rectangle_list_t *list)
}
static cairo_bool_t
-check_rectangles_contain (const char *message, cairo_bool_t uses_clip_rects,
+check_rectangles_contain (const cairo_test_context_t *ctx,
+ const char *message, cairo_bool_t uses_clip_rects,
cairo_rectangle_list_t *list,
double x, double y, double width, double height)
{
@@ -91,20 +93,21 @@ check_rectangles_contain (const char *message, cairo_bool_t uses_clip_rects,
list->rectangles[i].width == width && list->rectangles[i].height == height)
return 1;
}
- cairo_test_log ("Error: %s; rectangle list does not contain rectangle %f,%f,%f,%f\n",
+ cairo_test_log (ctx, "Error: %s; rectangle list does not contain rectangle %f,%f,%f,%f\n",
message, x, y, width, height);
return 0;
}
static cairo_bool_t
-check_clip_extents (const char *message, cairo_t *cr,
+check_clip_extents (const cairo_test_context_t *ctx,
+ const char *message, cairo_t *cr,
double x, double y, double width, double height)
{
double ext_x1, ext_y1, ext_x2, ext_y2;
cairo_clip_extents (cr, &ext_x1, &ext_y1, &ext_x2, &ext_y2);
if (ext_x1 == x && ext_y1 == y && ext_x2 == x + width && ext_y2 == y + height)
return 1;
- cairo_test_log ("Error: %s; clip extents %f,%f,%f,%f should be %f,%f,%f,%f\n",
+ cairo_test_log (ctx, "Error: %s; clip extents %f,%f,%f,%f should be %f,%f,%f,%f\n",
message, ext_x1, ext_y1, ext_x2 - ext_x1, ext_y2 - ext_y1,
x, y, width, height);
return 0;
@@ -113,6 +116,7 @@ check_clip_extents (const char *message, cairo_t *cr,
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_surface_t *surface;
cairo_t *cr2;
cairo_rectangle_list_t *rectangle_list;
@@ -154,9 +158,9 @@ draw (cairo_t *cr, int width, int height)
return the surface rectangle. */
phase = "No clip set";
rectangle_list = cairo_copy_clip_rectangle_list (cr2);
- if (!check_count (phase, uses_clip_rects, rectangle_list, 1) ||
- !check_clip_extents (phase, cr2, 0, 0, 100, 100) ||
- !check_rectangles_contain(phase, uses_clip_rects, rectangle_list, 0, 0, 100, 100)) {
+ if (!check_count (ctx, phase, uses_clip_rects, rectangle_list, 1) ||
+ !check_clip_extents (ctx, phase, cr2, 0, 0, 100, 100) ||
+ !check_rectangles_contain (ctx, phase, uses_clip_rects, rectangle_list, 0, 0, 100, 100)) {
cairo_rectangle_list_destroy (rectangle_list);
return CAIRO_TEST_FAILURE;
}
@@ -168,9 +172,9 @@ draw (cairo_t *cr, int width, int height)
cairo_rectangle (cr2, 10, 10, 80, 80);
cairo_clip (cr2);
rectangle_list = cairo_copy_clip_rectangle_list (cr2);
- if (!check_count (phase, uses_clip_rects, rectangle_list, 1) ||
- !check_clip_extents (phase, cr2, 10, 10, 80, 80) ||
- !check_rectangles_contain(phase, uses_clip_rects, rectangle_list, 10, 10, 80, 80)) {
+ if (!check_count (ctx, phase, uses_clip_rects, rectangle_list, 1) ||
+ !check_clip_extents (ctx, phase, cr2, 10, 10, 80, 80) ||
+ !check_rectangles_contain (ctx, phase, uses_clip_rects, rectangle_list, 10, 10, 80, 80)) {
cairo_rectangle_list_destroy (rectangle_list);
return CAIRO_TEST_FAILURE;
}
@@ -182,7 +186,7 @@ draw (cairo_t *cr, int width, int height)
cairo_save (cr2);
cairo_clip (cr2);
rectangle_list = cairo_copy_clip_rectangle_list (cr2);
- if (!check_count (phase, uses_clip_rects, rectangle_list, 0)) {
+ if (!check_count (ctx, phase, uses_clip_rects, rectangle_list, 0)) {
cairo_rectangle_list_destroy (rectangle_list);
return CAIRO_TEST_FAILURE;
}
@@ -198,10 +202,10 @@ draw (cairo_t *cr, int width, int height)
cairo_rectangle (cr2, 15, 15, 10, 10);
cairo_clip (cr2);
rectangle_list = cairo_copy_clip_rectangle_list (cr2);
- if (!check_count (phase, uses_clip_rects, rectangle_list, 2) ||
- !check_clip_extents (phase, cr2, 15, 15, 10, 10) ||
- !check_rectangles_contain(phase, uses_clip_rects, rectangle_list, 15, 15, 5, 5) ||
- !check_rectangles_contain(phase, uses_clip_rects, rectangle_list, 20, 20, 5, 5)) {
+ if (!check_count (ctx, phase, uses_clip_rects, rectangle_list, 2) ||
+ !check_clip_extents (ctx, phase, cr2, 15, 15, 10, 10) ||
+ !check_rectangles_contain (ctx, phase, uses_clip_rects, rectangle_list, 15, 15, 5, 5) ||
+ !check_rectangles_contain (ctx, phase, uses_clip_rects, rectangle_list, 20, 20, 5, 5)) {
cairo_rectangle_list_destroy (rectangle_list);
return CAIRO_TEST_FAILURE;
}
@@ -218,8 +222,8 @@ draw (cairo_t *cr, int width, int height)
cairo_clip (cr2);
rectangle_list = cairo_copy_clip_rectangle_list (cr2);
/* can't get this in one tight user-space rectangle */
- if (!check_unrepresentable (phase, rectangle_list) ||
- !check_clip_extents (phase, cr2, 0, 0, 100, 100)) {
+ if (!check_unrepresentable (ctx, phase, rectangle_list) ||
+ !check_clip_extents (ctx, phase, cr2, 0, 0, 100, 100)) {
cairo_rectangle_list_destroy (rectangle_list);
return CAIRO_TEST_FAILURE;
}
@@ -232,9 +236,9 @@ draw (cairo_t *cr, int width, int height)
cairo_rectangle (cr2, 5, 5, 40, 40);
cairo_clip (cr2);
rectangle_list = cairo_copy_clip_rectangle_list (cr2);
- if (!check_count (phase, uses_clip_rects, rectangle_list, 1) ||
- !check_clip_extents (phase, cr2, 5, 5, 40, 40) ||
- !check_rectangles_contain(phase, uses_clip_rects, rectangle_list, 5, 5, 40, 40)) {
+ if (!check_count (ctx, phase, uses_clip_rects, rectangle_list, 1) ||
+ !check_clip_extents (ctx, phase, cr2, 5, 5, 40, 40) ||
+ !check_rectangles_contain (ctx, phase, uses_clip_rects, rectangle_list, 5, 5, 40, 40)) {
cairo_rectangle_list_destroy (rectangle_list);
return CAIRO_TEST_FAILURE;
}
@@ -249,9 +253,9 @@ draw (cairo_t *cr, int width, int height)
cairo_restore (cr2);
cairo_clip (cr2);
rectangle_list = cairo_copy_clip_rectangle_list (cr2);
- if (!check_count (phase, uses_clip_rects, rectangle_list, 1) ||
- !check_clip_extents (phase, cr2, 10, 10, 80, 80) ||
- !check_rectangles_contain(phase, uses_clip_rects, rectangle_list, 10, 10, 80, 80)) {
+ if (!check_count (ctx, phase, uses_clip_rects, rectangle_list, 1) ||
+ !check_clip_extents (ctx, phase, cr2, 10, 10, 80, 80) ||
+ !check_rectangles_contain (ctx, phase, uses_clip_rects, rectangle_list, 10, 10, 80, 80)) {
cairo_rectangle_list_destroy (rectangle_list);
return CAIRO_TEST_FAILURE;
}
@@ -266,7 +270,7 @@ draw (cairo_t *cr, int width, int height)
cairo_restore (cr2);
cairo_clip (cr2);
rectangle_list = cairo_copy_clip_rectangle_list (cr2);
- if (!check_unrepresentable (phase, rectangle_list)) {
+ if (!check_unrepresentable (ctx, phase, rectangle_list)) {
cairo_rectangle_list_destroy (rectangle_list);
return CAIRO_TEST_FAILURE;
}
diff --git a/test/get-group-target.c b/test/get-group-target.c
index 73a2d951d..010f6ec59 100644
--- a/test/get-group-target.c
+++ b/test/get-group-target.c
@@ -30,7 +30,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"get-group-target",
"Test of both cairo_get_group_target and cairo_surface_get_device_offset",
SIZE, SIZE,
diff --git a/test/get-path-extents.c b/test/get-path-extents.c
index 4d1966b0d..5bfdcd7c3 100644
--- a/test/get-path-extents.c
+++ b/test/get-path-extents.c
@@ -29,7 +29,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"get-path-extents",
"Test cairo_fill_extents and cairo_stroke_extents",
0, 0,
@@ -41,7 +41,8 @@ enum ExtentsType { FILL, STROKE, PATH };
enum Relation { EQUALS, APPROX_EQUALS, CONTAINS };
static cairo_bool_t
-check_extents (const char *message, cairo_t *cr, enum ExtentsType type,
+check_extents (const cairo_test_context_t *ctx,
+ const char *message, cairo_t *cr, enum ExtentsType type,
enum Relation relation,
double x, double y, double width, double height)
{
@@ -97,7 +98,7 @@ check_extents (const char *message, cairo_t *cr, enum ExtentsType type,
break;
}
- cairo_test_log ("Error: %s; %s extents (%g, %g) x (%g, %g) should %s (%g, %g) x (%g, %g)\n",
+ cairo_test_log (ctx, "Error: %s; %s extents (%g, %g) x (%g, %g) should %s (%g, %g) x (%g, %g)\n",
message, type_string,
ext_x1, ext_y1, ext_x2 - ext_x1, ext_y2 - ext_y1,
relation_string,
@@ -108,6 +109,7 @@ check_extents (const char *message, cairo_t *cr, enum ExtentsType type,
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_surface_t *surface;
cairo_t *cr2;
const char *phase;
@@ -127,9 +129,9 @@ draw (cairo_t *cr, int width, int height)
cairo_set_miter_limit (cr2, 100);
phase = "No path";
- errors += !check_extents (phase, cr2, FILL, EQUALS, 0, 0, 0, 0);
- errors += !check_extents (phase, cr2, STROKE, EQUALS, 0, 0, 0, 0);
- errors += !check_extents (phase, cr2, PATH, EQUALS, 0, 0, 0, 0);
+ errors += !check_extents (ctx, phase, cr2, FILL, EQUALS, 0, 0, 0, 0);
+ errors += !check_extents (ctx, phase, cr2, STROKE, EQUALS, 0, 0, 0, 0);
+ errors += !check_extents (ctx, phase, cr2, PATH, EQUALS, 0, 0, 0, 0);
cairo_save (cr2);
@@ -137,31 +139,31 @@ draw (cairo_t *cr, int width, int height)
cairo_move_to (cr2, 200, 400);
cairo_rel_line_to (cr2, 0., 0.);
phase = "Degenerate line";
- errors += !check_extents (phase, cr2, FILL, EQUALS, 0, 0, 0, 0);
- errors += !check_extents (phase, cr2, STROKE, EQUALS, 0, 0, 0, 0);
- errors += !check_extents (phase, cr2, PATH, EQUALS, 200, 400, 0, 0);
+ errors += !check_extents (ctx, phase, cr2, FILL, EQUALS, 0, 0, 0, 0);
+ errors += !check_extents (ctx, phase, cr2, STROKE, EQUALS, 0, 0, 0, 0);
+ errors += !check_extents (ctx, phase, cr2, PATH, EQUALS, 200, 400, 0, 0);
cairo_new_path (cr2);
cairo_move_to (cr2, 200, 400);
cairo_rel_curve_to (cr2, 0., 0., 0., 0., 0., 0.);
phase = "Degenerate curve";
- errors += !check_extents (phase, cr2, FILL, EQUALS, 0, 0, 0, 0);
- errors += !check_extents (phase, cr2, STROKE, EQUALS, 0, 0, 0, 0);
- errors += !check_extents (phase, cr2, PATH, EQUALS, 200, 400, 0, 0);
+ errors += !check_extents (ctx, phase, cr2, FILL, EQUALS, 0, 0, 0, 0);
+ errors += !check_extents (ctx, phase, cr2, STROKE, EQUALS, 0, 0, 0, 0);
+ errors += !check_extents (ctx, phase, cr2, PATH, EQUALS, 200, 400, 0, 0);
cairo_new_path (cr2);
cairo_arc (cr2, 200, 400, 0., 0, 2 * M_PI);
phase = "Degenerate arc (R=0)";
- errors += !check_extents (phase, cr2, FILL, EQUALS, 0, 0, 0, 0);
- errors += !check_extents (phase, cr2, STROKE, EQUALS, 0, 0, 0, 0);
- errors += !check_extents (phase, cr2, PATH, EQUALS, 200, 400, 0, 0);
+ errors += !check_extents (ctx, phase, cr2, FILL, EQUALS, 0, 0, 0, 0);
+ errors += !check_extents (ctx, phase, cr2, STROKE, EQUALS, 0, 0, 0, 0);
+ errors += !check_extents (ctx, phase, cr2, PATH, EQUALS, 200, 400, 0, 0);
cairo_new_path (cr2);
cairo_arc (cr2, 200, 400, 10., 0, 0);
phase = "Degenerate arc (Θ=0)";
- errors += !check_extents (phase, cr2, FILL, EQUALS, 0, 0, 0, 0);
- errors += !check_extents (phase, cr2, STROKE, EQUALS, 0, 0, 0, 0);
- errors += !check_extents (phase, cr2, PATH, EQUALS, 200, 400, 0, 0);
+ errors += !check_extents (ctx, phase, cr2, FILL, EQUALS, 0, 0, 0, 0);
+ errors += !check_extents (ctx, phase, cr2, STROKE, EQUALS, 0, 0, 0, 0);
+ errors += !check_extents (ctx, phase, cr2, PATH, EQUALS, 200, 400, 0, 0);
cairo_new_path (cr2);
cairo_restore (cr2);
@@ -176,17 +178,17 @@ draw (cairo_t *cr, int width, int height)
cairo_move_to (cr2, 200, 400);
cairo_rel_line_to (cr2, 0, 0);
phase = "Single 'dot'";
- errors += !check_extents (phase, cr2, FILL, EQUALS, 0, 0, 0, 0);
- errors += !check_extents (phase, cr2, STROKE, EQUALS, 190, 390, 20, 20);
- errors += !check_extents (phase, cr2, PATH, EQUALS, 200, 400, 0, 0);
+ errors += !check_extents (ctx, phase, cr2, FILL, EQUALS, 0, 0, 0, 0);
+ errors += !check_extents (ctx, phase, cr2, STROKE, EQUALS, 190, 390, 20, 20);
+ errors += !check_extents (ctx, phase, cr2, PATH, EQUALS, 200, 400, 0, 0);
/* Add another dot without starting a new path */
cairo_move_to (cr2, 100, 500);
cairo_rel_line_to (cr2, 0, 0);
phase = "Multiple 'dots'";
- errors += !check_extents (phase, cr2, FILL, EQUALS, 0, 0, 0, 0);
- errors += !check_extents (phase, cr2, STROKE, EQUALS, 90, 390, 120, 120);
- errors += !check_extents (phase, cr2, PATH, EQUALS, 100, 400, 100, 100);
+ errors += !check_extents (ctx, phase, cr2, FILL, EQUALS, 0, 0, 0, 0);
+ errors += !check_extents (ctx, phase, cr2, STROKE, EQUALS, 90, 390, 120, 120);
+ errors += !check_extents (ctx, phase, cr2, PATH, EQUALS, 100, 400, 100, 100);
cairo_new_path (cr2);
@@ -199,18 +201,18 @@ draw (cairo_t *cr, int width, int height)
cairo_set_line_join (cr2, CAIRO_LINE_JOIN_ROUND);
cairo_move_to (cr2, 0, 180);
cairo_line_to (cr2, 750, 180);
- errors += !check_extents (phase, cr2, FILL, EQUALS, 0, 0, 0, 0);
- errors += !check_extents (phase, cr2, STROKE, EQUALS, -5, 175, 760, 10);
- errors += !check_extents (phase, cr2, PATH, EQUALS, 0, 180, 755, 0);
+ errors += !check_extents (ctx, phase, cr2, FILL, EQUALS, 0, 0, 0, 0);
+ errors += !check_extents (ctx, phase, cr2, STROKE, EQUALS, -5, 175, 760, 10);
+ errors += !check_extents (ctx, phase, cr2, PATH, EQUALS, 0, 180, 755, 0);
cairo_new_path (cr2);
cairo_restore (cr2);
phase = "Simple rect";
cairo_save (cr2);
cairo_rectangle (cr2, 10, 10, 80, 80);
- errors += !check_extents (phase, cr2, FILL, EQUALS, 10, 10, 80, 80);
- errors += !check_extents (phase, cr2, STROKE, EQUALS, 5, 5, 90, 90);
- errors += !check_extents (phase, cr2, PATH, EQUALS, 10, 10, 80, 80);
+ errors += !check_extents (ctx, phase, cr2, FILL, EQUALS, 10, 10, 80, 80);
+ errors += !check_extents (ctx, phase, cr2, STROKE, EQUALS, 5, 5, 90, 90);
+ errors += !check_extents (ctx, phase, cr2, PATH, EQUALS, 10, 10, 80, 80);
cairo_new_path (cr2);
cairo_restore (cr2);
@@ -218,9 +220,9 @@ draw (cairo_t *cr, int width, int height)
cairo_save (cr2);
cairo_rectangle (cr2, 10, 10, 10, 10);
cairo_rectangle (cr2, 20, 20, 10, 10);
- errors += !check_extents (phase, cr2, FILL, EQUALS, 10, 10, 20, 20);
- errors += !check_extents (phase, cr2, STROKE, EQUALS, 5, 5, 30, 30);
- errors += !check_extents (phase, cr2, PATH, EQUALS, 10, 10, 20, 20);
+ errors += !check_extents (ctx, phase, cr2, FILL, EQUALS, 10, 10, 20, 20);
+ errors += !check_extents (ctx, phase, cr2, STROKE, EQUALS, 5, 5, 30, 30);
+ errors += !check_extents (ctx, phase, cr2, PATH, EQUALS, 10, 10, 20, 20);
cairo_new_path (cr2);
cairo_restore (cr2);
@@ -232,9 +234,9 @@ draw (cairo_t *cr, int width, int height)
cairo_close_path (cr2);
/* miter joins protrude 5*(1+sqrt(2)) above the top-left corner and to
the right of the bottom-right corner */
- errors += !check_extents (phase, cr2, FILL, EQUALS, 10, 10, 80, 80);
- errors += !check_extents (phase, cr2, STROKE, CONTAINS, 0, 5, 95, 95);
- errors += !check_extents (phase, cr2, PATH, CONTAINS, 10, 10, 80, 80);
+ errors += !check_extents (ctx, phase, cr2, FILL, EQUALS, 10, 10, 80, 80);
+ errors += !check_extents (ctx, phase, cr2, STROKE, CONTAINS, 0, 5, 95, 95);
+ errors += !check_extents (ctx, phase, cr2, PATH, CONTAINS, 10, 10, 80, 80);
cairo_new_path (cr2);
cairo_restore (cr2);
@@ -247,17 +249,17 @@ draw (cairo_t *cr, int width, int height)
cairo_set_fill_rule (cr2, CAIRO_FILL_RULE_EVEN_ODD);
phase = "EVEN_ODD overlapping rectangles";
- errors += !check_extents (phase, cr2, FILL, EQUALS, 10, 10, 15, 30);
- errors += !check_extents (phase, cr2, STROKE, EQUALS, 8, 8, 34, 34);
- errors += !check_extents (phase, cr2, PATH, EQUALS, 10, 10, 30, 30);
+ errors += !check_extents (ctx, phase, cr2, FILL, EQUALS, 10, 10, 15, 30);
+ errors += !check_extents (ctx, phase, cr2, STROKE, EQUALS, 8, 8, 34, 34);
+ errors += !check_extents (ctx, phase, cr2, PATH, EQUALS, 10, 10, 30, 30);
/* Test other fill rule with the same path. */
cairo_set_fill_rule (cr2, CAIRO_FILL_RULE_WINDING);
phase = "WINDING overlapping rectangles";
- errors += !check_extents (phase, cr2, FILL, EQUALS, 10, 10, 30, 30);
- errors += !check_extents (phase, cr2, STROKE, EQUALS, 8, 8, 34, 34);
- errors += !check_extents (phase, cr2, PATH, EQUALS, 10, 10, 30, 30);
+ errors += !check_extents (ctx, phase, cr2, FILL, EQUALS, 10, 10, 30, 30);
+ errors += !check_extents (ctx, phase, cr2, STROKE, EQUALS, 8, 8, 34, 34);
+ errors += !check_extents (ctx, phase, cr2, PATH, EQUALS, 10, 10, 30, 30);
/* Now, change the direction of the second rectangle and test both
* fill rules again. */
@@ -267,17 +269,17 @@ draw (cairo_t *cr, int width, int height)
cairo_set_fill_rule (cr2, CAIRO_FILL_RULE_EVEN_ODD);
phase = "EVEN_ODD overlapping rectangles";
- errors += !check_extents (phase, cr2, FILL, EQUALS, 10, 10, 15, 30);
- errors += !check_extents (phase, cr2, STROKE, EQUALS, 8, 8, 34, 34);
- errors += !check_extents (phase, cr2, PATH, EQUALS, 10, 10, 30, 30);
+ errors += !check_extents (ctx, phase, cr2, FILL, EQUALS, 10, 10, 15, 30);
+ errors += !check_extents (ctx, phase, cr2, STROKE, EQUALS, 8, 8, 34, 34);
+ errors += !check_extents (ctx, phase, cr2, PATH, EQUALS, 10, 10, 30, 30);
/* Test other fill rule with the same path. */
cairo_set_fill_rule (cr2, CAIRO_FILL_RULE_WINDING);
phase = "WINDING overlapping rectangles";
- errors += !check_extents (phase, cr2, FILL, EQUALS, 10, 10, 15, 30);
- errors += !check_extents (phase, cr2, STROKE, EQUALS, 8, 8, 34, 34);
- errors += !check_extents (phase, cr2, PATH, EQUALS, 10, 10, 30, 30);
+ errors += !check_extents (ctx, phase, cr2, FILL, EQUALS, 10, 10, 15, 30);
+ errors += !check_extents (ctx, phase, cr2, STROKE, EQUALS, 8, 8, 34, 34);
+ errors += !check_extents (ctx, phase, cr2, PATH, EQUALS, 10, 10, 30, 30);
cairo_new_path (cr2);
@@ -288,7 +290,7 @@ draw (cairo_t *cr, int width, int height)
cairo_save (cr2);
cairo_arc (cr2, 250.0, 250.0, 157.0, 5.147, 3.432);
cairo_set_line_width (cr2, 154.0);
- errors += !check_extents (phase, cr2, STROKE, APPROX_EQUALS, 16, 38, 468, 446);
+ errors += !check_extents (ctx, phase, cr2, STROKE, APPROX_EQUALS, 16, 38, 468, 446);
cairo_new_path (cr2);
cairo_restore (cr2);
@@ -304,7 +306,7 @@ draw (cairo_t *cr, int width, int height)
string,
&scaled_font_extents);
if (memcmp (&extents, &scaled_font_extents, sizeof (extents))) {
- cairo_test_log ("Error: cairo_text_extents() does not match cairo_scaled_font_text_extents() - font extents (%f, %f) x (%f, %f) should be (%f, %f) x (%f, %f)\n",
+ cairo_test_log (ctx, "Error: cairo_text_extents() does not match cairo_scaled_font_text_extents() - font extents (%f, %f) x (%f, %f) should be (%f, %f) x (%f, %f)\n",
scaled_font_extents.x_bearing,
scaled_font_extents.y_bearing,
scaled_font_extents.width,
@@ -322,11 +324,11 @@ draw (cairo_t *cr, int width, int height)
/* XXX: We'd like to be able to use EQUALS here, but currently
* when hinting is enabled freetype returns integer extents. See
* http://cairographics.org/todo */
- errors += !check_extents (phase, cr2, FILL, APPROX_EQUALS,
+ errors += !check_extents (ctx, phase, cr2, FILL, APPROX_EQUALS,
0, 0, extents.width, extents.height);
- errors += !check_extents (phase, cr2, STROKE, APPROX_EQUALS,
+ errors += !check_extents (ctx, phase, cr2, STROKE, APPROX_EQUALS,
-1, -1, extents.width+2, extents.height+2);
- errors += !check_extents (phase, cr2, PATH, APPROX_EQUALS,
+ errors += !check_extents (ctx, phase, cr2, PATH, APPROX_EQUALS,
0, 0, extents.width, extents.height);
cairo_new_path (cr2);
cairo_restore (cr2);
@@ -335,9 +337,9 @@ draw (cairo_t *cr, int width, int height)
cairo_save (cr2);
cairo_scale (cr2, 2, 2);
cairo_rectangle (cr2, 5, 5, 40, 40);
- errors += !check_extents (phase, cr2, FILL, EQUALS, 5, 5, 40, 40);
- errors += !check_extents (phase, cr2, STROKE, EQUALS, 0, 0, 50, 50);
- errors += !check_extents (phase, cr2, PATH, EQUALS, 5, 5, 40, 40);
+ errors += !check_extents (ctx, phase, cr2, FILL, EQUALS, 5, 5, 40, 40);
+ errors += !check_extents (ctx, phase, cr2, STROKE, EQUALS, 0, 0, 50, 50);
+ errors += !check_extents (ctx, phase, cr2, PATH, EQUALS, 5, 5, 40, 40);
cairo_new_path (cr2);
cairo_restore (cr2);
@@ -347,9 +349,9 @@ draw (cairo_t *cr, int width, int height)
cairo_scale (cr2, 2, 2);
cairo_rectangle (cr2, 5, 5, 40, 40);
cairo_restore (cr2);
- errors += !check_extents (phase, cr2, FILL, EQUALS, 10, 10, 80, 80);
- errors += !check_extents (phase, cr2, STROKE, EQUALS, 5, 5, 90, 90);
- errors += !check_extents (phase, cr2, PATH, EQUALS, 10, 10, 80, 80);
+ errors += !check_extents (ctx, phase, cr2, FILL, EQUALS, 10, 10, 80, 80);
+ errors += !check_extents (ctx, phase, cr2, STROKE, EQUALS, 5, 5, 90, 90);
+ errors += !check_extents (ctx, phase, cr2, PATH, EQUALS, 10, 10, 80, 80);
cairo_new_path (cr2);
cairo_restore (cr2);
@@ -366,9 +368,9 @@ draw (cairo_t *cr, int width, int height)
the axes. With the stroke width added to the rotated path,
the largest axis-aligned square is a bit over 38 on either side of
the axes. */
- errors += !check_extents (phase, cr2, FILL, CONTAINS, -35, -35, 35, 35);
- errors += !check_extents (phase, cr2, STROKE, CONTAINS, -38, -38, 38, 38);
- errors += !check_extents (phase, cr2, PATH, CONTAINS, -35, -35, 35, 35);
+ errors += !check_extents (ctx, phase, cr2, FILL, CONTAINS, -35, -35, 35, 35);
+ errors += !check_extents (ctx, phase, cr2, STROKE, CONTAINS, -38, -38, 38, 38);
+ errors += !check_extents (ctx, phase, cr2, PATH, CONTAINS, -35, -35, 35, 35);
cairo_new_path (cr2);
cairo_restore (cr2);
diff --git a/test/get-xrender-format.c b/test/get-xrender-format.c
index 9dec1d99f..fbb7d0c92 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;
}
diff --git a/test/glyph-cache-pressure.c b/test/glyph-cache-pressure.c
index 72044ee63..f0ab7d1c5 100644
--- a/test/glyph-cache-pressure.c
+++ b/test/glyph-cache-pressure.c
@@ -51,7 +51,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"glyph-cache-pressure",
"Ensure that all backends behave well under artificial glyph cache pressure",
223, TEXT_SIZE + 4,
diff --git a/test/gradient-alpha.c b/test/gradient-alpha.c
index 6b762476d..38a282f3a 100644
--- a/test/gradient-alpha.c
+++ b/test/gradient-alpha.c
@@ -27,7 +27,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"gradient-alpha",
"Tests drawing of a gradient with various alpha values in the color stops\n",
10, 10,
diff --git a/test/gradient-zero-stops.c b/test/gradient-zero-stops.c
index 0cf145d0f..0605ed0f6 100644
--- a/test/gradient-zero-stops.c
+++ b/test/gradient-zero-stops.c
@@ -34,7 +34,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"gradient-zero-stops",
"Verifies that gradients with no stops dont cause problems.",
2, 2,
diff --git a/test/group-paint.c b/test/group-paint.c
index bfc23e427..1f6b1f604 100644
--- a/test/group-paint.c
+++ b/test/group-paint.c
@@ -27,16 +27,15 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"group-paint",
"test push_group(); pop_group_to_source(); set_operator(SOURCE); paint();",
10, 10,
draw
};
-
static cairo_test_status_t
-draw (cairo_t *cr, int dst_width, int dst_height)
+draw (cairo_t *cr, int width, int height)
{
cairo_push_group (cr);
diff --git a/test/imagediff.c b/test/imagediff.c
index 188c1a979..c170c8e5b 100644
--- a/test/imagediff.c
+++ b/test/imagediff.c
@@ -54,7 +54,7 @@ main (int argc, char *argv[])
ax = ay = bx = by = 0;
}
- status = image_diff (argv[1], argv[2], NULL, ax, ay, bx, by, &result);
+ status = image_diff (NULL, argv[1], argv[2], NULL, ax, ay, bx, by, &result);
if (status) {
fprintf (stderr, "Error comparing images: %s\n",
diff --git a/test/in-fill-empty-trapezoid.c b/test/in-fill-empty-trapezoid.c
index 45051f8dd..9d846a3f1 100644
--- a/test/in-fill-empty-trapezoid.c
+++ b/test/in-fill-empty-trapezoid.c
@@ -38,21 +38,26 @@
int
main (void)
{
+ cairo_test_context_t ctx;
int x,y;
int width = 10;
int height = 10;
- cairo_surface_t *surf = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height);
- cairo_t *cr = cairo_create (surf);
+ cairo_surface_t *surf;
+ cairo_t *cr;
int false_positive_count = 0;
cairo_status_t status;
char const * description =
"Test that the tessellator isn't producing obviously empty trapezoids";
cairo_test_status_t ret;
- cairo_test_init ("in-fill-empty-trapezoid");
- cairo_test_log ("%s\n", description);
+ cairo_test_init (&ctx, "in-fill-empty-trapezoid");
+ cairo_test_log (&ctx, "%s\n", description);
printf ("%s\n", description);
+ surf = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height);
+ cr = cairo_create (surf);
+ cairo_surface_destroy (surf);
+
/* Empty horizontal trapezoid. */
cairo_move_to (cr, 0, height/3);
cairo_line_to (cr, width, height/3);
@@ -79,24 +84,23 @@ main (void)
}
}
cairo_destroy (cr);
- cairo_surface_destroy (surf);
/* Check that everything went well. */
ret = CAIRO_TEST_SUCCESS;
if (CAIRO_STATUS_SUCCESS != status) {
- cairo_test_log ("Failed to create a test surface and path: %s\n",
+ cairo_test_log (&ctx, "Failed to create a test surface and path: %s\n",
cairo_status_to_string (status));
ret = CAIRO_TEST_FAILURE;
}
if (0 != false_positive_count) {
- cairo_test_log ("Point sampling found %d false positives "
+ cairo_test_log (&ctx, "Point sampling found %d false positives "
"from cairo_in_fill()\n",
false_positive_count);
ret = CAIRO_TEST_FAILURE;
}
- cairo_test_fini ();
+ cairo_test_fini (&ctx);
return ret;
}
diff --git a/test/in-fill-trapezoid.c b/test/in-fill-trapezoid.c
index a544e4392..c44ffb829 100644
--- a/test/in-fill-trapezoid.c
+++ b/test/in-fill-trapezoid.c
@@ -28,7 +28,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"in-fill-trapezoid",
"Test _cairo_trap_contains via cairo_in_fill",
0, 0,
@@ -38,6 +38,7 @@ cairo_test_t test = {
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 ret = CAIRO_TEST_SUCCESS;
cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
@@ -46,7 +47,7 @@ draw (cairo_t *cr, int width, int height)
cairo_new_path (cr);
cairo_rectangle (cr, -10, -10, 20, 20);
if (! cairo_in_fill (cr, 0, 0)) {
- cairo_test_log ("Error: Failed to find point inside rectangle\n");
+ cairo_test_log (ctx, "Error: Failed to find point inside rectangle\n");
ret = CAIRO_TEST_FAILURE;
}
@@ -54,7 +55,7 @@ draw (cairo_t *cr, int width, int height)
cairo_new_path (cr);
cairo_arc (cr, 0, 0, 10, 0, 2 * M_PI);
if (! cairo_in_fill (cr, 0, 0)) {
- cairo_test_log ("Error: Failed to find point inside circle\n");
+ cairo_test_log (ctx, "Error: Failed to find point inside circle\n");
ret = CAIRO_TEST_FAILURE;
}
@@ -63,7 +64,7 @@ draw (cairo_t *cr, int width, int height)
cairo_rectangle (cr, -10, -10, 20, 20);
cairo_rectangle (cr, -5, -5, 10, 10);
if (cairo_in_fill (cr, 0, 0)) {
- cairo_test_log ("Error: Found an unexpected point inside rectangular hole\n");
+ cairo_test_log (ctx, "Error: Found an unexpected point inside rectangular hole\n");
ret = CAIRO_TEST_FAILURE;
}
@@ -72,7 +73,7 @@ draw (cairo_t *cr, int width, int height)
cairo_arc (cr, 0, 0, 10, 0, 2 * M_PI);
cairo_arc (cr, 0, 0, 5, 0, 2 * M_PI);
if (cairo_in_fill (cr, 0, 0)) {
- cairo_test_log ("Error: Found an unexpected point inside circular hole\n");
+ cairo_test_log (ctx, "Error: Found an unexpected point inside circular hole\n");
ret = CAIRO_TEST_FAILURE;
}
diff --git a/test/infinite-join.c b/test/infinite-join.c
index 74d4206fa..c2c728f66 100644
--- a/test/infinite-join.c
+++ b/test/infinite-join.c
@@ -35,7 +35,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"infinite-join",
"Test case for infinite loop when stroking with round joins",
8, 8,
diff --git a/test/invalid-matrix.c b/test/invalid-matrix.c
index c25197f1a..8db3df13b 100644
--- a/test/invalid-matrix.c
+++ b/test/invalid-matrix.c
@@ -36,7 +36,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"invalid-matrix",
"Test that all relevant public functions return CAIRO_STATUS_INVALID_MATRIX as appropriate",
0, 0,
@@ -46,6 +46,7 @@ cairo_test_t test = {
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_status_t status;
cairo_surface_t *target;
cairo_font_face_t *font_face;
@@ -61,11 +62,11 @@ draw (cairo_t *cr, int width, int height)
#define CHECK_STATUS(status, function_name) \
if ((status) == CAIRO_STATUS_SUCCESS) { \
- cairo_test_log ("Error: %s with invalid matrix passed\n", \
+ cairo_test_log (ctx, "Error: %s with invalid matrix passed\n", \
(function_name)); \
return CAIRO_TEST_FAILURE; \
} else if ((status) != CAIRO_STATUS_INVALID_MATRIX) { \
- cairo_test_log ("Error: %s with invalid matrix returned unexpected status " \
+ cairo_test_log (ctx, "Error: %s with invalid matrix returned unexpected status " \
"(%d): %s\n", \
(function_name), \
status, \
diff --git a/test/large-clip.c b/test/large-clip.c
index 3fccaf824..02fa93a6a 100644
--- a/test/large-clip.c
+++ b/test/large-clip.c
@@ -29,7 +29,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"large-clip",
"Incorrect clipping when the clip rectangle doesn't fit in 16 bits signed",
SIZE, SIZE,
diff --git a/test/large-font.c b/test/large-font.c
index 85c135d93..63418e13c 100644
--- a/test/large-font.c
+++ b/test/large-font.c
@@ -47,7 +47,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"large-font",
"Draws a very large font to exercise a glyph-positioning bug",
WIDTH, HEIGHT,
@@ -57,8 +57,6 @@ cairo_test_t test = {
static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
- cairo_font_options_t *font_options;
-
/* paint white so we don't need separate ref images for
* RGB24 and ARGB32 */
cairo_set_source_rgb (cr, 1., 1., 1.);
diff --git a/test/large-source.c b/test/large-source.c
index c4781d0aa..1756424f9 100644
--- a/test/large-source.c
+++ b/test/large-source.c
@@ -37,7 +37,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"large-source",
"Exercises mozilla bug 424333 - handling of massive images",
20, 20,
diff --git a/test/leaky-dash.c b/test/leaky-dash.c
index d78fac56c..2a76715ad 100644
--- a/test/leaky-dash.c
+++ b/test/leaky-dash.c
@@ -36,7 +36,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"leaky-dash",
"Exercises bug #4863 in which a dashed stroke leaks into half the rectangle being filled"
"\nknown bug (#4863) which has existed since the 1.0 release",
diff --git a/test/leaky-dashed-rectangle.c b/test/leaky-dashed-rectangle.c
index 0d9e2460b..5a867a42b 100644
--- a/test/leaky-dashed-rectangle.c
+++ b/test/leaky-dashed-rectangle.c
@@ -35,7 +35,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"leaky-dashed-rectangle",
"Exercises bug in which a dashed stroke leaks in from outside the surface",
WIDTH, HEIGHT,
diff --git a/test/leaky-polygon.c b/test/leaky-polygon.c
index 252686095..fbe747549 100644
--- a/test/leaky-polygon.c
+++ b/test/leaky-polygon.c
@@ -58,7 +58,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"leaky-polygon",
"Exercises a corner case in the trapezoid rasterization in which pixels outside the trapezoids received a non-zero alpha",
WIDTH, HEIGHT,
diff --git a/test/line-width-scale.c b/test/line-width-scale.c
index eada6c6b0..523b7d1b3 100644
--- a/test/line-width-scale.c
+++ b/test/line-width-scale.c
@@ -54,7 +54,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"line-width-scale",
"Tests interaction of cairo_set_line_width with cairo_scale",
WIDTH, HEIGHT,
@@ -158,8 +158,7 @@ static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
int i;
- typedef void (*figure_t) (cairo_t *cr);
- figure_t figures[4] = {
+ void (* const figures[4]) (cairo_t *cr) = {
scale_then_set_line_width_and_stroke,
scale_path_and_line_width,
set_line_width_then_scale_and_stroke,
diff --git a/test/line-width-zero.c b/test/line-width-zero.c
index 139a47106..449f435a1 100644
--- a/test/line-width-zero.c
+++ b/test/line-width-zero.c
@@ -35,7 +35,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"line-width-zero",
"Test all stroke operations and all cap,join styles with line width of zero",
0, 0,
diff --git a/test/line-width.c b/test/line-width.c
index ad51c74d8..b1e31ff29 100644
--- a/test/line-width.c
+++ b/test/line-width.c
@@ -32,7 +32,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"line-width",
"Tests cairo_set_line_width",
IMAGE_WIDTH, IMAGE_HEIGHT,
diff --git a/test/linear-gradient-reflect.c b/test/linear-gradient-reflect.c
index 779ccd8d9..0f0dea6e3 100644
--- a/test/linear-gradient-reflect.c
+++ b/test/linear-gradient-reflect.c
@@ -32,7 +32,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"linear-gradient-reflect",
"Tests the drawing of linear gradient with reflect",
WIDTH, HEIGHT,
diff --git a/test/linear-gradient.c b/test/linear-gradient.c
index 3dad477c7..166f64390 100644
--- a/test/linear-gradient.c
+++ b/test/linear-gradient.c
@@ -56,7 +56,7 @@ static const int n_stops[] = { 2, 3 };
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"linear-gradient",
"Tests the drawing of linear gradients\n",
WIDTH, HEIGHT,
@@ -84,7 +84,7 @@ draw_unit (cairo_t *cr,
cairo_rotate (cr, rotate_angle);
pattern = cairo_pattern_create_linear (-0.5 * cos (gradient_angle), -0.5 * sin (gradient_angle),
- 0.5 * cos (gradient_angle), 0.5 * sin (gradient_angle));
+ 0.5 * cos (gradient_angle), 0.5 * sin (gradient_angle));
if (n_stops == 2) {
cairo_pattern_add_color_stop_rgb (pattern, 0.,
diff --git a/test/long-dashed-lines.c b/test/long-dashed-lines.c
index fce6d796e..788951ced 100644
--- a/test/long-dashed-lines.c
+++ b/test/long-dashed-lines.c
@@ -27,7 +27,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"long-dashed-lines",
"Exercises _cairo_box_intersects_line_segment()",
60, 60,
@@ -72,4 +72,3 @@ main (void)
{
return cairo_test (&test);
}
-
diff --git a/test/long-lines.c b/test/long-lines.c
index 8b189b2b6..dfbbe0dc1 100644
--- a/test/long-lines.c
+++ b/test/long-lines.c
@@ -21,18 +21,18 @@
* IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Authors: Carl D. Worth <cworth@cworth.org>
- * Emmanuel Pacaud <emmanuel.pacaud@lapp.in2p3.fr>
+ * Emmanuel Pacaud <emmanuel.pacaud@lapp.in2p3.fr>
*/
#include "cairo-test.h"
-#define LINE_WIDTH 1.
-#define SIZE 10
+#define LINE_WIDTH 1.
+#define SIZE 10
#define LINE_NBR 6
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"long-lines",
"Test long lines"
"\nLong lines are not drawn due to the limitations of the internal 16.16 fixed-point coordinates",
@@ -45,12 +45,12 @@ struct {
double length;
double red, green, blue;
} lines[LINE_NBR] = {
- { 100.0, 1.0, 0.0, 0.0 },
- { 10000.0, 0.0, 1.0, 0.0 },
- { 100000.0, 0.0, 0.0, 1.0 },
- { 1000000.0, 1.0, 1.0, 0.0 },
- { 10000000.0, 0.0, 1.0, 1.0 },
- {100000000.0, 1.0, 0.0, 1.0 }
+ { 100.0, 1.0, 0.0, 0.0 },
+ { 10000.0, 0.0, 1.0, 0.0 },
+ { 100000.0, 0.0, 0.0, 1.0 },
+ { 1000000.0, 1.0, 1.0, 0.0 },
+ { 10000000.0, 0.0, 1.0, 1.0 },
+ { 100000000.0, 1.0, 0.0, 1.0 }
};
static cairo_test_status_t
@@ -65,7 +65,6 @@ draw (cairo_t *cr, int width, int height)
cairo_paint (cr);
cairo_restore (cr);
-
cairo_set_line_width (cr, LINE_WIDTH);
pos = SIZE + .5;
diff --git a/test/mask-alpha.c b/test/mask-alpha.c
index de5394d27..284e2cb39 100644
--- a/test/mask-alpha.c
+++ b/test/mask-alpha.c
@@ -41,7 +41,7 @@ static cairo_test_draw_function_t draw;
* (0.8, 0.8, 0.8, 0.4).
*/
-cairo_test_t test = {
+static const cairo_test_t test = {
"mask-alpha",
"A simple test painting a group through a circle mask",
WIDTH, HEIGHT,
diff --git a/test/mask-ctm.c b/test/mask-ctm.c
index d6939902a..c6814b018 100644
--- a/test/mask-ctm.c
+++ b/test/mask-ctm.c
@@ -27,7 +27,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"mask-ctm",
"Test that cairo_mask is affected properly by the CTM",
10, 10,
@@ -39,7 +39,7 @@ draw (cairo_t *cr, int width, int height)
{
cairo_surface_t *mask_surface;
cairo_pattern_t *mask;
- static uint32_t data[] = {
+ uint32_t data[] = {
0x80000000, 0x80000000,
0x80000000, 0x80000000,
};
diff --git a/test/mask-surface-ctm.c b/test/mask-surface-ctm.c
index 02384c6c5..f4a0c3945 100644
--- a/test/mask-surface-ctm.c
+++ b/test/mask-surface-ctm.c
@@ -27,7 +27,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"mask-surface-ctm",
"Test that cairo_mask_surface is affected properly by the CTM",
10, 10,
@@ -38,7 +38,7 @@ static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
cairo_surface_t *mask;
- static uint32_t data[] = {
+ uint32_t data[] = {
0x80000000, 0x80000000,
0x80000000, 0x80000000,
};
diff --git a/test/mask.c b/test/mask.c
index 14dd8b30e..711c3eb74 100644
--- a/test/mask.c
+++ b/test/mask.c
@@ -32,22 +32,22 @@
#define HEIGHT 16
#define PAD 2
-const char png_filename[] = "romedalen.png";
+static const char png_filename[] = "romedalen.png";
static void
-set_solid_pattern (cairo_t *cr, int x, int y)
+set_solid_pattern (const cairo_test_context_t *ctx, cairo_t *cr, int x, int y)
{
cairo_set_source_rgb (cr, 0, 0, 0.6);
}
static void
-set_translucent_pattern (cairo_t *cr, int x, int y)
+set_translucent_pattern (const cairo_test_context_t *ctx, cairo_t *cr, int x, int y)
{
cairo_set_source_rgba (cr, 0, 0, 0.6, 0.5);
}
static void
-set_gradient_pattern (cairo_t *cr, int x, int y)
+set_gradient_pattern (const cairo_test_context_t *ctx, cairo_t *cr, int x, int y)
{
cairo_pattern_t *pattern;
@@ -60,11 +60,11 @@ set_gradient_pattern (cairo_t *cr, int x, int y)
}
static void
-set_image_pattern (cairo_t *cr, int x, int y)
+set_image_pattern (const cairo_test_context_t *ctx, cairo_t *cr, int x, int y)
{
cairo_pattern_t *pattern;
- pattern = cairo_test_create_pattern_from_png (png_filename);
+ pattern = cairo_test_create_pattern_from_png (ctx, png_filename);
cairo_set_source (cr, pattern);
cairo_pattern_destroy (pattern);
}
@@ -156,20 +156,20 @@ clip_circle (cairo_t *cr, int x, int y)
cairo_new_path (cr);
}
-static void (*pattern_funcs[])(cairo_t *cr, int x, int y) = {
+static void (* const pattern_funcs[])(const cairo_test_context_t *ctx, cairo_t *cr, int x, int y) = {
set_solid_pattern,
set_translucent_pattern,
set_gradient_pattern,
set_image_pattern,
};
-static void (*mask_funcs[])(cairo_t *cr, int x, int y) = {
+static void (* const mask_funcs[])(cairo_t *cr, int x, int y) = {
mask_alpha,
mask_gradient,
mask_polygon,
};
-static void (*clip_funcs[])(cairo_t *cr, int x, int y) = {
+static void (* const clip_funcs[])(cairo_t *cr, int x, int y) = {
clip_none,
clip_rects,
clip_circle,
@@ -181,7 +181,7 @@ static void (*clip_funcs[])(cairo_t *cr, int x, int y) = {
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"mask",
"Tests of cairo_mask",
IMAGE_WIDTH, IMAGE_HEIGHT,
@@ -191,6 +191,7 @@ cairo_test_t test = {
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_surface_t *tmp_surface;
cairo_pattern_t *tmp_pattern;
size_t i, j, k;
@@ -225,7 +226,7 @@ draw (cairo_t *cr, int width, int height)
cairo_save (cr2);
clip_funcs[k] (cr2, x, y);
- pattern_funcs[i] (cr2, x, y);
+ pattern_funcs[i] (ctx, cr2, x, y);
mask_funcs[j] (cr2, x, y);
cairo_restore (cr2);
diff --git a/test/meta-surface-pattern.c b/test/meta-surface-pattern.c
index a047b3e3b..58f05b466 100644
--- a/test/meta-surface-pattern.c
+++ b/test/meta-surface-pattern.c
@@ -40,14 +40,13 @@ static cairo_test_draw_function_t draw;
* CAIRO_EXTEND_NONE and a non identity pattern matrix.
*/
-cairo_test_t test = {
+static const cairo_test_t test = {
"meta-surface-pattern",
"Paint meta surface pattern with non identity pattern matrix",
WIDTH, HEIGHT,
draw
};
-
static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
diff --git a/test/miter-precision.c b/test/miter-precision.c
index 533c30e79..272067723 100644
--- a/test/miter-precision.c
+++ b/test/miter-precision.c
@@ -35,7 +35,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"miter-precision",
"test how cairo deals with small miters"
"\ncurrent code draws inappropriate bevels at times",
@@ -49,7 +49,7 @@ draw (cairo_t *cr, int width, int height)
double xscale, yscale;
cairo_set_source_rgb (cr, 1, 1, 1);
cairo_paint (cr);
-
+
cairo_set_source_rgb (cr, 0, 0, 0);
cairo_set_miter_limit (cr, 100000);
for (xscale = 1; xscale <= 1000; xscale += 999)
@@ -69,7 +69,7 @@ draw (cairo_t *cr, int width, int height)
cairo_stroke (cr);
cairo_restore (cr);
}
-
+
return CAIRO_TEST_SUCCESS;
}
diff --git a/test/move-to-show-surface.c b/test/move-to-show-surface.c
index 869320786..e017fa6f9 100644
--- a/test/move-to-show-surface.c
+++ b/test/move-to-show-surface.c
@@ -47,7 +47,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"move-to-show-surface",
"Tests calls to cairo_show_surface after cairo_move_to",
2, 2,
diff --git a/test/multi-page.c b/test/multi-page.c
index f0265e25d..4e0749afe 100644
--- a/test/multi-page.c
+++ b/test/multi-page.c
@@ -130,11 +130,13 @@ draw_some_pages (cairo_surface_t *surface)
int
main (void)
{
+ cairo_test_context_t ctx;
cairo_surface_t *surface;
cairo_status_t status;
const char *filename;
+ cairo_test_status_t result = CAIRO_TEST_SUCCESS;
- cairo_test_init ("multi-page");
+ cairo_test_init (&ctx, "multi-page");
#if CAIRO_HAS_PS_SURFACE
filename = "multi-page.ps";
@@ -143,9 +145,9 @@ main (void)
WIDTH_IN_POINTS, HEIGHT_IN_POINTS);
status = cairo_surface_status (surface);
if (status) {
- cairo_test_log ("Failed to create ps surface for file %s: %s\n",
+ cairo_test_log (&ctx, "Failed to create ps surface for file %s: %s\n",
filename, cairo_status_to_string (status));
- return CAIRO_TEST_FAILURE;
+ result = CAIRO_TEST_FAILURE;
}
draw_some_pages (surface);
@@ -162,9 +164,9 @@ main (void)
WIDTH_IN_POINTS, HEIGHT_IN_POINTS);
status = cairo_surface_status (surface);
if (status) {
- cairo_test_log ("Failed to create pdf surface for file %s: %s\n",
+ cairo_test_log (&ctx, "Failed to create pdf surface for file %s: %s\n",
filename, cairo_status_to_string (status));
- return CAIRO_TEST_FAILURE;
+ result = CAIRO_TEST_FAILURE;
}
draw_some_pages (surface);
@@ -174,7 +176,7 @@ main (void)
printf ("multi-page: Please check %s to ensure it looks happy.\n", filename);
#endif
- cairo_test_fini ();
+ cairo_test_fini (&ctx);
- return CAIRO_TEST_SUCCESS;
+ return result;
}
diff --git a/test/new-sub-path.c b/test/new-sub-path.c
index 93580cebd..19beaed31 100644
--- a/test/new-sub-path.c
+++ b/test/new-sub-path.c
@@ -29,7 +29,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"new-sub-path",
"Test the cairo_new_sub_path call",
8 * SIZE,
diff --git a/test/nil-surface.c b/test/nil-surface.c
index 91f1aa6f5..b2070fe0c 100644
--- a/test/nil-surface.c
+++ b/test/nil-surface.c
@@ -35,7 +35,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"nil-surface",
"Test that nil surfaces do not make cairo crash.",
1, 1,
@@ -45,6 +45,7 @@ cairo_test_t test = {
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_surface_t *surface;
cairo_pattern_t *pattern;
cairo_t *cr2;
@@ -71,7 +72,7 @@ draw (cairo_t *cr, int width, int height)
/* Check that the error made it all that way. */
if (cairo_status (cr2) != CAIRO_STATUS_FILE_NOT_FOUND) {
- cairo_test_log ("Error: Received status of \"%s\" rather than expected \"%s\"\n",
+ cairo_test_log (ctx, "Error: Received status of \"%s\" rather than expected \"%s\"\n",
cairo_status_to_string (cairo_status (cr2)),
cairo_status_to_string (CAIRO_STATUS_FILE_NOT_FOUND));
cairo_destroy (cr2);
@@ -96,7 +97,7 @@ draw (cairo_t *cr, int width, int height)
/* Check that the error made it all that way. */
if (cairo_status (cr2) != CAIRO_STATUS_NULL_POINTER) {
- cairo_test_log ("Error: Received status of \"%s\" rather than expected \"%s\"\n",
+ cairo_test_log (ctx, "Error: Received status of \"%s\" rather than expected \"%s\"\n",
cairo_status_to_string (cairo_status (cr2)),
cairo_status_to_string (CAIRO_STATUS_NULL_POINTER));
cairo_destroy (cr2);
@@ -127,7 +128,7 @@ draw (cairo_t *cr, int width, int height)
/* Trigger invalid restore. */
cairo_restore (cr2);
if (cairo_status (cr2) != CAIRO_STATUS_INVALID_RESTORE) {
- cairo_test_log ("Error: Received status of \"%s\" rather than expected \"%s\"\n",
+ cairo_test_log (ctx, "Error: Received status of \"%s\" rather than expected \"%s\"\n",
cairo_status_to_string (cairo_status (cr2)),
cairo_status_to_string (CAIRO_STATUS_INVALID_RESTORE));
cairo_destroy (cr2);
@@ -145,7 +146,7 @@ draw (cairo_t *cr, int width, int height)
cr2 = cairo_create (NULL);
if (cairo_status (cr2) != CAIRO_STATUS_NULL_POINTER) {
- cairo_test_log ("Error: Received status of \"%s\" rather than expected \"%s\"\n",
+ cairo_test_log (ctx, "Error: Received status of \"%s\" rather than expected \"%s\"\n",
cairo_status_to_string (cairo_status (cr2)),
cairo_status_to_string (CAIRO_STATUS_NULL_POINTER));
cairo_destroy (cr2);
@@ -154,7 +155,7 @@ draw (cairo_t *cr, int width, int height)
/* Test that get_target returns something valid */
if (cairo_get_target (cr2) == NULL) {
- cairo_test_log ("Error: cairo_get_target() returned NULL\n");
+ cairo_test_log (ctx, "Error: cairo_get_target() returned NULL\n");
cairo_destroy (cr2);
return CAIRO_TEST_FAILURE;
}
diff --git a/test/operator-clear.c b/test/operator-clear.c
index e6cb042a7..f1eb32248 100644
--- a/test/operator-clear.c
+++ b/test/operator-clear.c
@@ -128,12 +128,12 @@ draw_rects (cairo_t *cr, int x, int y)
cairo_fill (cr);
}
-static void (*pattern_funcs[])(cairo_t *cr, int x, int y) = {
+static void (* const pattern_funcs[])(cairo_t *cr, int x, int y) = {
set_solid_pattern,
set_gradient_pattern,
};
-static void (*draw_funcs[])(cairo_t *cr, int x, int y) = {
+static void (* const draw_funcs[])(cairo_t *cr, int x, int y) = {
draw_mask,
draw_glyphs,
draw_polygon,
@@ -146,7 +146,7 @@ static void (*draw_funcs[])(cairo_t *cr, int x, int y) = {
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"operator-clear",
"Test of CAIRO_OPERATOR_CLEAR",
IMAGE_WIDTH, IMAGE_HEIGHT,
@@ -156,6 +156,7 @@ cairo_test_t test = {
static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
+ const cairo_test_context_t *ctx = cairo_test_get_context (cr);
size_t i, j, x, y;
cairo_pattern_t *pattern;
@@ -187,14 +188,14 @@ draw (cairo_t *cr, int width, int height)
pattern_funcs[i] (cr, x, y);
draw_funcs[j] (cr, x, y);
if (cairo_status (cr))
- cairo_test_log ("%d %d HERE!\n", (int)i, (int)j);
+ cairo_test_log (ctx, "%d %d HERE!\n", (int)i, (int)j);
cairo_restore (cr);
}
}
if (cairo_status (cr) != CAIRO_STATUS_SUCCESS)
- cairo_test_log ("%d %d .HERE!\n", (int)i, (int)j);
+ cairo_test_log (ctx, "%d %d .HERE!\n", (int)i, (int)j);
return CAIRO_TEST_SUCCESS;
}
diff --git a/test/operator-source.c b/test/operator-source.c
index e63bceaf9..882723ee0 100644
--- a/test/operator-source.c
+++ b/test/operator-source.c
@@ -165,14 +165,14 @@ draw_rects (cairo_t *cr, int x, int y)
cairo_fill (cr);
}
-static void (*pattern_funcs[])(cairo_t *cr, int x, int y) = {
+static void (* const pattern_funcs[])(cairo_t *cr, int x, int y) = {
set_solid_pattern,
set_translucent_pattern,
set_gradient_pattern,
set_surface_pattern,
};
-static void (*draw_funcs[])(cairo_t *cr, int x, int y) = {
+static void (* const draw_funcs[])(cairo_t *cr, int x, int y) = {
draw_mask,
draw_glyphs,
draw_polygon,
@@ -185,7 +185,7 @@ static void (*draw_funcs[])(cairo_t *cr, int x, int y) = {
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"operator-source",
"Test of CAIRO_OPERATOR_SOURCE",
IMAGE_WIDTH, IMAGE_HEIGHT,
@@ -195,6 +195,7 @@ cairo_test_t test = {
static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
+ const cairo_test_context_t *ctx = cairo_test_get_context (cr);
size_t i, j, x, y;
cairo_pattern_t *pattern;
@@ -226,14 +227,14 @@ draw (cairo_t *cr, int width, int height)
pattern_funcs[i] (cr, x, y);
draw_funcs[j] (cr, x, y);
if (cairo_status (cr))
- cairo_test_log ("%d %d HERE!\n", (int)i, (int)j);
+ cairo_test_log (ctx, "%d %d HERE!\n", (int)i, (int)j);
cairo_restore (cr);
}
}
if (cairo_status (cr) != CAIRO_STATUS_SUCCESS)
- cairo_test_log ("%d %d .HERE!\n", (int)i, (int)j);
+ cairo_test_log (ctx, "%d %d .HERE!\n", (int)i, (int)j);
return CAIRO_TEST_SUCCESS;
}
diff --git a/test/over-above-source.c b/test/over-above-source.c
index 8999e4ad3..928fb3694 100644
--- a/test/over-above-source.c
+++ b/test/over-above-source.c
@@ -39,7 +39,7 @@ static cairo_test_draw_function_t draw;
* surface, it's the reverse where OVER is native while SOURCE is a
* fallback. */
-cairo_test_t test = {
+static const cairo_test_t test = {
"over-above-source",
"A simple test drawing a circle with OVER after a triangle drawn with SOURCE",
WIDTH, HEIGHT,
diff --git a/test/over-around-source.c b/test/over-around-source.c
index e98c1870c..030e42d2c 100644
--- a/test/over-around-source.c
+++ b/test/over-around-source.c
@@ -39,7 +39,7 @@ static cairo_test_draw_function_t draw;
* surface, it's the reverse where OVER is native while SOURCE is a
* fallback. */
-cairo_test_t test = {
+static const cairo_test_t test = {
"over-around-source",
"A simple test drawing a triangle with SOURCE between two circles drawn with OVER",
WIDTH, HEIGHT,
diff --git a/test/over-below-source.c b/test/over-below-source.c
index df7e7d102..74dac6f62 100644
--- a/test/over-below-source.c
+++ b/test/over-below-source.c
@@ -39,7 +39,7 @@ static cairo_test_draw_function_t draw;
* surface, it's the reverse where OVER is native while SOURCE is a
* fallback. */
-cairo_test_t test = {
+static const cairo_test_t test = {
"over-below-source",
"A simple test drawing a circle with OVER before a triangle drawn with SOURCE",
WIDTH, HEIGHT,
diff --git a/test/over-between-source.c b/test/over-between-source.c
index 9c60bbda8..f88b6cc58 100644
--- a/test/over-between-source.c
+++ b/test/over-between-source.c
@@ -39,7 +39,7 @@ static cairo_test_draw_function_t draw;
* surface, it's the reverse where OVER is native while SOURCE is a
* fallback. */
-cairo_test_t test = {
+static const cairo_test_t test = {
"over-between-source",
"A simple test drawing a circle with OVER between two triangles drawn with SOURCE",
WIDTH, HEIGHT,
diff --git a/test/paint-repeat.c b/test/paint-repeat.c
index 892cbf867..8e7f4ab10 100644
--- a/test/paint-repeat.c
+++ b/test/paint-repeat.c
@@ -27,7 +27,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"paint-repeat",
"Test calls to cairo_paint with a repeating source surface pattern",
8, 8,
@@ -38,7 +38,7 @@ static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
cairo_surface_t *surface;
- static uint32_t data[16] = {
+ uint32_t data[16] = {
0xffffffff, 0xffffffff, 0xffff0000, 0xffff0000,
0xffffffff, 0xffffffff, 0xffff0000, 0xffff0000,
diff --git a/test/paint-source-alpha.c b/test/paint-source-alpha.c
index 36a158b86..764b744ae 100644
--- a/test/paint-source-alpha.c
+++ b/test/paint-source-alpha.c
@@ -28,7 +28,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"paint-source-alpha",
"Simple test of cairo_paint with a source surface with non-opaque alpha",
32, 32,
@@ -39,7 +39,7 @@ static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
cairo_surface_t *surface;
- static uint32_t data[16] = {
+ uint32_t data[16] = {
0x80808080, 0x80808080, 0x80800000, 0x80800000,
0x80808080, 0x80808080, 0x80800000, 0x80800000,
diff --git a/test/paint-with-alpha.c b/test/paint-with-alpha.c
index 864b95673..adfb7ce18 100644
--- a/test/paint-with-alpha.c
+++ b/test/paint-with-alpha.c
@@ -28,7 +28,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"paint-with-alpha",
"Simple test of cairo_paint_with_alpha",
32, 32,
@@ -39,7 +39,7 @@ static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
cairo_surface_t *surface;
- static uint32_t data[16] = {
+ uint32_t data[16] = {
0xffffffff, 0xffffffff, 0xffff0000, 0xffff0000,
0xffffffff, 0xffffffff, 0xffff0000, 0xffff0000,
diff --git a/test/paint.c b/test/paint.c
index 0149db684..6f5ecf226 100644
--- a/test/paint.c
+++ b/test/paint.c
@@ -27,7 +27,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"paint",
"Test calls to cairo_paint",
8, 8,
diff --git a/test/pattern-get-type.c b/test/pattern-get-type.c
index d64dd881a..96ed0c947 100644
--- a/test/pattern-get-type.c
+++ b/test/pattern-get-type.c
@@ -28,12 +28,13 @@
int
main (void)
{
+ cairo_test_context_t ctx;
cairo_surface_t *surface;
cairo_pattern_t *solid_rgb, *solid_rgba, *surface_pattern, *linear, *radial;
+ cairo_test_status_t result = CAIRO_TEST_SUCCESS;
- cairo_test_init ("pattern-get-type");
-
- cairo_test_log ("Creating patterns of all types\n");
+ cairo_test_init (&ctx, "pattern-get-type");
+ cairo_test_log (&ctx, "Creating patterns of all types\n");
solid_rgb = cairo_pattern_create_rgb (0.0, 0.1, 0.2);
solid_rgba = cairo_pattern_create_rgba (0.3, 0.4, 0.5, 0.6);
@@ -44,24 +45,24 @@ main (void)
radial = cairo_pattern_create_radial (10.0, 10.0, 0.1,
10.0, 10.0, 1.0);
- cairo_test_log ("Verifying return values of cairo_pattern_get_type\n");
+ cairo_test_log (&ctx, "Verifying return values of cairo_pattern_get_type\n");
if (cairo_pattern_get_type (solid_rgb) != CAIRO_PATTERN_TYPE_SOLID)
- return CAIRO_TEST_FAILURE;
+ result = CAIRO_TEST_FAILURE;
if (cairo_pattern_get_type (solid_rgba) != CAIRO_PATTERN_TYPE_SOLID)
- return CAIRO_TEST_FAILURE;
+ result = CAIRO_TEST_FAILURE;
if (cairo_pattern_get_type (surface_pattern) != CAIRO_PATTERN_TYPE_SURFACE)
- return CAIRO_TEST_FAILURE;
+ result = CAIRO_TEST_FAILURE;
if (cairo_pattern_get_type (linear) != CAIRO_PATTERN_TYPE_LINEAR)
- return CAIRO_TEST_FAILURE;
+ result = CAIRO_TEST_FAILURE;
if (cairo_pattern_get_type (radial) != CAIRO_PATTERN_TYPE_RADIAL)
- return CAIRO_TEST_FAILURE;
+ result = CAIRO_TEST_FAILURE;
- cairo_test_log ("Cleaning up\n");
+ cairo_test_log (&ctx, "Cleaning up\n");
cairo_pattern_destroy (solid_rgb);
cairo_pattern_destroy (solid_rgba);
@@ -70,7 +71,7 @@ main (void)
cairo_pattern_destroy (linear);
cairo_pattern_destroy (radial);
- cairo_test_fini ();
+ cairo_test_fini (&ctx);
- return CAIRO_TEST_SUCCESS;
+ return result;
}
diff --git a/test/pattern-getters.c b/test/pattern-getters.c
index aa420bf3f..a42d47b5e 100644
--- a/test/pattern-getters.c
+++ b/test/pattern-getters.c
@@ -29,7 +29,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"pattern-getters",
"Tests calls to pattern getter functions",
1, 1,
@@ -39,12 +39,12 @@ cairo_test_t test = {
#define CHECK_SUCCESS do { if (status) return CAIRO_TEST_FAILURE; } while (0)
static int
-double_buf_equal (double *a, double *b, int nc)
+double_buf_equal (const cairo_test_context_t *ctx, double *a, double *b, int nc)
{
int i;
for (i = 0; i < nc; i++) {
if (!CAIRO_TEST_DOUBLE_EQUALS(a[i],b[i])) {
- cairo_test_log ("Error: doubles not equal: %g, %g\n",
+ cairo_test_log (ctx, "Error: doubles not equal: %g, %g\n",
a[i], b[i]);
return 0;
}
@@ -55,6 +55,7 @@ double_buf_equal (double *a, double *b, int nc)
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_status_t status;
cairo_pattern_t *pat;
@@ -70,7 +71,7 @@ draw (cairo_t *cr, int width, int height)
!CAIRO_TEST_DOUBLE_EQUALS(g,0.3) ||
!CAIRO_TEST_DOUBLE_EQUALS(b,0.4) ||
!CAIRO_TEST_DOUBLE_EQUALS(a,0.5)) {
- cairo_test_log ("Error: cairo_pattern_get_rgba returned unexepcted results: %g, %g, %g, %g\n",
+ cairo_test_log (ctx, "Error: cairo_pattern_get_rgba returned unexepcted results: %g, %g, %g, %g\n",
r, g, b, a);
return CAIRO_TEST_FAILURE;
}
@@ -88,7 +89,7 @@ draw (cairo_t *cr, int width, int height)
CHECK_SUCCESS;
if (surf != cairo_get_target (cr)) {
- cairo_test_log ("Error: cairo_pattern_get_resurface returned wrong surface\n");
+ cairo_test_log (ctx, "Error: cairo_pattern_get_resurface returned wrong surface\n");
return CAIRO_TEST_FAILURE;
}
@@ -144,7 +145,7 @@ draw (cairo_t *cr, int width, int height)
if (status != CAIRO_STATUS_INVALID_INDEX)
return CAIRO_TEST_FAILURE;
- if (!double_buf_equal (new_buf, expected_values, sizeof(expected_values)/sizeof(double)) != 0)
+ if (!double_buf_equal (ctx, new_buf, expected_values, sizeof(expected_values)/sizeof(double)) != 0)
return CAIRO_TEST_FAILURE;
cairo_pattern_destroy (pat);
diff --git a/test/pdf-features.c b/test/pdf-features.c
index de3248f43..74804cd84 100644
--- a/test/pdf-features.c
+++ b/test/pdf-features.c
@@ -86,13 +86,14 @@ struct {
int
main (void)
{
+ cairo_test_context_t ctx;
cairo_surface_t *surface;
cairo_t *cr;
cairo_status_t status;
const char *filename;
size_t i;
- cairo_test_init ("pdf-features");
+ cairo_test_init (&ctx, "pdf-features");
filename = "pdf-features.pdf";
@@ -130,14 +131,14 @@ main (void)
cairo_surface_destroy (surface);
if (status) {
- cairo_test_log ("Failed to create pdf surface for file %s: %s\n",
+ cairo_test_log (&ctx, "Failed to create pdf surface for file %s: %s\n",
filename, cairo_status_to_string (status));
return CAIRO_TEST_FAILURE;
}
printf ("pdf-features: Please check %s to ensure it looks/prints correctly.\n", filename);
- cairo_test_fini ();
+ cairo_test_fini (&ctx);
return CAIRO_TEST_SUCCESS;
}
diff --git a/test/pixman-rotate.c b/test/pixman-rotate.c
index 4d8e3001f..d115494b7 100644
--- a/test/pixman-rotate.c
+++ b/test/pixman-rotate.c
@@ -41,7 +41,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"pixman-rotate",
"Exposes pixman off-by-one error when rotating",
IMAGE_WIDTH, IMAGE_HEIGHT,
diff --git a/test/ps-features.c b/test/ps-features.c
index 597b73cf1..b3ac50d10 100644
--- a/test/ps-features.c
+++ b/test/ps-features.c
@@ -89,6 +89,7 @@ struct {
int
main (void)
{
+ cairo_test_context_t ctx;
cairo_surface_t *surface;
cairo_t *cr;
cairo_status_t status;
@@ -96,7 +97,7 @@ main (void)
size_t i;
char dsc[255];
- cairo_test_init ("ps-features");
+ cairo_test_init (&ctx, "ps-features");
filename = "ps-features.ps";
@@ -144,14 +145,14 @@ main (void)
cairo_surface_destroy (surface);
if (status) {
- cairo_test_log ("Failed to create ps surface for file %s: %s\n",
+ cairo_test_log (&ctx, "Failed to create ps surface for file %s: %s\n",
filename, cairo_status_to_string (status));
return CAIRO_TEST_FAILURE;
}
printf ("ps-features: Please check %s to ensure it looks/prints correctly.\n", filename);
- cairo_test_fini ();
+ cairo_test_fini (&ctx);
return CAIRO_TEST_SUCCESS;
}
diff --git a/test/pthread-show-text.c b/test/pthread-show-text.c
index 0f0ec891e..daf04c389 100644
--- a/test/pthread-show-text.c
+++ b/test/pthread-show-text.c
@@ -75,6 +75,7 @@ start (void *closure)
int
main (int argc, char *argv[])
{
+ cairo_test_context_t ctx;
int err;
int i, num_threads;
pthread_t *pthread;
@@ -85,16 +86,16 @@ main (int argc, char *argv[])
num_threads = NUM_THREADS_DEFAULT;
}
- cairo_test_init ("pthread-show-text");
-
- cairo_test_log ("Running with %d threads.\n", num_threads);
+ cairo_test_init (&ctx, "pthread-show-text");
+ cairo_test_log (&ctx, "Running with %d threads.\n", num_threads);
pthread = xmalloc (num_threads * sizeof (pthread_t));
for (i = 0; i < num_threads; i++) {
err = pthread_create (&pthread[i], NULL, start, NULL);
if (err) {
- cairo_test_log ("pthread_create failed: %s\n", strerror(err));
+ cairo_test_log (&ctx, "pthread_create failed: %s\n", strerror(err));
+ cairo_test_fini (&ctx);
return CAIRO_TEST_FAILURE;
}
}
@@ -104,7 +105,7 @@ main (int argc, char *argv[])
free (pthread);
- cairo_test_fini ();
+ cairo_test_fini (&ctx);
return CAIRO_TEST_SUCCESS;
}
diff --git a/test/push-group.c b/test/push-group.c
index 4e6fed059..c14227889 100644
--- a/test/push-group.c
+++ b/test/push-group.c
@@ -34,7 +34,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"push-group",
"Verify that cairo_push_group works.",
WIDTH, HEIGHT,
diff --git a/test/radial-gradient.c b/test/radial-gradient.c
index 1207943ae..7a56ec1d7 100644
--- a/test/radial-gradient.c
+++ b/test/radial-gradient.c
@@ -34,7 +34,7 @@ static cairo_test_draw_function_t draw;
#define WIDTH (SIZE * NUM_GRADIENTS)
#define HEIGHT (SIZE * NUM_EXTEND)
-cairo_test_t test = {
+static const cairo_test_t test = {
"radial-gradient",
"Simple test of radial gradients",
WIDTH, HEIGHT,
diff --git a/test/random-intersections.c b/test/random-intersections.c
index 5aa8e489e..bf3c98c70 100644
--- a/test/random-intersections.c
+++ b/test/random-intersections.c
@@ -29,7 +29,7 @@ static cairo_test_draw_function_t draw;
#define SIZE 512
#define NUM_SEGMENTS 128
-cairo_test_t test = {
+static const cairo_test_t test = {
"random-intersections",
"Tests the tessellator trapezoid generation and intersection computation",
SIZE+3, SIZE+3,
diff --git a/test/rectangle-rounding-error.c b/test/rectangle-rounding-error.c
index 2cfbe9c9d..5d8fd78c4 100644
--- a/test/rectangle-rounding-error.c
+++ b/test/rectangle-rounding-error.c
@@ -32,7 +32,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"rectangle-rounding-error",
"This demonstrates (or not) a rounding error that causes a gap between "
"two neighbouring rectangles.",
diff --git a/test/rectilinear-miter-limit.c b/test/rectilinear-miter-limit.c
index 114472c21..a935fd54b 100644
--- a/test/rectilinear-miter-limit.c
+++ b/test/rectilinear-miter-limit.c
@@ -33,7 +33,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"rectilinear-miter-limit",
"Test that the rectilinear stroke optimization doesn't break cairo_set_miter_limit",
WIDTH, HEIGHT,
diff --git a/test/rectilinear-stroke.c b/test/rectilinear-stroke.c
index 379284d28..3c6758650 100644
--- a/test/rectilinear-stroke.c
+++ b/test/rectilinear-stroke.c
@@ -30,7 +30,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"rectilinear-stroke",
"Test rectilinear stroke operations (covering only whole pixels)",
SIZE, SIZE,
diff --git a/test/reflected-stroke.c b/test/reflected-stroke.c
index aa320987c..1721009fe 100644
--- a/test/reflected-stroke.c
+++ b/test/reflected-stroke.c
@@ -27,7 +27,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"reflected-stroke",
"Exercises the stroker with a reflected ctm",
200, 200,
diff --git a/test/rel-path.c b/test/rel-path.c
index 0f42321b9..38096bc0a 100644
--- a/test/rel-path.c
+++ b/test/rel-path.c
@@ -26,7 +26,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"rel-path",
"Tests calls to various relative path functions",
SIZE, SIZE,
@@ -81,24 +81,25 @@ invalid_rel_curve_to (cairo_surface_t *target)
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_status_t status;
/* first test that a relative move without a current point fails... */
status = invalid_rel_move_to (cairo_get_target (cr));
if (status != CAIRO_STATUS_NO_CURRENT_POINT) {
- cairo_test_log ("Error: invalid cairo_rel_move_to() did not raise NO_CURRENT_POINT\n");
+ cairo_test_log (ctx, "Error: invalid cairo_rel_move_to() did not raise NO_CURRENT_POINT\n");
return CAIRO_TEST_FAILURE;
}
status = invalid_rel_line_to (cairo_get_target (cr));
if (status != CAIRO_STATUS_NO_CURRENT_POINT) {
- cairo_test_log ("Error: invalid cairo_rel_line_to() did not raise NO_CURRENT_POINT\n");
+ cairo_test_log (ctx, "Error: invalid cairo_rel_line_to() did not raise NO_CURRENT_POINT\n");
return CAIRO_TEST_FAILURE;
}
status = invalid_rel_curve_to (cairo_get_target (cr));
if (status != CAIRO_STATUS_NO_CURRENT_POINT) {
- cairo_test_log ("Error: invalid cairo_rel_curve_to() did not raise NO_CURRENT_POINT\n");
+ cairo_test_log (ctx, "Error: invalid cairo_rel_curve_to() did not raise NO_CURRENT_POINT\n");
return CAIRO_TEST_FAILURE;
}
diff --git a/test/rgb24-ignore-alpha.c b/test/rgb24-ignore-alpha.c
index 2739d2638..1d2b167ba 100644
--- a/test/rgb24-ignore-alpha.c
+++ b/test/rgb24-ignore-alpha.c
@@ -31,7 +31,7 @@ static cairo_test_draw_function_t draw;
#define WIDTH 2
#define HEIGHT 2
-cairo_test_t test = {
+static const cairo_test_t test = {
"rgb24-ignore-alpha",
"Test that when using an RGB24 image as a source, there is no alpha channel",
WIDTH, HEIGHT,
diff --git a/test/rotate-image-surface-paint.c b/test/rotate-image-surface-paint.c
index 378b1ee1a..25ce9c558 100644
--- a/test/rotate-image-surface-paint.c
+++ b/test/rotate-image-surface-paint.c
@@ -31,7 +31,7 @@ static cairo_test_draw_function_t draw;
#define SIZE 20
#define PAD 2
-cairo_test_t test = {
+static const cairo_test_t test = {
"rotate-image-surface-paint",
"Test call sequence: image_surface_create; rotate; set_source_surface; paint"
"\nThis test is known to fail on the ps backend currently",
diff --git a/test/scale-down-source-surface-paint.c b/test/scale-down-source-surface-paint.c
index f5effabfe..2a2efccf7 100644
--- a/test/scale-down-source-surface-paint.c
+++ b/test/scale-down-source-surface-paint.c
@@ -27,7 +27,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"scale-down-source-surface-paint",
"Test call sequence: cairo_scale; cairo_set_source_surface; cairo_paint, with a scale < 1.0",
6, 6,
@@ -38,7 +38,7 @@ static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
cairo_surface_t *surface;
- static uint32_t data[16] = {
+ uint32_t data[16] = {
0xffffffff, 0xffffffff, 0xffff0000, 0xffff0000,
0xffffffff, 0xffffffff, 0xffff0000, 0xffff0000,
diff --git a/test/scale-source-surface-paint.c b/test/scale-source-surface-paint.c
index 1fbe0c428..947334221 100644
--- a/test/scale-source-surface-paint.c
+++ b/test/scale-source-surface-paint.c
@@ -27,7 +27,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"scale-source-surface-paint",
"Test call sequence: cairo_scale; cairo_set_source_surface; cairo_paint",
12, 12,
@@ -38,7 +38,7 @@ static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
cairo_surface_t *surface;
- static uint32_t data[16] = {
+ uint32_t data[16] = {
0xffffffff, 0xffffffff, 0xffff0000, 0xffff0000,
0xffffffff, 0xffffffff, 0xffff0000, 0xffff0000,
diff --git a/test/select-font-face.c b/test/select-font-face.c
index 57120ca15..c5ff56b7d 100644
--- a/test/select-font-face.c
+++ b/test/select-font-face.c
@@ -29,7 +29,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"select-font-face",
"Tests using cairo_select_font_face to draw text in different faces",
192, TEXT_SIZE + 4,
diff --git a/test/select-font-no-show-text.c b/test/select-font-no-show-text.c
index c0e4f46ad..752891b8e 100644
--- a/test/select-font-no-show-text.c
+++ b/test/select-font-no-show-text.c
@@ -43,7 +43,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"select-font-no-show-text",
"Test calling cairo_select_font_face but never drawing text.",
0, 0,
diff --git a/test/self-copy.c b/test/self-copy.c
index 63e18974e..1afb31e61 100644
--- a/test/self-copy.c
+++ b/test/self-copy.c
@@ -31,7 +31,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"self-copy",
"Test copying from a surface to itself with a clip",
SIZE, SIZE,
diff --git a/test/self-intersecting.c b/test/self-intersecting.c
index 870783e65..d2b62657e 100644
--- a/test/self-intersecting.c
+++ b/test/self-intersecting.c
@@ -46,7 +46,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"self-intersecting",
"Test strokes of self-intersecting paths"
"\nSelf-intersecting strokes are wrong due to incremental trapezoidization.",
diff --git a/test/set-source.c b/test/set-source.c
index eca3f1888..05dd3cb5d 100644
--- a/test/set-source.c
+++ b/test/set-source.c
@@ -27,7 +27,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"set-source",
"Tests calls to various set_source functions",
5, 5,
diff --git a/test/show-text-current-point.c b/test/show-text-current-point.c
index 5ff367588..2fd2387ce 100644
--- a/test/show-text-current-point.c
+++ b/test/show-text-current-point.c
@@ -29,7 +29,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"show-text-current-point",
"Test that cairo_show_text adjusts the current point properly",
263, TEXT_SIZE + 4,
diff --git a/test/skew-extreme.c b/test/skew-extreme.c
index 919937bc1..c682d08b3 100644
--- a/test/skew-extreme.c
+++ b/test/skew-extreme.c
@@ -57,7 +57,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"skew-extreme",
"Test cases of extreme skew.",
WIDTH, HEIGHT,
diff --git a/test/smask-fill.c b/test/smask-fill.c
index 980018e4c..66f8b0dc1 100644
--- a/test/smask-fill.c
+++ b/test/smask-fill.c
@@ -27,7 +27,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"smask-fill",
"Test the support of \"soft\" masks with fills",
60, 60,
@@ -80,4 +80,3 @@ main (void)
{
return cairo_test (&test);
}
-
diff --git a/test/smask-image-mask.c b/test/smask-image-mask.c
index 5c805e1cd..1edec2986 100644
--- a/test/smask-image-mask.c
+++ b/test/smask-image-mask.c
@@ -27,7 +27,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"smask-image-mask",
"Test the support of \"soft\" masks with a secondary image mask",
60, 60,
@@ -37,7 +37,7 @@ cairo_test_t test = {
static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
- static uint32_t data[] = {
+ uint32_t data[] = {
0xaa000000, 0x55000000,
0x55000000, 0xaa000000,
};
@@ -89,4 +89,3 @@ main (void)
{
return cairo_test (&test);
}
-
diff --git a/test/smask-mask.c b/test/smask-mask.c
index 3d8cb0566..c38be37a0 100644
--- a/test/smask-mask.c
+++ b/test/smask-mask.c
@@ -27,7 +27,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"smask-mask",
"Test the support of \"soft\" masks with a secondary mask",
60, 60,
@@ -104,4 +104,3 @@ main (void)
{
return cairo_test (&test);
}
-
diff --git a/test/smask-paint.c b/test/smask-paint.c
index c075ade3f..d0b9e945c 100644
--- a/test/smask-paint.c
+++ b/test/smask-paint.c
@@ -27,7 +27,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"smask-paint",
"Test the support of \"soft\" masks with paints",
60, 60,
@@ -87,4 +87,3 @@ main (void)
{
return cairo_test (&test);
}
-
diff --git a/test/smask-stroke.c b/test/smask-stroke.c
index c70825a56..fa0afd60f 100644
--- a/test/smask-stroke.c
+++ b/test/smask-stroke.c
@@ -27,7 +27,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"smask-stroke",
"Test the support of \"soft\" masks with strokes",
60, 60,
@@ -80,4 +80,3 @@ main (void)
{
return cairo_test (&test);
}
-
diff --git a/test/smask-text.c b/test/smask-text.c
index 589c71df7..822ea5af4 100644
--- a/test/smask-text.c
+++ b/test/smask-text.c
@@ -27,7 +27,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"smask-text",
"Test the support of \"soft\" masks with text",
120, 60,
@@ -89,4 +89,3 @@ main (void)
{
return cairo_test (&test);
}
-
diff --git a/test/smask.c b/test/smask.c
index 28eaed061..2b1d5b360 100644
--- a/test/smask.c
+++ b/test/smask.c
@@ -27,7 +27,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"smask",
"Test the support of \"soft\" masks",
60, 60,
@@ -37,7 +37,7 @@ cairo_test_t test = {
static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
- static uint32_t data[] = {
+ uint32_t data[] = {
0x80000000, 0x80000000,
0x80000000, 0x80000000,
};
@@ -127,4 +127,3 @@ main (void)
{
return cairo_test (&test);
}
-
diff --git a/test/solid-pattern-cache-stress.c b/test/solid-pattern-cache-stress.c
index 39c645491..42928aaa4 100644
--- a/test/solid-pattern-cache-stress.c
+++ b/test/solid-pattern-cache-stress.c
@@ -39,7 +39,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"solid-pattern-cache-stress",
"Stress the solid pattern cache and ensure it behaves",
1, 1,
diff --git a/test/source-clip-scale.c b/test/source-clip-scale.c
index 26684d304..4c5569546 100644
--- a/test/source-clip-scale.c
+++ b/test/source-clip-scale.c
@@ -31,7 +31,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"source-clip-scale",
"Test that a source surface is not affected by a clip when scaling",
SIZE * 2, SIZE,
diff --git a/test/source-clip.c b/test/source-clip.c
index 46eb233b1..b24f95c11 100644
--- a/test/source-clip.c
+++ b/test/source-clip.c
@@ -31,7 +31,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"source-clip",
"Test that a source surface is not affected by a clip",
SIZE, SIZE,
diff --git a/test/source-surface-scale-paint.c b/test/source-surface-scale-paint.c
index 8c3096a80..908367c5c 100644
--- a/test/source-surface-scale-paint.c
+++ b/test/source-surface-scale-paint.c
@@ -27,7 +27,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"source-surface-scale-paint",
"Test call sequence: cairo_set_source_surface; cairo_scale; cairo_paint",
8, 8,
@@ -38,7 +38,7 @@ static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
cairo_surface_t *surface;
- static uint32_t data[16] = {
+ uint32_t data[16] = {
0xffffffff, 0xffffffff, 0xffff0000, 0xffff0000,
0xffffffff, 0xffffffff, 0xffff0000, 0xffff0000,
diff --git a/test/stroke-ctm-caps.c b/test/stroke-ctm-caps.c
index 07a918eba..bfe2bef83 100644
--- a/test/stroke-ctm-caps.c
+++ b/test/stroke-ctm-caps.c
@@ -41,7 +41,7 @@ static cairo_test_draw_function_t draw;
* (0.8, 0.8, 0.8, 0.4).
*/
-cairo_test_t test = {
+static const cairo_test_t test = {
"stroke-ctm-caps",
"Test that the stroker correctly passes the device-space vector to the stroker for endcaps",
WIDTH, HEIGHT,
diff --git a/test/stroke-image.c b/test/stroke-image.c
index 20b868c44..01ad43619 100644
--- a/test/stroke-image.c
+++ b/test/stroke-image.c
@@ -32,7 +32,7 @@ static cairo_test_draw_function_t draw;
#define IMAGE_SIZE (SIZE-PAD*2)
#define LINE_WIDTH 10
-cairo_test_t test = {
+static const cairo_test_t test = {
"stroke-image",
"Test stroking with an image source, with a non-identity CTM",
SIZE, SIZE,
diff --git a/test/surface-finish-twice.c b/test/surface-finish-twice.c
index 3751939a0..149f29cd5 100644
--- a/test/surface-finish-twice.c
+++ b/test/surface-finish-twice.c
@@ -44,7 +44,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"surface-finish-twice",
"Test to exercise a crash when calling cairo_surface_finish twice on the same surface.",
0, 0,
diff --git a/test/surface-pattern-big-scale-down.c b/test/surface-pattern-big-scale-down.c
index c938d9982..49cf6adef 100644
--- a/test/surface-pattern-big-scale-down.c
+++ b/test/surface-pattern-big-scale-down.c
@@ -30,7 +30,7 @@ static cairo_test_draw_function_t draw;
#define SRC_WIDTH 2048
#define SRC_HEIGHT 32
-cairo_test_t test = {
+static const cairo_test_t test = {
"surface-pattern-big-scale-down",
"Test scaled-down transformed not-repeated surface patterns with large images and offsets",
512, 16,
diff --git a/test/surface-pattern-scale-down.c b/test/surface-pattern-scale-down.c
index 337a4e7a6..4e9b48ffa 100644
--- a/test/surface-pattern-scale-down.c
+++ b/test/surface-pattern-scale-down.c
@@ -32,7 +32,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"surface-pattern-scale-down",
"Test scaled-down transformed not-repeated surface patterns"
"\nFails xlib backend (with argb32) with inexplicable alpha in result",
diff --git a/test/surface-pattern-scale-up.c b/test/surface-pattern-scale-up.c
index ccc498ee2..ef7a4d136 100644
--- a/test/surface-pattern-scale-up.c
+++ b/test/surface-pattern-scale-up.c
@@ -32,7 +32,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"surface-pattern-scale-up",
"Test scaled-up transformed not-repeated surface patterns"
"\nFails xlib backend (with argb32) with inexplicable alpha in result",
diff --git a/test/surface-pattern.c b/test/surface-pattern.c
index 2104dbacc..41ffdc961 100644
--- a/test/surface-pattern.c
+++ b/test/surface-pattern.c
@@ -32,7 +32,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"surface-pattern",
"Test transformed repeated surface patterns"
"\nExhibiting a strange (very minor) failure in ps backend with device-offset",
diff --git a/test/surface-source.c b/test/surface-source.c
index 5a034ad09..61ab65e73 100644
--- a/test/surface-source.c
+++ b/test/surface-source.c
@@ -30,7 +30,7 @@ static cairo_surface_t *create_source_surface (int size);
#define SIZE 90
-cairo_test_t test = {
+static const cairo_test_t test = {
NAME "-surface-source",
"Test using various surfaces as the source",
SIZE, SIZE,
diff --git a/test/svg-clip.c b/test/svg-clip.c
index 77ae9e984..0dfab4d87 100644
--- a/test/svg-clip.c
+++ b/test/svg-clip.c
@@ -106,16 +106,20 @@ test_clip (cairo_t *cr, double width, double height)
int
main (void)
{
+ cairo_test_context_t ctx;
cairo_t *cr;
const char *filename = "svg-clip.svg";
cairo_surface_t *surface;
- cairo_test_init ("svg-clip");
+ cairo_test_init (&ctx, "svg-clip");
surface = cairo_svg_surface_create (filename,
WIDTH_IN_POINTS, HEIGHT_IN_POINTS);
- if (surface == NULL) {
- fprintf (stderr, "Failed to create svg surface for file %s\n", filename);
+ if (cairo_surface_status (surface)) {
+ cairo_test_log (&ctx,
+ "Failed to create svg surface for file %s: %s\n",
+ filename, cairo_status_to_string (cairo_surface_status (surface)));
+ cairo_test_fini (&ctx);
return CAIRO_TEST_FAILURE;
}
@@ -130,7 +134,7 @@ main (void)
printf ("svg-clip: Please check %s to make sure it looks happy.\n",
filename);
- cairo_test_fini ();
+ cairo_test_fini (&ctx);
- return 0;
+ return CAIRO_TEST_SUCCESS;
}
diff --git a/test/svg-surface.c b/test/svg-surface.c
index 99b7b4ea0..f6b843ac9 100644
--- a/test/svg-surface.c
+++ b/test/svg-surface.c
@@ -89,16 +89,21 @@ draw (cairo_t *cr, int width, int height)
int
main (void)
{
+ cairo_test_context_t ctx;
cairo_t *cr;
const char *filename = "svg-surface.svg";
cairo_surface_t *surface;
- cairo_test_init ("svg-surface");
+ cairo_test_init (&ctx, "svg-surface");
surface = cairo_svg_surface_create (filename,
WIDTH_IN_POINTS, HEIGHT_IN_POINTS);
- if (surface == NULL) {
- fprintf (stderr, "Failed to create svg surface for file %s\n", filename);
+ if (cairo_surface_status (surface)) {
+ cairo_test_log (&ctx,
+ "Failed to create svg surface for file %s: %s\n",
+ filename,
+ cairo_status_to_string (cairo_surface_status (surface)));
+ cairo_test_fini (&ctx);
return CAIRO_TEST_FAILURE;
}
@@ -113,7 +118,7 @@ main (void)
printf ("svg-surface: Please check svg-surface.svg to make sure it looks happy.\n");
- cairo_test_fini ();
+ cairo_test_fini (&ctx);
- return 0;
+ return CAIRO_TEST_SUCCESS;
}
diff --git a/test/text-antialias-gray.c b/test/text-antialias-gray.c
index dd0f34e5f..20292240f 100644
--- a/test/text-antialias-gray.c
+++ b/test/text-antialias-gray.c
@@ -31,7 +31,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"text-antialias-gray",
"Tests text rendering with grayscale antialiasing",
WIDTH, HEIGHT,
@@ -43,7 +43,7 @@ draw (cairo_t *cr, int width, int height)
{
cairo_text_extents_t extents;
cairo_font_options_t *font_options;
- static char black[] = "black", blue[] = "blue";
+ const char black[] = "black", blue[] = "blue";
/* We draw in the default black, so paint white first. */
cairo_save (cr);
diff --git a/test/text-antialias-none.c b/test/text-antialias-none.c
index f53fde491..af279d8ca 100644
--- a/test/text-antialias-none.c
+++ b/test/text-antialias-none.c
@@ -31,7 +31,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"text-antialias-none",
"Tests text rendering with no antialiasing",
WIDTH, HEIGHT,
@@ -43,7 +43,7 @@ draw (cairo_t *cr, int width, int height)
{
cairo_text_extents_t extents;
cairo_font_options_t *font_options;
- static char black[] = "black", blue[] = "blue";
+ const char black[] = "black", blue[] = "blue";
/* We draw in the default black, so paint white first. */
cairo_save (cr);
diff --git a/test/text-antialias-subpixel.c b/test/text-antialias-subpixel.c
index 440c3a3b9..a9989973f 100644
--- a/test/text-antialias-subpixel.c
+++ b/test/text-antialias-subpixel.c
@@ -31,7 +31,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"text-antialias-subpixel",
"Tests text rendering with subpixel antialiasing",
WIDTH, HEIGHT,
@@ -43,7 +43,7 @@ draw (cairo_t *cr, int width, int height)
{
cairo_text_extents_t extents;
cairo_font_options_t *font_options;
- static char black[] = "black", blue[] = "blue";
+ const char black[] = "black", blue[] = "blue";
cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
cairo_paint (cr);
diff --git a/test/text-cache-crash.c b/test/text-cache-crash.c
index 00b3b2931..b78b3a33c 100644
--- a/test/text-cache-crash.c
+++ b/test/text-cache-crash.c
@@ -57,14 +57,14 @@
* Found the bug. cairo_gstate_select_font was noticing when the
* same font was selected twice in a row and was erroneously failing
* to free the old reference. Committed a fix and verified it also
- * fixed the orginal test case.
+ * fixed the original test case.
*/
#include "cairo-test.h"
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"text-cache-crash",
"Test case for bug causing an assertion failure in _cairo_cache_lookup",
0, 0,
diff --git a/test/text-lcd-filter-fir3.c b/test/text-lcd-filter-fir3.c
index a6445b51c..7f95978d8 100644
--- a/test/text-lcd-filter-fir3.c
+++ b/test/text-lcd-filter-fir3.c
@@ -31,7 +31,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"text-lcd-filter-fir3",
"Tests text rendering with a 3x3 kernel FIR LCD filter",
WIDTH, HEIGHT,
@@ -43,7 +43,7 @@ draw (cairo_t *cr, int width, int height)
{
cairo_text_extents_t extents;
cairo_font_options_t *font_options;
- static char black[] = "black", blue[] = "blue";
+ const char black[] = "black", blue[] = "blue";
/* We draw in the default black, so paint white first. */
cairo_save (cr);
diff --git a/test/text-lcd-filter-fir5.c b/test/text-lcd-filter-fir5.c
index 54bee806a..a5102b93e 100644
--- a/test/text-lcd-filter-fir5.c
+++ b/test/text-lcd-filter-fir5.c
@@ -31,7 +31,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"text-lcd-filter-fir5",
"Tests text rendering with a 5x5 kernel FIR LCD filter",
WIDTH, HEIGHT,
@@ -43,7 +43,7 @@ draw (cairo_t *cr, int width, int height)
{
cairo_text_extents_t extents;
cairo_font_options_t *font_options;
- static char black[] = "black", blue[] = "blue";
+ const char black[] = "black", blue[] = "blue";
/* We draw in the default black, so paint white first. */
cairo_save (cr);
diff --git a/test/text-lcd-filter-intra-pixel.c b/test/text-lcd-filter-intra-pixel.c
index 3f8b4863b..c02b4413d 100644
--- a/test/text-lcd-filter-intra-pixel.c
+++ b/test/text-lcd-filter-intra-pixel.c
@@ -31,7 +31,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"text-lcd-filter-intra-pixel",
"Tests text rendering with intra-pixel LCD filter",
WIDTH, HEIGHT,
@@ -43,7 +43,7 @@ draw (cairo_t *cr, int width, int height)
{
cairo_text_extents_t extents;
cairo_font_options_t *font_options;
- static char black[] = "black", blue[] = "blue";
+ const char black[] = "black", blue[] = "blue";
/* We draw in the default black, so paint white first. */
cairo_save (cr);
diff --git a/test/text-lcd-filter-none.c b/test/text-lcd-filter-none.c
index 87e358ab7..f84483e92 100644
--- a/test/text-lcd-filter-none.c
+++ b/test/text-lcd-filter-none.c
@@ -31,7 +31,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"text-lcd-filter-none",
"Tests text rendering with no LCD filter",
WIDTH, HEIGHT,
@@ -43,7 +43,7 @@ draw (cairo_t *cr, int width, int height)
{
cairo_text_extents_t extents;
cairo_font_options_t *font_options;
- static char black[] = "black", blue[] = "blue";
+ const char black[] = "black", blue[] = "blue";
/* We draw in the default black, so paint white first. */
cairo_save (cr);
diff --git a/test/text-pattern.c b/test/text-pattern.c
index 15a909df0..eae9caebf 100644
--- a/test/text-pattern.c
+++ b/test/text-pattern.c
@@ -30,7 +30,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"text-pattern",
"Patterned Text\n",
IMAGE_WIDTH, IMAGE_HEIGHT,
diff --git a/test/text-rotate.c b/test/text-rotate.c
index 71d9cc366..da214610c 100644
--- a/test/text-rotate.c
+++ b/test/text-rotate.c
@@ -92,7 +92,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"text-rotate",
"Tests show_text under various rotations",
WIDTH, HEIGHT,
@@ -106,7 +106,7 @@ draw (cairo_t *cr, int width, int height)
int i, x_off, y_off;
cairo_text_extents_t extents;
cairo_font_options_t *font_options;
- static char text[] = "cairo";
+ const char text[] = "cairo";
/* paint white so we don't need separate ref images for
* RGB24 and ARGB32 */
diff --git a/test/text-transform.c b/test/text-transform.c
index 78a68d75a..c1148e5ba 100644
--- a/test/text-transform.c
+++ b/test/text-transform.c
@@ -32,9 +32,9 @@ static cairo_test_draw_function_t draw;
#define FONT_SIZE 32.0
-const char png_filename[] = "romedalen.png";
+static const char png_filename[] = "romedalen.png";
-cairo_test_t test = {
+static const cairo_test_t test = {
"text-transform",
"Test various applications of the font matrix",
SIZE, SIZE,
@@ -78,6 +78,7 @@ draw_text (cairo_t *cr)
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_pattern_t *pattern;
cairo_set_source_rgb (cr, 1., 1., 1.);
@@ -94,7 +95,7 @@ draw (cairo_t *cr, int width, int height)
cairo_translate (cr, SIZE, SIZE);
cairo_rotate (cr, M_PI);
- pattern = cairo_test_create_pattern_from_png (png_filename);
+ pattern = cairo_test_create_pattern_from_png (ctx, png_filename);
cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT);
cairo_set_source (cr, pattern);
cairo_pattern_destroy (pattern);
diff --git a/test/text-zero-len.c b/test/text-zero-len.c
index fff978302..dbcd2c558 100644
--- a/test/text-zero-len.c
+++ b/test/text-zero-len.c
@@ -45,7 +45,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"text-zero-len",
"Tests show_text and text_path with a zero-sized string",
0, 0,
@@ -78,6 +78,7 @@ font_extents_equal (const cairo_font_extents_t *A,
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_text_extents_t extents, nil_extents;
cairo_font_extents_t font_extents, nil_font_extents;
cairo_scaled_font_t *scaled_font;
@@ -104,7 +105,7 @@ draw (cairo_t *cr, int width, int height)
memset (&extents, 0xff, sizeof (cairo_text_extents_t));
cairo_text_extents (cr, "", &extents);
if (! text_extents_equal (&extents, &nil_extents)) {
- cairo_test_log ("Error: cairo_text_extents(\"\"); extents (%g, %g, %g, %g, %g, %g)\n",
+ cairo_test_log (ctx, "Error: cairo_text_extents(\"\"); extents (%g, %g, %g, %g, %g, %g)\n",
extents.x_bearing, extents.y_bearing,
extents.width, extents.height,
extents.x_advance, extents.y_advance);
@@ -114,7 +115,7 @@ draw (cairo_t *cr, int width, int height)
memset (&extents, 0xff, sizeof (cairo_text_extents_t));
cairo_text_extents (cr, NULL, &extents);
if (! text_extents_equal (&extents, &nil_extents)) {
- cairo_test_log ("Error: cairo_text_extents(NULL); extents (%g, %g, %g, %g, %g, %g)\n",
+ cairo_test_log (ctx, "Error: cairo_text_extents(NULL); extents (%g, %g, %g, %g, %g, %g)\n",
extents.x_bearing, extents.y_bearing,
extents.width, extents.height,
extents.x_advance, extents.y_advance);
@@ -124,7 +125,7 @@ draw (cairo_t *cr, int width, int height)
memset (&extents, 0xff, sizeof (cairo_text_extents_t));
cairo_glyph_extents (cr, (void*)8, 0, &extents);
if (! text_extents_equal (&extents, &nil_extents)) {
- cairo_test_log ("Error: cairo_glyph_extents(); extents (%g, %g, %g, %g, %g, %g)\n",
+ cairo_test_log (ctx, "Error: cairo_glyph_extents(); extents (%g, %g, %g, %g, %g, %g)\n",
extents.x_bearing, extents.y_bearing,
extents.width, extents.height,
extents.x_advance, extents.y_advance);
@@ -136,7 +137,7 @@ draw (cairo_t *cr, int width, int height)
memset (&extents, 0xff, sizeof (cairo_text_extents_t));
cairo_scaled_font_text_extents (scaled_font, "", &extents);
if (! text_extents_equal (&extents, &nil_extents)) {
- cairo_test_log ("Error: cairo_scaled_font_text_extents(\"\"); extents (%g, %g, %g, %g, %g, %g)\n",
+ cairo_test_log (ctx, "Error: cairo_scaled_font_text_extents(\"\"); extents (%g, %g, %g, %g, %g, %g)\n",
extents.x_bearing, extents.y_bearing,
extents.width, extents.height,
extents.x_advance, extents.y_advance);
@@ -146,7 +147,7 @@ draw (cairo_t *cr, int width, int height)
memset (&extents, 0xff, sizeof (cairo_text_extents_t));
cairo_scaled_font_text_extents (scaled_font, NULL, &extents);
if (! text_extents_equal (&extents, &nil_extents)) {
- cairo_test_log ("Error: cairo_scaled_font_text_extents(NULL); extents (%g, %g, %g, %g, %g, %g)\n",
+ cairo_test_log (ctx, "Error: cairo_scaled_font_text_extents(NULL); extents (%g, %g, %g, %g, %g, %g)\n",
extents.x_bearing, extents.y_bearing,
extents.width, extents.height,
extents.x_advance, extents.y_advance);
@@ -156,7 +157,7 @@ draw (cairo_t *cr, int width, int height)
memset (&extents, 0xff, sizeof (cairo_text_extents_t));
cairo_scaled_font_glyph_extents (scaled_font, (void*)8, 0, &extents);
if (! text_extents_equal (&extents, &nil_extents)) {
- cairo_test_log ("Error: cairo_scaled_font_glyph_extents(NULL); extents (%g, %g, %g, %g, %g, %g)\n",
+ cairo_test_log (ctx, "Error: cairo_scaled_font_glyph_extents(NULL); extents (%g, %g, %g, %g, %g, %g)\n",
extents.x_bearing, extents.y_bearing,
extents.width, extents.height,
extents.x_advance, extents.y_advance);
@@ -169,7 +170,7 @@ draw (cairo_t *cr, int width, int height)
memset (&extents, 0xff, sizeof (cairo_text_extents_t));
cairo_text_extents (cr, "test", &extents);
if (! text_extents_equal (&extents, &nil_extents)) {
- cairo_test_log ("Error: cairo_set_font_size(0); cairo_text_extents(\"test\"); extents (%g, %g, %g, %g, %g, %g)\n",
+ cairo_test_log (ctx, "Error: cairo_set_font_size(0); cairo_text_extents(\"test\"); extents (%g, %g, %g, %g, %g, %g)\n",
extents.x_bearing, extents.y_bearing,
extents.width, extents.height,
extents.x_advance, extents.y_advance);
@@ -181,7 +182,7 @@ draw (cairo_t *cr, int width, int height)
memset (&font_extents, 0xff, sizeof (cairo_font_extents_t));
cairo_font_extents (cr, &font_extents);
if (! font_extents_equal (&font_extents, &nil_font_extents)) {
- cairo_test_log ("Error: cairo_set_font_size(0); cairo_font_extents(); extents (%g, %g, %g, %g, %g)\n",
+ cairo_test_log (ctx, "Error: cairo_set_font_size(0); cairo_font_extents(); extents (%g, %g, %g, %g, %g)\n",
font_extents.ascent, font_extents.descent,
font_extents.height,
font_extents.max_x_advance, font_extents.max_y_advance);
@@ -193,7 +194,7 @@ draw (cairo_t *cr, int width, int height)
memset (&font_extents, 0xff, sizeof (cairo_font_extents_t));
cairo_scaled_font_extents (scaled_font, &font_extents);
if (! font_extents_equal (&font_extents, &nil_font_extents)) {
- cairo_test_log ("Error: cairo_set_font_size(0); cairo_scaled_font_extents(); extents (%g, %g, %g, %g, %g)\n",
+ cairo_test_log (ctx, "Error: cairo_set_font_size(0); cairo_scaled_font_extents(); extents (%g, %g, %g, %g, %g)\n",
font_extents.ascent, font_extents.descent,
font_extents.height,
font_extents.max_x_advance, font_extents.max_y_advance);
diff --git a/test/transforms.c b/test/transforms.c
index 97b8fe853..5731b8e23 100644
--- a/test/transforms.c
+++ b/test/transforms.c
@@ -30,7 +30,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"transforms",
"Test various transformations.",
WIDTH, HEIGHT,
diff --git a/test/translate-show-surface.c b/test/translate-show-surface.c
index a505f369a..819ab69c8 100644
--- a/test/translate-show-surface.c
+++ b/test/translate-show-surface.c
@@ -45,7 +45,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"translate-show-surface",
"Tests calls to cairo_show_surface after cairo_translate",
2, 2,
diff --git a/test/trap-clip.c b/test/trap-clip.c
index 3712c9024..0decb7ba4 100644
--- a/test/trap-clip.c
+++ b/test/trap-clip.c
@@ -31,22 +31,22 @@
#define HEIGHT 16
#define PAD 2
-const char png_filename[] = "romedalen.png";
+static const char png_filename[] = "romedalen.png";
static void
-set_solid_pattern (cairo_t *cr, int x, int y)
+set_solid_pattern (const cairo_test_context_t *ctx, cairo_t *cr, int x, int y)
{
cairo_set_source_rgb (cr, 0, 0, 0.6);
}
static void
-set_translucent_pattern (cairo_t *cr, int x, int y)
+set_translucent_pattern (const cairo_test_context_t *ctx, cairo_t *cr, int x, int y)
{
cairo_set_source_rgba (cr, 0, 0, 0.6, 0.5);
}
static void
-set_gradient_pattern (cairo_t *cr, int x, int y)
+set_gradient_pattern (const cairo_test_context_t *ctx, cairo_t *cr, int x, int y)
{
cairo_pattern_t *pattern;
@@ -59,11 +59,11 @@ set_gradient_pattern (cairo_t *cr, int x, int y)
}
static void
-set_image_pattern (cairo_t *cr, int x, int y)
+set_image_pattern (const cairo_test_context_t *ctx, cairo_t *cr, int x, int y)
{
cairo_pattern_t *pattern;
- pattern = cairo_test_create_pattern_from_png (png_filename);
+ pattern = cairo_test_create_pattern_from_png (ctx, png_filename);
cairo_set_source (cr, pattern);
cairo_pattern_destroy (pattern);
}
@@ -140,20 +140,20 @@ clip_circle (cairo_t *cr, int x, int y)
cairo_new_path (cr);
}
-static void (*pattern_funcs[])(cairo_t *cr, int x, int y) = {
+static void (* const pattern_funcs[])(const cairo_test_context_t *ctx, cairo_t *cr, int x, int y) = {
set_solid_pattern,
set_translucent_pattern,
set_gradient_pattern,
set_image_pattern,
};
-static void (*draw_funcs[])(cairo_t *cr, int x, int y) = {
+static void (* const draw_funcs[])(cairo_t *cr, int x, int y) = {
draw_rect,
draw_rects,
draw_polygon,
};
-static void (*clip_funcs[])(cairo_t *cr, int x, int y) = {
+static void (* const clip_funcs[])(cairo_t *cr, int x, int y) = {
clip_none,
clip_rect,
clip_rects,
@@ -166,7 +166,7 @@ static void (*clip_funcs[])(cairo_t *cr, int x, int y) = {
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"trap-clip",
"Trapezoid clipping\n",
IMAGE_WIDTH, IMAGE_HEIGHT,
@@ -176,6 +176,7 @@ cairo_test_t test = {
static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
+ const cairo_test_context_t *ctx = cairo_test_get_context (cr);
size_t i, j, k, x, y;
for (k = 0; k < ARRAY_SIZE (clip_funcs); k++) {
@@ -188,10 +189,10 @@ draw (cairo_t *cr, int width, int height)
cairo_move_to (cr, x, y);
clip_funcs[k] (cr, x, y);
- pattern_funcs[i] (cr, x, y);
+ pattern_funcs[i] (ctx, cr, x, y);
draw_funcs[j] (cr, x, y);
if (cairo_status (cr))
- cairo_test_log ("%d %d HERE!\n", (int)i, (int)j);
+ cairo_test_log (ctx, "%d %d HERE!\n", (int)i, (int)j);
cairo_restore (cr);
}
@@ -199,7 +200,7 @@ draw (cairo_t *cr, int width, int height)
}
if (cairo_status (cr) != CAIRO_STATUS_SUCCESS)
- cairo_test_log ("%d %d .HERE!\n", (int)i, (int)j);
+ cairo_test_log (ctx, "%d %d .HERE!\n", (int)i, (int)j);
return CAIRO_TEST_SUCCESS;
}
diff --git a/test/truetype-tables.c b/test/truetype-tables.c
index c279c8b8a..37f515a40 100644
--- a/test/truetype-tables.c
+++ b/test/truetype-tables.c
@@ -34,15 +34,15 @@
int
main (void)
{
+ cairo_test_context_t ctx;
cairo_test_status_t ret = CAIRO_TEST_SUCCESS;
- cairo_test_init ("truetype-tables");
-
- cairo_test_log ("Test that the size of TrueType table structs is correct\n");
+ cairo_test_init (&ctx, "truetype-tables");
+ cairo_test_log (&ctx, "Test that the size of TrueType table structs is correct\n");
#define check(st, sz) \
if (sizeof (st) != (sz)) { \
- cairo_test_log ("sizeof (%s): got %d, expected %d", #st, (int)sizeof (st), sz); \
+ cairo_test_log (&ctx, "sizeof (%s): got %d, expected %d", #st, (int)sizeof (st), sz); \
ret = CAIRO_TEST_FAILURE; \
}
@@ -55,7 +55,7 @@ main (void)
check (tt_composite_glyph_t, 18);
check (tt_glyph_data_t, 28);
- cairo_test_fini ();
+ cairo_test_fini (&ctx);
return ret;
}
diff --git a/test/unantialiased-shapes.c b/test/unantialiased-shapes.c
index 2ca4ee829..298f1c1d4 100644
--- a/test/unantialiased-shapes.c
+++ b/test/unantialiased-shapes.c
@@ -27,7 +27,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"unantialiased-shapes",
"Test shape drawing without antialiasing",
320, 240,
diff --git a/test/unbounded-operator.c b/test/unbounded-operator.c
index 06f5cb128..043edfd69 100644
--- a/test/unbounded-operator.c
+++ b/test/unbounded-operator.c
@@ -116,7 +116,7 @@ draw_rects (cairo_t *cr, int x, int y)
cairo_fill (cr);
}
-static void (*draw_funcs[])(cairo_t *cr, int x, int y) = {
+static void (*const draw_funcs[])(cairo_t *cr, int x, int y) = {
draw_mask,
draw_glyphs,
draw_polygon,
@@ -134,7 +134,7 @@ static cairo_operator_t operators[] = {
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"unbounded-operator",
"Operators with an effect for transparent source/mask",
IMAGE_WIDTH, IMAGE_HEIGHT,
@@ -144,6 +144,7 @@ cairo_test_t test = {
static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
+ const cairo_test_context_t *ctx = cairo_test_get_context (cr);
size_t i, j, x, y;
cairo_pattern_t *pattern;
@@ -176,14 +177,14 @@ draw (cairo_t *cr, int width, int height)
draw_funcs[j] (cr, x, y);
if (cairo_status (cr))
- cairo_test_log ("%d %d HERE!\n", (int)i, (int)j);
+ cairo_test_log (ctx, "%d %d HERE!\n", (int)i, (int)j);
cairo_restore (cr);
}
}
if (cairo_status (cr) != CAIRO_STATUS_SUCCESS)
- cairo_test_log ("%d %d .HERE!\n", (int)i, (int)j);
+ cairo_test_log (ctx, "%d %d .HERE!\n", (int)i, (int)j);
return CAIRO_TEST_SUCCESS;
}
diff --git a/test/user-font-proxy.c b/test/user-font-proxy.c
index 770b0c487..a4769663f 100644
--- a/test/user-font-proxy.c
+++ b/test/user-font-proxy.c
@@ -40,7 +40,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"user-font-proxy",
"Tests a user-font using a native font in its render_glyph",
#ifndef ROTATED
diff --git a/test/user-font.c b/test/user-font.c
index b0b5fce3e..57a174a65 100644
--- a/test/user-font.c
+++ b/test/user-font.c
@@ -40,7 +40,7 @@
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"user-font",
"Tests user font feature",
#ifndef ROTATED
diff --git a/test/xlib-expose-event.c b/test/xlib-expose-event.c
index 338f29879..c872047bc 100644
--- a/test/xlib-expose-event.c
+++ b/test/xlib-expose-event.c
@@ -131,11 +131,11 @@ clone_similar_surface (cairo_surface_t * target, cairo_surface_t *surface)
}
static void
-draw_image (cairo_t *cr)
+draw_image (const cairo_test_context_t *ctx, cairo_t *cr)
{
cairo_surface_t *surface, *similar;
- surface = cairo_test_create_surface_from_png (png_filename);
+ surface = cairo_test_create_surface_from_png (ctx, png_filename);
similar = clone_similar_surface (cairo_get_group_target (cr), surface);
cairo_surface_destroy (surface);
@@ -146,7 +146,10 @@ draw_image (cairo_t *cr)
}
static void
-draw (cairo_surface_t *surface, cairo_rectangle_t *region, int n_regions)
+draw (const cairo_test_context_t *ctx,
+ cairo_surface_t *surface,
+ cairo_rectangle_t *region,
+ int n_regions)
{
cairo_t *cr = cairo_create (surface);
if (region != NULL) {
@@ -159,7 +162,7 @@ draw (cairo_surface_t *surface, cairo_rectangle_t *region, int n_regions)
cairo_clip (cr);
}
cairo_push_group (cr);
- draw_image (cr);
+ draw_image (ctx, cr);
draw_mask (cr);
cairo_pop_group_to_source (cr);
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
@@ -168,7 +171,7 @@ draw (cairo_surface_t *surface, cairo_rectangle_t *region, int n_regions)
}
static cairo_test_status_t
-compare (cairo_surface_t *surface)
+compare (const cairo_test_context_t *ctx, cairo_surface_t *surface)
{
cairo_t *cr;
cairo_surface_t *image, *reference, *diff;
@@ -183,12 +186,12 @@ compare (cairo_surface_t *surface)
cairo_paint (cr);
cairo_destroy (cr);
- reference = cairo_test_create_surface_from_png ("xlib-expose-event-ref.png");
+ reference = cairo_test_create_surface_from_png (ctx, "xlib-expose-event-ref.png");
if (cairo_image_surface_get_width (image) != cairo_image_surface_get_width (reference) ||
cairo_image_surface_get_height (image) != cairo_image_surface_get_height (reference))
return CAIRO_TEST_FAILURE;
- compare_surfaces (reference, image, diff, &result);
+ compare_surfaces (ctx, reference, image, diff, &result);
cairo_surface_destroy (reference);
cairo_surface_destroy (image);
@@ -200,6 +203,7 @@ compare (cairo_surface_t *surface)
int
main (void)
{
+ cairo_test_context_t ctx;
Display *dpy;
Drawable drawable;
int screen;
@@ -208,16 +212,16 @@ main (void)
int i, j;
cairo_test_status_t result = CAIRO_TEST_SUCCESS;
- cairo_test_init ("xlib-expose-event");
+ cairo_test_init (&ctx, "xlib-expose-event");
dpy = XOpenDisplay (NULL);
if (dpy == NULL) {
- cairo_test_log ("xlib-expose-event: Cannot open display, skipping\n");
+ cairo_test_log (&ctx, "xlib-expose-event: Cannot open display, skipping\n");
goto CLEANUP_TEST;
}
if (! check_visual (dpy)) {
- cairo_test_log ("xlib-expose-event: default visual is not RGB24 or BGR24, skipping\n");
+ cairo_test_log (&ctx, "xlib-expose-event: default visual is not RGB24 or BGR24, skipping\n");
goto CLEANUP_DISPLAY;
}
@@ -229,7 +233,7 @@ main (void)
DefaultVisual (dpy, screen),
SIZE, SIZE);
clear (surface);
- draw (surface, NULL, 0);
+ draw (&ctx, surface, NULL, 0);
for (i = 0; i < NLOOPS; i++) {
for (j = 0; j < NLOOPS; j++) {
region[0].x = i * SIZE / NLOOPS;
@@ -252,11 +256,11 @@ main (void)
region[3].width = SIZE / 4;
region[3].height = SIZE / 4;
- draw (surface, region, 4);
+ draw (&ctx, surface, region, 4);
}
}
- result = compare (surface);
+ result = compare (&ctx, surface);
cairo_surface_destroy (surface);
@@ -268,7 +272,7 @@ main (void)
CLEANUP_TEST:
cairo_debug_reset_static_data ();
- cairo_test_fini ();
+ cairo_test_fini (&ctx);
return result;
}
diff --git a/test/xlib-surface.c b/test/xlib-surface.c
index 4bac497ce..20c2bc95a 100644
--- a/test/xlib-surface.c
+++ b/test/xlib-surface.c
@@ -131,7 +131,8 @@ erase_pattern (cairo_surface_t *surface)
}
static cairo_test_status_t
-do_test (Display *dpy,
+do_test (const cairo_test_context_t *ctx,
+ Display *dpy,
unsigned char *reference_data,
unsigned char *test_data,
unsigned char *diff_data,
@@ -242,7 +243,7 @@ do_test (Display *dpy,
&result);
}
- cairo_test_log ("xlib-surface: %s, %s, %s%s: %s\n",
+ cairo_test_log (ctx, "xlib-surface: %s, %s, %s%s: %s\n",
use_render ? " render" : "no-render",
set_size ? " size" : "no-size",
use_pixmap ? "pixmap" : "window",
@@ -275,13 +276,13 @@ check_visual (Display *dpy)
#undef xcalloc
static void *
-xcalloc (size_t a, size_t b)
+xcalloc (cairo_test_context_t *ctx, size_t a, size_t b)
{
void *ptr = calloc (a, b);
if (ptr == NULL) {
- cairo_test_log ("xlib-surface: unable to allocate memory, skipping\n");
- cairo_test_fini ();
- exit (0);
+ cairo_test_log (ctx, "xlib-surface: unable to allocate memory, skipping\n");
+ cairo_test_fini (ctx);
+ exit (CAIRO_TEST_SUCCESS);
}
return ptr;
}
@@ -289,6 +290,7 @@ xcalloc (size_t a, size_t b)
int
main (void)
{
+ cairo_test_context_t ctx;
Display *dpy;
unsigned char *reference_data;
unsigned char *test_data;
@@ -300,26 +302,26 @@ main (void)
cairo_test_status_t status, result = CAIRO_TEST_SUCCESS;
int stride;
- cairo_test_init ("xlib-surface");
+ cairo_test_init (&ctx, "xlib-surface");
dpy = XOpenDisplay (NULL);
if (!dpy) {
- cairo_test_log ("xlib-surface: Cannot open display, skipping\n");
- cairo_test_fini ();
+ cairo_test_log (&ctx, "xlib-surface: Cannot open display, skipping\n");
+ cairo_test_fini (&ctx);
return CAIRO_TEST_SUCCESS;
}
if (!check_visual (dpy)) {
- cairo_test_log ("xlib-surface: default visual is not RGB24 or BGR24, skipping\n");
- cairo_test_fini ();
- return 0;
+ cairo_test_log (&ctx, "xlib-surface: default visual is not RGB24 or BGR24, skipping\n");
+ cairo_test_fini (&ctx);
+ return CAIRO_TEST_SUCCESS;
}
stride = cairo_format_stride_for_width (CAIRO_FORMAT_RGB24, SIZE);
- reference_data = xcalloc (SIZE, stride);
- test_data = xcalloc (SIZE, stride);
- diff_data = xcalloc (SIZE, stride);
+ reference_data = xcalloc (&ctx, SIZE, stride);
+ test_data = xcalloc (&ctx, SIZE, stride);
+ diff_data = xcalloc (&ctx, SIZE, stride);
reference_surface = cairo_image_surface_create_for_data (reference_data,
CAIRO_FORMAT_RGB24,
@@ -332,7 +334,7 @@ main (void)
for (set_size = 0; set_size <= 1; set_size++)
for (use_pixmap = 0; use_pixmap <= 1; use_pixmap++)
for (offscreen = 0; offscreen <= 1; offscreen++) {
- status = do_test (dpy,
+ status = do_test (&ctx, dpy,
reference_data, test_data, diff_data,
1, use_pixmap, set_size, offscreen);
if (status)
@@ -342,7 +344,7 @@ main (void)
for (set_size = 0; set_size <= 1; set_size++)
for (use_pixmap = 0; use_pixmap <= 1; use_pixmap++)
for (offscreen = 0; offscreen <= 1; offscreen++) {
- status = do_test (dpy,
+ status = do_test (&ctx, dpy,
reference_data, test_data, diff_data,
0, use_pixmap, set_size, offscreen);
if (status)
@@ -355,9 +357,7 @@ main (void)
XCloseDisplay (dpy);
- cairo_debug_reset_static_data ();
-
- cairo_test_fini ();
+ cairo_test_fini (&ctx);
return result;
}
diff --git a/test/zero-alpha.c b/test/zero-alpha.c
index 9a01b22d7..84658f7f9 100644
--- a/test/zero-alpha.c
+++ b/test/zero-alpha.c
@@ -44,7 +44,7 @@
*/
static cairo_test_draw_function_t draw;
-cairo_test_t test = {
+static const cairo_test_t test = {
"zero-alpha",
"Testing that drawing with zero alpha has no effect",
SIZE, SIZE,