[cairo-commit] 5 commits - test/cairo-test.c test/cairo-test.h test/create-for-stream.c test/fallback-resolution.c test/.gitignore test/multi-page.c test/pdf-features.c test/pdf-mime-data.c test/pdf-surface-source.c test/png.c test/ps-eps.c test/ps-features.c test/ps-surface-source.c test/svg-clip.c test/svg-surface.c test/svg-surface-source.c
Uli Schlachter
psychon at kemper.freedesktop.org
Mon Sep 9 12:34:58 PDT 2013
test/.gitignore | 4 ----
test/cairo-test.c | 10 +++++-----
test/cairo-test.h | 3 +++
test/create-for-stream.c | 14 +++++++++++---
test/fallback-resolution.c | 20 +-------------------
test/multi-page.c | 10 +++++++---
test/pdf-features.c | 7 ++++++-
test/pdf-mime-data.c | 13 +++++++++----
test/pdf-surface-source.c | 8 +++++++-
test/png.c | 9 ++++++++-
test/ps-eps.c | 20 +-------------------
test/ps-features.c | 9 ++++++---
test/ps-surface-source.c | 8 +++++++-
test/svg-clip.c | 7 ++++++-
test/svg-surface-source.c | 8 +++++++-
test/svg-surface.c | 9 +++++++--
16 files changed, 91 insertions(+), 68 deletions(-)
New commits:
commit 53255625c07d8f24403f0cb1b5a4dbaac142e4da
Author: Bryce W. Harrington <b.harrington at samsung.com>
Date: Sun Sep 8 20:10:04 2013 +0000
svg, test: Refer to output filename by variable, not a hardcoded value
Signed-off-by: Bryce Harrington <b.harrington at samsung.com>
Signed-off-by: Uli Schlachter <psychon at znc.in>
diff --git a/test/svg-surface.c b/test/svg-surface.c
index c0cdc16..8ee3b61 100644
--- a/test/svg-surface.c
+++ b/test/svg-surface.c
@@ -122,7 +122,7 @@ preamble (cairo_test_context_t *ctx)
cairo_destroy (cr);
cairo_surface_destroy (surface);
- printf ("svg-surface: Please check svg-surface.svg to make sure it looks happy.\n");
+ printf ("svg-surface: Please check %s to make sure it looks happy.\n", filename);
free (filename);
return CAIRO_TEST_SUCCESS;
}
commit f9dcd07d22a5269bf799317a36bb2887d8f9af64
Author: Bryce W. Harrington <b.harrington at samsung.com>
Date: Sun Sep 8 20:10:03 2013 +0000
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 at samsung.com>
Signed-off-by: Uli Schlachter <psychon at znc.in>
diff --git a/test/create-for-stream.c b/test/create-for-stream.c
index e999795..af1632f 100644
--- a/test/create-for-stream.c
+++ b/test/create-for-stream.c
@@ -239,6 +239,8 @@ preamble (cairo_test_context_t *ctx)
{
cairo_test_status_t status = CAIRO_TEST_UNTESTED;
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_test_is_target_enabled (ctx, "ps2") ||
@@ -247,7 +249,8 @@ preamble (cairo_test_context_t *ctx)
if (status == CAIRO_TEST_UNTESTED)
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_for_stream);
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");
if (status == CAIRO_TEST_SUCCESS)
status = test_status;
+ free (filename);
}
#endif
@@ -263,7 +267,8 @@ preamble (cairo_test_context_t *ctx)
if (status == CAIRO_TEST_UNTESTED)
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_for_stream);
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");
if (status == CAIRO_TEST_SUCCESS)
status = test_status;
+ free (filename);
}
#endif
@@ -281,7 +287,8 @@ preamble (cairo_test_context_t *ctx)
if (status == CAIRO_TEST_UNTESTED)
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_for_stream);
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");
if (status == CAIRO_TEST_SUCCESS)
status = test_status;
+ free (filename);
}
#endif
diff --git a/test/fallback-resolution.c b/test/fallback-resolution.c
index 138b3a4..df53e62 100644
--- a/test/fallback-resolution.c
+++ b/test/fallback-resolution.c
@@ -320,24 +320,6 @@ generate_reference (double ppi_x, double ppi_y, const char *filename)
}
#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 */
static cairo_test_status_t
preamble (cairo_test_context_t *ctx)
@@ -363,7 +345,7 @@ preamble (cairo_test_context_t *ctx)
};
unsigned int i;
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);
diff --git a/test/multi-page.c b/test/multi-page.c
index dea3b42..e5b3dd2 100644
--- a/test/multi-page.c
+++ b/test/multi-page.c
@@ -133,8 +133,9 @@ preamble (cairo_test_context_t *ctx)
{
cairo_surface_t *surface;
cairo_status_t status;
- const char *filename;
+ char *filename;
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_test_is_target_enabled (ctx, "ps2") ||
@@ -143,7 +144,7 @@ preamble (cairo_test_context_t *ctx)
if (result == CAIRO_TEST_UNTESTED)
result = CAIRO_TEST_SUCCESS;
- filename = CAIRO_TEST_OUTPUT_DIR "/" BASENAME ".ps";
+ xasprintf (&filename, "%s/%s", path, BASENAME ".ps");
surface = cairo_ps_surface_create (filename,
WIDTH_IN_POINTS, HEIGHT_IN_POINTS);
status = cairo_surface_status (surface);
@@ -156,6 +157,7 @@ preamble (cairo_test_context_t *ctx)
draw_some_pages (surface);
cairo_surface_destroy (surface);
+ free (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)
result = CAIRO_TEST_SUCCESS;
- filename = CAIRO_TEST_OUTPUT_DIR "/" BASENAME ".pdf";
+ xasprintf (&filename, "%s/%s", path, BASENAME ".pdf");
surface = cairo_pdf_surface_create (filename,
WIDTH_IN_POINTS, HEIGHT_IN_POINTS);
status = cairo_surface_status (surface);
@@ -179,6 +181,7 @@ preamble (cairo_test_context_t *ctx)
draw_some_pages (surface);
cairo_surface_destroy (surface);
+ free (filename);
printf ("multi-page: Please check %s to ensure it looks happy.\n", filename);
}
diff --git a/test/pdf-features.c b/test/pdf-features.c
index c5f6bea..0cc50ed 100644
--- a/test/pdf-features.c
+++ b/test/pdf-features.c
@@ -89,11 +89,14 @@ preamble (cairo_test_context_t *ctx)
cairo_t *cr;
cairo_status_t status;
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"))
return CAIRO_TEST_UNTESTED;
+ xasprintf (&filename, "%s/%s.pdf", path, BASENAME);
+
/* The initial size passed here is the default size that will be
* inheritable by each page. That is, any page for which this
* 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_surface_destroy (surface);
+ free (filename);
if (status) {
cairo_test_log (ctx, "Failed to create pdf surface for file %s: %s\n",
diff --git a/test/pdf-mime-data.c b/test/pdf-mime-data.c
index e4fbaa2..c575c4a 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;
diff --git a/test/pdf-surface-source.c b/test/pdf-surface-source.c
index 6307271..354a725 100644
--- a/test/pdf-surface-source.c
+++ b/test/pdf-surface-source.c
@@ -34,9 +34,13 @@ static cairo_surface_t *
create_source_surface (int size)
{
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.);
+ free (filename);
return surface;
}
diff --git a/test/png.c b/test/png.c
index 1dfc793..c01fbd7 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));
diff --git a/test/ps-eps.c b/test/ps-eps.c
index 1961463..66224e2 100644
--- a/test/ps-eps.c
+++ b/test/ps-eps.c
@@ -239,31 +239,13 @@ check_bbox (cairo_test_context_t *ctx,
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
preamble (cairo_test_context_t *ctx)
{
cairo_t *cr;
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;
+ const char *path = cairo_test_mkdir (CAIRO_TEST_OUTPUT_DIR) ? CAIRO_TEST_OUTPUT_DIR : ".";
for (i = 0; i < ctx->num_targets; i++) {
const cairo_boilerplate_target_t *target = ctx->targets_to_test[i];
diff --git a/test/ps-features.c b/test/ps-features.c
index 2eb9ace..fe5de42 100644
--- a/test/ps-features.c
+++ b/test/ps-features.c
@@ -91,9 +91,10 @@ preamble (cairo_test_context_t *ctx)
cairo_surface_t *surface;
cairo_t *cr;
cairo_status_t status;
- const char *filename;
size_t i;
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") ||
cairo_test_is_target_enabled (ctx, "ps3")))
@@ -101,8 +102,7 @@ preamble (cairo_test_context_t *ctx)
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
* passing 0,0), if we use cairo_ps_surface_set_size on the first
* page. */
@@ -149,10 +149,12 @@ preamble (cairo_test_context_t *ctx)
if (status) {
cairo_test_log (ctx, "Failed to create ps surface for file %s: %s\n",
filename, cairo_status_to_string (status));
+ free (filename);
return CAIRO_TEST_FAILURE;
}
printf ("ps-features: Please check %s to ensure it looks/prints correctly.\n", filename);
+ free (filename);
return CAIRO_TEST_SUCCESS;
}
diff --git a/test/ps-surface-source.c b/test/ps-surface-source.c
index 3573cb2..16c6776 100644
--- a/test/ps-surface-source.c
+++ b/test/ps-surface-source.c
@@ -34,9 +34,13 @@ static cairo_surface_t *
create_source_surface (int size)
{
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.);
+ free (filename);
return surface;
}
diff --git a/test/svg-clip.c b/test/svg-clip.c
index 149033b..b39e29f 100644
--- a/test/svg-clip.c
+++ b/test/svg-clip.c
@@ -108,8 +108,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"))
@@ -117,12 +118,14 @@ 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)) {
cairo_test_log (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;
}
@@ -136,6 +139,7 @@ preamble (cairo_test_context_t *ctx)
printf ("svg-clip: Please check %s to make sure it looks happy.\n",
filename);
+ free (filename);
return CAIRO_TEST_SUCCESS;
}
diff --git a/test/svg-surface-source.c b/test/svg-surface-source.c
index 2c33980..3c7730f 100644
--- a/test/svg-surface-source.c
+++ b/test/svg-surface-source.c
@@ -34,10 +34,14 @@ static cairo_surface_t *
create_source_surface (int size)
{
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);
cairo_surface_set_fallback_resolution (surface, 72., 72.);
+ free (filename);
return surface;
}
diff --git a/test/svg-surface.c b/test/svg-surface.c
index 30cf994..c0cdc16 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;
}
commit be7f1ac98f62669743f381df8845886d29a9f7f4
Author: Bryce W. Harrington <b.harrington at samsung.com>
Date: Sun Sep 8 20:10:03 2013 +0000
test: Make cairo_test_mkdir() usable throughout tests.
Signed-off-by: Bryce Harrington <b.harrington at samsung.com>
Signed-off-by: Uli Schlachter <psychon at znc.in>
diff --git a/test/cairo-test.c b/test/cairo-test.c
index 7bcb0ba..119506d 100644
--- a/test/cairo-test.c
+++ b/test/cairo-test.c
@@ -103,8 +103,8 @@ static int cairo_test_timeout = 60;
#define NUM_DEVICE_OFFSETS 2
#define NUM_DEVICE_SCALE 2
-static cairo_bool_t
-_cairo_test_mkdir (const char *path)
+cairo_bool_t
+cairo_test_mkdir (const char *path)
{
#if ! HAVE_MKDIR
return FALSE;
@@ -158,7 +158,7 @@ _cairo_test_init (cairo_test_context_t *ctx,
ctx->test_name = _cairo_test_fixup_name (test_name);
ctx->output = output;
- _cairo_test_mkdir (ctx->output);
+ cairo_test_mkdir (ctx->output);
ctx->malloc_failure = 0;
#if HAVE_MEMFAULT
@@ -421,7 +421,7 @@ cairo_test_target_has_similar (const cairo_test_context_t *ctx,
return DIRECT;
xasprintf (&path, "%s/%s",
- _cairo_test_mkdir (ctx->output) ? ctx->output : ".",
+ cairo_test_mkdir (ctx->output) ? ctx->output : ".",
ctx->test_name);
has_similar = DIRECT;
@@ -761,7 +761,7 @@ cairo_test_for_target (cairo_test_context_t *ctx,
target->file_extension);
}
- have_output_dir = _cairo_test_mkdir (ctx->output);
+ have_output_dir = cairo_test_mkdir (ctx->output);
xasprintf (&base_path, "%s/%s",
have_output_dir ? ctx->output : ".",
base_name);
diff --git a/test/cairo-test.h b/test/cairo-test.h
index 87ba7df..c753728 100644
--- a/test/cairo-test.h
+++ b/test/cairo-test.h
@@ -318,6 +318,9 @@ cairo_test_get_reference_image (cairo_test_context_t *ctx,
const char *filename,
cairo_bool_t flatten);
+cairo_bool_t
+cairo_test_mkdir (const char *path);
+
CAIRO_END_DECLS
#endif
commit 6731023f1bba7e26dbbc06defdbb37ac5267e9db
Author: Bryce W. Harrington <b.harrington at samsung.com>
Date: Sun Sep 8 20:10:03 2013 +0000
test: Fix several tests to place output files in the output directory
The standard location for test output is cairo/test/output. The harness
itself was updated to write automatically generated images in this
directory, however a number of tests generate their own local output
files.
This patch updates these tests to write their output into
CAIRO_TEST_OUTPUT_DIR (which defaults to cairo/test/output) as well, in
the interest of decluttering the test directory.
Signed-off-by: Bryce Harrington <b.harrington at samsung.com>
Signed-off-by: Uli Schlachter <psychon at znc.in>
diff --git a/test/create-for-stream.c b/test/create-for-stream.c
index 3dde378..e999795 100644
--- a/test/create-for-stream.c
+++ b/test/create-for-stream.c
@@ -247,7 +247,7 @@ preamble (cairo_test_context_t *ctx)
if (status == CAIRO_TEST_UNTESTED)
status = CAIRO_TEST_SUCCESS;
- test_status = test_surface (ctx, "ps", BASENAME ".ps",
+ test_status = test_surface (ctx, "ps", CAIRO_TEST_OUTPUT_DIR "/" BASENAME ".ps",
cairo_ps_surface_create,
cairo_ps_surface_create_for_stream);
cairo_test_log (ctx, "TEST: %s TARGET: %s RESULT: %s\n",
@@ -263,7 +263,7 @@ preamble (cairo_test_context_t *ctx)
if (status == CAIRO_TEST_UNTESTED)
status = CAIRO_TEST_SUCCESS;
- test_status = test_surface (ctx, "pdf", BASENAME ".pdf",
+ test_status = test_surface (ctx, "pdf", CAIRO_TEST_OUTPUT_DIR "/" BASENAME ".pdf",
cairo_pdf_surface_create,
cairo_pdf_surface_create_for_stream);
cairo_test_log (ctx, "TEST: %s TARGET: %s RESULT: %s\n",
@@ -281,7 +281,7 @@ preamble (cairo_test_context_t *ctx)
if (status == CAIRO_TEST_UNTESTED)
status = CAIRO_TEST_SUCCESS;
- test_status = test_surface (ctx, "svg", BASENAME ".svg",
+ test_status = test_surface (ctx, "svg", CAIRO_TEST_OUTPUT_DIR "/" BASENAME ".svg",
cairo_svg_surface_create,
cairo_svg_surface_create_for_stream);
cairo_test_log (ctx, "TEST: %s TARGET: %s RESULT: %s\n",
diff --git a/test/multi-page.c b/test/multi-page.c
index 0b73902..dea3b42 100644
--- a/test/multi-page.c
+++ b/test/multi-page.c
@@ -51,6 +51,7 @@
#define HEIGHT_IN_INCHES 3
#define WIDTH_IN_POINTS (WIDTH_IN_INCHES * 72.0)
#define HEIGHT_IN_POINTS (HEIGHT_IN_INCHES * 72.0)
+#define BASENAME "multi-page.out"
static void
draw_smiley (cairo_t *cr, double width, double height, double smile_ratio)
@@ -142,7 +143,7 @@ preamble (cairo_test_context_t *ctx)
if (result == CAIRO_TEST_UNTESTED)
result = CAIRO_TEST_SUCCESS;
- filename = "multi-page.out.ps";
+ filename = CAIRO_TEST_OUTPUT_DIR "/" BASENAME ".ps";
surface = cairo_ps_surface_create (filename,
WIDTH_IN_POINTS, HEIGHT_IN_POINTS);
status = cairo_surface_status (surface);
@@ -165,7 +166,7 @@ preamble (cairo_test_context_t *ctx)
if (result == CAIRO_TEST_UNTESTED)
result = CAIRO_TEST_SUCCESS;
- filename = "multi-page.out.pdf";
+ filename = CAIRO_TEST_OUTPUT_DIR "/" BASENAME ".pdf";
surface = cairo_pdf_surface_create (filename,
WIDTH_IN_POINTS, HEIGHT_IN_POINTS);
status = cairo_surface_status (surface);
diff --git a/test/pdf-features.c b/test/pdf-features.c
index f8850c4..c5f6bea 100644
--- a/test/pdf-features.c
+++ b/test/pdf-features.c
@@ -39,6 +39,7 @@
#define INCHES_TO_POINTS(in) ((in) * 72.0)
#define MM_TO_POINTS(mm) ((mm) / 25.4 * 72.0)
#define TEXT_SIZE 12
+#define BASENAME "pdf-features.out"
static struct {
const char *page_size;
@@ -84,11 +85,11 @@ static struct {
static cairo_test_status_t
preamble (cairo_test_context_t *ctx)
{
- const char *filename = "pdf-features.out.pdf";
cairo_surface_t *surface;
cairo_t *cr;
cairo_status_t status;
size_t i;
+ const char *filename = CAIRO_TEST_OUTPUT_DIR "/" BASENAME ".pdf";
if (! cairo_test_is_target_enabled (ctx, "pdf"))
return CAIRO_TEST_UNTESTED;
diff --git a/test/pdf-mime-data.c b/test/pdf-mime-data.c
index 00cde9d..e4fbaa2 100644
--- a/test/pdf-mime-data.c
+++ b/test/pdf-mime-data.c
@@ -39,6 +39,7 @@
* are not using a jpeg library */
#define IMAGE_FILE "romedalen"
+#define BASENAME "pdf-mime-data.out"
static cairo_test_status_t
read_file (const cairo_test_context_t *ctx,
@@ -83,7 +84,7 @@ read_file (const cairo_test_context_t *ctx,
static cairo_test_status_t
preamble (cairo_test_context_t *ctx)
{
- const char *filename = "pdf-mime-data.out.pdf";
+ const char *filename = CAIRO_TEST_OUTPUT_DIR "/" BASENAME ".pdf";
cairo_surface_t *image;
cairo_surface_t *surface;
cairo_t *cr;
@@ -134,7 +135,7 @@ preamble (cairo_test_context_t *ctx)
printf ("pdf-mime-data: Please check %s to ensure it looks/prints correctly.\n", filename);
- sprintf (command, "pdfimages -j %s pdf-mime-data.out", filename);
+ sprintf (command, "pdfimages -j %s %s", filename, CAIRO_TEST_OUTPUT_DIR "/" BASENAME);
exit_status = system (command);
if (exit_status) {
cairo_test_log (ctx, "pdfimages failed with exit status %d\n", exit_status);
@@ -147,12 +148,12 @@ preamble (cairo_test_context_t *ctx)
return test_status;
}
- test_status = read_file (ctx, "pdf-mime-data.out-000.jpg", &out_data, &out_len);
+ test_status = read_file (ctx, CAIRO_TEST_OUTPUT_DIR "/" BASENAME "-000.jpg", &out_data, &out_len);
if (test_status) {
free (data);
cairo_test_log (ctx,
"Could not read input jpeg file %s\n",
- "pdf-mime-data.out-000.jpg");
+ CAIRO_TEST_OUTPUT_DIR "/" BASENAME "-000.jpg");
return test_status;
}
diff --git a/test/pdf-surface-source.c b/test/pdf-surface-source.c
index 078af3a..6307271 100644
--- a/test/pdf-surface-source.c
+++ b/test/pdf-surface-source.c
@@ -28,12 +28,14 @@
#include "surface-source.c"
+#define BASENAME "pdf-surface-source.out"
+
static cairo_surface_t *
create_source_surface (int size)
{
cairo_surface_t *surface;
- surface = cairo_pdf_surface_create ("pdf-surface-source.out.pdf", size, size);
+ surface = cairo_pdf_surface_create (CAIRO_TEST_OUTPUT_DIR "/" BASENAME ".pdf", size, size);
cairo_surface_set_fallback_resolution (surface, 72., 72.);
return surface;
diff --git a/test/png.c b/test/png.c
index 3980ddc..1dfc793 100644
--- a/test/png.c
+++ b/test/png.c
@@ -30,6 +30,7 @@
/* Test the idempotency of write_png->read_png */
#define RGB_MASK 0x00ffffff
+#define BASENAME "png.out"
static cairo_bool_t
image_surface_equals (cairo_surface_t *A, cairo_surface_t *B)
@@ -77,7 +78,7 @@ 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 = "png.out.png";
+ const char *filename = CAIRO_TEST_OUTPUT_DIR "/" BASENAME ".png";
cairo_surface_t *surface0, *surface1;
cairo_status_t status;
uint32_t argb32 = 0xdeadbede;
diff --git a/test/ps-features.c b/test/ps-features.c
index e3cf9b4..2eb9ace 100644
--- a/test/ps-features.c
+++ b/test/ps-features.c
@@ -42,6 +42,7 @@
#define INCHES_TO_POINTS(in) ((in) * 72.0)
#define MM_TO_POINTS(mm) ((mm) / 25.4 * 72.0)
#define TEXT_SIZE 12
+#define BASENAME "ps-features.out"
static struct {
const char *page_size;
@@ -100,7 +101,7 @@ preamble (cairo_test_context_t *ctx)
return CAIRO_TEST_UNTESTED;
}
- filename = "ps-features.out.ps";
+ filename = CAIRO_TEST_OUTPUT_DIR "/" BASENAME ".ps";
/* 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
diff --git a/test/ps-surface-source.c b/test/ps-surface-source.c
index 37f57ee..3573cb2 100644
--- a/test/ps-surface-source.c
+++ b/test/ps-surface-source.c
@@ -28,12 +28,14 @@
#include "surface-source.c"
+#define BASENAME "ps-surface-source.out"
+
static cairo_surface_t *
create_source_surface (int size)
{
cairo_surface_t *surface;
- surface = cairo_ps_surface_create ("ps-surface-source.out.ps", size, size);
+ surface = cairo_ps_surface_create (CAIRO_TEST_OUTPUT_DIR "/" BASENAME ".ps", size, size);
cairo_surface_set_fallback_resolution (surface, 72., 72.);
return surface;
diff --git a/test/svg-clip.c b/test/svg-clip.c
index 035b236..149033b 100644
--- a/test/svg-clip.c
+++ b/test/svg-clip.c
@@ -32,6 +32,7 @@
#define WIDTH_IN_POINTS 600
#define HEIGHT_IN_POINTS 600
+#define BASENAME "svg-clip.out"
static void
test_clip (cairo_t *cr, double width, double height)
@@ -107,7 +108,7 @@ static cairo_test_status_t
preamble (cairo_test_context_t *ctx)
{
cairo_t *cr;
- const char *filename = "svg-clip.out.svg";
+ const char *filename = CAIRO_TEST_OUTPUT_DIR "/" BASENAME ".svg";
cairo_surface_t *surface;
if (! cairo_test_is_target_enabled (ctx, "svg11") &&
diff --git a/test/svg-surface-source.c b/test/svg-surface-source.c
index c97d3ca..2c33980 100644
--- a/test/svg-surface-source.c
+++ b/test/svg-surface-source.c
@@ -28,12 +28,14 @@
#include "surface-source.c"
+#define BASENAME "svg-surface-source.out"
+
static cairo_surface_t *
create_source_surface (int size)
{
cairo_surface_t *surface;
- surface = cairo_svg_surface_create ("svg-surface-source.out.svg",
+ surface = cairo_svg_surface_create (CAIRO_TEST_OUTPUT_DIR "/" BASENAME ".svg",
size, size);
cairo_surface_set_fallback_resolution (surface, 72., 72.);
diff --git a/test/svg-surface.c b/test/svg-surface.c
index 4e29f1b..30cf994 100644
--- a/test/svg-surface.c
+++ b/test/svg-surface.c
@@ -37,6 +37,7 @@
#define HEIGHT_IN_INCHES 3
#define WIDTH_IN_POINTS (WIDTH_IN_INCHES * 72)
#define HEIGHT_IN_POINTS (HEIGHT_IN_INCHES * 72)
+#define BASENAME "svg-surface.out"
static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
@@ -90,7 +91,7 @@ static cairo_test_status_t
preamble (cairo_test_context_t *ctx)
{
cairo_t *cr;
- const char *filename = "svg-surface.out.svg";
+ const char *filename = CAIRO_TEST_OUTPUT_DIR "/" BASENAME ".svg";
cairo_surface_t *surface;
if (! cairo_test_is_target_enabled (ctx, "svg11") &&
commit f3574b8b3b3e9dbd9fca927096e5a8205e57033d
Author: Bryce W. Harrington <b.harrington at samsung.com>
Date: Sun Sep 8 20:10:03 2013 +0000
test: Don't ignore test output files left in test directory
Tests should be placing output files in the output/ directory now,
although not all tests follow this standard practice. Drop the
"*.out.*" from .gitignore to make improper test behavior more evident.
Signed-off-by: Bryce Harrington <b.harrington at samsung.com>
Signed-off-by: Uli Schlachter <psychon at znc.in>
diff --git a/test/.gitignore b/test/.gitignore
index dba5877..836f3f9 100644
--- a/test/.gitignore
+++ b/test/.gitignore
@@ -18,10 +18,6 @@ pdf2png
ps2png
svg2png
valgrind-log
-*.out.*
-*.pass.*
-*.fail.*
-*.diff.png
*.manifest
*.gcda
*.gcno
More information about the cairo-commit
mailing list