diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2008-09-03 16:38:03 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2008-10-31 12:30:11 +0000 |
commit | e90073f7ddc6f461a935bc360c409b04f1fe9f74 (patch) | |
tree | efda94d1ecd13143cdad23f14552661165e7601e /test/png.c | |
parent | 8457972d40088cda165f31fdd7bd9b4c19c6e095 (diff) | |
download | cairo-e90073f7ddc6f461a935bc360c409b04f1fe9f74.tar.gz |
[test] Build test suite into single binary.
Avoid calling libtool to link every single test case, by building just one
binary from all the sources.
This binary is then given the task of choosing tests to run (based on user
selection and individual test requirement), forking each test into its own
process and accumulating the results.
Diffstat (limited to 'test/png.c')
-rw-r--r-- | test/png.c | 56 |
1 files changed, 29 insertions, 27 deletions
diff --git a/test/png.c b/test/png.c index 23fc9fe67..0a375cb7d 100644 --- a/test/png.c +++ b/test/png.c @@ -25,7 +25,6 @@ #include "cairo-test.h" -#include <cairo.h> #include <assert.h> /* Test the idempotency of write_png->read_png */ @@ -63,7 +62,7 @@ format_to_string (cairo_format_t format) } static void -print_surface (cairo_test_context_t *ctx, cairo_surface_t *surface) +print_surface (const cairo_test_context_t *ctx, cairo_surface_t *surface) { cairo_test_log (ctx, "%s (%dx%d)\n", @@ -72,39 +71,37 @@ print_surface (cairo_test_context_t *ctx, cairo_surface_t *surface) cairo_image_surface_get_height (surface)); } -int -main (void) +static cairo_test_status_t +preamble (cairo_test_context_t *ctx) { - cairo_test_context_t ctx; + const char *filename = "png-out.png"; cairo_surface_t *surface0, *surface1; cairo_status_t status; uint32_t argb32 = 0xdeadbede; cairo_test_status_t result = CAIRO_TEST_SUCCESS; - cairo_test_init (&ctx, "png"); - surface0 = cairo_image_surface_create_for_data ((unsigned char *) &argb32, CAIRO_FORMAT_ARGB32, 1, 1, 4); assert (cairo_surface_status (surface0) == CAIRO_STATUS_SUCCESS); - status = cairo_surface_write_to_png (surface0, "png-test.png"); + status = cairo_surface_write_to_png (surface0, filename); if (status) { - cairo_test_log (&ctx, "Error writing 'png-test.png': %s\n", - cairo_status_to_string (status)); + cairo_test_log (ctx, "Error writing '%s': %s\n", + filename, cairo_status_to_string (status)); result = CAIRO_TEST_FAILURE; } - surface1 = cairo_image_surface_create_from_png ("png-test.png"); + surface1 = cairo_image_surface_create_from_png (filename); status = cairo_surface_status (surface1); if (status) { - cairo_test_log (&ctx, "Error reading 'png-test.png': %s\n", - cairo_status_to_string (status)); + cairo_test_log (ctx, "Error reading '%s': %s\n", + filename, cairo_status_to_string (status)); result = CAIRO_TEST_FAILURE; } if (! image_surface_equals (surface0, surface1)) { - cairo_test_log (&ctx, "Error surface mismatch.\n"); - cairo_test_log (&ctx, "to png: "); print_surface (&ctx, surface0); - cairo_test_log (&ctx, "from png: "); print_surface (&ctx, surface1); + cairo_test_log (ctx, "Error surface mismatch.\n"); + cairo_test_log (ctx, "to png: "); print_surface (ctx, surface0); + cairo_test_log (ctx, "from png: "); print_surface (ctx, surface1); result = CAIRO_TEST_FAILURE; } assert (*(uint32_t *) cairo_image_surface_get_data (surface1) == argb32); @@ -117,24 +114,24 @@ main (void) CAIRO_FORMAT_RGB24, 1, 1, 4); assert (cairo_surface_status (surface0) == CAIRO_STATUS_SUCCESS); - status = cairo_surface_write_to_png (surface0, "png-test.png"); + status = cairo_surface_write_to_png (surface0, filename); if (status) { - cairo_test_log (&ctx, "Error writing 'png-test.png': %s\n", - cairo_status_to_string (status)); + cairo_test_log (ctx, "Error writing '%s': %s\n", + filename, cairo_status_to_string (status)); result = CAIRO_TEST_FAILURE; } - surface1 = cairo_image_surface_create_from_png ("png-test.png"); + surface1 = cairo_image_surface_create_from_png (filename); status = cairo_surface_status (surface1); if (status) { - cairo_test_log (&ctx, "Error reading 'png-test.png': %s\n", - cairo_status_to_string (status)); + cairo_test_log (ctx, "Error reading '%s': %s\n", + filename, cairo_status_to_string (status)); result = CAIRO_TEST_FAILURE; } if (! image_surface_equals (surface0, surface1)) { - cairo_test_log (&ctx, "Error surface mismatch.\n"); - cairo_test_log (&ctx, "to png: "); print_surface (&ctx, surface0); - cairo_test_log (&ctx, "from png: "); print_surface (&ctx, surface1); + cairo_test_log (ctx, "Error surface mismatch.\n"); + cairo_test_log (ctx, "to png: "); print_surface (ctx, surface0); + cairo_test_log (ctx, "from png: "); print_surface (ctx, surface1); result = CAIRO_TEST_FAILURE; } assert ((*(uint32_t *) cairo_image_surface_get_data (surface1) & RGB_MASK) @@ -143,7 +140,12 @@ main (void) cairo_surface_destroy (surface0); cairo_surface_destroy (surface1); - cairo_test_fini (&ctx); - return result; } + +CAIRO_TEST (png, + "Check that the png export/import is idempotent.", + "png, api", /* keywords */ + NULL, /* requirements */ + 0, 0, + preamble, NULL) |