[cairo-commit] cairo/test .cvsignore, 1.51, 1.51.2.1 Makefile.am, 1.91, 1.91.2.1 cairo-test.c, 1.55.2.1, 1.55.2.2 cairo-test.h, 1.13.4.1, 1.13.4.2

Carl Worth commit at pdx.freedesktop.org
Tue Sep 13 12:20:18 PDT 2005


Committed by: cworth

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

Modified Files:
      Tag: BRANCH_1_0
	.cvsignore Makefile.am cairo-test.c cairo-test.h 
Log Message:
2005-09-13  Carl Worth  <cworth at cworth.org>

        * test/cairo-test.h: Add documentation for cairo_test functions.

        * test/cairo-test.c: (cairo_test_init), (cairo_test_expecting):
        Abstract log fie creation into cairo_test_init for use by tests
        that don't use cairo_test().

        * test/.cvsignore:
        * test/Makefile.am:
        * test/pthread-show-text.c: (start), (main): Add new test for bug
        #4299 as reported by Alexey Shabalin.


Index: .cvsignore
===================================================================
RCS file: /cvs/cairo/cairo/test/.cvsignore,v
retrieving revision 1.51
retrieving revision 1.51.2.1
diff -u -d -r1.51 -r1.51.2.1
--- .cvsignore	31 Aug 2005 16:00:02 -0000	1.51
+++ .cvsignore	13 Sep 2005 19:20:15 -0000	1.51.2.1
@@ -39,9 +39,10 @@
 pdf-clip.pdf
 pdf-surface
 pdf-surface.pdf
+pixman-rotate
 ps-surface
 ps-surface.ps
-pixman-rotate
+pthread-show-text
 rectangle-rounding-error
 rel-path
 scale-source-surface-paint

Index: Makefile.am
===================================================================
RCS file: /cvs/cairo/cairo/test/Makefile.am,v
retrieving revision 1.91
retrieving revision 1.91.2.1
diff -u -d -r1.91 -r1.91.2.1
--- Makefile.am	31 Aug 2005 16:00:02 -0000	1.91
+++ Makefile.am	13 Sep 2005 19:20:15 -0000	1.91.2.1
@@ -56,6 +56,10 @@
 user-data			\
 rel-path
 
+if HAVE_PTHREAD
+TESTS += pthread-show-text
+endif
+
 if CAIRO_HAS_FT_FONT
 TESTS += ft-font-create-for-ft-face
 endif
@@ -218,8 +222,9 @@
 path_data_LDADD = $(LDADDS)
 pdf_surface_LDADD = $(LDADDS)
 pdf_clip_LDADD = $(LDADDS)
-ps_surface_LDADD = $(LDADDS)
 pixman_rotate_LDADD = $(LDADDS)
+ps_surface_LDADD = $(LDADDS)
+pthread_show_text_LDADD = $(LDADDS)
 rectangle_rounding_error_LDADD = $(LDADDS)
 scale_source_surface_paint_LDADD = $(LDADDS)
 select_font_no_show_text_LDADD = $(LDADDS)

Index: cairo-test.c
===================================================================
RCS file: /cvs/cairo/cairo/test/cairo-test.c,v
retrieving revision 1.55.2.1
retrieving revision 1.55.2.2
diff -u -d -r1.55.2.1 -r1.55.2.2
--- cairo-test.c	31 Aug 2005 23:15:53 -0000	1.55.2.1
+++ cairo-test.c	13 Sep 2005 19:20:15 -0000	1.55.2.2
@@ -48,6 +48,9 @@
 #define vsnprintf _vsnprintf
 #endif
 
+static void
+xunlink (const char *pathname);
+
 #define CAIRO_TEST_LOG_SUFFIX ".log"
 #define CAIRO_TEST_PNG_SUFFIX "-out.png"
 #define CAIRO_TEST_REF_SUFFIX "-ref.png"
@@ -59,6 +62,22 @@
 FILE *cairo_test_log_file;
 
 void
+cairo_test_init (const char *test_name)
+{
+    char *log_name;
+
+    xasprintf (&log_name, "%s%s", test_name, CAIRO_TEST_LOG_SUFFIX);
+    xunlink (log_name);
+
+    cairo_test_log_file = fopen (log_name, "a");
+    if (cairo_test_log_file == NULL) {
+	fprintf (stderr, "Error opening log file: %s\n", log_name);
+	cairo_test_log_file = stderr;
+    }
+    free (log_name);
+}
+
+void
 cairo_test_log (const char *fmt, ...)
 {
     va_list va;
@@ -532,17 +551,8 @@
 	    { "xlib", create_xlib_surface, cleanup_xlib},
 #endif
 	};
-    char *log_name;
-
-    xasprintf (&log_name, "%s%s", test->name, CAIRO_TEST_LOG_SUFFIX);
-    xunlink (log_name);
 
-    cairo_test_log_file = fopen (log_name, "a");
-    if (cairo_test_log_file == NULL) {
-	fprintf (stderr, "Error opening log file: %s\n", log_name);
-	cairo_test_log_file = stderr;
-    }
-    free (log_name);
+    cairo_test_init (test->name);
 
     /* The intended logic here is that we return overall SUCCESS
      * iff. there is at least one tested backend and that all tested

Index: cairo-test.h
===================================================================
RCS file: /cvs/cairo/cairo/test/cairo-test.h,v
retrieving revision 1.13.4.1
retrieving revision 1.13.4.2
diff -u -d -r1.13.4.1 -r1.13.4.2
--- cairo-test.h	1 Sep 2005 09:17:37 -0000	1.13.4.1
+++ cairo-test.h	13 Sep 2005 19:20:15 -0000	1.13.4.2
@@ -71,15 +71,58 @@
 
 typedef cairo_test_status_t  (*cairo_test_draw_function_t) (cairo_t *cr, int width, int height);
 
-/* cairo_test.c */
+/* The standard test interface which works by examining result image.
+ *
+ * cairo_test() accepts a draw function which will be called once for
+ * each testable backend. The following checks will be performed for
+ * each backend: 
+ *
+ * 1) If draw() does not return CAIRO_TEST_SUCCESS then this backend
+ *    fails.
+ *
+ * 2) Otherwise, if cairo_status(cr) indicates an error then this
+ *    backend fails.
+ *
+ * 3) Otherwise, if the image size is 0, then this backend passes.
+ *
+ * 4) Otherwise, if every channel of every pixel exactly matches the
+ *    reference image then this backend passes. If not, this backend
+ *    fails.
+ *
+ * The overall test result is PASS if and only if there is at least
+ * one backend that is tested and if all tested backend pass according
+ * to the four criteria above.
+ */
 cairo_test_status_t
 cairo_test (cairo_test_t *test, cairo_test_draw_function_t draw);
 
+/* Like cairo_test, but the text is expected to fail for the stated
+ * reason. Any test calling this variant should be listed in the
+ * XFAIL_TESTS list in Makefile.am. */
 cairo_test_status_t
 cairo_test_expect_failure (cairo_test_t		      *test, 
 			   cairo_test_draw_function_t  draw,
 			   const char		      *reason);
 
+/* 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.
+ */
+
+/* Initialize test-specific resources, (log files, etc.) */
+void
+cairo_test_init (const char *test_name);
+
+/* Print a message to the log file, ala printf. */
+void
+cairo_test_log (const char *fmt, ...);
+
+/* Helper functions that take care of finding source images even when
+ * building in a non-srcdir manner, (ie. the tests will be run in a
+ * directory that is different from the one where the source image
+ * exists). */
 cairo_surface_t *
 cairo_test_create_surface_from_png (const char *filename);
 
@@ -87,9 +130,6 @@
 cairo_test_create_pattern_from_png (const char *filename);
 
 void
-cairo_test_log (const char *fmt, ...);
-
-void
 xasprintf (char **strp, const char *fmt, ...);
 
 #endif



More information about the cairo-commit mailing list