[cairo-commit]
cairo/test Makefile.am, 1.16, 1.17 cairo_test.c, 1.8, 1.9
Carl Worth
commit at pdx.freedesktop.org
Tue Mar 8 13:44:17 PST 2005
Committed by: cworth
Update of /cvs/cairo/cairo/test
In directory gabe:/tmp/cvs-serv3366/test
Modified Files:
Makefile.am cairo_test.c
Log Message:
* test/cairo_test.c (xunlink): Shared function for checking unlink
errrors.
(cairo_test): Move all error messages to test-specific log files
for quieter test output.
* test/Makefile.am (XFAIL_TESTS): Make pixman_rotate an expected
failure.
Index: Makefile.am
===================================================================
RCS file: /cvs/cairo/cairo/test/Makefile.am,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- Makefile.am 6 Mar 2005 20:05:23 -0000 1.16
+++ Makefile.am 8 Mar 2005 21:44:15 -0000 1.17
@@ -11,7 +11,7 @@
clip_twice \
pixman_rotate
-# And all new test go here too. I really don't like having to repeat
+# And all new tests go here too. I really don't like having to repeat
# this list. Anyone know a good way to avoid it? Can I use a wildcard
# here?
EXTRA_DIST = \
@@ -35,11 +35,9 @@
# here. New failures due to local, uncommitted code changes are
# regression bugs that should not be listed here. Instead they should
# be fixed before the code is committed.
-#
-# clip_twice fails because of loss of precision when converting to and
-# from premultiplied alpha in the test framework.
XFAIL_TESTS = \
move_to_show_surface \
+pixman_rotate \
text_rotate
check_PROGRAMS = $(TESTS)
Index: cairo_test.c
===================================================================
RCS file: /cvs/cairo/cairo/test/cairo_test.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- cairo_test.c 2 Feb 2005 05:45:52 -0000 1.8
+++ cairo_test.c 8 Mar 2005 21:44:15 -0000 1.9
@@ -37,6 +37,7 @@
#include "write_png.h"
#include "xmalloc.h"
+#define CAIRO_TEST_LOG_SUFFIX ".log"
#define CAIRO_TEST_PNG_SUFFIX "-out.png"
#define CAIRO_TEST_REF_SUFFIX "-ref.png"
#define CAIRO_TEST_DIFF_SUFFIX "-diff.png"
@@ -84,19 +85,30 @@
#endif /* !HAVE_VASNPRINTF */
}
+static void
+xunlink (const char *pathname)
+{
+ if (unlink (pathname) < 0 && errno != ENOENT) {
+ fprintf (stderr, " Error: Cannot remove %s: %s\n",
+ pathname, strerror (errno));
+ exit (1);
+ }
+}
+
cairo_test_status_t
cairo_test (cairo_test_t *test, cairo_test_draw_function_t draw)
{
cairo_t *cr;
int stride;
unsigned char *png_buf, *ref_buf, *diff_buf;
- char *png_name, *ref_name, *diff_name;
+ char *log_name, *png_name, *ref_name, *diff_name;
char *srcdir;
int pixels_changed;
int ref_width, ref_height, ref_stride;
read_png_status_t png_status;
cairo_test_status_t ret;
FILE *png_file;
+ FILE *log_file;
/* The cairo part of the test is the easiest part */
cr = cairo_create ();
@@ -124,6 +136,7 @@
srcdir = getenv ("srcdir");
if (!srcdir)
srcdir = ".";
+ xasprintf (&log_name, "%s%s", test->name, CAIRO_TEST_LOG_SUFFIX);
xasprintf (&png_name, "%s%s", test->name, CAIRO_TEST_PNG_SUFFIX);
xasprintf (&ref_name, "%s/%s%s", srcdir, test->name, CAIRO_TEST_REF_SUFFIX);
xasprintf (&diff_name, "%s%s", test->name, CAIRO_TEST_DIFF_SUFFIX);
@@ -132,32 +145,40 @@
write_png_argb32 (png_buf, png_file, test->width, test->height, stride);
fclose (png_file);
+ xunlink (log_name);
+
ref_buf = NULL;
png_status = (read_png_argb32 (ref_name, &ref_buf, &ref_width, &ref_height, &ref_stride));
if (png_status) {
+ log_file = fopen (log_name, "a");
switch (png_status)
{
case READ_PNG_FILE_NOT_FOUND:
- fprintf (stderr, " Error: No reference image found: %s\n", ref_name);
+ fprintf (log_file, "Error: No reference image found: %s\n", ref_name);
break;
case READ_PNG_FILE_NOT_PNG:
- fprintf (stderr, " Error: %s is not a png image\n", ref_name);
+ fprintf (log_file, "Error: %s is not a png image\n", ref_name);
break;
default:
- fprintf (stderr, " Error: Failed to read %s\n", ref_name);
+ fprintf (log_file, "Error: Failed to read %s\n", ref_name);
}
+ fclose (log_file);
ret = CAIRO_TEST_FAILURE;
goto BAIL;
+ } else {
}
if (test->width != ref_width || test->height != ref_height) {
- fprintf (stderr,
- " Error: Image size mismatch: (%dx%d) vs. (%dx%d)\n"
- " for %s vs %s\n",
+ log_file = fopen (log_name, "a");
+ fprintf (log_file,
+ "Error: Image size mismatch: (%dx%d) vs. (%dx%d)\n"
+ " for %s vs %s\n",
test->width, test->height,
ref_width, ref_height,
png_name, ref_name);
+ fclose (log_file);
+
ret = CAIRO_TEST_FAILURE;
goto BAIL;
}
@@ -165,20 +186,18 @@
pixels_changed = buffer_diff (png_buf, ref_buf, diff_buf,
test->width, test->height, stride);
if (pixels_changed) {
- fprintf (stderr, " Error: %d pixels differ from reference image %s\n",
+ log_file = fopen (log_name, "a");
+ fprintf (log_file, "Error: %d pixels differ from reference image %s\n",
pixels_changed, ref_name);
png_file = fopen (diff_name, "w");
write_png_argb32 (diff_buf, png_file, test->width, test->height, stride);
fclose (png_file);
+ fclose (log_file);
+
ret = CAIRO_TEST_FAILURE;
goto BAIL;
} else {
- if (unlink (diff_name) < 0 && errno != ENOENT) {
- fprintf (stderr, " Error: Cannot remove %s: %s\n",
- diff_name, strerror (errno));
- ret = CAIRO_TEST_FAILURE;
- goto BAIL;
- }
+ xunlink (diff_name);
}
ret = CAIRO_TEST_SUCCESS;
@@ -187,6 +206,7 @@
free (png_buf);
free (ref_buf);
free (diff_buf);
+ free (log_name);
free (png_name);
free (ref_name);
free (diff_name);
More information about the cairo-commit
mailing list