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>
This commit is contained in:
Bryce W. Harrington 2013-09-08 20:10:03 +00:00 committed by Uli Schlachter
parent be7f1ac98f
commit f9dcd07d22
13 changed files with 66 additions and 55 deletions

View file

@ -239,6 +239,8 @@ preamble (cairo_test_context_t *ctx)
{ {
cairo_test_status_t status = CAIRO_TEST_UNTESTED; cairo_test_status_t status = CAIRO_TEST_UNTESTED;
cairo_test_status_t test_status; cairo_test_status_t test_status;
char *filename;
const char *path = cairo_test_mkdir (CAIRO_TEST_OUTPUT_DIR) ? CAIRO_TEST_OUTPUT_DIR : ".";
#if CAIRO_HAS_PS_SURFACE #if CAIRO_HAS_PS_SURFACE
if (cairo_test_is_target_enabled (ctx, "ps2") || if (cairo_test_is_target_enabled (ctx, "ps2") ||
@ -247,7 +249,8 @@ preamble (cairo_test_context_t *ctx)
if (status == CAIRO_TEST_UNTESTED) if (status == CAIRO_TEST_UNTESTED)
status = CAIRO_TEST_SUCCESS; status = CAIRO_TEST_SUCCESS;
test_status = test_surface (ctx, "ps", CAIRO_TEST_OUTPUT_DIR "/" BASENAME ".ps", xasprintf (&filename, "%s/%s", path, BASENAME ".ps");
test_status = test_surface (ctx, "ps", filename,
cairo_ps_surface_create, cairo_ps_surface_create,
cairo_ps_surface_create_for_stream); cairo_ps_surface_create_for_stream);
cairo_test_log (ctx, "TEST: %s TARGET: %s RESULT: %s\n", cairo_test_log (ctx, "TEST: %s TARGET: %s RESULT: %s\n",
@ -255,6 +258,7 @@ preamble (cairo_test_context_t *ctx)
test_status ? "FAIL" : "PASS"); test_status ? "FAIL" : "PASS");
if (status == CAIRO_TEST_SUCCESS) if (status == CAIRO_TEST_SUCCESS)
status = test_status; status = test_status;
free (filename);
} }
#endif #endif
@ -263,7 +267,8 @@ preamble (cairo_test_context_t *ctx)
if (status == CAIRO_TEST_UNTESTED) if (status == CAIRO_TEST_UNTESTED)
status = CAIRO_TEST_SUCCESS; status = CAIRO_TEST_SUCCESS;
test_status = test_surface (ctx, "pdf", CAIRO_TEST_OUTPUT_DIR "/" BASENAME ".pdf", xasprintf (&filename, "%s/%s", path, BASENAME ".pdf");
test_status = test_surface (ctx, "pdf", filename,
cairo_pdf_surface_create, cairo_pdf_surface_create,
cairo_pdf_surface_create_for_stream); cairo_pdf_surface_create_for_stream);
cairo_test_log (ctx, "TEST: %s TARGET: %s RESULT: %s\n", cairo_test_log (ctx, "TEST: %s TARGET: %s RESULT: %s\n",
@ -271,6 +276,7 @@ preamble (cairo_test_context_t *ctx)
test_status ? "FAIL" : "PASS"); test_status ? "FAIL" : "PASS");
if (status == CAIRO_TEST_SUCCESS) if (status == CAIRO_TEST_SUCCESS)
status = test_status; status = test_status;
free (filename);
} }
#endif #endif
@ -281,7 +287,8 @@ preamble (cairo_test_context_t *ctx)
if (status == CAIRO_TEST_UNTESTED) if (status == CAIRO_TEST_UNTESTED)
status = CAIRO_TEST_SUCCESS; status = CAIRO_TEST_SUCCESS;
test_status = test_surface (ctx, "svg", CAIRO_TEST_OUTPUT_DIR "/" BASENAME ".svg", xasprintf (&filename, "%s/%s", path, BASENAME ".svg");
test_status = test_surface (ctx, "svg", filename,
cairo_svg_surface_create, cairo_svg_surface_create,
cairo_svg_surface_create_for_stream); cairo_svg_surface_create_for_stream);
cairo_test_log (ctx, "TEST: %s TARGET: %s RESULT: %s\n", cairo_test_log (ctx, "TEST: %s TARGET: %s RESULT: %s\n",
@ -289,6 +296,7 @@ preamble (cairo_test_context_t *ctx)
test_status ? "FAIL" : "PASS"); test_status ? "FAIL" : "PASS");
if (status == CAIRO_TEST_SUCCESS) if (status == CAIRO_TEST_SUCCESS)
status = test_status; status = test_status;
free (filename);
} }
#endif #endif

View file

@ -320,24 +320,6 @@ generate_reference (double ppi_x, double ppi_y, const char *filename)
} }
#endif #endif
static cairo_bool_t
_cairo_test_mkdir (const char *path)
{
#if ! HAVE_MKDIR
return FALSE;
#elif HAVE_MKDIR == 1
if (mkdir (path) == 0)
return TRUE;
#elif HAVE_MKDIR == 2
if (mkdir (path, 0770) == 0)
return TRUE;
#else
#error Bad value for HAVE_MKDIR
#endif
return errno == EEXIST;
}
/* TODO: Split each ppi case out to its own CAIRO_TEST() test case */ /* TODO: Split each ppi case out to its own CAIRO_TEST() test case */
static cairo_test_status_t static cairo_test_status_t
preamble (cairo_test_context_t *ctx) preamble (cairo_test_context_t *ctx)
@ -363,7 +345,7 @@ preamble (cairo_test_context_t *ctx)
}; };
unsigned int i; unsigned int i;
int n, num_ppi; int n, num_ppi;
const char *path = _cairo_test_mkdir (CAIRO_TEST_OUTPUT_DIR) ? CAIRO_TEST_OUTPUT_DIR : "."; const char *path = cairo_test_mkdir (CAIRO_TEST_OUTPUT_DIR) ? CAIRO_TEST_OUTPUT_DIR : ".";
num_ppi = ARRAY_LENGTH (ppi); num_ppi = ARRAY_LENGTH (ppi);

View file

@ -133,8 +133,9 @@ preamble (cairo_test_context_t *ctx)
{ {
cairo_surface_t *surface; cairo_surface_t *surface;
cairo_status_t status; cairo_status_t status;
const char *filename; char *filename;
cairo_test_status_t result = CAIRO_TEST_UNTESTED; cairo_test_status_t result = CAIRO_TEST_UNTESTED;
const char *path = cairo_test_mkdir (CAIRO_TEST_OUTPUT_DIR) ? CAIRO_TEST_OUTPUT_DIR : ".";
#if CAIRO_HAS_PS_SURFACE #if CAIRO_HAS_PS_SURFACE
if (cairo_test_is_target_enabled (ctx, "ps2") || if (cairo_test_is_target_enabled (ctx, "ps2") ||
@ -143,7 +144,7 @@ preamble (cairo_test_context_t *ctx)
if (result == CAIRO_TEST_UNTESTED) if (result == CAIRO_TEST_UNTESTED)
result = CAIRO_TEST_SUCCESS; result = CAIRO_TEST_SUCCESS;
filename = CAIRO_TEST_OUTPUT_DIR "/" BASENAME ".ps"; xasprintf (&filename, "%s/%s", path, BASENAME ".ps");
surface = cairo_ps_surface_create (filename, surface = cairo_ps_surface_create (filename,
WIDTH_IN_POINTS, HEIGHT_IN_POINTS); WIDTH_IN_POINTS, HEIGHT_IN_POINTS);
status = cairo_surface_status (surface); status = cairo_surface_status (surface);
@ -156,6 +157,7 @@ preamble (cairo_test_context_t *ctx)
draw_some_pages (surface); draw_some_pages (surface);
cairo_surface_destroy (surface); cairo_surface_destroy (surface);
free (filename);
printf ("multi-page: Please check %s to ensure it looks happy.\n", filename); printf ("multi-page: Please check %s to ensure it looks happy.\n", filename);
} }
@ -166,7 +168,7 @@ preamble (cairo_test_context_t *ctx)
if (result == CAIRO_TEST_UNTESTED) if (result == CAIRO_TEST_UNTESTED)
result = CAIRO_TEST_SUCCESS; result = CAIRO_TEST_SUCCESS;
filename = CAIRO_TEST_OUTPUT_DIR "/" BASENAME ".pdf"; xasprintf (&filename, "%s/%s", path, BASENAME ".pdf");
surface = cairo_pdf_surface_create (filename, surface = cairo_pdf_surface_create (filename,
WIDTH_IN_POINTS, HEIGHT_IN_POINTS); WIDTH_IN_POINTS, HEIGHT_IN_POINTS);
status = cairo_surface_status (surface); status = cairo_surface_status (surface);
@ -179,6 +181,7 @@ preamble (cairo_test_context_t *ctx)
draw_some_pages (surface); draw_some_pages (surface);
cairo_surface_destroy (surface); cairo_surface_destroy (surface);
free (filename);
printf ("multi-page: Please check %s to ensure it looks happy.\n", filename); printf ("multi-page: Please check %s to ensure it looks happy.\n", filename);
} }

View file

@ -89,11 +89,14 @@ preamble (cairo_test_context_t *ctx)
cairo_t *cr; cairo_t *cr;
cairo_status_t status; cairo_status_t status;
size_t i; size_t i;
const char *filename = CAIRO_TEST_OUTPUT_DIR "/" BASENAME ".pdf"; char *filename;
const char *path = cairo_test_mkdir (CAIRO_TEST_OUTPUT_DIR) ? CAIRO_TEST_OUTPUT_DIR : ".";
if (! cairo_test_is_target_enabled (ctx, "pdf")) if (! cairo_test_is_target_enabled (ctx, "pdf"))
return CAIRO_TEST_UNTESTED; return CAIRO_TEST_UNTESTED;
xasprintf (&filename, "%s/%s.pdf", path, BASENAME);
/* The initial size passed here is the default size that will be /* The initial size passed here is the default size that will be
* inheritable by each page. That is, any page for which this * inheritable by each page. That is, any page for which this
* initial size applies will not have its own /MediaBox entry in * initial size applies will not have its own /MediaBox entry in
@ -125,6 +128,7 @@ preamble (cairo_test_context_t *ctx)
cairo_destroy (cr); cairo_destroy (cr);
cairo_surface_destroy (surface); cairo_surface_destroy (surface);
free (filename);
if (status) { if (status) {
cairo_test_log (ctx, "Failed to create pdf surface for file %s: %s\n", cairo_test_log (ctx, "Failed to create pdf surface for file %s: %s\n",

View file

@ -84,7 +84,6 @@ read_file (const cairo_test_context_t *ctx,
static cairo_test_status_t static cairo_test_status_t
preamble (cairo_test_context_t *ctx) preamble (cairo_test_context_t *ctx)
{ {
const char *filename = CAIRO_TEST_OUTPUT_DIR "/" BASENAME ".pdf";
cairo_surface_t *image; cairo_surface_t *image;
cairo_surface_t *surface; cairo_surface_t *surface;
cairo_t *cr; cairo_t *cr;
@ -96,6 +95,8 @@ preamble (cairo_test_context_t *ctx)
unsigned int len, out_len; unsigned int len, out_len;
char command[4096]; char command[4096];
int exit_status; 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")) if (! cairo_test_is_target_enabled (ctx, "pdf"))
return CAIRO_TEST_UNTESTED; return CAIRO_TEST_UNTESTED;
@ -113,6 +114,7 @@ preamble (cairo_test_context_t *ctx)
width = cairo_image_surface_get_width (image); width = cairo_image_surface_get_width (image);
height = cairo_image_surface_get_height (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); surface = cairo_pdf_surface_create (filename, width + 20, height + 20);
cr = cairo_create (surface); cr = cairo_create (surface);
cairo_translate (cr, 10, 10); cairo_translate (cr, 10, 10);
@ -128,6 +130,7 @@ preamble (cairo_test_context_t *ctx)
cairo_surface_destroy (image); cairo_surface_destroy (image);
if (status) { if (status) {
free (filename);
cairo_test_log (ctx, "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)); filename, cairo_status_to_string (status));
return CAIRO_TEST_FAILURE; 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); sprintf (command, "pdfimages -j %s %s", filename, CAIRO_TEST_OUTPUT_DIR "/" BASENAME);
exit_status = system (command); exit_status = system (command);
free (filename);
if (exit_status) { if (exit_status) {
cairo_test_log (ctx, "pdfimages failed with exit status %d\n", exit_status); cairo_test_log (ctx, "pdfimages failed with exit status %d\n", exit_status);
return CAIRO_TEST_FAILURE; return CAIRO_TEST_FAILURE;

View file

@ -34,9 +34,13 @@ static cairo_surface_t *
create_source_surface (int size) create_source_surface (int size)
{ {
cairo_surface_t *surface; cairo_surface_t *surface;
char *filename;
const char *path = cairo_test_mkdir (CAIRO_TEST_OUTPUT_DIR) ? CAIRO_TEST_OUTPUT_DIR : ".";
surface = cairo_pdf_surface_create (CAIRO_TEST_OUTPUT_DIR "/" BASENAME ".pdf", size, size); xasprintf (&filename, "%s/%s.pdf", path, BASENAME);
surface = cairo_pdf_surface_create (filename, size, size);
cairo_surface_set_fallback_resolution (surface, 72., 72.); cairo_surface_set_fallback_resolution (surface, 72., 72.);
free (filename);
return surface; return surface;
} }

View file

@ -78,11 +78,13 @@ print_surface (const cairo_test_context_t *ctx, cairo_surface_t *surface)
static cairo_test_status_t static cairo_test_status_t
preamble (cairo_test_context_t *ctx) preamble (cairo_test_context_t *ctx)
{ {
const char *filename = CAIRO_TEST_OUTPUT_DIR "/" BASENAME ".png";
cairo_surface_t *surface0, *surface1; cairo_surface_t *surface0, *surface1;
cairo_status_t status; cairo_status_t status;
uint32_t argb32 = 0xdeadbede; 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, surface0 = cairo_image_surface_create_for_data ((unsigned char *) &argb32,
CAIRO_FORMAT_ARGB32, CAIRO_FORMAT_ARGB32,
1, 1, 4); 1, 1, 4);
@ -92,6 +94,7 @@ preamble (cairo_test_context_t *ctx)
filename, cairo_status_to_string (status)); filename, cairo_status_to_string (status));
cairo_surface_destroy (surface0); cairo_surface_destroy (surface0);
free (filename);
return cairo_test_status_from_status (ctx, status); return cairo_test_status_from_status (ctx, status);
} }
surface1 = cairo_image_surface_create_from_png (filename); 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 (surface1);
cairo_surface_destroy (surface0); cairo_surface_destroy (surface0);
free (filename);
return cairo_test_status_from_status (ctx, status); 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 (surface0);
cairo_surface_destroy (surface1); cairo_surface_destroy (surface1);
free (filename);
return CAIRO_TEST_FAILURE; return CAIRO_TEST_FAILURE;
} }
assert (*(uint32_t *) cairo_image_surface_get_data (surface1) == argb32); 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); surface1 = cairo_image_surface_create_from_png (filename);
status = cairo_surface_status (surface1); status = cairo_surface_status (surface1);
free (filename);
if (status) { if (status) {
cairo_test_log (ctx, "Error reading '%s': %s\n", cairo_test_log (ctx, "Error reading '%s': %s\n",
filename, cairo_status_to_string (status)); filename, cairo_status_to_string (status));

View file

@ -239,31 +239,13 @@ check_bbox (cairo_test_context_t *ctx,
return TRUE; return TRUE;
} }
static cairo_bool_t
_cairo_test_mkdir (const char *path)
{
#if ! HAVE_MKDIR
return FALSE;
#elif HAVE_MKDIR == 1
if (mkdir (path) == 0)
return TRUE;
#elif HAVE_MKDIR == 2
if (mkdir (path, 0770) == 0)
return TRUE;
#else
#error Bad value for HAVE_MKDIR
#endif
return errno == EEXIST;
}
static cairo_test_status_t static cairo_test_status_t
preamble (cairo_test_context_t *ctx) preamble (cairo_test_context_t *ctx)
{ {
cairo_t *cr; cairo_t *cr;
cairo_test_status_t ret = CAIRO_TEST_UNTESTED; cairo_test_status_t ret = CAIRO_TEST_UNTESTED;
const char *path = _cairo_test_mkdir (CAIRO_TEST_OUTPUT_DIR) ? CAIRO_TEST_OUTPUT_DIR : ".";
unsigned int i; unsigned int i;
const char *path = cairo_test_mkdir (CAIRO_TEST_OUTPUT_DIR) ? CAIRO_TEST_OUTPUT_DIR : ".";
for (i = 0; i < ctx->num_targets; i++) { for (i = 0; i < ctx->num_targets; i++) {
const cairo_boilerplate_target_t *target = ctx->targets_to_test[i]; const cairo_boilerplate_target_t *target = ctx->targets_to_test[i];

View file

@ -91,9 +91,10 @@ preamble (cairo_test_context_t *ctx)
cairo_surface_t *surface; cairo_surface_t *surface;
cairo_t *cr; cairo_t *cr;
cairo_status_t status; cairo_status_t status;
const char *filename;
size_t i; size_t i;
char dsc[255]; char dsc[255];
char *filename;
const char *path = cairo_test_mkdir (CAIRO_TEST_OUTPUT_DIR) ? CAIRO_TEST_OUTPUT_DIR : ".";
if (! (cairo_test_is_target_enabled (ctx, "ps2") || if (! (cairo_test_is_target_enabled (ctx, "ps2") ||
cairo_test_is_target_enabled (ctx, "ps3"))) cairo_test_is_target_enabled (ctx, "ps3")))
@ -101,8 +102,7 @@ preamble (cairo_test_context_t *ctx)
return CAIRO_TEST_UNTESTED; return CAIRO_TEST_UNTESTED;
} }
filename = CAIRO_TEST_OUTPUT_DIR "/" BASENAME ".ps"; xasprintf (&filename, "%s/%s.ps", path, BASENAME);
/* We demonstrate that the initial size doesn't matter (we're /* We demonstrate that the initial size doesn't matter (we're
* passing 0,0), if we use cairo_ps_surface_set_size on the first * passing 0,0), if we use cairo_ps_surface_set_size on the first
* page. */ * page. */
@ -149,10 +149,12 @@ preamble (cairo_test_context_t *ctx)
if (status) { if (status) {
cairo_test_log (ctx, "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)); filename, cairo_status_to_string (status));
free (filename);
return CAIRO_TEST_FAILURE; return CAIRO_TEST_FAILURE;
} }
printf ("ps-features: Please check %s to ensure it looks/prints correctly.\n", filename); printf ("ps-features: Please check %s to ensure it looks/prints correctly.\n", filename);
free (filename);
return CAIRO_TEST_SUCCESS; return CAIRO_TEST_SUCCESS;
} }

View file

@ -34,9 +34,13 @@ static cairo_surface_t *
create_source_surface (int size) create_source_surface (int size)
{ {
cairo_surface_t *surface; cairo_surface_t *surface;
char *filename;
const char *path = cairo_test_mkdir (CAIRO_TEST_OUTPUT_DIR) ? CAIRO_TEST_OUTPUT_DIR : ".";
surface = cairo_ps_surface_create (CAIRO_TEST_OUTPUT_DIR "/" BASENAME ".ps", size, size); xasprintf (&filename, "%s/%s.ps", path, BASENAME);
surface = cairo_ps_surface_create (filename, size, size);
cairo_surface_set_fallback_resolution (surface, 72., 72.); cairo_surface_set_fallback_resolution (surface, 72., 72.);
free (filename);
return surface; return surface;
} }

View file

@ -108,8 +108,9 @@ static cairo_test_status_t
preamble (cairo_test_context_t *ctx) preamble (cairo_test_context_t *ctx)
{ {
cairo_t *cr; cairo_t *cr;
const char *filename = CAIRO_TEST_OUTPUT_DIR "/" BASENAME ".svg";
cairo_surface_t *surface; 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") && if (! cairo_test_is_target_enabled (ctx, "svg11") &&
! cairo_test_is_target_enabled (ctx, "svg12")) ! cairo_test_is_target_enabled (ctx, "svg12"))
@ -117,12 +118,14 @@ preamble (cairo_test_context_t *ctx)
return CAIRO_TEST_UNTESTED; return CAIRO_TEST_UNTESTED;
} }
xasprintf (&filename, "%s/%s.svg", path, BASENAME);
surface = cairo_svg_surface_create (filename, surface = cairo_svg_surface_create (filename,
WIDTH_IN_POINTS, HEIGHT_IN_POINTS); WIDTH_IN_POINTS, HEIGHT_IN_POINTS);
if (cairo_surface_status (surface)) { if (cairo_surface_status (surface)) {
cairo_test_log (ctx, cairo_test_log (ctx,
"Failed to create svg surface for file %s: %s\n", "Failed to create svg surface for file %s: %s\n",
filename, cairo_status_to_string (cairo_surface_status (surface))); filename, cairo_status_to_string (cairo_surface_status (surface)));
free (filename);
return CAIRO_TEST_FAILURE; return CAIRO_TEST_FAILURE;
} }
@ -136,6 +139,7 @@ preamble (cairo_test_context_t *ctx)
printf ("svg-clip: Please check %s to make sure it looks happy.\n", printf ("svg-clip: Please check %s to make sure it looks happy.\n",
filename); filename);
free (filename);
return CAIRO_TEST_SUCCESS; return CAIRO_TEST_SUCCESS;
} }

View file

@ -34,10 +34,14 @@ static cairo_surface_t *
create_source_surface (int size) create_source_surface (int size)
{ {
cairo_surface_t *surface; cairo_surface_t *surface;
char *filename;
const char *path = cairo_test_mkdir (CAIRO_TEST_OUTPUT_DIR) ? CAIRO_TEST_OUTPUT_DIR : ".";
surface = cairo_svg_surface_create (CAIRO_TEST_OUTPUT_DIR "/" BASENAME ".svg", xasprintf (&filename, "%s/%s.svg", path, BASENAME);
surface = cairo_svg_surface_create (filename,
size, size); size, size);
cairo_surface_set_fallback_resolution (surface, 72., 72.); cairo_surface_set_fallback_resolution (surface, 72., 72.);
free (filename);
return surface; return surface;
} }

View file

@ -91,8 +91,9 @@ static cairo_test_status_t
preamble (cairo_test_context_t *ctx) preamble (cairo_test_context_t *ctx)
{ {
cairo_t *cr; cairo_t *cr;
const char *filename = CAIRO_TEST_OUTPUT_DIR "/" BASENAME ".svg";
cairo_surface_t *surface; 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") && if (! cairo_test_is_target_enabled (ctx, "svg11") &&
! cairo_test_is_target_enabled (ctx, "svg12")) ! cairo_test_is_target_enabled (ctx, "svg12"))
@ -100,6 +101,7 @@ preamble (cairo_test_context_t *ctx)
return CAIRO_TEST_UNTESTED; return CAIRO_TEST_UNTESTED;
} }
xasprintf (&filename, "%s/%s.svg", path, BASENAME);
surface = cairo_svg_surface_create (filename, surface = cairo_svg_surface_create (filename,
WIDTH_IN_POINTS, HEIGHT_IN_POINTS); WIDTH_IN_POINTS, HEIGHT_IN_POINTS);
if (cairo_surface_status (surface)) { 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", "Failed to create svg surface for file %s: %s\n",
filename, filename,
cairo_status_to_string (cairo_surface_status (surface))); cairo_status_to_string (cairo_surface_status (surface)));
free (filename);
return CAIRO_TEST_FAILURE; return CAIRO_TEST_FAILURE;
} }
@ -120,6 +123,7 @@ preamble (cairo_test_context_t *ctx)
cairo_surface_destroy (surface); cairo_surface_destroy (surface);
printf ("svg-surface: Please check svg-surface.svg to make sure it looks happy.\n"); printf ("svg-surface: Please check svg-surface.svg to make sure it looks happy.\n");
free (filename);
return CAIRO_TEST_SUCCESS; return CAIRO_TEST_SUCCESS;
} }