test-suite.rst 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. .. _test-suite:
  2. ==============================================================================
  3. libinput test suite
  4. ==============================================================================
  5. libinput's primary test suite can be invoked with
  6. ::
  7. $ sudo ./builddir/libinput-test-suite
  8. When developing libinput, the ``libinput-test-suite`` should always be
  9. run to check for behavior changes and/or regressions. For quick iteration,
  10. the number of tests to run can be filtered, see :ref:`test-filtering`.
  11. This allows for developers to verify a subset of tests (e.g.
  12. touchpad tap-to-click) while hacking on that specific feature and only run
  13. the full suite when development is finished.
  14. .. note:: The test suite relies on udev and the kernel, specifically uinput.
  15. It creates virtual input devices and replays the events. This may
  16. interfere with your running session. The test suite is not suitable
  17. for running inside containers.
  18. In addition, libinput ships with a set of (primarily janitorial) tests that
  19. must pass for any merge request. These tests are invoked by calling
  20. ``meson test -C builddir`` (or ``ninja test``). The ``libinput-test-suite`` is
  21. part of that test set by default.
  22. The upstream CI runs all these tests and is run for every merge request.
  23. .. _test-job-control:
  24. ------------------------------------------------------------------------------
  25. Job control in the test suite
  26. ------------------------------------------------------------------------------
  27. The test suite runner has a make-like job control enabled by the ``-j`` or
  28. ``--jobs`` flag and will fork off as many parallel processes as given by this
  29. flag. The default if unspecified is 8. When debugging a specific test case
  30. failure it is recommended to employ test filters (see :ref:`test-filtering`)
  31. and disable parallel tests. The test suite automatically disables parallel
  32. make when run in gdb.
  33. .. _test-config:
  34. ------------------------------------------------------------------------------
  35. X.Org config to avoid interference
  36. ------------------------------------------------------------------------------
  37. uinput devices created by the test suite are usually recognised by X as
  38. input devices. All events sent through these devices will generate X events
  39. and interfere with your desktop.
  40. Copy the file ``$srcdir/test/50-litest.conf`` into your ``/etc/X11/xorg.conf.d``
  41. and restart X. This will ignore any litest devices and thus not interfere
  42. with your desktop.
  43. .. _test-root:
  44. ------------------------------------------------------------------------------
  45. Permissions required to run tests
  46. ------------------------------------------------------------------------------
  47. Most tests require the creation of uinput devices and access to the
  48. resulting ``/dev/input/eventX`` nodes. Some tests require temporary udev rules.
  49. **This usually requires the tests to be run as root**. If not run as
  50. root, the test suite runner will exit with status 77, an exit status
  51. interpreted as "skipped".
  52. .. _test-filtering:
  53. ------------------------------------------------------------------------------
  54. Selective running of tests
  55. ------------------------------------------------------------------------------
  56. litest's tests are grouped into test groups, test names and devices. A test
  57. group is e.g. "touchpad:tap" and incorporates all tapping-related tests for
  58. touchpads. Each test function is (usually) run with one or more specific
  59. devices. The ``--list`` commandline argument shows the list of suites and
  60. tests. This is useful when trying to figure out if a specific test is
  61. run for a device.
  62. ::
  63. $ ./builddir/libinput-test-suite --list
  64. ...
  65. pointer:left-handed:
  66. pointer_left_handed_during_click_multiple_buttons:
  67. trackpoint
  68. ms-surface-cover
  69. mouse-wheelclickcount
  70. mouse-wheelclickangle
  71. low-dpi-mouse
  72. mouse-roccat
  73. mouse-wheel-tilt
  74. mouse
  75. logitech-trackball
  76. cyborg-rat
  77. magicmouse
  78. pointer_left_handed_during_click:
  79. trackpoint
  80. ms-surface-cover
  81. mouse-wheelclickcount
  82. mouse-wheelclickangle
  83. low-dpi-mouse
  84. mouse-roccat
  85. mouse-wheel-tilt
  86. mouse
  87. logitech-trackball
  88. cyborg-rat
  89. litest-magicmouse-device
  90. pointer_left_handed:
  91. trackpoint
  92. ms-surface-cover
  93. mouse-wheelclickcount
  94. mouse-wheelclickangle
  95. low-dpi-mouse
  96. mouse-roccat
  97. mouse-wheel-tilt
  98. mouse
  99. ...
  100. In the above example, the "pointer:left-handed" suite contains multiple
  101. tests, e.g. "pointer_left_handed_during_click" (this is also the function
  102. name of the test, making it easy to grep for). This particular test is run
  103. for various devices including the trackpoint device and the magic mouse
  104. device.
  105. The "no device" entry signals that litest does not instantiate a uinput
  106. device for a specific test (though the test itself may
  107. instantiate one).
  108. The ``--filter-test`` argument enables selective running of tests through
  109. basic shell-style function name matching. For example:
  110. ::
  111. $ ./builddir/libinput-test-suite --filter-test="*1fg_tap*"
  112. The ``--filter-device`` argument enables selective running of tests through
  113. basic shell-style device name matching. The device names matched are the
  114. litest-specific shortnames, see the output of ``--list``. For example:
  115. ::
  116. $ ./builddir/libinput-test-suite --filter-device="synaptics*"
  117. The ``--filter-group`` argument enables selective running of test groups
  118. through basic shell-style test group matching. The test groups matched are
  119. litest-specific test groups, see the output of ``--list``. For example:
  120. ::
  121. $ ./builddir/libinput-test-suite --filter-group="touchpad:*hover*"
  122. The ``--filter-device`` and ``--filter-group`` arguments can be combined with
  123. ``--list`` to show which groups and devices will be affected.
  124. .. _test-verbosity:
  125. ------------------------------------------------------------------------------
  126. Controlling test output
  127. ------------------------------------------------------------------------------
  128. Each test supports the ``--verbose`` commandline option to enable debugging
  129. output, see **libinput_log_set_priority()** for details. The ``LITEST_VERBOSE``
  130. environment variable, if set, also enables verbose mode.
  131. ::
  132. $ ./builddir/libinput-test-suite --verbose
  133. $ LITEST_VERBOSE=1 meson test -C builddir
  134. .. _test-installed:
  135. ------------------------------------------------------------------------------
  136. Installing the test suite
  137. ------------------------------------------------------------------------------
  138. If libinput is configured to install the tests, the test suite is available
  139. as the ``libinput test-suite`` command. When run as installed binary, the
  140. behavior of the test suite changes:
  141. - the ``libinput.so`` used is the one in the library lookup paths
  142. - no system-wide quirks are installed by the test suite, only those specific
  143. to the test devices
  144. - test device-specific quirks are installed in the system-wide quirks
  145. directory, usually ``/usr/share/libinput/``.
  146. It is not advisable to run ``libinput test-suite`` on a production machine.
  147. Data loss may occur. The primary use-case for the installed test suite is
  148. verification of distribution composes.
  149. .. note:: The ``prefix`` is still used by the test suite. For verification
  150. of a system package, the test suite must be configured with the same prefix.
  151. To configure libinput to install the tests, use the ``-Dinstall-tests=true``
  152. meson option::
  153. $ meson setup builddir -Dtests=true -Dinstall-tests=true <other options>
  154. .. _test-meson-suites:
  155. ------------------------------------------------------------------------------
  156. Meson test suites
  157. ------------------------------------------------------------------------------
  158. This section is primarily of interest to distributors that want to run test
  159. or developers working on libinput's CI.
  160. Tests invoked by ``meson test`` are grouped into test suites, the test suite
  161. names identify when the respective test can be run:
  162. - ``valgrind``: tests that can be run under valgrind (in addition to a
  163. normal run)
  164. - ``root``: tests that must be run as root
  165. - ``hardware``: tests that require a VM or physical machine
  166. - ``all``: all tests, only needed because of
  167. `meson bug 5340 <https://github.com/mesonbuild/meson/issues/5340>`_
  168. The suite names can be provided as filters to ``meson test
  169. --suite=<suitename>`` or ``meson test --no-suite=<suitename>``.
  170. For example, if running a container-based CI, you may specify the test
  171. suites as:
  172. ::
  173. $ meson test --no-suite=hardware # only run container-friendly tests
  174. $ meson test --suite=valgrind --setup=valgrind # run all valgrind-compatible tests
  175. $ meson test --no-suite=root # run all tests not requiring root
  176. These suites are subject to change at any time.