[cairo-commit] 2 commits - test/cairo-test.c

Behdad Esfahbod behdad at kemper.freedesktop.org
Thu Aug 10 12:11:53 PDT 2006


 test/cairo-test.c |   35 +++++++++++++++++++++++++----------
 1 files changed, 25 insertions(+), 10 deletions(-)

New commits:
diff-tree cecf396f6fe8424ec80f6f143df3622b92a5522e (from 15074cbb04498b59af4f3d9d3f2e99a2113e6730)
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Thu Aug 10 15:11:46 2006 -0400

    [test] Point out to the test log file on failures

diff --git a/test/cairo-test.c b/test/cairo-test.c
index db4d151..69a667d 100644
--- a/test/cairo-test.c
+++ b/test/cairo-test.c
@@ -1994,6 +1994,11 @@ cairo_test_expecting (cairo_test_t *test
 	}
     }
 
+    if (ret != CAIRO_TEST_SUCCESS)
+        printf ("Check %s%s out for more information.\n", test->name, CAIRO_TEST_LOG_SUFFIX);
+
+    /* if no target was requested for test, succeed, otherwise if all
+     * were untested, fail. */
     if (ret == CAIRO_TEST_UNTESTED)
 	ret = num_targets ? CAIRO_TEST_FAILURE : CAIRO_TEST_SUCCESS;
 
diff-tree 15074cbb04498b59af4f3d9d3f2e99a2113e6730 (from 67ff765e30af538a7955267c046af446dd8844ed)
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Thu Aug 10 14:58:33 2006 -0400

    [test] Behave better if no ref image was found for a test

diff --git a/test/cairo-test.c b/test/cairo-test.c
index 5bc8d5f..db4d151 100644
--- a/test/cairo-test.c
+++ b/test/cairo-test.c
@@ -1525,12 +1525,7 @@ cairo_ref_name_for_test_target_format (c
     else
 	goto done;
 
-    xasprintf (&ref_name, "/dev/null");
-    cairo_test_log ("Error: Cannot find reference image for %s/%s-%s-%s%s\n",srcdir,
-		    test_name,
-		    target_name,
-		    format,
-		    CAIRO_TEST_REF_SUFFIX);
+    ref_name = NULL;
 
 done:
     return ref_name;
@@ -1654,6 +1649,17 @@ cairo_test_for_target (cairo_test_t		 *t
 	int pixels_changed;
 	xunlink (png_name);
 	(target->write_to_png) (surface, png_name);
+
+	if (!ref_name) {
+	    cairo_test_log ("Error: Cannot find reference image for %s/%s-%s-%s%s\n",srcdir,
+			    test->name,
+			    target->name,
+			    format,
+			    CAIRO_TEST_REF_SUFFIX);
+	    ret = CAIRO_TEST_FAILURE;
+	    goto UNWIND_CAIRO;
+	}
+
 	if (target->content == CAIRO_TEST_CONTENT_COLOR_ALPHA_FLATTENED)
 	    pixels_changed = image_diff_flattened (png_name, ref_name, diff_name, dev_offset, dev_offset, 0, 0);
 	else
@@ -1680,10 +1686,14 @@ UNWIND_SURFACE:
 	target->cleanup_target (target->closure);
 
 UNWIND_STRINGS:
-    free (png_name);
-    free (ref_name);
-    free (diff_name);
-    free (offset_str);
+    if (png_name)
+      free (png_name);
+    if (ref_name)
+      free (ref_name);
+    if (diff_name)
+      free (diff_name);
+    if (offset_str)
+      free (offset_str);
 
     return ret;
 }


More information about the cairo-commit mailing list