diff options
author | Bryce W. Harrington <b.harrington@samsung.com> | 2013-09-08 20:10:03 +0000 |
---|---|---|
committer | Uli Schlachter <psychon@znc.in> | 2013-09-09 21:25:12 +0200 |
commit | f9dcd07d22a5269bf799317a36bb2887d8f9af64 (patch) | |
tree | 42bab64d56c64a19469d410d8b83a287a05c83c3 /test/pdf-mime-data.c | |
parent | be7f1ac98f62669743f381df8845886d29a9f7f4 (diff) | |
download | cairo-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/pdf-mime-data.c')
-rw-r--r-- | test/pdf-mime-data.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/test/pdf-mime-data.c b/test/pdf-mime-data.c index e4fbaa258..c575c4add 100644 --- a/test/pdf-mime-data.c +++ b/test/pdf-mime-data.c @@ -84,7 +84,6 @@ read_file (const cairo_test_context_t *ctx, static cairo_test_status_t preamble (cairo_test_context_t *ctx) { - const char *filename = CAIRO_TEST_OUTPUT_DIR "/" BASENAME ".pdf"; cairo_surface_t *image; cairo_surface_t *surface; cairo_t *cr; @@ -96,6 +95,8 @@ preamble (cairo_test_context_t *ctx) unsigned int len, out_len; char command[4096]; int exit_status; + char *filename; + const char *path = cairo_test_mkdir (CAIRO_TEST_OUTPUT_DIR) ? CAIRO_TEST_OUTPUT_DIR : "."; if (! cairo_test_is_target_enabled (ctx, "pdf")) return CAIRO_TEST_UNTESTED; @@ -113,6 +114,7 @@ preamble (cairo_test_context_t *ctx) width = cairo_image_surface_get_width (image); height = cairo_image_surface_get_height (image); + xasprintf (&filename, "%s/%s.pdf", path, BASENAME); surface = cairo_pdf_surface_create (filename, width + 20, height + 20); cr = cairo_create (surface); cairo_translate (cr, 10, 10); @@ -128,6 +130,7 @@ preamble (cairo_test_context_t *ctx) cairo_surface_destroy (image); if (status) { + free (filename); cairo_test_log (ctx, "Failed to create pdf surface for file %s: %s\n", filename, cairo_status_to_string (status)); return CAIRO_TEST_FAILURE; @@ -137,6 +140,7 @@ preamble (cairo_test_context_t *ctx) sprintf (command, "pdfimages -j %s %s", filename, CAIRO_TEST_OUTPUT_DIR "/" BASENAME); exit_status = system (command); + free (filename); if (exit_status) { cairo_test_log (ctx, "pdfimages failed with exit status %d\n", exit_status); return CAIRO_TEST_FAILURE; |