be5741acf0e4af170b3235ca326ecd615eeaea19
[platform/core/graphics/cairo.git] / test / Makefile.am
1 include $(top_srcdir)/build/Makefile.am.common
2
3 include $(top_srcdir)/test/Makefile.sources
4
5 SUBDIRS=pdiff .
6
7 # Then we have a collection of tests that are only run if certain
8 # features are compiled into cairo
9 if HAVE_REAL_PTHREAD
10 test_sources += $(pthread_test_sources)
11 endif
12
13 if CAIRO_HAS_FT_FONT
14 if CAIRO_HAS_FC_FONT
15 test_sources += $(ft_font_test_sources)
16 endif
17 endif
18
19 if CAIRO_HAS_EGL_FUNCTIONS
20 test_sources += $(egl_surface_test_sources)
21 endif
22
23 # Need to add quartz-surface-source
24 if CAIRO_HAS_QUARTZ_SURFACE
25 test_sources += $(quartz_surface_test_sources)
26 endif
27
28 if CAIRO_HAS_PDF_SURFACE
29 test_sources += $(pdf_surface_test_sources)
30 endif
31
32 if CAIRO_HAS_PS_SURFACE
33 test_sources += $(ps_surface_test_sources)
34 endif
35
36 if CAIRO_HAS_SVG_SURFACE
37 test_sources += $(svg_surface_test_sources)
38 endif
39
40 if CAIRO_HAS_TEST_SURFACES
41 test_sources += $(test_fallback16_surface_test_sources)
42 endif
43
44 if CAIRO_HAS_XCB_SURFACE
45 test_sources += $(xcb_surface_test_sources)
46 endif
47
48 if CAIRO_HAS_XLIB_SURFACE
49 test_sources += $(xlib_surface_test_sources)
50 endif
51
52 if CAIRO_HAS_XLIB_XRENDER_SURFACE
53 test_sources += $(xlib_xrender_surface_test_sources)
54 endif
55
56 if CAIRO_HAS_MULTI_PAGE_SURFACES
57 test_sources += $(multi_page_surface_test_sources)
58 endif
59
60 # Include fallback-resolution (once!) if we have any of the vector surfaces
61 if BUILD_ANY2PPM
62 if CAIRO_HAS_SVG_SURFACE
63 test = $(fallback_resolution_test_sources)
64 endif
65 if CAIRO_HAS_PDF_SURFACE
66 test = $(fallback_resolution_test_sources)
67 endif
68 if CAIRO_HAS_PS_SURFACE
69 test = $(fallback_resolution_test_sources)
70 endif
71 endif
72 test_sources += $(test)
73
74 noinst_PROGRAMS = cairo-test-suite$(EXEEXT) # always build
75 noinst_SCRIPTS = check-refs.sh
76
77 TESTS += cairo-test-suite$(EXEEXT)
78
79 cairo-test-constructors.c: Makefile $(test_sources) make-cairo-test-constructors.sh
80         (cd $(srcdir) && sh ./make-cairo-test-constructors.sh $(test_sources)) > $@
81
82 cairo_test_suite_SOURCES =              \
83         $(cairo_test_suite_sources)     \
84         $(cairo_test_suite_headers)     \
85         $(test_sources)                 \
86         cairo-test-constructors.c
87 cairo_test_suite_CFLAGS = $(AM_CFLAGS) $(real_pthread_CFLAGS) 
88 cairo_test_suite_LDADD =                                        \
89         $(real_pthread_LIBS)                                    \
90         $(top_builddir)/test/pdiff/libpdiff.la                  \
91         $(top_builddir)/boilerplate/libcairoboilerplate.la      \
92         $(top_builddir)/src/libcairo.la                         \
93         $(CAIRO_LDADD)
94 cairo_test_suite_DEPENDENCIES = \
95         $(top_builddir)/test/pdiff/libpdiff.la                  \
96         $(top_builddir)/boilerplate/libcairoboilerplate.la      \
97         $(top_builddir)/src/libcairo.la
98 if BUILD_ANY2PPM
99 cairo_test_suite_DEPENDENCIES += \
100         any2ppm$(EXEEXT)
101 endif
102
103 if HAVE_SHM
104 EXTRA_PROGRAMS += cairo-test-trace
105 cairo_test_trace_SOURCES =              \
106         cairo-test-trace.c              \
107         buffer-diff.c                   \
108         buffer-diff.h
109 cairo_test_trace_CFLAGS = $(AM_CFLAGS) $(real_pthread_CFLAGS) 
110 cairo_test_trace_LDADD =                \
111         $(real_pthread_LIBS)                                    \
112         $(top_builddir)/test/pdiff/libpdiff.la                  \
113         $(top_builddir)/util/cairo-script/libcairo-script-interpreter.la \
114         $(top_builddir)/boilerplate/libcairoboilerplate.la      \
115         $(top_builddir)/src/libcairo.la                         \
116         $(top_builddir)/util/cairo-missing/libcairo-missing.la  \
117         $(CAIRO_LDADD) \
118         $(SHM_LIBS)
119 cairo_test_trace_DEPENDENCIES = \
120         $(top_builddir)/test/pdiff/libpdiff.la                  \
121         $(top_builddir)/util/cairo-script/libcairo-script-interpreter.la \
122         $(top_builddir)/boilerplate/libcairoboilerplate.la      \
123         $(top_builddir)/src/libcairo.la                         \
124         $(top_builddir)/util/cairo-missing/libcairo-missing.la  \
125         $(NULL)
126 endif
127
128 BUILT_SOURCES += cairo-test-constructors.c
129 EXTRA_DIST += $(BUILT_SOURCES) $(noinst_SCRIPTS) COPYING make-cairo-test-constructors.sh run-cairo-test-suite.sh generate_refs.sh tiger.inc
130 CLEANFILES += $(BUILT_SOURCES)
131
132 EXTRA_DIST +=           \
133 6x13.pcf                \
134 index.html              \
135 jp2.jp2                 \
136 jpeg.jpg                \
137 png.png                 \
138 romedalen.jpg           \
139 romedalen.png           \
140 scarab.jpg              \
141 surface-source.c        \
142 testtable.js            \
143 reference
144
145 # Any test that doesn't generate a log file goes here
146 NOLOG_TESTS =                   \
147 fallback-resolution             \
148 font-options                    \
149 multi-page                      \
150 pdf-features                    \
151 png                             \
152 ps-eps                          \
153 ps-features                     \
154 svg-clip                        \
155 svg-surface                     \
156 toy-font-face                   \
157 user-data
158
159 # A target to summarise the failures
160 check-summary:
161         @FAILED_TESTS=""; \
162         for t in output/*.log; do \
163             if grep -e '\<FAIL\>' $$t >/dev/null 2>&1; then \
164                 FAILED_TESTS="$$FAILED_TESTS $$t"; \
165             fi; \
166         done; \
167         if test -n "$$FAILED_TESTS"; then \
168             echo "Failed tests:"; \
169             surfaces=""; \
170             for t in $$FAILED_TESTS; do \
171                 name="$${t##output/}"; name="$${name%.log}"; \
172                 echo -n "     $$name: "; \
173                 grep -e '\<FAIL\>' $$t | sed -e 's/.*TARGET: \([^ ]*\).*/\1/' | sort | uniq | tr '\n' ' '; \
174                 echo; \
175                 for s in `grep -e '\<FAIL\>' $$t | sed -e 's/.*TARGET: \([^ ]*\).*/\1/' | sort | uniq`; do \
176                     ss=`echo $$s | tr '-' '_'`; \
177                     tt=`echo $$name | tr '-' '_'`; \
178                     eval $$ss=\""$${!ss} $$tt"\"; \
179                     echo $$surfaces | grep $$ss >/dev/null || surfaces="$$surfaces $$ss"; \
180                 done; \
181             done; \
182             echo -n "Failures per surface - "; \
183             first=""; \
184             for s in $$surfaces; do \
185                 ss=`echo $$s | tr '_' '-'`; \
186                 test -n "$$first" && echo -n ", "; \
187                 cnt=`echo $${!s} | wc -w`; \
188                 echo -n "$$ss: $$cnt"; \
189                 first="false"; \
190             done; \
191             echo "."; \
192             for s in $$surfaces; do \
193                 ss=`echo $$s | tr '_' '-'`; \
194                 cnt=`echo $${!s} | wc -w`; \
195                 echo -n "       $$ss [$$cnt]: "; \
196                 echo $${!s} | tr '_' '-'; \
197             done; \
198         fi
199
200 AM_CPPFLAGS =                                   \
201         -I$(srcdir)                             \
202         -I$(srcdir)/pdiff                       \
203         -I$(top_srcdir)/boilerplate             \
204         -I$(top_srcdir)/util/cairo-missing      \
205         -I$(top_srcdir)/util/cairo-script       \
206         -I$(top_srcdir)/src                     \
207         -I$(top_builddir)/src                   \
208         $(CAIRO_CFLAGS)
209 AM_LDFLAGS = $(CAIRO_LDFLAGS)
210
211 $(top_builddir)/boilerplate/libcairoboilerplate.la: $(top_builddir)/src/libcairo.la
212         cd $(top_builddir)/boilerplate && $(MAKE) $(AM_MAKEFLAGS) libcairoboilerplate.la
213
214 $(top_builddir)/src/libcairo.la:
215         cd $(top_builddir)/src && $(MAKE) $(AM_MAKEFLAGS) libcairo.la
216
217 $(top_builddir)/test/pdiff/libpdiff.la:
218         cd $(top_builddir)/test/pdiff && $(MAKE) $(AM_MAKEFLAGS) libpdiff.la
219
220 $(top_builddir)/test/pdiff/perceptualdiff:
221         cd $(top_builddir)/test/pdiff && $(MAKE) $(AM_MAKEFLAGS) perceptualdiff
222
223 $(top_builddir)/util/cairo-script/libcairo-script-interpreter.la: $(top_builddir)/src/libcairo.la
224         cd $(top_builddir)/util/cairo-script && $(MAKE) $(AM_MAKEFLAGS) libcairo-script-interpreter.la
225
226 EXTRA_PROGRAMS += imagediff png-flatten
227
228 imagediff_SOURCES = \
229         imagediff.c     \
230         buffer-diff.c   \
231         buffer-diff.h
232 imagediff_LDADD = \
233         $(top_builddir)/test/pdiff/libpdiff.la \
234         $(top_builddir)/src/libcairo.la
235
236 png_flatten_SOURCES = png-flatten.c
237 png_flatten_LDADD = $(top_builddir)/src/libcairo.la \
238                     $(CAIRO_LDADD)
239
240 if BUILD_ANY2PPM
241 check_PROGRAMS += any2ppm
242 any2ppm_CFLAGS = $(AM_CFLAGS) $(POPPLER_CFLAGS) $(LIBRSVG_CFLAGS) $(LIBSPECTRE_CFLAGS)
243 # add LDADD, so poppler/librsvg uses "our" cairo
244 any2ppm_LDFLAGS = $(AM_LDFLAGS) $(CAIRO_TEST_UNDEFINED_LDFLAGS)
245 any2ppm_LDADD = \
246                 $(top_builddir)/util/cairo-script/libcairo-script-interpreter.la \
247                 $(top_builddir)/src/libcairo.la \
248                 $(CAIRO_LDADD) \
249                 $(CAIROBOILERPLATE_LIBS) \
250                 $(POPPLER_LIBS) \
251                 $(LIBRSVG_LIBS) \
252                 $(LIBSPECTRE_LIBS)
253 endif
254
255 if CAIRO_CAN_TEST_PDF_SURFACE
256 check_PROGRAMS += pdf2png
257 pdf2png_CFLAGS = $(AM_CFLAGS) $(POPPLER_CFLAGS)
258 # add LDADD, so poppler uses "our" cairo
259 pdf2png_LDFLAGS = $(AM_LDFLAGS) $(CAIRO_TEST_UNDEFINED_LDFLAGS)
260 pdf2png_LDADD  = $(top_builddir)/src/libcairo.la \
261                  $(CAIRO_LDADD) \
262                  $(POPPLER_LIBS)
263 endif
264
265 if CAIRO_CAN_TEST_SVG_SURFACE
266 check_PROGRAMS += svg2png
267 svg2png_CFLAGS = $(AM_CFLAGS) $(LIBRSVG_CFLAGS)
268 # add LDADD, so librsvg uses "our" cairo
269 svg2png_LDFLAGS = $(AM_LDFLAGS) $(CAIRO_TEST_UNDEFINED_LDFLAGS)
270 svg2png_LDADD  = $(top_builddir)/src/libcairo.la \
271                  $(CAIRO_LDADD) \
272                  $(LIBRSVG_LIBS)
273 endif
274
275 if CAIRO_HAS_SPECTRE
276 check_PROGRAMS += ps2png
277 ps2png_CFLAGS = $(AM_CFLAGS) $(LIBSPECTRE_CFLAGS)
278 # add LDADD, so ps2png uses "our" cairo
279 ps2png_LDFLAGS = $(AM_LDFLAGS) $(CAIRO_TEST_UNDEFINED_LDFLAGS)
280 ps2png_LDADD  = $(top_builddir)/src/libcairo.la \
281                 $(CAIRO_LDADD) \
282                 $(LIBSPECTRE_LIBS)
283 endif
284
285 EXTRA_PROGRAMS += $(TESTS)
286
287 # Do a funny transition of CAIRO_TEST_TARGET through TARGETS such that
288 # one can limit tested targets both through CAIRO_TEST_TARGET env var
289 # and TARGETS make var on the command line.  Same for the rest.
290 TARGETS = $(CAIRO_TEST_TARGET)
291 TARGETS_EXCLUDE = $(CAIRO_TEST_TARGET_EXCLUDE)
292 FORMAT = $(CAIRO_TEST_TARGET_FORMAT)
293 NUM_THREADS = $(CAIRO_TEST_NUM_THREADS)
294 MODE = $(CAIRO_TEST_MODE)
295
296 # Same about ENV vs CAIRO_TEST_ENV.  ENV is used with "make run" only
297 ENV = $(CAIRO_TEST_ENV)
298
299 TESTS_ENVIRONMENT = CAIRO_TEST_MODE="$(MODE)" CAIRO_TEST_TARGET="$(TARGETS)" CAIRO_TEST_TARGET_FORMAT="$(FORMAT)" CAIRO_TEST_TARGET_EXCLUDE="$(TARGETS_EXCLUDE)" CAIRO_TEST_NUM_THREADS="$(NUM_THREADS)" $(ENV)
300
301 EXTRA_VALGRIND_FLAGS = $(CAIRO_EXTRA_VALGRIND_FLAGS)
302 VALGRIND_FLAGS = \
303         --tool=memcheck --suppressions=$(srcdir)/.valgrind-suppressions \
304         --track-origins=yes \
305         --leak-check=yes --show-reachable=yes \
306         $(EXTRA_VALGRIND_FLAGS)
307
308 CLEANFILES +=                                   \
309         valgrind-log                            \
310         ref.hash                                \
311         ref.list                                \
312         png-test.png                            \
313         png.out.png                             \
314         create-for-stream.pdf                   \
315         create-for-stream.ps                    \
316         create-for-stream.svg                   \
317         svg-surface-source.out.svg              \
318         pdf-surface-source.out.pdf              \
319         ps-surface-source.out.ps                \
320         pdf-features.pdf                        \
321         pdf-mime-data.out*                      \
322         ps-features.ps                          \
323         svg-clip.svg                            \
324         svg-surface.svg                         \
325         multi-page.pdf                          \
326         multi-page.ps                           \
327         $(NULL)
328
329 # This used to be a simple 'echo ${RM} *.ps *.pdf *.svg *.etc', but
330 # most systems cannot handle all of our clean files together.
331 # Then it became a fancy find using many GNU extensions, but then the ugly
332 # reality of portability was raised and it became....
333 clean-local:
334         rm -rf output
335         -${FIND} . -name '*.log'      -print | ${XARGS} ${RM}
336         -${FIND} . -name '*.[is]'     -print | ${XARGS} ${RM}
337 clean-caches:
338         -${FIND} output -name '*.fail.*' -print | ${XARGS} ${RM}
339         -${FIND} output -name '*.pass.*' -print | ${XARGS} ${RM}
340
341 # The following definitions both should work.
342 #FAILED_TESTS = `grep -l '\<FAIL\>' $(test_sources:.c=.log) 2>/dev/null | sed -e 's/[.]log$$//' | xargs echo`
343 FAILED_TESTS = `grep -l '\<FAIL\>' $(test_sources:.c=.log) 2>/dev/null | tr '\n' ' ' | sed -e 's/[.]log  */ /g; s/^ //; s/ $$//'`
344
345 recheck = check CAIRO_TESTS="$(FAILED_TESTS)"
346
347 # Re-checks all failed tests, i.e. tests with a log file that has a failure
348 recheck:
349         @echo Re-checking failed tests
350         @$(MAKE) $(AM_MAKEFLAGS) $(recheck)
351
352 # Checks tests.
353 # Target doesn't fail if tests fail.
354 test:
355         @$(MAKE) $(AM_MAKEFLAGS) check
356
357 # Re-checks tests.
358 # Target doesn't fail if tests fail.
359 retest:
360         @CAIRO_TESTS="$(FAILED_TESTS)"; \
361         $(MAKE) $(AM_MAKEFLAGS) check
362
363 # Run tests under a tool specified by TOOL.  For example, make run TOOL=gdb
364 run:
365         $(MAKE) $(AM_MAKEFLAGS) check TESTS_ENVIRONMENT='$(TESTS_ENVIRONMENT) $(top_builddir)/libtool --mode=execute env $(TOOL)'
366
367 # Check tests under valgrind.  Saves log to valgrind-log
368 check-valgrind:
369         $(MAKE) $(AM_MAKEFLAGS) check TESTS_ENVIRONMENT='$(TESTS_ENVIRONMENT) CAIRO_TEST_MODE="$(MODE),foreground CAIRO_TEST_TIMEOUT=0" $(top_builddir)/libtool --mode=execute valgrind $(VALGRIND_FLAGS)' 2>&1 | tee valgrind-log
370
371 #%.log: %.c cairo-test-suite
372 #-./cairo-test-suite $(<:.c=)
373
374 NOLOG_TESTS_LOG = $(NOLOG_TESTS:=.log)
375
376 $(NOLOG_TESTS_LOG):
377         @echo dummy > $@
378
379 # Identify identical reference images
380 check-ref-dups: check-refs.sh $(top_builddir)/test/pdiff/perceptualdiff
381         sh $(srcdir)/check-refs.sh $(top_builddir)/test/pdiff/perceptualdiff
382
383 # Remove identical reference images (DANGEROUS)
384 clean-ref-dups: check-refs.sh $(top_builddir)/test/pdiff/perceptualdiff
385         sh $(srcdir)/check-refs.sh | cut -d' ' -f2 | while read f; do git rm "reference/$$f"; done
386
387 results.tar:
388         @tar cf $@ index.html testtable.js *.log output/*.log; \
389         for i in output/*.fail.png ; do \
390                 testname=$${i#output/} ; \
391                 testname=$${testname%%.*} ; \
392                 echo tar uf $@ reference/$${testname}*.ref.png $${i%fail.png}out.png $${i%fail.png}diff.png ; \
393                 tar uf $@ reference/$${testname}*.ref.png $${i%fail.png}out.png $${i%fail.png}diff.png ; \
394         done
395
396 results.tar.gz: results.tar
397         gzip -c $< > $@
398
399 release-verify-sane-tests:
400
401 .PHONY: check-valgrind test recheck retest check-ref-dups release-verify-sane-tests
402
403 EXTRA_DIST += Makefile.win32