[cairo] [PATCH 12/12] test: Do not open files in non-existing dirs
Andrea Canciani
ranma42 at gmail.com
Sat Nov 12 13:20:04 PST 2011
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 files changed, 20 insertions(+), 18 deletions(-)
diff --git a/test/cairo-test.c b/test/cairo-test.c
index 0943f67..9e0341b 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)
--
1.7.5.4
More information about the cairo
mailing list