[cairo-commit] 6 commits - src/cairo-type1-fallback.c test/cairo-test.c test/cairo-test.h test/copy-path.c test/create-for-stream.c test/fallback-resolution.c test/font-face-get-type.c test/.gitignore test/in-fill-empty-trapezoid.c test/multi-page.c test/pattern-getters.c test/pattern-get-type.c test/pdf-features.c test/ps-features.c test/pthread-show-text.c test/svg-clip.c test/svg-surface.c test/truetype-tables.c test/.valgrind-suppressions test/xlib-surface.c

Carl Worth cworth at kemper.freedesktop.org
Fri Mar 2 12:31:08 PST 2007


 src/cairo-type1-fallback.c     |    3 ++-
 test/.gitignore                |    2 ++
 test/.valgrind-suppressions    |   24 ++++++++++++++++++++++++
 test/cairo-test.c              |   16 +++++++++++-----
 test/cairo-test.h              |   14 +++++++++-----
 test/copy-path.c               |    2 ++
 test/create-for-stream.c       |    2 ++
 test/fallback-resolution.c     |    2 ++
 test/font-face-get-type.c      |    2 ++
 test/in-fill-empty-trapezoid.c |    2 ++
 test/multi-page.c              |    2 ++
 test/pattern-get-type.c        |    2 ++
 test/pattern-getters.c         |    2 ++
 test/pdf-features.c            |    9 +--------
 test/ps-features.c             |    9 +--------
 test/pthread-show-text.c       |    8 +-------
 test/svg-clip.c                |    2 ++
 test/svg-surface.c             |    2 ++
 test/truetype-tables.c         |    2 ++
 test/xlib-surface.c            |   32 +++++++++++++-------------------
 20 files changed, 86 insertions(+), 53 deletions(-)

New commits:
diff-tree cd43c03d162efc87a1845c7ffbadfab00ac23d1f (from 8c579ef8354720c06db702db1e6e2aaab0efed82)
Author: Carl Worth <cworth at cworth.org>
Date:   Fri Mar 2 12:30:53 2007 -0800

    Fix leak of an output stream in cairo_type1_font_destroy

diff --git a/src/cairo-type1-fallback.c b/src/cairo-type1-fallback.c
index 4776faf..48cfaf2 100644
--- a/src/cairo-type1-fallback.c
+++ b/src/cairo-type1-fallback.c
@@ -680,8 +680,9 @@ static void
 cairo_type1_font_destroy (cairo_type1_font_t *font)
 {
     free (font->widths);
-    _cairo_array_fini (&font->contents);
     cairo_scaled_font_destroy (font->type1_scaled_font);
+    _cairo_array_fini (&font->contents);
+    _cairo_output_stream_destroy (font->output);
     free (font);
 }
 
diff-tree 8c579ef8354720c06db702db1e6e2aaab0efed82 (from 9854d01a8d3a1f9f6148dfd6e22623c4586aaa96)
Author: Carl Worth <cworth at cworth.org>
Date:   Fri Mar 2 12:30:14 2007 -0800

    More tightening of test cleanup to avoid valgrind complaints.

diff --git a/test/cairo-test.c b/test/cairo-test.c
index 738bd63..0228a17 100755
--- a/test/cairo-test.c
+++ b/test/cairo-test.c
@@ -108,6 +108,10 @@ void
 cairo_test_fini (void)
 {
     fclose (cairo_test_log_file);
+    cairo_debug_reset_static_data ();
+#if HAVE_FCFINI
+    FcFini ();
+#endif
 }
 
 void
@@ -562,10 +566,6 @@ cairo_test_expecting (cairo_test_t *test
 
     free (targets_to_test);
 
-#if HAVE_FCFINI
-    FcFini ();
-#endif
-
     return ret;
 }
 
diff --git a/test/fallback-resolution.c b/test/fallback-resolution.c
index 5448765..b8d7e04 100644
--- a/test/fallback-resolution.c
+++ b/test/fallback-resolution.c
@@ -145,5 +145,7 @@ main (void)
 		backend_filename[backend]);
     }
 
+    cairo_test_fini ();
+
     return CAIRO_TEST_SUCCESS;
 }
diff --git a/test/font-face-get-type.c b/test/font-face-get-type.c
index 57cc859..a3298fa 100644
--- a/test/font-face-get-type.c
+++ b/test/font-face-get-type.c
@@ -66,5 +66,7 @@ main (void)
     cairo_destroy (cr);
     cairo_surface_destroy (surface);
 
+    cairo_test_fini ();
+
     return CAIRO_TEST_SUCCESS;
 }
diff --git a/test/pdf-features.c b/test/pdf-features.c
index f790499..de3248f 100644
--- a/test/pdf-features.c
+++ b/test/pdf-features.c
@@ -26,9 +26,6 @@
 #include <stdio.h>
 #include <cairo.h>
 #include <cairo-pdf.h>
-#if HAVE_FCFINI
-#include <fontconfig/fontconfig.h>
-#endif
 
 #include "cairo-test.h"
 
@@ -140,11 +137,7 @@ main (void)
 
     printf ("pdf-features: Please check %s to ensure it looks/prints correctly.\n", filename);
 
-    cairo_debug_reset_static_data ();
-
-#if HAVE_FCFINI
-    FcFini ();
-#endif
+    cairo_test_fini ();
 
     return CAIRO_TEST_SUCCESS;
 }
diff --git a/test/ps-features.c b/test/ps-features.c
index e2882ff..597b73c 100644
--- a/test/ps-features.c
+++ b/test/ps-features.c
@@ -26,9 +26,6 @@
 #include <stdio.h>
 #include <cairo.h>
 #include <cairo-ps.h>
-#if HAVE_FCFINI
-#include <fontconfig/fontconfig.h>
-#endif
 
 #include "cairo-test.h"
 
@@ -154,11 +151,7 @@ main (void)
 
     printf ("ps-features: Please check %s to ensure it looks/prints correctly.\n", filename);
 
-    cairo_debug_reset_static_data ();
-
-#if HAVE_FCFINI
-    FcFini ();
-#endif
+    cairo_test_fini ();
 
     return CAIRO_TEST_SUCCESS;
 }
diff --git a/test/pthread-show-text.c b/test/pthread-show-text.c
index b674e37..0f0ec89 100644
--- a/test/pthread-show-text.c
+++ b/test/pthread-show-text.c
@@ -35,9 +35,6 @@
 #include <string.h>
 #include <stdlib.h>
 #include <pthread.h>
-#if HAVE_FCFINI
-#include <fontconfig/fontconfig.h>
-#endif
 
 #define NUM_THREADS_DEFAULT 50
 #define NUM_ITERATIONS 50
@@ -107,10 +104,7 @@ main (int argc, char *argv[])
 
     free (pthread);
 
-    cairo_debug_reset_static_data ();
-#if HAVE_FCFINI
-    FcFini ();
-#endif
+    cairo_test_fini ();
 
     return CAIRO_TEST_SUCCESS;
 }
diff-tree 9854d01a8d3a1f9f6148dfd6e22623c4586aaa96 (from b52dda62fea0745cc28d6149dc4688ade524b4df)
Author: Carl Worth <cworth at cworth.org>
Date:   Fri Mar 2 11:32:47 2007 -0800

    Fix leak in pattern-getters test (missing cairo_pattern_destroy)

diff --git a/test/pattern-getters.c b/test/pattern-getters.c
index fcfd0b9..d4014ea 100644
--- a/test/pattern-getters.c
+++ b/test/pattern-getters.c
@@ -160,6 +160,8 @@ draw (cairo_t *cr, int width, int height
 	    !DOUBLE_EQUALS(e,5.0) ||
 	    !DOUBLE_EQUALS(f,6.0))
 	    return CAIRO_TEST_FAILURE;
+
+	cairo_pattern_destroy (pat);
     }
 
     cairo_set_source_rgb (cr, 0, 1, 0);
diff-tree b52dda62fea0745cc28d6149dc4688ade524b4df (from 7d6e21c7e298e1795f36fdf021d61ef4ed0ca0fa)
Author: Carl Worth <cworth at cworth.org>
Date:   Fri Mar 2 11:31:13 2007 -0800

    Augment cairo_test_init with cairo_test_fini to avoid leak
    
    Without this, any tests that were using cairo_test_init rather than
    cairo_test would end up leaking a FILE* for the log file. So this
    keeps valgrind much more happy with the test suite.

diff --git a/test/cairo-test.c b/test/cairo-test.c
index 16173b6..738bd63 100755
--- a/test/cairo-test.c
+++ b/test/cairo-test.c
@@ -105,6 +105,12 @@ cairo_test_init (const char *test_name)
 }
 
 void
+cairo_test_fini (void)
+{
+    fclose (cairo_test_log_file);
+}
+
+void
 cairo_test_log (const char *fmt, ...)
 {
     va_list va;
@@ -552,7 +558,7 @@ cairo_test_expecting (cairo_test_t *test
 	ret = CAIRO_TEST_FAILURE;
     }
 
-    fclose (cairo_test_log_file);
+    cairo_test_fini ();
 
     free (targets_to_test);
 
diff --git a/test/cairo-test.h b/test/cairo-test.h
index a2d0285..d3612ba 100755
--- a/test/cairo-test.h
+++ b/test/cairo-test.h
@@ -101,17 +101,21 @@ typedef struct _cairo_test {
 cairo_test_status_t
 cairo_test (cairo_test_t *test);
 
-/* cairo_test_init() and cairo_test_log() exist to help in writing
- * tests for which cairo_test() is not appropriate for one reason or
- * another. For example, some tests might not be doing any drawing at
- * all, or may need to create their own cairo_t rather than be handed
- * one by cairo_test.
+/* cairo_test_init(), cairo_test_log(), and cairo_test_fini() exist to
+ * help in writing tests for which cairo_test() is not appropriate for
+ * one reason or another. For example, some tests might not be doing
+ * any drawing at all, or may need to create their own cairo_t rather
+ * than be handed one by cairo_test.
  */
 
 /* Initialize test-specific resources, (log files, etc.) */
 void
 cairo_test_init (const char *test_name);
 
+/* Finalize test-specific resource. */
+void
+cairo_test_fini (void);
+
 /* Print a message to the log file, ala printf. */
 void
 cairo_test_log (const char *fmt, ...) CAIRO_PRINTF_FORMAT(1, 2);
diff --git a/test/copy-path.c b/test/copy-path.c
index b763546..142bfa5 100644
--- a/test/copy-path.c
+++ b/test/copy-path.c
@@ -124,6 +124,8 @@ draw (cairo_t *cr, int width, int height
     }
     cairo_path_destroy (path);
 
+    cairo_destroy (cr_error);
+
     /* We draw in the default black, so paint white first. */
     cairo_save (cr);
     cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); /* white */
diff --git a/test/create-for-stream.c b/test/create-for-stream.c
index cbe8200..937eaf5 100644
--- a/test/create-for-stream.c
+++ b/test/create-for-stream.c
@@ -223,5 +223,7 @@ main (void)
 	return status;
 #endif
 
+    cairo_test_fini ();
+
     return CAIRO_TEST_SUCCESS;
 }
diff --git a/test/in-fill-empty-trapezoid.c b/test/in-fill-empty-trapezoid.c
index 58d347a..61fdb70 100644
--- a/test/in-fill-empty-trapezoid.c
+++ b/test/in-fill-empty-trapezoid.c
@@ -94,5 +94,7 @@ main (void)
 	return CAIRO_TEST_FAILURE;
     }
 
+    cairo_test_fini ();
+
     return CAIRO_TEST_SUCCESS;
 }
diff --git a/test/multi-page.c b/test/multi-page.c
index 86cf188..f0265e2 100644
--- a/test/multi-page.c
+++ b/test/multi-page.c
@@ -174,5 +174,7 @@ main (void)
     printf ("multi-page: Please check %s to ensure it looks happy.\n", filename);
 #endif
 
+    cairo_test_fini ();
+
     return CAIRO_TEST_SUCCESS;
 }
diff --git a/test/pattern-get-type.c b/test/pattern-get-type.c
index a6aba03..d64dd88 100644
--- a/test/pattern-get-type.c
+++ b/test/pattern-get-type.c
@@ -70,5 +70,7 @@ main (void)
     cairo_pattern_destroy (linear);
     cairo_pattern_destroy (radial);
 
+    cairo_test_fini ();
+
     return CAIRO_TEST_SUCCESS;
 }
diff --git a/test/svg-clip.c b/test/svg-clip.c
index dcdf028..81af104 100644
--- a/test/svg-clip.c
+++ b/test/svg-clip.c
@@ -130,5 +130,7 @@ main (void)
     printf ("svg-surface: Please check %s to make sure it looks happy.\n",
 	    filename);
 
+    cairo_test_fini ();
+
     return 0;
 }
diff --git a/test/svg-surface.c b/test/svg-surface.c
index 355394c..99b7b4e 100644
--- a/test/svg-surface.c
+++ b/test/svg-surface.c
@@ -113,5 +113,7 @@ main (void)
 
     printf ("svg-surface: Please check svg-surface.svg to make sure it looks happy.\n");
 
+    cairo_test_fini ();
+
     return 0;
 }
diff --git a/test/truetype-tables.c b/test/truetype-tables.c
index 851db90..c279c8b 100644
--- a/test/truetype-tables.c
+++ b/test/truetype-tables.c
@@ -55,5 +55,7 @@ main (void)
     check (tt_composite_glyph_t,	18);
     check (tt_glyph_data_t,	28);
 
+    cairo_test_fini ();
+
     return ret;
 }
diff --git a/test/xlib-surface.c b/test/xlib-surface.c
index 44bea92..3b6d1b5 100644
--- a/test/xlib-surface.c
+++ b/test/xlib-surface.c
@@ -38,7 +38,6 @@
 #define OFFSCREEN_OFFSET 50
 
 cairo_bool_t result = 0;
-FILE *log_file = NULL;
 
 static void
 draw_pattern (cairo_surface_t *surface)
@@ -177,14 +176,14 @@ do_test (Display        *dpy,
 			     &result);
     }
 
-    fprintf (log_file, "xlib-surface: %s, %s, %s%s: %s\n",
-	     use_render ? "   render" : "no-render",
-	     set_size ? "   size" : "no-size",
-	     use_pixmap ? "pixmap" : "window",
-	     use_pixmap ?
-	     "           " :
-	     (offscreen ? ", offscreen" : ",  onscreen"),
-	     result.pixels_changed ? "FAIL" : "PASS");
+    cairo_test_log ("xlib-surface: %s, %s, %s%s: %s\n",
+		    use_render ? "   render" : "no-render",
+		    set_size ? "   size" : "no-size",
+		    use_pixmap ? "pixmap" : "window",
+		    use_pixmap ?
+		    "           " :
+		    (offscreen ? ", offscreen" : ",  onscreen"),
+		    result.pixels_changed ? "FAIL" : "PASS");
 
     if (result.pixels_changed)
 	return CAIRO_TEST_FAILURE;
@@ -222,22 +221,17 @@ main (void)
     cairo_test_status_t status, result = CAIRO_TEST_SUCCESS;
 
     cairo_test_init ("xlib-surface");
-    log_file = fopen ("xlib-surface.log", "w");
-    if (log_file == NULL) {
-	fprintf (stderr, "Error opening log file: %s\n", "xlib-surface.log");
-	log_file = stderr;
-    }
 
     dpy = XOpenDisplay (NULL);
     if (!dpy) {
-	fprintf (log_file, "xlib-surface: Cannot open display, skipping\n");
-	fclose (log_file);
+	cairo_test_log ("xlib-surface: Cannot open display, skipping\n");
+	cairo_test_fini ();
 	return 0;
     }
 
     if (!check_visual (dpy)) {
-	fprintf (log_file, "xlib-surface: default visual is not RGB24 or BGR24, skipping\n");
-	fclose (log_file);
+	cairo_test_log ("xlib-surface: default visual is not RGB24 or BGR24, skipping\n");
+	cairo_test_fini ();
 	return 0;
     }
 
@@ -283,7 +277,7 @@ main (void)
 
     cairo_debug_reset_static_data ();
 
-    fclose (log_file);
+    cairo_test_fini ();
 
     return result;
 }
diff-tree 7d6e21c7e298e1795f36fdf021d61ef4ed0ca0fa (from e054314e5ec1f3fbdc97ed2175dd3d26d7581a5f)
Author: Carl Worth <cworth at cworth.org>
Date:   Fri Mar 2 11:29:40 2007 -0800

    Add even more XrmGetFileDatabase leaks to the valgrind suppressions file

diff --git a/test/.valgrind-suppressions b/test/.valgrind-suppressions
index 910dd59..cd3a086 100644
--- a/test/.valgrind-suppressions
+++ b/test/.valgrind-suppressions
@@ -477,3 +477,27 @@
    fun:NewDatabase
    fun:XrmGetFileDatabase
 }
+{
+   XrmGetFileDatabase is fairly obnoxious about leaving reachable memory around
+   Memcheck:Leak
+   fun:malloc
+   fun:_XlcSetConverter
+   fun:_XlcDefaultLoader
+   fun:_XOpenLC
+   fun:_XrmInitParseInfo
+   fun:NewDatabase
+   fun:XrmGetFileDatabase
+}
+{
+   XrmGetFileDatabase is fairly obnoxious about leaving reachable memory around
+   Memcheck:Leak
+   fun:malloc
+   fun:_XlcSetConverter
+   fun:_XlcAddUtf8Converters
+   fun:_XlcDefaultLoader
+   fun:_XOpenLC
+   fun:_XrmInitParseInfo
+   fun:NewDatabase
+   fun:XrmGetFileDatabase
+}
+
diff-tree e054314e5ec1f3fbdc97ed2175dd3d26d7581a5f (from 02f2ece88dbceaf2466bd61410dd8e88a4c95e08)
Author: Carl Worth <cworth at cworth.org>
Date:   Fri Mar 2 09:34:46 2007 -0800

    Add a couple of missing test cases to .gitignore

diff --git a/test/.gitignore b/test/.gitignore
index cf094e1..e514f5d 100644
--- a/test/.gitignore
+++ b/test/.gitignore
@@ -33,6 +33,7 @@ dash-caps-joins
 dash-no-dash
 dash-offset-negative
 dash-scale
+dash-state
 dash-zero-length
 degenerate-path
 device-offset
@@ -70,6 +71,7 @@ leaky-polygon
 line-width
 line-width-scale
 linear-gradient
+linear-gradient-reflect
 long-lines
 mask
 mask-ctm


More information about the cairo-commit mailing list