summaryrefslogtreecommitdiff
path: root/test/svg-surface.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/svg-surface.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/svg-surface.c')
-rw-r--r--test/svg-surface.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/test/svg-surface.c b/test/svg-surface.c
index 30cf99466..c0cdc1616 100644
--- a/test/svg-surface.c
+++ b/test/svg-surface.c
@@ -91,8 +91,9 @@ static cairo_test_status_t
preamble (cairo_test_context_t *ctx)
{
cairo_t *cr;
- const char *filename = CAIRO_TEST_OUTPUT_DIR "/" BASENAME ".svg";
cairo_surface_t *surface;
+ char *filename;
+ const char *path = cairo_test_mkdir (CAIRO_TEST_OUTPUT_DIR) ? CAIRO_TEST_OUTPUT_DIR : ".";
if (! cairo_test_is_target_enabled (ctx, "svg11") &&
! cairo_test_is_target_enabled (ctx, "svg12"))
@@ -100,6 +101,7 @@ preamble (cairo_test_context_t *ctx)
return CAIRO_TEST_UNTESTED;
}
+ xasprintf (&filename, "%s/%s.svg", path, BASENAME);
surface = cairo_svg_surface_create (filename,
WIDTH_IN_POINTS, HEIGHT_IN_POINTS);
if (cairo_surface_status (surface)) {
@@ -107,6 +109,7 @@ preamble (cairo_test_context_t *ctx)
"Failed to create svg surface for file %s: %s\n",
filename,
cairo_status_to_string (cairo_surface_status (surface)));
+ free (filename);
return CAIRO_TEST_FAILURE;
}
@@ -120,6 +123,7 @@ preamble (cairo_test_context_t *ctx)
cairo_surface_destroy (surface);
printf ("svg-surface: Please check svg-surface.svg to make sure it looks happy.\n");
+ free (filename);
return CAIRO_TEST_SUCCESS;
}