README 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. Regression test suite for cairo.
  2. How to use cairo's test suite
  3. =============================
  4. Using this test should be as simple as running:
  5. make test
  6. assuming that the cairo distribution in the directory above has been
  7. configured and built. The test suite here goes through some effort to
  8. run against the locally compiled library rather than any installed
  9. version, but those efforts may fall short depending on the level of your
  10. libtool madness.
  11. The results of the test suite run are summarized in an index.html
  12. file, which, when viewed in a web browser makes it quite easy to
  13. visually see any failed renderings alongside the corresponding
  14. reference image, (and a diff image as well).
  15. The test suite needs to be run before any code is committed and before
  16. any release. See below for hints and rules governing the use of the suite.
  17. The test suite is built as a single binary, which allows you to choose
  18. individual or categories of tests to run. For example, if you want to
  19. run all text related tests you can use:
  20. ./cairo-test-suite text
  21. Or if you want to check the current status of known failures:
  22. ./cairo-test-suite XFAIL
  23. Or to run a subset of tests, use the -k option to run only the tests
  24. that include the given keyword:
  25. ./cairo-test-suite -k downscale
  26. The binary also permits controlling which backend is used via the
  27. CAIRO_TEST_TARGET environment variable, so for instance:
  28. CAIRO_TEST_TARGET=gl ./cairo-test-suite -k blur
  29. This binary should be backwards-compatible with all library versions,
  30. allowing you to compare current versus past behaviour for any test.
  31. Tailoring tests running
  32. -----------------------
  33. There are some mechanisms to limit the tests run during "make test".
  34. These come very handy when doing development, but should not be used
  35. to circumvent the "pass" requirements listed below.
  36. make's TARGETS environment variable can be used to limit the backends when
  37. running the tests. It should contain a (space-, comma-separated) list of
  38. backends. CAIRO_TESTS environment variable, which is a comma-, space-seperated
  39. lists, can be used to limit the tests run.
  40. For example:
  41. CAIRO_TESTS="zero-alpha" make test TARGETS=image,ps
  42. make's FORMAT variable can also be used to limit the content formats when
  43. running the tests. It should contain a (space-, comma-separated) list of
  44. content formats to test.
  45. For example:
  46. CAIRO_TESTS="zero-alpha" make test TARGETS=image,ps FORMAT="rgb,rgba"
  47. Another very handy mechanism when trying to fix bugs is:
  48. make retest
  49. This will re-run the test suite, but only on tests that failed on the
  50. last run. So this is a much faster way of checking if changes actually
  51. fix bugs rather than running the entire test suite again.
  52. The test suite first compares the output from the current run against the
  53. previous in order to skip more expensive image comparisons . If you think
  54. this is interfering with the results, you can clear the cached results using:
  55. make clean-caches
  56. Running tests under modified environments or tools
  57. -------------------------------------------------
  58. To run tests under a tool like gdb, one can use the run target and
  59. the TOOL variable. For example:
  60. CAIRO_TESTS=user-font make run TOOL=gdb TARGETS=pdf
  61. If you want to run under valgrind, there is a specific target for that
  62. that also sets a bunch of useful valgrind options. Try:
  63. CAIRO_TESTS=user-font make check-valgrind
  64. You can run tests under a modified environment you can use the ENV
  65. make variable. However, that environment will also affect the libtool
  66. wrapper of the tests. To only affect the actual test binaries, pass
  67. such environment as TOOL:
  68. CAIRO_TESTS=user-font make run TOOL="LD_PRELOAD=/path/to/something.so"
  69. Getting the elusive zero failures
  70. ---------------------------------
  71. It's generally been very difficult to achieve a test run with zero
  72. failures. The difficulties stem from the various versions of the many
  73. libraries that the test suite depends on, (it depends on a lot more
  74. than cairo itself), as well as fonts and other system-specific
  75. settings. If your system differs significantly from the system on
  76. which the reference images were generated, then you will likely see
  77. the test suite reporting "failures", (even if cairo is working just
  78. fine).
  79. We are constantly working to reduce the number of variables that need
  80. to be tweaked to get a clean run, (for example, by bundling fonts with
  81. the test suite itself), and also working to more carefully document
  82. the software configuration used to generate the reference images.
  83. Here are some of the relevant details:
  84. * Your system must have a copy of the DejaVu font, the sha1sum of
  85. the version used are listed in [...]. These are
  86. "DejaVu Sans" (DejaVuSans.ttf) [1cd336329f45f241002ded61893d91e3acd04436];
  87. "DejaVu Sans Mono" (DejaVuSansMono.ttf) [0458c0f0fb57f3eb8ced62f26fe7c5ed4e6a9a68];
  88. "DejaVu Serif" (DejaVuSerif.ttf) [93502d0d0445d1fe1c9f51e51b3e0169266346ce];
  89. [the DejaVu fonts can be installed from the ttf-dejavu 2.33-2 Debian package]
  90. and also
  91. "Nimbus Sans L" (n019003l.pfb)
  92. [which can be found in the gsfonts Debian package].
  93. * Currently, you must be using a build of cairo using freetype
  94. (cairo-ft) as the default font backend. Otherwise all tests
  95. involving text are likely to fail.
  96. * To test the pdf backend, you will want the very latest version of
  97. poppler as made available via git:
  98. git clone git://anongit.freedesktop.org/git/poppler/poppler
  99. As of this writing, no released version of poppler contains all
  100. the fixes you will need to avoid false negatives from the test
  101. suite.
  102. * To test the ps backend, you will need ghostscript version 9.04.
  103. * Testing the xlib backend is problematic since many X server
  104. drivers have bugs that are exercised by the test suite. (Or, if
  105. not actual bugs, differ slightly in their output in such a way
  106. that the test suite will report errors.) This can be quite handy
  107. if you want to debug an X server driver, but since most people
  108. don't want to do that, another option is to run against a headless
  109. X server that uses only software for all rendering. One such X
  110. server is Xvfb which can be started like this:
  111. Xvfb -screen 0 1680x1024x24 -ac -nolisten tcp :2
  112. after which the test suite can be run against it like so:
  113. DISPLAY=:2 make test
  114. We have been using Xvfb for testing cairo releases and ensuring
  115. that all tests behave as expected with this X server.
  116. What if I can't make my system match?
  117. -------------------------------------
  118. For one reason or another, you may be unable to get a clean run of the
  119. test suite even if cairo is working properly, (for example, you might
  120. be on a system without freetype). In this case, it's still useful to
  121. be able to determine if code changes you make to cairo result in any
  122. regressions to the test suite. But it's hard to notice regressions if
  123. there are many failures both before and after your changes.
  124. For this scenario, you can capture the output of a run of the test
  125. suite before your changes, and then use the CAIRO_REF_DIR environment
  126. variable to use that output as the reference images for a run after
  127. your changes. The process looks like this:
  128. # Before code change there may be failures we don't care about
  129. make test
  130. # Let's save those output images
  131. mkdir /some/directory/
  132. cp -r test/output /some/directory/
  133. # hack, hack, hack
  134. # Now to see if nothing changed:
  135. CAIRO_REF_DIR=/some/directory/ make test
  136. Best practices for cairo developers
  137. ===================================
  138. If we all follow the guidelines below, then both the test suite and
  139. cairo itself will stay much healthier, and we'll all have a lot more
  140. fun hacking on cairo.
  141. Before committing
  142. -----------------
  143. All tests should return a result of PASS or XFAIL. The XFAIL results
  144. indicate known bugs. The final message should be one of the following:
  145. All XX tests behaved as expected (YY expected failures)
  146. All XX tests passed
  147. If any tests have a status of FAIL, then the new code has caused a
  148. regression error which should be fixed before the code is committed.
  149. When a new bug is found
  150. -----------------------
  151. A new test case should be added by imitating the style of an existing
  152. test. This means adding the following files:
  153. new-bug.c
  154. reference/new-bug.ref.png
  155. reference/new-bug.xfail.png
  156. Where new-bug.c is a minimal program to demonstrate the bug, following
  157. the style of existing tests. The new-bug.ref.png image should contain
  158. the desired result of new-bug.c if the bug were fixed while
  159. new-bug.xfail.png contains the current results of the test.
  160. Makefile.sources should be edited by adding new-bug.c to test_sources.
  161. And last but not least, don't forget to "git add" the new files.
  162. When a new feature is added
  163. ---------------------------
  164. It's important for the regression suite to keep pace with development
  165. of the library. So a new test should be added for each new feature.
  166. The work involved is similar the work described above for new bugs.
  167. The only distinction is that the test is expected to pass so it
  168. should not need a new-bug.xfail.png file.
  169. While working on a test
  170. -----------------------
  171. Before a bugfix or feature is ready, it may be useful to compare
  172. output from different builds. For convenience, you can set
  173. CAIRO_REF_DIR to point at a previous test directory, relative
  174. to the current test directory, and any previous output will be
  175. used by preference as reference images.
  176. When a bug is fixed
  177. -------------------
  178. The fix should be verified by running the test suite which should
  179. result in an "unexpected pass" for the test of interest. Rejoice as
  180. appropriate, then remove the relevant xfail.png file from git.
  181. Before releasing
  182. ----------------
  183. All tests should return a result of PASS for all supported (those enabled by
  184. default) backends, meaning all known bugs are fixed, resulting in the happy
  185. message:
  186. All XX tests passed
  187. Some notes on limitations in poppler
  188. ====================================
  189. One of the difficulties of our current test infrastructure is that we
  190. rely on external tools to convert cairo's vector output (PDF,
  191. PostScript, and SVG), into an image that can be used for the image
  192. comparison. This means that any bugs in that conversion tool will
  193. result in false negatives in the test suite.
  194. We've identified several such bugs in the poppler library which is
  195. used to convert PDF to an image. This is particularly discouraging
  196. because 1) poppler is free software that will be used by *many* cairo
  197. users, and 2) poppler calls into cairo for its rendering so it should
  198. be able to do a 100% faithful conversion.
  199. So we have an interest in ensuring that these poppler bugs get fixed
  200. sooner rather than later. As such, we're trying to be good citizens by
  201. reporting all such poppler bugs that we identify to the poppler
  202. bugzilla. Here's a tracking bug explaining the situation:
  203. Poppler does not yet handle everything in the cairo test suite
  204. https://bugs.freedesktop.org/show_bug.cgi?id=12143
  205. Here's the rule: If a cairo-pdf test reports a failure, but viewing
  206. the resulting PDF file with acroread suggests that the PDF itself is
  207. correct, then there's likely a bug in poppler. In this case, we can
  208. simply report the poppler bug, (making it block 12143 above), post the
  209. PDF result from the test suite, and list the bug in this file. Once
  210. we've done this, we can capture poppler's buggy output as a
  211. pdf-specific reference image (as reference/*.xfail.png) so that the
  212. test suite will regard the test as passing, (and we'll ensure there
  213. is no regression).
  214. Once the poppler bug gets fixed, the test suite will start reporting a
  215. false negative again, and this will be easy to fix by simply removing
  216. the pdf-specific reference image.
  217. Here are the reported poppler bugs and the tests they affect:
  218. Poppler doesn't correctly handle gradients with transparency
  219. https://bugs.freedesktop.org/show_bug.cgi?id=12144
  220. --------------------------------------------------
  221. fill-alpha-pattern
  222. gradient-alpha
  223. gradient-constant-alpha
  224. linear-gradient
  225. linear-gradient-reflect
  226. radial-gradient
  227. trap-clip
  228. Poppler should paint images with CAIRO_EXTEND_PAD
  229. https://bugs.freedesktop.org/show_bug.cgi?id=14578
  230. --------------------------------------------------
  231. paint-source-alpha
  232. paint-with-alpha
  233. rotate-image-surface-paint
  234. scale-source-surface-paint
  235. Incorrect clipping of group object (regression?)
  236. https://bugs.freedesktop.org/show_bug.cgi?id=14580
  237. --------------------------------------------------
  238. push-group
  239. spurious horizontal stripes in color gradients
  240. https://bugs.freedesktop.org/show_bug.cgi?id=10942
  241. --------------------------------------------------
  242. smask
  243. smask-fill
  244. smask-image-mask
  245. smask-mask
  246. smask-paint
  247. smask-stroke
  248. smask-text
  249. Ghostscript does not correctly render small miters
  250. http://bugs.ghostscript.com/show_bug.cgi?id=690098
  251. --------------------------------------------------
  252. miter-precision