summaryrefslogtreecommitdiff
path: root/test/png.c
diff options
context:
space:
mode:
authorBryce W. Harrington <b.harrington@samsung.com>2013-09-08 20:10:03 +0000
committerUli Schlachter <psychon@znc.in>2013-09-09 21:25:12 +0200
commitf9dcd07d22a5269bf799317a36bb2887d8f9af64 (patch)
tree42bab64d56c64a19469d410d8b83a287a05c83c3 /test/png.c
parentbe7f1ac98f62669743f381df8845886d29a9f7f4 (diff)
downloadcairo-f9dcd07d22a5269bf799317a36bb2887d8f9af64.tar.gz
test: Ensure output dirs exist, falling back to current dir if needed
This change makes several tests behave more like ps-eps.c, et al by making them attempt to mkdir "output", and in case of trouble use "." instead. filenames are now allocated at runtime due to this change, so ensure the corresponding free()'s are in place as well. This should facilitate running the test suite with a relative path outside cairo's source tree, such as when employing the CAIRO_REF_DIR environment variable. Signed-off-by: Bryce Harrington <b.harrington@samsung.com> Signed-off-by: Uli Schlachter <psychon@znc.in>
Diffstat (limited to 'test/png.c')
-rw-r--r--test/png.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/test/png.c b/test/png.c
index 1dfc793ec..c01fbd7bd 100644
--- a/test/png.c
+++ b/test/png.c
@@ -78,11 +78,13 @@ print_surface (const cairo_test_context_t *ctx, cairo_surface_t *surface)
static cairo_test_status_t
preamble (cairo_test_context_t *ctx)
{
- const char *filename = CAIRO_TEST_OUTPUT_DIR "/" BASENAME ".png";
cairo_surface_t *surface0, *surface1;
cairo_status_t status;
uint32_t argb32 = 0xdeadbede;
+ char *filename;
+ const char *path = cairo_test_mkdir (CAIRO_TEST_OUTPUT_DIR) ? CAIRO_TEST_OUTPUT_DIR : ".";
+ xasprintf (&filename, "%s/%s.png", path, BASENAME);
surface0 = cairo_image_surface_create_for_data ((unsigned char *) &argb32,
CAIRO_FORMAT_ARGB32,
1, 1, 4);
@@ -92,6 +94,7 @@ preamble (cairo_test_context_t *ctx)
filename, cairo_status_to_string (status));
cairo_surface_destroy (surface0);
+ free (filename);
return cairo_test_status_from_status (ctx, status);
}
surface1 = cairo_image_surface_create_from_png (filename);
@@ -102,6 +105,7 @@ preamble (cairo_test_context_t *ctx)
cairo_surface_destroy (surface1);
cairo_surface_destroy (surface0);
+ free (filename);
return cairo_test_status_from_status (ctx, status);
}
@@ -112,6 +116,7 @@ preamble (cairo_test_context_t *ctx)
cairo_surface_destroy (surface0);
cairo_surface_destroy (surface1);
+ free (filename);
return CAIRO_TEST_FAILURE;
}
assert (*(uint32_t *) cairo_image_surface_get_data (surface1) == argb32);
@@ -131,6 +136,7 @@ preamble (cairo_test_context_t *ctx)
}
surface1 = cairo_image_surface_create_from_png (filename);
status = cairo_surface_status (surface1);
+ free (filename);
if (status) {
cairo_test_log (ctx, "Error reading '%s': %s\n",
filename, cairo_status_to_string (status));