aboutsummaryrefslogtreecommitdiff
path: root/tests/qemu-iotests/testenv.py
AgeCommit message (Collapse)Author
2024-02-12iotests: give tempdir an identifying nameDaniel P. Berrangé
If something goes wrong causing the iotests not to cleanup their temporary directory, it is useful if the dir had an identifying name to show what is to blame. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> Message-ID: <20240205155158.1843304-1-berrange@redhat.com> Revieved-by: Michael Tokarev <mjt@tls.msk.ru> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com> (cherry picked from commit 7d2faf0ce2ccc896ac56bc5ed2cdf4a55056a8bb) Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2023-11-28iotests: fix default machine type detectionAndrey Drobyshev
The machine type is being detected based on "-M help" output, and we're searching for the line ending with " (default)". However, in downstream one of the machine types s marked as deprecated might become the default, in which case this logic breaks as the line would now end with " (default) (deprecated)". To fix potential issues here, let's relax that requirement and detect the mere presence of " (default)" line instead. Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com> Message-ID: <20231122121538.32903-1-andrey.drobyshev@virtuozzo.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2023-10-17iotests: get rid of '..' in path environment outputJohn Snow
Resolve the build_root before we append more items onto it so that the environment output is more concise with less parent directory confetti in it. Signed-off-by: John Snow <jsnow@redhat.com> Message-ID: <20230621002121.1609612-4-jsnow@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2023-03-22iotests: allow test discovery before buildingDaniel P. Berrangé
The 'check' script can be invoked in "dry run" mode, in which case it merely does test discovery and prints out all their names. Despite only doing test discovery it still validates that the various QEMU binaries can be found. This makes it impossible todo test discovery prior to building QEMU. This is a desirable feature to support, because it will let meson discover tests. Fortunately the code in the TestEnv constructor is ordered in a way that makes this fairly trivial to achieve. We can just short circuit the constructor after the basic directory paths have been set. Reviewed-by: Thomas Huth <thuth@redhat.com> Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> Acked-by: Hanna Czenczek <hreitz@redhat.com> Tested-by: Thomas Huth <thuth@redhat.com> Message-Id: <20230303160727.3977246-3-berrange@redhat.com> Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Message-Id: <20230315174331.2959-20-alex.bennee@linaro.org>
2023-03-22iotests: explicitly pass source/build dir to 'check' commandDaniel P. Berrangé
The 'check' script has some rather dubious logic whereby it assumes that if invoked as a symlink, then it is running from a separate source tree and build tree, otherwise it assumes the current working directory is a combined source and build tree. This doesn't work if you want to invoke the 'check' script using its full source tree path while still using a split source and build tree layout. This would be a typical situation with meson if you ask it to find the 'check' script path using files('check'). Rather than trying to make the logic more magical, add support for explicitly passing the dirs using --source-dir and --build-dir. If either is omitted the current logic is maintained. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Acked-by: Hanna Czenczek <hreitz@redhat.com> Tested-by: Thomas Huth <thuth@redhat.com> Message-Id: <20230303160727.3977246-2-berrange@redhat.com> Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Message-Id: <20230315174331.2959-19-alex.bennee@linaro.org>
2022-03-22tests: add (riscv virt) machine mapping to testenvlaokz
Some qemu-iotests(040 etc) use PCI disk to do test. Without the mapping, RISC-V flavor use spike as default machine which has no PCI bus, causing test failure. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/894 Signed-off-by: Kai Zhang <laokz@foxmail.com> Message-Id: <tencent_E4219E870165A978DB5BBE50BD53D33D2E06@qq.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Signed-off-by: Hanna Reitz <hreitz@redhat.com>
2022-03-07iotests: Write test output to TEST_DIRHanna Reitz
Drop the use of OUTPUT_DIR (test/qemu-iotests under the build directory), and instead write test output files (.out.bad, .notrun, and .casenotrun) to TEST_DIR. With this, the same test can be run concurrently without the separate instances interfering, because they will need separate TEST_DIRs anyway. Running the same test separately is useful when running the iotests with various format/protocol combinations in parallel, or when you just want to aggressively exercise a single test (e.g. when it fails only sporadically). Putting this output into TEST_DIR means that it will stick around for inspection after the test run is done (though running the same test in the same TEST_DIR will overwrite it, just as it used to be); but given that TEST_DIR is a scratch directory, it should be clear that users can delete all of its content at any point. (And if TEST_DIR is on tmpfs, it will just disappear on shutdown.) Contrarily, alternative approaches that would put these output files into OUTPUT_DIR with some prefix to differentiate between separate test runs might easily lead to cluttering OUTPUT_DIR. (This change means OUTPUT_DIR is no longer written to by the iotests, so we can drop its usage altogether.) Signed-off-by: Hanna Reitz <hreitz@redhat.com> Message-Id: <20220221172909.762858-1-hreitz@redhat.com> [hreitz: Simplified `Path(os.path.join(x, y))` to `Path(x, y)`, as suggested by Vladimir; and rebased on 9086c7639822b6 ("tests/qemu-iotests: Rework the checks and spots using GNU sed")] Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2022-01-28check-block: replace -makecheck with TAP outputPaolo Bonzini
Let "meson test" take care of showing the results of the individual tests, consistently with other output from "make check V=1". Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2021-10-12python, iotests: remove socket_scm_helperJohn Snow
It's not used anymore, now. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Hanna Reitz <hreitz@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Message-id: 20210923004938.3999963-11-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-10-06iotests: add 'qemu' package location to PYTHONPATH in testenvJohn Snow
We can drop the sys.path hacking in various places by doing this. Additionally, by doing it in one place right up top, we can print interesting warnings in case the environment does not look correct. (See next commit.) If we ever decide to change how the environment is crafted, all of the "help me find my python packages" goop is all in one place, right in one function. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Message-Id: <20210923180715.4168522-2-jsnow@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2021-09-01qemu-iotests: add option to show qemu binary logs on stdoutEmanuele Giuseppe Esposito
Using the flag -p, allow the qemu binary to print to stdout. Also create the common function _close_qemu_log_file() to avoid accessing machine.py private fields directly and have duplicate code. Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Message-Id: <20210809090114.64834-16-eesposit@redhat.com> Signed-off-by: Hanna Reitz <hreitz@redhat.com>
2021-09-01qemu-iotests: extend the check script to prepare supporting valgrind for ↵Emanuele Giuseppe Esposito
python tests Currently, the check script only parses the option and sets the VALGRIND_QEMU environmental variable to "y". Add another local python variable that prepares the command line, identical to the one provided in the test scripts. Because the python script does not know in advance the valgrind PID to assign to the log file name, use the "%p" flag in valgrind log file name that automatically puts the process PID at runtime. Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Message-Id: <20210809090114.64834-11-eesposit@redhat.com> Signed-off-by: Hanna Reitz <hreitz@redhat.com>
2021-09-01qemu-iotests: add option to attach gdbserverEmanuele Giuseppe Esposito
Define -gdb flag and GDB_OPTIONS environment variable to python tests to attach a gdbserver to each qemu instance. This patch only adds and parses this flag, it does not yet add the implementation for it. if -gdb is not provided but $GDB_OPTIONS is set, ignore the environment variable. Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Message-Id: <20210809090114.64834-6-eesposit@redhat.com> Signed-off-by: Hanna Reitz <hreitz@redhat.com>
2021-05-14qemu-iotests: fix case of SOCK_DIR already in the environmentPaolo Bonzini
Due to a typo, in this case the SOCK_DIR was not being created. Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Tested-by: Emanuele Giuseppe Esposito <eesposit@redhat.com> Message-Id: <20210323181928.311862-6-pbonzini@redhat.com> Message-Id: <20210503110110.476887-6-pbonzini@redhat.com> Signed-off-by: Max Reitz <mreitz@redhat.com>
2021-05-14qemu-iotests: let "check" spawn an arbitrary test commandPaolo Bonzini
Right now there is no easy way for "check" to print a reproducer command. Because such a reproducer command line would be huge, we can instead teach check to start a command of our choice. This can be for example a Python unit test with arguments to only run a specific subtest. Move the trailing empty line to print_env(), since it always looks better and one caller was not adding it. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Tested-by: Emanuele Giuseppe Esposito <eesposit@redhat.com> Message-Id: <20210323181928.311862-5-pbonzini@redhat.com> Message-Id: <20210503110110.476887-5-pbonzini@redhat.com> Signed-off-by: Max Reitz <mreitz@redhat.com>
2021-05-14qemu-iotests: move command line and environment handling from TestRunner to ↵Paolo Bonzini
TestEnv In the next patch, "check" will learn how to execute a test script without going through TestRunner. To enable this, keep only the text output and subprocess handling in the TestRunner; move into TestEnv the logic to prepare for running a subprocess. Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Tested-by: Emanuele Giuseppe Esposito <eesposit@redhat.com> Message-Id: <20210323181928.311862-4-pbonzini@redhat.com> Message-Id: <20210503110110.476887-4-pbonzini@redhat.com> Signed-off-by: Max Reitz <mreitz@redhat.com>
2021-03-24iotests: test m68k with the virt machineLaurent Vivier
This allows to cover the virtio tests with a 32bit big-endian virtio-mmio machine. Signed-off-by: Laurent Vivier <laurent@vivier.eu> Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Reviewed-by: Cornelia Huck <cohuck@redhat.com> Message-Id: <20210319202335.2397060-6-laurent@vivier.eu> Message-Id: <20210323165308.15244-21-alex.bennee@linaro.org>
2021-02-02iotests: Revert emulator selection to old behaviourKevin Wolf
If the qemu-system-{arch} binary for the host architecture can't be found, the old 'check' implementation selected the alphabetically first system emulator binary that it could find. The new Python implementation just uses the first result of glob.iglob(), which has an undefined order. This is a problem that breaks CI because the iotests aren't actually prepared to run on any emulator. They should be, so this is really a bug in the failing test cases that should be fixed there, but as a quick fix, let's revert to the old behaviour to let CI runs succeed again. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Message-Id: <20210202142802.119999-1-kwolf@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2021-01-27iotests: add testenv.pyVladimir Sementsov-Ogievskiy
Add TestEnv class, which will handle test environment in a new python iotests running framework. Don't add compat=1.1 for qcow2 IMGOPTS, as v3 is default anyway. Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Message-Id: <20210125185056.129513-4-vsementsov@virtuozzo.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>