xref: /qemu/docs/devel/testing/functional.rst (revision 2f418cc9915284cb8eb7d607ec70fe13fe55ce5c)
1c3e24cffSThomas Huth.. _checkfunctional-ref:
2c3e24cffSThomas Huth
3c3e24cffSThomas HuthFunctional testing with Python
4c3e24cffSThomas Huth==============================
5c3e24cffSThomas Huth
6c3e24cffSThomas HuthThe ``tests/functional`` directory hosts functional tests written in
7c3e24cffSThomas HuthPython. They are usually higher level tests, and may interact with
8c3e24cffSThomas Huthexternal resources and with various guest operating systems.
9c3e24cffSThomas Huth
10c3e24cffSThomas HuthThe tests should be written in the style of the Python `unittest`_ framework,
11c3e24cffSThomas Huthusing stdio for the TAP protocol. The folder ``tests/functional/qemu_test``
12c3e24cffSThomas Huthprovides classes (e.g. the ``QemuBaseTest``, ``QemuUserTest`` and the
13c3e24cffSThomas Huth``QemuSystemTest`` classes) and utility functions that help to get your test
14c3e24cffSThomas Huthinto the right shape, e.g. by replacing the 'stdout' python object to redirect
15c3e24cffSThomas Huththe normal output of your test to stderr instead.
16c3e24cffSThomas Huth
17c3e24cffSThomas HuthNote that if you don't use one of the QemuBaseTest based classes for your
18c3e24cffSThomas Huthtest, or if you spawn subprocesses from your test, you have to make sure
19c3e24cffSThomas Huththat there is no TAP-incompatible output written to stdio, e.g. either by
20c3e24cffSThomas Huthprefixing every line with a "# " to mark the output as a TAP comment, or
21c3e24cffSThomas Huthe.g. by capturing the stdout output of subprocesses (redirecting it to
22c3e24cffSThomas Huthstderr is OK).
23c3e24cffSThomas Huth
24c3e24cffSThomas HuthTests based on ``qemu_test.QemuSystemTest`` can easily:
25c3e24cffSThomas Huth
26c3e24cffSThomas Huth * Customize the command line arguments given to the convenience
27c3e24cffSThomas Huth   ``self.vm`` attribute (a QEMUMachine instance)
28c3e24cffSThomas Huth
29c3e24cffSThomas Huth * Interact with the QEMU monitor, send QMP commands and check
30c3e24cffSThomas Huth   their results
31c3e24cffSThomas Huth
32c3e24cffSThomas Huth * Interact with the guest OS, using the convenience console device
33c3e24cffSThomas Huth   (which may be useful to assert the effectiveness and correctness of
34c3e24cffSThomas Huth   command line arguments or QMP commands)
35c3e24cffSThomas Huth
36c3e24cffSThomas Huth * Download (and cache) remote data files, such as firmware and kernel
37c3e24cffSThomas Huth   images
38c3e24cffSThomas Huth
39c3e24cffSThomas HuthRunning tests
40c3e24cffSThomas Huth-------------
41c3e24cffSThomas Huth
42c3e24cffSThomas HuthYou can run the functional tests simply by executing:
43c3e24cffSThomas Huth
44c3e24cffSThomas Huth.. code::
45c3e24cffSThomas Huth
46c3e24cffSThomas Huth  make check-functional
47c3e24cffSThomas Huth
48c3e24cffSThomas HuthIt is also possible to run tests for a certain target only, for example
49c3e24cffSThomas Huththe following line will only run the tests for the x86_64 target:
50c3e24cffSThomas Huth
51c3e24cffSThomas Huth.. code::
52c3e24cffSThomas Huth
53c3e24cffSThomas Huth  make check-functional-x86_64
54c3e24cffSThomas Huth
55c3e24cffSThomas HuthTo run a single test file without the meson test runner, you can also
56c3e24cffSThomas Huthexecute the file directly by specifying two environment variables first,
57c3e24cffSThomas Huththe PYTHONPATH that has to include the python folder and the tests/functional
58c3e24cffSThomas Huthfolder of the source tree, and QEMU_TEST_QEMU_BINARY that has to point
594a722d2eSThomas Huthto the QEMU binary that should be used for the test. The current working
604a722d2eSThomas Huthdirectory should be your build folder. For example::
61c3e24cffSThomas Huth
62c3e24cffSThomas Huth  $ export PYTHONPATH=../python:../tests/functional
63c3e24cffSThomas Huth  $ export QEMU_TEST_QEMU_BINARY=$PWD/qemu-system-x86_64
644a722d2eSThomas Huth  $ pyvenv/bin/python3 ../tests/functional/test_file.py
65c3e24cffSThomas Huth
66dbaaef7dSDaniel P. BerrangéThe test framework will automatically purge any scratch files created during
67dbaaef7dSDaniel P. Berrangéthe tests. If needing to debug a failed test, it is possible to keep these
68dbaaef7dSDaniel P. Berrangéfiles around on disk by setting ```QEMU_TEST_KEEP_SCRATCH=1``` as an env
69dbaaef7dSDaniel P. Berrangévariable.  Any preserved files will be deleted the next time the test is run
70dbaaef7dSDaniel P. Berrangéwithout this variable set.
71dbaaef7dSDaniel P. Berrangé
72bcbd8c0eSThomas HuthLogging
73bcbd8c0eSThomas Huth-------
74bcbd8c0eSThomas Huth
75bcbd8c0eSThomas HuthThe framework collects log files for each test in the build directory
76bcbd8c0eSThomas Huthin the following subfolder::
77bcbd8c0eSThomas Huth
78bcbd8c0eSThomas Huth <builddir>/tests/functional/<arch>/<fileid>.<classid>.<testname>/
79bcbd8c0eSThomas Huth
80bcbd8c0eSThomas HuthThere are usually three log files:
81bcbd8c0eSThomas Huth
82bcbd8c0eSThomas Huth* ``base.log`` contains the generic logging information that is written
83bcbd8c0eSThomas Huth  by the calls to the logging functions in the test code (e.g. by calling
84bcbd8c0eSThomas Huth  the ``self.log.info()`` or ``self.log.debug()`` functions).
85bcbd8c0eSThomas Huth* ``console.log`` contains the output of the serial console of the guest.
86bcbd8c0eSThomas Huth* ``default.log`` contains the output of QEMU. This file could be named
87bcbd8c0eSThomas Huth  differently if the test chooses to use a different identifier for
88bcbd8c0eSThomas Huth  the guest VM (e.g. when the test spins up multiple VMs).
89bcbd8c0eSThomas Huth
90bcbd8c0eSThomas HuthIntroduction to writing tests
91bcbd8c0eSThomas Huth-----------------------------
92c3e24cffSThomas Huth
93c3e24cffSThomas HuthThe ``tests/functional/qemu_test`` directory provides the ``qemu_test``
94c3e24cffSThomas HuthPython module, containing the ``qemu_test.QemuSystemTest`` class.
95c3e24cffSThomas HuthHere is a simple usage example:
96c3e24cffSThomas Huth
97c3e24cffSThomas Huth.. code::
98c3e24cffSThomas Huth
99c3e24cffSThomas Huth  #!/usr/bin/env python3
100c3e24cffSThomas Huth
101c3e24cffSThomas Huth  from qemu_test import QemuSystemTest
102c3e24cffSThomas Huth
103c3e24cffSThomas Huth  class Version(QemuSystemTest):
104c3e24cffSThomas Huth
105c3e24cffSThomas Huth      def test_qmp_human_info_version(self):
106c3e24cffSThomas Huth          self.vm.launch()
107c3e24cffSThomas Huth          res = self.vm.cmd('human-monitor-command',
108c3e24cffSThomas Huth                            command_line='info version')
109c3e24cffSThomas Huth          self.assertRegex(res, r'^(\d+\.\d+\.\d)')
110c3e24cffSThomas Huth
111c3e24cffSThomas Huth  if __name__ == '__main__':
112c3e24cffSThomas Huth      QemuSystemTest.main()
113c3e24cffSThomas Huth
114c3e24cffSThomas HuthBy providing the "hash bang" line at the beginning of the script, marking
115c3e24cffSThomas Huththe file as executable and by calling into QemuSystemTest.main(), the test
116c3e24cffSThomas Huthcan also be run stand-alone, without a test runner. OTOH when run via a test
117c3e24cffSThomas Huthrunner, the QemuSystemTest.main() function takes care of running the test
118c3e24cffSThomas Huthfunctions in the right fassion (e.g. with TAP output that is required by the
119c3e24cffSThomas Huthmeson test runner).
120c3e24cffSThomas Huth
121c3e24cffSThomas HuthThe ``qemu_test.QemuSystemTest`` base test class
122c3e24cffSThomas Huth^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
123c3e24cffSThomas Huth
124c3e24cffSThomas HuthThe ``qemu_test.QemuSystemTest`` class has a number of characteristics
125c3e24cffSThomas Huththat are worth being mentioned.
126c3e24cffSThomas Huth
127c3e24cffSThomas HuthFirst of all, it attempts to give each test a ready to use QEMUMachine
128c3e24cffSThomas Huthinstance, available at ``self.vm``.  Because many tests will tweak the
129c3e24cffSThomas HuthQEMU command line, launching the QEMUMachine (by using ``self.vm.launch()``)
130c3e24cffSThomas Huthis left to the test writer.
131c3e24cffSThomas Huth
132c3e24cffSThomas HuthThe base test class has also support for tests with more than one
133c3e24cffSThomas HuthQEMUMachine. The way to get machines is through the ``self.get_vm()``
134c3e24cffSThomas Huthmethod which will return a QEMUMachine instance. The ``self.get_vm()``
135c3e24cffSThomas Huthmethod accepts arguments that will be passed to the QEMUMachine creation
136c3e24cffSThomas Huthand also an optional ``name`` attribute so you can identify a specific
137c3e24cffSThomas Huthmachine and get it more than once through the tests methods. A simple
138c3e24cffSThomas Huthand hypothetical example follows:
139c3e24cffSThomas Huth
140c3e24cffSThomas Huth.. code::
141c3e24cffSThomas Huth
142c3e24cffSThomas Huth  from qemu_test import QemuSystemTest
143c3e24cffSThomas Huth
144c3e24cffSThomas Huth  class MultipleMachines(QemuSystemTest):
145c3e24cffSThomas Huth      def test_multiple_machines(self):
146c3e24cffSThomas Huth          first_machine = self.get_vm()
147c3e24cffSThomas Huth          second_machine = self.get_vm()
148c3e24cffSThomas Huth          self.get_vm(name='third_machine').launch()
149c3e24cffSThomas Huth
150c3e24cffSThomas Huth          first_machine.launch()
151c3e24cffSThomas Huth          second_machine.launch()
152c3e24cffSThomas Huth
153c3e24cffSThomas Huth          first_res = first_machine.cmd(
154c3e24cffSThomas Huth              'human-monitor-command',
155c3e24cffSThomas Huth              command_line='info version')
156c3e24cffSThomas Huth
157c3e24cffSThomas Huth          second_res = second_machine.cmd(
158c3e24cffSThomas Huth              'human-monitor-command',
159c3e24cffSThomas Huth              command_line='info version')
160c3e24cffSThomas Huth
161c3e24cffSThomas Huth          third_res = self.get_vm(name='third_machine').cmd(
162c3e24cffSThomas Huth              'human-monitor-command',
163c3e24cffSThomas Huth              command_line='info version')
164c3e24cffSThomas Huth
165c3e24cffSThomas Huth          self.assertEqual(first_res, second_res, third_res)
166c3e24cffSThomas Huth
167c3e24cffSThomas HuthAt test "tear down", ``qemu_test.QemuSystemTest`` handles all the QEMUMachines
168c3e24cffSThomas Huthshutdown.
169c3e24cffSThomas Huth
170c3e24cffSThomas HuthQEMUMachine
171c3e24cffSThomas Huth-----------
172c3e24cffSThomas Huth
173c3e24cffSThomas HuthThe QEMUMachine API is already widely used in the Python iotests,
174c3e24cffSThomas Huthdevice-crash-test and other Python scripts.  It's a wrapper around the
175c3e24cffSThomas Huthexecution of a QEMU binary, giving its users:
176c3e24cffSThomas Huth
177c3e24cffSThomas Huth * the ability to set command line arguments to be given to the QEMU
178c3e24cffSThomas Huth   binary
179c3e24cffSThomas Huth
180c3e24cffSThomas Huth * a ready to use QMP connection and interface, which can be used to
181c3e24cffSThomas Huth   send commands and inspect its results, as well as asynchronous
182c3e24cffSThomas Huth   events
183c3e24cffSThomas Huth
184c3e24cffSThomas Huth * convenience methods to set commonly used command line arguments in
185c3e24cffSThomas Huth   a more succinct and intuitive way
186c3e24cffSThomas Huth
187c3e24cffSThomas HuthQEMU binary selection
188c3e24cffSThomas Huth^^^^^^^^^^^^^^^^^^^^^
189c3e24cffSThomas Huth
190c3e24cffSThomas HuthThe QEMU binary used for the ``self.vm`` QEMUMachine instance will
1918188356aSDaniel P. Berrangéprimarily depend on the value of the ``qemu_bin`` instance attribute.
192c3e24cffSThomas HuthIf it is not explicitly set by the test code, its default value will
193c3e24cffSThomas Huthbe the result the QEMU_TEST_QEMU_BINARY environment variable.
194c3e24cffSThomas Huth
1951a8755a5SDaniel P. BerrangéDebugging hung QEMU
1961a8755a5SDaniel P. Berrangé^^^^^^^^^^^^^^^^^^^
1971a8755a5SDaniel P. Berrangé
1981a8755a5SDaniel P. BerrangéWhen test cases go wrong it may be helpful to debug a stalled QEMU
1991a8755a5SDaniel P. Berrangéprocess. While the QEMUMachine class owns the primary QMP monitor
2001a8755a5SDaniel P. Berrangésocket, it is possible to request a second QMP monitor be created
2011a8755a5SDaniel P. Berrangéby setting the ``QEMU_TEST_QMP_BACKDOOR`` env variable to refer
2021a8755a5SDaniel P. Berrangéto a UNIX socket name. The ``qmp-shell`` command can then be
2031a8755a5SDaniel P. Berrangéattached to the stalled QEMU to examine its live state.
2041a8755a5SDaniel P. Berrangé
205c3e24cffSThomas HuthAttribute reference
206c3e24cffSThomas Huth-------------------
207c3e24cffSThomas Huth
208c3e24cffSThomas HuthQemuBaseTest
209c3e24cffSThomas Huth^^^^^^^^^^^^
210c3e24cffSThomas Huth
211c3e24cffSThomas HuthThe following attributes are available on any ``qemu_test.QemuBaseTest``
212c3e24cffSThomas Huthinstance.
213c3e24cffSThomas Huth
214c3e24cffSThomas Hutharch
215c3e24cffSThomas Huth""""
216c3e24cffSThomas Huth
217c3e24cffSThomas HuthThe target architecture of the QEMU binary.
218c3e24cffSThomas Huth
219c3e24cffSThomas HuthTests are also free to use this attribute value, for their own needs.
220c3e24cffSThomas HuthA test may, for instance, use this value when selecting the architecture
221c3e24cffSThomas Huthof a kernel or disk image to boot a VM with.
222c3e24cffSThomas Huth
223c3e24cffSThomas Huthqemu_bin
224c3e24cffSThomas Huth""""""""
225c3e24cffSThomas Huth
226c3e24cffSThomas HuthThe preserved value of the ``QEMU_TEST_QEMU_BINARY`` environment
227c3e24cffSThomas Huthvariable.
228c3e24cffSThomas Huth
229c3e24cffSThomas HuthQemuUserTest
230c3e24cffSThomas Huth^^^^^^^^^^^^
231c3e24cffSThomas Huth
232c3e24cffSThomas HuthThe QemuUserTest class can be used for running an executable via the
233c3e24cffSThomas Huthusermode emulation binaries.
234c3e24cffSThomas Huth
235c3e24cffSThomas HuthQemuSystemTest
236c3e24cffSThomas Huth^^^^^^^^^^^^^^
237c3e24cffSThomas Huth
238c3e24cffSThomas HuthThe QemuSystemTest class can be used for running tests via one of the
239c3e24cffSThomas Huthqemu-system-* binaries.
240c3e24cffSThomas Huth
241c3e24cffSThomas Huthvm
242c3e24cffSThomas Huth""
243c3e24cffSThomas Huth
244c3e24cffSThomas HuthA QEMUMachine instance, initially configured according to the given
245c3e24cffSThomas Huth``qemu_bin`` parameter.
246c3e24cffSThomas Huth
247c3e24cffSThomas Huthcpu
248c3e24cffSThomas Huth"""
249c3e24cffSThomas Huth
250c3e24cffSThomas HuthThe cpu model that will be set to all QEMUMachine instances created
251c3e24cffSThomas Huthby the test.
252c3e24cffSThomas Huth
253c3e24cffSThomas Huthmachine
254c3e24cffSThomas Huth"""""""
255c3e24cffSThomas Huth
256c3e24cffSThomas HuthThe machine type that will be set to all QEMUMachine instances created
257c3e24cffSThomas Huthby the test. By using the set_machine() function of the QemuSystemTest
258c3e24cffSThomas Huthclass to set this attribute, you can automatically check whether the
259c3e24cffSThomas Huthmachine is available to skip the test in case it is not built into the
260c3e24cffSThomas HuthQEMU binary.
261c3e24cffSThomas Huth
262c3e24cffSThomas HuthAsset handling
263c3e24cffSThomas Huth--------------
264c3e24cffSThomas Huth
265c3e24cffSThomas HuthMany functional tests download assets (e.g. Linux kernels, initrds,
266c3e24cffSThomas Huthfirmware images, etc.) from the internet to be able to run tests with
267c3e24cffSThomas Huththem. This imposes additional challenges to the test framework.
268c3e24cffSThomas Huth
269e7f091d0SAditya GuptaFirst there is the problem that some people might not have an
270c3e24cffSThomas Huthunconstrained internet connection, so such tests should not be run by
271c3e24cffSThomas Huthdefault when running ``make check``. To accomplish this situation,
272c3e24cffSThomas Huththe tests that download files should only be added to the "thorough"
273c3e24cffSThomas Huthspeed mode in the meson.build file, while the "quick" speed mode is
274c3e24cffSThomas Huthfine for functional tests that can be run without downloading files.
275c3e24cffSThomas Huth``make check`` then only runs the quick functional tests along with
276c3e24cffSThomas Huththe other quick tests from the other test suites. If you choose to
277*2f418cc9SGustavo Romerorun only ``make check-functional``, the "thorough" tests will be
278c3e24cffSThomas Huthexecuted, too. And to run all functional tests along with the others,
279c3e24cffSThomas Huthyou can use something like::
280c3e24cffSThomas Huth
281c3e24cffSThomas Huth  make -j$(nproc) check SPEED=thorough
282c3e24cffSThomas Huth
283c3e24cffSThomas HuthThe second problem with downloading files from the internet are time
284c3e24cffSThomas Huthconstraints. The time for downloading files should not be taken into
285c3e24cffSThomas Huthaccount when the test is running and the timeout of the test is ticking
286c3e24cffSThomas Huth(since downloading can be very slow, depending on the network bandwidth).
287c3e24cffSThomas HuthThis problem is solved by downloading the assets ahead of time, before
288c3e24cffSThomas Huththe tests are run. This pre-caching is done with the qemu_test.Asset
289c3e24cffSThomas Huthclass. To use it in your test, declare an asset in your test class with
290c3e24cffSThomas Huthits URL and SHA256 checksum like this::
291c3e24cffSThomas Huth
292e7f091d0SAditya Gupta    from qemu_test import Asset
293e7f091d0SAditya Gupta
294e7f091d0SAditya Gupta    ASSET_somename = Asset(
295c3e24cffSThomas Huth        ('https://www.qemu.org/assets/images/qemu_head_200.png'),
296c3e24cffSThomas Huth        '34b74cad46ea28a2966c1d04e102510daf1fd73e6582b6b74523940d5da029dd')
297c3e24cffSThomas Huth
298c3e24cffSThomas HuthIn your test function, you can then get the file name of the cached
299c3e24cffSThomas Huthasset like this::
300c3e24cffSThomas Huth
301c3e24cffSThomas Huth    def test_function(self):
302c3e24cffSThomas Huth        file_path = self.ASSET_somename.fetch()
303c3e24cffSThomas Huth
304c3e24cffSThomas HuthThe pre-caching will be done automatically when running
305c3e24cffSThomas Huth``make check-functional`` (but not when running e.g.
306c3e24cffSThomas Huth``make check-functional-<target>``). In case you just want to download
307c3e24cffSThomas Huththe assets without running the tests, you can do so by running::
308c3e24cffSThomas Huth
309c3e24cffSThomas Huth    make precache-functional
310c3e24cffSThomas Huth
311c3e24cffSThomas HuthThe cache is populated in the ``~/.cache/qemu/download`` directory by
312c3e24cffSThomas Huthdefault, but the location can be changed by setting the
313c3e24cffSThomas Huth``QEMU_TEST_CACHE_DIR`` environment variable.
314c3e24cffSThomas Huth
315c3e24cffSThomas HuthSkipping tests
316c3e24cffSThomas Huth--------------
317c3e24cffSThomas Huth
318c3e24cffSThomas HuthSince the test framework is based on the common Python unittest framework,
319c3e24cffSThomas Huthyou can use the usual Python decorators which allow for easily skipping
320c3e24cffSThomas Huthtests running under certain conditions, for example, on the lack of a binary
321c3e24cffSThomas Huthon the test system or when the running environment is a CI system. For further
322c3e24cffSThomas Huthinformation about those decorators, please refer to:
323c3e24cffSThomas Huth
324c3e24cffSThomas Huth  https://docs.python.org/3/library/unittest.html#skipping-tests-and-expected-failures
325c3e24cffSThomas Huth
326c3e24cffSThomas HuthWhile the conditions for skipping tests are often specifics of each one, there
327c3e24cffSThomas Huthare recurring scenarios identified by the QEMU developers and the use of
328c3e24cffSThomas Huthenvironment variables became a kind of standard way to enable/disable tests.
329c3e24cffSThomas Huth
330c3e24cffSThomas HuthHere is a list of the most used variables:
331c3e24cffSThomas Huth
332c3e24cffSThomas HuthQEMU_TEST_ALLOW_LARGE_STORAGE
333c3e24cffSThomas Huth^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
334c3e24cffSThomas HuthTests which are going to fetch or produce assets considered *large* are not
335c3e24cffSThomas Huthgoing to run unless that ``QEMU_TEST_ALLOW_LARGE_STORAGE=1`` is exported on
336c3e24cffSThomas Huththe environment.
337c3e24cffSThomas Huth
338c3e24cffSThomas HuthThe definition of *large* is a bit arbitrary here, but it usually means an
339c3e24cffSThomas Huthasset which occupies at least 1GB of size on disk when uncompressed.
340c3e24cffSThomas Huth
341c3e24cffSThomas HuthQEMU_TEST_ALLOW_UNTRUSTED_CODE
342c3e24cffSThomas Huth^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
343c3e24cffSThomas HuthThere are tests which will boot a kernel image or firmware that can be
344c3e24cffSThomas Huthconsidered not safe to run on the developer's workstation, thus they are
345c3e24cffSThomas Huthskipped by default. The definition of *not safe* is also arbitrary but
346c3e24cffSThomas Huthusually it means a blob which either its source or build process aren't
347c3e24cffSThomas Huthpublic available.
348c3e24cffSThomas Huth
349c3e24cffSThomas HuthYou should export ``QEMU_TEST_ALLOW_UNTRUSTED_CODE=1`` on the environment in
350c3e24cffSThomas Huthorder to allow tests which make use of those kind of assets.
351c3e24cffSThomas Huth
352c3e24cffSThomas HuthQEMU_TEST_FLAKY_TESTS
353c3e24cffSThomas Huth^^^^^^^^^^^^^^^^^^^^^
354c3e24cffSThomas HuthSome tests are not working reliably and thus are disabled by default.
355c3e24cffSThomas HuthThis includes tests that don't run reliably on GitLab's CI which
356c3e24cffSThomas Huthusually expose real issues that are rarely seen on developer machines
357c3e24cffSThomas Huthdue to the constraints of the CI environment. If you encounter a
358c3e24cffSThomas Huthsimilar situation then raise a bug and then mark the test as shown on
359c3e24cffSThomas Huththe code snippet below:
360c3e24cffSThomas Huth
361c3e24cffSThomas Huth.. code::
362c3e24cffSThomas Huth
363c3e24cffSThomas Huth  # See https://gitlab.com/qemu-project/qemu/-/issues/nnnn
364c3e24cffSThomas Huth  @skipUnless(os.getenv('QEMU_TEST_FLAKY_TESTS'), 'Test is unstable on GitLab')
365c3e24cffSThomas Huth  def test(self):
366c3e24cffSThomas Huth      do_something()
367c3e24cffSThomas Huth
368c3e24cffSThomas HuthTests should not live in this state forever and should either be fixed
369c3e24cffSThomas Huthor eventually removed.
370c3e24cffSThomas Huth
3714ae633b0SThomas HuthQEMU_TEST_ALLOW_SLOW
3724ae633b0SThomas Huth^^^^^^^^^^^^^^^^^^^^
3734ae633b0SThomas HuthTests that have a very long runtime and might run into timeout issues
3744ae633b0SThomas Huthe.g. if the QEMU binary has been compiled with debugging options enabled.
3754ae633b0SThomas HuthTo avoid these timeout issues by default and to save some precious CPU
3764ae633b0SThomas Huthcycles during normal testing, such tests are disabled by default unless
3774ae633b0SThomas Huththe QEMU_TEST_ALLOW_SLOW environment variable has been set.
3784ae633b0SThomas Huth
379c3e24cffSThomas Huth
380c3e24cffSThomas Huth.. _unittest: https://docs.python.org/3/library/unittest.html
381