From 1501c86536fcf21ce168644de58bfbc27ff6e710 Mon Sep 17 00:00:00 2001 From: Andrea Canciani Date: Tue, 1 Nov 2011 18:02:15 +0100 Subject: [PATCH] test: Do not open files in non-existing dirs The output directory should be made before trying to open log files in it. Fixes the bug causing cairo-test-suite to log to stderr on the first run (i.e. when test/output does not exist). --- test/cairo-test.c | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/test/cairo-test.c b/test/cairo-test.c index 0943f6743..9e0341b35 100644 --- a/test/cairo-test.c +++ b/test/cairo-test.c @@ -102,6 +102,24 @@ static int cairo_test_timeout = 60; #define NUM_DEVICE_OFFSETS 2 +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 char * _cairo_test_fixup_name (const char *original) { @@ -139,6 +157,8 @@ _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); + ctx->malloc_failure = 0; #if HAVE_MEMFAULT if (getenv ("CAIRO_TEST_MALLOC_FAILURE")) @@ -381,24 +401,6 @@ done: return ref_name; } -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; -} - cairo_test_similar_t cairo_test_target_has_similar (const cairo_test_context_t *ctx, const cairo_boilerplate_target_t *target)