[cairo-commit] cairo/test cairo_test.c, 1.2, 1.3 text_cache_crash.c, 1.1, 1.2

Carl Worth commit at pdx.freedesktop.org
Tue Nov 23 12:53:49 PST 2004


Committed by: cworth

Update of /cvs/cairo/cairo/test
In directory gabe:/tmp/cvs-serv9854/test

Modified Files:
	cairo_test.c text_cache_crash.c 
Log Message:

        * test/text_cache_crash.c: Add note that bug has been fixed.
        (main): Instrumentation code for testing cache destruction.

        * test/cairo_test.c (cairo_test): Support tests that produce no
        output, (don't check image if (width,height) == (0,0)).

        * src/cairoint.h: Add #include <assert.h> here rather than in
        multiple .c files.

        * src/cairo_cache.c: Add const qualifier to static
        cache_arrangements table.
        (_cache_sane_state): Remove refcount assertion as it it false
        during the cairo_cache_destroy.
        (_cache_sane_state): #include <assert.h> moved up to cairoint.h
        (_entry_destroy): Fix bug in assertion (used_memory >=
        entry->memory), not >.
        (_cairo_cache_destroy): Fix timing of refcount decrement so that
        the destroy function actually works.


Index: cairo_test.c
===================================================================
RCS file: /cvs/cairo/cairo/test/cairo_test.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- cairo_test.c	27 Oct 2004 01:19:55 -0000	1.2
+++ cairo_test.c	23 Nov 2004 20:53:46 -0000	1.3
@@ -127,6 +127,13 @@
 
     cairo_destroy (cr);
 
+    /* Skip image check for tests with no image (width,height == 0,0) */
+    if (test->width == 0 || test->height == 0) {
+	free (png_buf);
+	free (diff_buf);
+	return CAIRO_TEST_SUCCESS;
+    }
+
     /* Then we've got a bunch of string manipulation and file I/O for the check */
     srcdir = getenv ("srcdir");
     if (!srcdir)

Index: text_cache_crash.c
===================================================================
RCS file: /cvs/cairo/cairo/test/text_cache_crash.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- text_cache_crash.c	4 Nov 2004 22:23:50 -0000	1.1
+++ text_cache_crash.c	23 Nov 2004 20:53:47 -0000	1.2
@@ -51,17 +51,21 @@
  *	text_cache_crash: cairo_cache.c:422: _cairo_cache_lookup: Assertion `cache->max_memory >= (cache->used_memory + new_entry->memory)' failed.
  *
  *   I'll have to go back and try the original test after I fix this.
+ *
+ * 2004-11-13 Carl Worth <cworth at cworth.org>
+ *
+ *   Found the bug. cairo_gstate_select_font was noticing when the
+ *   same font was selected twice in a row and was erroneously failing
+ *   to free the old reference. Committed a fix and verified it also
+ *   fixed the orginal test case.
  */
 
 #include "cairo_test.h"
 
-#define WIDTH  100
-#define HEIGHT 60
-
 cairo_test_t test = {
     "text_cache_crash",
     "Test case for bug causing an assertion failure in _cairo_cache_lookup",
-    WIDTH, HEIGHT
+    0, 0,
 };
 #include <cairo.h>
 
@@ -80,6 +84,24 @@
 int
 main (void)
 {
-    return cairo_test (&test, draw);
+    int ret;
+
+    ret = cairo_test (&test, draw);
+
+    /* It's convenient to be able to free all memory (including
+     * statically allocated memory). This makes it quite easy to use
+     * tools such as valgrind to verify that there are no memory leaks
+     * whatsoever.
+     *
+     * But I'm not sure what would be a sensible cairo API function
+     * for this. The cairo_destroy_caches call below is just something
+     * I made as a local modification to cairo.
+     */
+    /*
+    cairo_destroy_caches ();
+    FcFini ();
+    */
+
+    return ret;
 }
 




More information about the cairo-commit mailing list