[PATCH 12/12] test: Do not open files in non-existing dirs

Andrea Canciani <[email protected]>
Newsgroups gmane.comp.lib.cairo
Message-ID <[email protected]>
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

--
cairo mailing list
[email protected]
http://lists.cairographics.org/mailman/listinfo/cairo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.