[cairo-commit] test/create-for-stream.c

Chris Wilson ickle at kemper.freedesktop.org
Mon Apr 16 08:57:54 PDT 2007


 test/create-for-stream.c |   37 ++++++++++++++++++++-----------------
 1 files changed, 20 insertions(+), 17 deletions(-)

New commits:
diff-tree cab4d41cae4463841bca297a7e16c970633c8c21 (from 9d435d5fbfae0f64053f6596f73410bc352cd2de)
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Apr 16 16:57:24 2007 +0100

    create-for-stream - free resources after test failure.
    
    create-for-stream often fails whilst running under valgrind due to the
    postscript output containing a CreationDate with seconds resolution,
    hence the visibility of the resource leaks during failure.

diff --git a/test/create-for-stream.c b/test/create-for-stream.c
index 937eaf5..9068be8 100644
--- a/test/create-for-stream.c
+++ b/test/create-for-stream.c
@@ -177,12 +177,14 @@ test_surface (const char		 *filename,
     if (fread (file_contents, 1, wc.index, fp) != wc.index) {
 	cairo_test_log ("Failed to read %s: %s\n",
 			filename, strerror (errno));
+	fclose (fp);
 	return CAIRO_TEST_FAILURE;
     }
 
     if (memcmp (file_contents, wc.buffer, wc.index) != 0) {
 	cairo_test_log ("Stream based output differ from file output for %s\n",
 			filename);
+	fclose (fp);
 	return CAIRO_TEST_FAILURE;
     }
 
@@ -195,35 +197,36 @@ test_surface (const char		 *filename,
 int
 main (void)
 {
-    cairo_test_status_t status;
+    cairo_test_status_t status = CAIRO_TEST_SUCCESS;
+    cairo_test_status_t test_status;
 
     cairo_test_init ("create-for-stream");
 
 #if CAIRO_HAS_PS_SURFACE
-    status = test_surface ("create-for-stream.ps",
-			   cairo_ps_surface_create,
-			   cairo_ps_surface_create_for_stream);
-    if (status != CAIRO_TEST_SUCCESS)
-	return status;
+    test_status = test_surface ("create-for-stream.ps",
+			        cairo_ps_surface_create,
+			        cairo_ps_surface_create_for_stream);
+    if (status == CAIRO_TEST_SUCCESS)
+	status = test_status;
 #endif
 
 #if CAIRO_HAS_PDF_SURFACE
-    status = test_surface ("create-for-stream.pdf",
-			   cairo_pdf_surface_create,
-			   cairo_pdf_surface_create_for_stream);
-    if (status != CAIRO_TEST_SUCCESS)
-	return status;
+    test_status = test_surface ("create-for-stream.pdf",
+			        cairo_pdf_surface_create,
+			        cairo_pdf_surface_create_for_stream);
+    if (status == CAIRO_TEST_SUCCESS)
+	status = test_status;
 #endif
 
 #if CAIRO_HAS_SVG_SURFACE
-    status = test_surface ("create-for-stream.svg",
-			   cairo_svg_surface_create,
-			   cairo_svg_surface_create_for_stream);
-    if (status != CAIRO_TEST_SUCCESS)
-	return status;
+    test_status = test_surface ("create-for-stream.svg",
+			        cairo_svg_surface_create,
+			        cairo_svg_surface_create_for_stream);
+    if (status == CAIRO_TEST_SUCCESS)
+	status = test_status;
 #endif
 
     cairo_test_fini ();
 
-    return CAIRO_TEST_SUCCESS;
+    return status;
 }


More information about the cairo-commit mailing list