[PATCH v3 6/7] test: Ensure output dirs exist, falling back to current dir if needed

"Bryce W. Harrington" <[email protected]>
Newsgroups gmane.comp.lib.cairo
Message-ID <[email protected]>
This change makes several tests behave more like ps-eps.c, et al by
making them attempt to mkdir "output", and in case of trouble use "."
instead.  filenames are now allocated at runtime due to this change, so
ensure the corresponding free()'s are in place as well.

This should facilitate running the test suite with a relative path
outside cairo's source tree, such as when employing the CAIRO_REF_DIR
environment variable.

Signed-off-by: Bryce Harrington <[email protected]>
---
 test/fallback-resolution.c |   20 +-------------------
 1 file changed, 1 insertion(+), 19 deletions(-)

diff --git a/test/fallback-resolution.c b/test/fallback-resolution.c
index 138b3a4..df53e62 100644
--- a/test/fallback-resolution.c
+++ b/test/fallback-resolution.c
@@ -320,24 +320,6 @@ generate_reference (double ppi_x, double ppi_y, const char *filename)
 }
 #endif
 
-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;
-}
-
 /* TODO: Split each ppi case out to its own CAIRO_TEST() test case */
 static cairo_test_status_t
 preamble (cairo_test_context_t *ctx)
@@ -363,7 +345,7 @@ preamble (cairo_test_context_t *ctx)
     };
     unsigned int i;
     int n, num_ppi;
-    const char *path = _cairo_test_mkdir (CAIRO_TEST_OUTPUT_DIR) ? CAIRO_TEST_OUTPUT_DIR : ".";
+    const char *path = cairo_test_mkdir (CAIRO_TEST_OUTPUT_DIR) ? CAIRO_TEST_OUTPUT_DIR : ".";
 
     num_ppi = ARRAY_LENGTH (ppi);
 
-- 
1.7.9.5
-- 
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.