Makefile.am 12 KB

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