[test] Pass a 'complete' name to create_surface().

Construct the test name to pass to the boilerplate creation routines such
that it uniquely identifies the test in terms of test, target, content and
pass (similar, offset, thread). This allows the vector targets to create
output different output files for each test, whereas before, later tests
would overwrite existing files making debugging more difficult.
This commit is contained in:
Chris Wilson 2008-08-13 16:04:41 +01:00
parent 517e532fb7
commit 93af67d7fd
5 changed files with 35 additions and 46 deletions

View file

@ -68,8 +68,7 @@ _cairo_boilerplate_pdf_create_surface (const char *name,
ptc->width = width;
ptc->height = height;
xasprintf (&ptc->filename, "%s-pdf-%s-%d-out.pdf",
name, cairo_boilerplate_content_name (content), id);
xasprintf (&ptc->filename, "%s-out.pdf", name);
surface = cairo_pdf_surface_create (ptc->filename, width, height);
if (cairo_surface_status (surface))

View file

@ -63,8 +63,7 @@ _cairo_boilerplate_ps_create_surface (const char *name,
*closure = ptc = xmalloc (sizeof (ps_target_closure_t));
xasprintf (&ptc->filename, "%s-ps-%s-%d-out.ps",
name, cairo_boilerplate_content_name (content), id);
xasprintf (&ptc->filename, "%s-out.ps", name);
ptc->width = width;
ptc->height = height;

View file

@ -61,8 +61,7 @@ _cairo_boilerplate_svg_create_surface (const char *name,
ptc->width = width;
ptc->height = height;
xasprintf (&ptc->filename, "%s-svg-%s-%d-out.svg",
name, cairo_boilerplate_content_name (content), id);
xasprintf (&ptc->filename, "%s-out.svg", name);
surface = cairo_svg_surface_create (ptc->filename, width, height);
if (cairo_surface_status (surface))

View file

@ -178,8 +178,7 @@ _cairo_boilerplate_win32_printing_create_surface (const char *name,
*closure = ptc = xmalloc (sizeof (win32_target_closure_t));
xasprintf (&ptc->filename, "%s-win32-printing-%s-out.ps",
name, cairo_boilerplate_content_name (content));
xasprintf (&ptc->filename, "%s-out.ps", name);
memset (&di, 0, sizeof (DOCINFO));
di.cbSize = sizeof (DOCINFO);
di.lpszDocName = ptc->filename;

View file

@ -360,8 +360,9 @@ cairo_test_for_target (const cairo_test_context_t *ctx,
cairo_test_status_t status;
cairo_surface_t *surface = NULL;
cairo_t *cr;
const char *no_offset_str = "";
char *png_name, *ref_name, *diff_name, *offset_str;
const char *empty_str = "";
char *offset_str, *thread_str;
char *base_name, *png_name, *ref_name, *diff_name;
cairo_test_status_t ret;
cairo_content_t expected_content;
cairo_font_options_t *font_options;
@ -373,43 +374,35 @@ cairo_test_for_target (const cairo_test_context_t *ctx,
/* Get the strings ready that we'll need. */
format = cairo_boilerplate_content_name (target->content);
ref_name = cairo_ref_name_for_test_target_format (ctx,
ctx->test->name,
target->name,
format);
if (dev_offset)
xasprintf (&offset_str, "-%d", dev_offset);
else
offset_str = (char *) no_offset_str;
offset_str = (char *) empty_str;
if (ctx->thread)
xasprintf (&thread_str, "-thread%d", ctx->thread);
else
thread_str = (char *) empty_str;
ref_name = cairo_ref_name_for_test_target_format (ctx, ctx->test->name, target->name, format);
if (ctx->thread == 0) {
xasprintf (&png_name, "%s-%s-%s%s%s%s",
ctx->test->name,
target->name,
format,
similar ? "-similar" : "",
offset_str, CAIRO_TEST_PNG_SUFFIX);
xasprintf (&diff_name, "%s-%s-%s%s%s%s",
ctx->test->name,
target->name,
format,
similar ? "-similar" : "",
offset_str, CAIRO_TEST_DIFF_SUFFIX);
} else {
xasprintf (&png_name, "%s-%s-%s%s%s-%d%s",
ctx->test->name,
target->name,
format,
similar ? "-similar" : "",
offset_str,
ctx->thread,
CAIRO_TEST_PNG_SUFFIX);
xasprintf (&diff_name, "%s-%s-%s%s%s-%d%s",
ctx->test->name,
target->name,
format,
similar ? "-similar" : "",
offset_str,
ctx->thread,
CAIRO_TEST_DIFF_SUFFIX);
}
xasprintf (&base_name, "%s-%s-%s%s%s%s",
ctx->test->name,
target->name,
format,
similar ? "-similar" : "",
offset_str,
thread_str);
if (offset_str != empty_str)
free (offset_str);
if (thread_str != empty_str)
free (thread_str);
xasprintf (&png_name, "%s%s", base_name, CAIRO_TEST_PNG_SUFFIX);
xasprintf (&diff_name, "%s%s", base_name, CAIRO_TEST_DIFF_SUFFIX);
if (target->is_vector) {
int i;
@ -434,7 +427,7 @@ cairo_test_for_target (const cairo_test_context_t *ctx,
/* Run the actual drawing code. */
ret = CAIRO_TEST_SUCCESS;
surface = (target->create_surface) (ctx->test->name,
surface = (target->create_surface) (base_name,
target->content,
width, height,
ctx->test->width + 25 * NUM_DEVICE_OFFSETS,
@ -601,8 +594,8 @@ UNWIND_STRINGS:
free (ref_name);
if (diff_name)
free (diff_name);
if (offset_str != no_offset_str)
free (offset_str);
if (base_name)
free (base_name);
return ret;
}