Re: [PATCH 2/2] test: Fix several tests to place output files in the output directory
Uli Schlachter <[email protected]>
| Newsgroups | gmane.comp.lib.cairo |
|---|---|
| Message-ID | <[email protected]> |
On 17.07.2013 06:38, Bryce W. Harrington wrote: > 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 as well, in the interest of decluttering the test > directory. > > Signed-off-by: Bryce Harrington <[email protected]> > --- > test/create-for-stream.c | 2 +- > test/multi-page.c | 5 +++-- > test/pdf-features.c | 3 ++- > test/pdf-mime-data.c | 9 +++++---- > test/pdf-surface-source.c | 4 +++- > test/png.c | 3 ++- > test/ps-features.c | 3 ++- > test/ps-surface-source.c | 4 +++- > test/svg-clip.c | 3 ++- > test/svg-surface-source.c | 4 +++- > test/svg-surface.c | 3 ++- > 11 files changed, 28 insertions(+), 15 deletions(-) > > diff --git a/test/create-for-stream.c b/test/create-for-stream.c > index 3dde378..fdd4e01 100644 > --- a/test/create-for-stream.c > +++ b/test/create-for-stream.c > @@ -57,7 +57,7 @@ > #define WIDTH_IN_POINTS (WIDTH_IN_INCHES * 72.0) > #define HEIGHT_IN_POINTS (HEIGHT_IN_INCHES * 72.0) > > -#define BASENAME "create-for-stream.out" > +#define BASENAME "output/create-for-stream.out" I don't really like this. First, I think that "output/" should be put into a common header file under another define and then be used by all tests together, because "output/" is nothing per-test specific. Also, I wonder how good the test suite copes with being run with a relative path. All these path names seem to be interpreted relative to the current working directory. Thanks to the CAIRO_REF_DIR environment variable, it *might* be possible to run the test suite from outside of cairo's source directory. In this case all of these tests will fail because there is no directory called output/ (which makes me wonder who creates output/ currently...) Ok, I took a look at the source: We already have a define CAIRO_TEST_OUTPUT_DIR for "output" which is only used in three places, all of them using it like _cairo_test_mkdir(CAIRO_TEST_OUTPUT_DIR). I guess this means that this patch would need something equivalent. Uli > static cairo_test_status_t > draw (cairo_t *cr, int width, int height) > diff --git a/test/multi-page.c b/test/multi-page.c > index 0b73902..95741d3 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 "output/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 = 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 = 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..5f167f7 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 "output/pdf-features.out" > > static struct { > const char *page_size; > @@ -84,7 +85,7 @@ static struct { > static cairo_test_status_t > preamble (cairo_test_context_t *ctx) > { > - const char *filename = "pdf-features.out.pdf"; > + const char *filename = BASENAME ".pdf"; > cairo_surface_t *surface; > cairo_t *cr; > cairo_status_t status; > diff --git a/test/pdf-mime-data.c b/test/pdf-mime-data.c > index 00cde9d..9d7d36f 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 "output/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 = 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, 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, 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"); > + BASENAME "-000.jpg"); > return test_status; > } > > diff --git a/test/pdf-surface-source.c b/test/pdf-surface-source.c > index 078af3a..13cdd08 100644 > --- a/test/pdf-surface-source.c > +++ b/test/pdf-surface-source.c > @@ -28,12 +28,14 @@ > > #include "surface-source.c" > > +#define BASENAME "output/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 (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..d58c030 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 "output/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 = 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..c8545ee 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 "output/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 = 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..7c5c5aa 100644 > --- a/test/ps-surface-source.c > +++ b/test/ps-surface-source.c > @@ -28,12 +28,14 @@ > > #include "surface-source.c" > > +#define BASENAME "output/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 (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..d02c69e 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 "output/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 = 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..64b7f86 100644 > --- a/test/svg-surface-source.c > +++ b/test/svg-surface-source.c > @@ -28,12 +28,14 @@ > > #include "surface-source.c" > > +#define BASENAME "output/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 (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..59d67ad 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 "output/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 = BASENAME ".svg"; > cairo_surface_t *surface; > > if (! cairo_test_is_target_enabled (ctx, "svg11") && -- - Buck, when, exactly, did you lose your mind? - Three months ago. I woke up one morning married to a pineapple. An ugly pineapple... But I loved her. -- cairo mailing list [email protected] http://lists.cairographics.org/mailman/listinfo/cairo