summaryrefslogtreecommitdiffstats
path: root/tests/qemu-iotests/iotests.py
Commit message (Collapse)AuthorAgeFilesLines
* iotests.py: add unarchive_sample_image() helperVladimir Sementsov-Ogievskiy2021-03-081-0/+10
| | | | | | | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Message-Id: <20210224104707.88430-6-vsementsov@virtuozzo.com> Reviewed-by: Denis V. Lunev <den@openvz.org> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* iotests.py: qemu_nbd_popen: remove pid file after useVladimir Sementsov-Ogievskiy2021-02-121-1/+5
| | | | | | | | | To not interfere with other qemu_nbd_popen() calls in same test. Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20210205163720.887197-8-vsementsov@virtuozzo.com> Signed-off-by: Eric Blake <eblake@redhat.com>
* iotests: rewrite check into pythonVladimir Sementsov-Ogievskiy2021-01-271-0/+8
| | | | | | | | | | | | | | | | | | | | Just use classes introduced in previous three commits. Behavior difference is described in these three commits. Drop group file, as it becomes unused. Drop common.env: now check is in python, and for tests we use same python interpreter that runs the check itself. Use build environment PYTHON in check-block instead, to keep "make check" use the same python. Checking for virtio-blk moved to iotests.py, as it actually iotests.py dependency. Actually not all python iotests depend on it, so in future it may be refactored to checked only when really needed. Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Message-Id: <20210125185056.129513-6-vsementsov@virtuozzo.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* iotests: Move try_remove to iotests.pyMax Reitz2021-01-261-4/+7
| | | | | | | | Signed-off-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Reviewed-by: Willian Rampazzo <willianr@redhat.com> Message-Id: <20210118105720.14824-4-mreitz@redhat.com>
* iotests.py: Assume a couple of variables as givenMax Reitz2021-01-261-13/+13
| | | | | | | | | | | | | | | | | | | | | | | | There are a couple of environment variables that we fetch with os.environ.get() without supplying a default. Clearly they are required and expected to be set by the ./check script (as evidenced by execute_setup_common(), which checks for test_dir and qemu_default_machine to be set, and aborts if they are not). Using .get() this way has the disadvantage of returning an Optional[str] type, which mypy will complain about when tests just assume these values to be str. Use [] instead, which raises a KeyError for environment variables that are not set. When this exception is raised, catch it and move the abort code from execute_setup_common() there. Drop the 'assert iotests.sock_dir is not None' from iotest 300, because that sort of thing is precisely what this patch wants to prevent. Signed-off-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Reviewed-by: Willian Rampazzo <willianr@redhat.com> Message-Id: <20210118105720.14824-2-mreitz@redhat.com>
* iotests.py: qemu_io(): reuse qemu_tool_pipe_and_status()Vladimir Sementsov-Ogievskiy2021-01-211-8/+1Star
| | | | | | | | | Just drop code duplication. Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Message-Id: <20201130134024.19212-5-vsementsov@virtuozzo.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Eric Blake <eblake@redhat.com>
* iotests.py: fix qemu_tool_pipe_and_status()Vladimir Sementsov-Ogievskiy2021-01-211-3/+2Star
| | | | | | | | | qemu_img_args variable is unrelated here. We should print just args. Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Message-Id: <20201130134024.19212-4-vsementsov@virtuozzo.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Eric Blake <eblake@redhat.com>
* iotests.py: execute_setup_common(): add required_fmts argumentVladimir Sementsov-Ogievskiy2020-12-181-1/+8
| | | | | | | | | | Add a parameter to skip test if some needed additional formats are not supported (for example filter drivers). Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Message-Id: <20201021145859.11201-12-vsementsov@virtuozzo.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Max Reitz <mreitz@redhat.com>
* iotests: qemu_io_silent: support --image-optsVladimir Sementsov-Ogievskiy2020-12-181-1/+6
| | | | | | | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Message-Id: <20201021145859.11201-11-vsementsov@virtuozzo.com> Signed-off-by: Max Reitz <mreitz@redhat.com>
* iotests: add filter_qmp_virtio_scsi functionMaxim Levitsky2020-11-091-0/+10
| | | | | | | | | | | | filter_qmp_virtio_scsi can be used to filter virtio-scsi-pci/ccw differences. Note that this patch was only tested on x86. Suggested-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com> Tested-by: Christian Borntraeger <borntraeger@de.ibm.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Message-Id: <20201104185025.434703-2-mlevitsk@redhat.com> Signed-off-by: Max Reitz <mreitz@redhat.com>
* iotests: Use Python 3 style super()Kevin Wolf2020-11-031-4/+4
| | | | | | | | | | | | | | | pylint complains about the use of super with the current class and instance as arguments in VM.__init__(): iotests.py:546:8: R1725: Consider using Python 3 style super() without arguments (super-with-arguments) No reason not to follow the advice and make it happy, so let's do this. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Message-Id: <20201027163806.290960-4-kwolf@redhat.com> Reviewed-by: John Snow <jsnow@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* iotests.py: Fix type check errors in wait_migration()Kevin Wolf2020-11-031-0/+4
| | | | | | | | | | | | | | | | | | | | | Commit 1847a4a8c20 clarified that event_wait() can return None (though only with timeout=0) and commit f12a282ff47 annotated it as returning Optional[QMPMessage]. Type checks in wait_migration() fail because of the unexpected optional return type: iotests.py:750: error: Value of type variable "Msg" of "log" cannot be "Optional[Dict[str, Any]]" iotests.py:751: error: Value of type "Optional[Dict[str, Any]]" is not indexable iotests.py:754: error: Value of type "Optional[Dict[str, Any]]" is not indexable Fortunately, the non-zero default timeout is used in the event_wait() call, so we can make mypy happy by just asserting this. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Message-Id: <20201027163806.290960-2-kwolf@redhat.com> Reviewed-by: John Snow <jsnow@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* iotests.py: Adjust HMP kwargs typingJohn Snow2020-10-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | mypy wants to ensure there's consistency between the kwargs arguments types and any unspecified keyword arguments. In this case, conv_keys is a bool, but the remaining keys are Any type. Mypy (correctly) infers the **kwargs type to be **Dict[str, str], which is not compatible with conv_keys: bool. Because QMP typing is a little fraught right now anyway, re-type kwargs to Dict[str, Any] which has the benefit of silencing this check right now. A future re-design might type these more aggressively, but this will give us a baseline to work from with minimal disruption. (Thanks Kevin Wolf for the debugging assist here) Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Message-id: 20201006235817.3280413-11-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
* iotests: Allow supported and unsupported formats at the same timeKevin Wolf2020-10-021-5/+1Star
| | | | | | | | | | | | | | This is useful for specifying 'generic' as supported (which includes only writable image formats), but still excluding some incompatible writable formats. It also removes more lines than it adds. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Message-Id: <20200924152717.287415-31-kwolf@redhat.com> Acked-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* iotests: Introduce qemu_nbd_list_log()Kevin Wolf2020-10-021-1/+12
| | | | | | | | | | Add a function to list the NBD exports offered by an NBD server. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Message-Id: <20200924152717.287415-30-kwolf@redhat.com> Acked-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* iotests: Factor out qemu_tool_pipe_and_status()Kevin Wolf2020-10-021-26/+23Star
| | | | | | | | | | | | We have three almost identical functions that call an external process and return its output and return code. Refactor them into small wrappers around a common function. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Message-Id: <20200924152717.287415-29-kwolf@redhat.com> Acked-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* configure: Bump the minimum required Python version to 3.6Thomas Huth2020-10-021-2/+0Star
| | | | | | | | | | | | All our supported build platforms have Python 3.6 or newer nowadays, and there are some useful features in Python 3.6 which are not available in 3.5 yet (e.g. the type hint annotations which will allow us to statically type the QAPI parser), so let's bump the minimum Python version to 3.6 now. Signed-off-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Message-Id: <20200923162908.95372-1-thuth@redhat.com> Message-Id: <20200925154027.12672-16-alex.bennee@linaro.org>
* qemu-iotests: Simplify FilePath __init__Nir Soffer2020-09-151-3/+2Star
| | | | | | | | | Use list comprehension instead of append loop. Signed-off-by: Nir Soffer <nsoffer@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Message-Id: <20200828232152.205833-6-nsoffer@redhat.com> Signed-off-by: Max Reitz <mreitz@redhat.com>
* qemu-iotests: Merge FilePaths and FilePathNir Soffer2020-09-151-13/+10Star
| | | | | | | | | | | | | | | | | | | FilePath creates now one temporary file: with FilePath("a") as a: Or more: with FilePath("a", "b", "c") as (a, b, c): This is also the behavior of the file_path() helper, used by some of the tests. Now we have only 2 helpers for creating temporary files instead of 3. Signed-off-by: Nir Soffer <nsoffer@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Message-Id: <20200828232152.205833-5-nsoffer@redhat.com> Signed-off-by: Max Reitz <mreitz@redhat.com>
* qemu-iotests: Support varargs syntax in FilePathsNir Soffer2020-09-151-4/+4
| | | | | | | | | | | | | | | | | | Accept variable number of names instead of a sequence: with FilePaths("a", "b", "c") as (a, b, c): The disadvantage is that base_dir must be used as kwarg: with FilePaths("a", "b", base_dir=soc_dir) as (sock1, sock2): But this is more clear and calling optional argument as positional arguments is bad idea anyway. Signed-off-by: Nir Soffer <nsoffer@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Message-Id: <20200828232152.205833-4-nsoffer@redhat.com> Signed-off-by: Max Reitz <mreitz@redhat.com>
* qemu-iotests: Fix FilePaths docstringNir Soffer2020-09-151-6/+13
| | | | | | | | | | | | | | When this class was extracted from FilePath, the docstring was not updated for generating multiple files, and the example usage was referencing unrelated file. While fixing the docstring, add example for creating sockets, which should use iotests.sock_dir instead of the default base_dir. Fixes: de263986b5dc Signed-off-by: Nir Soffer <nsoffer@redhat.com> Message-Id: <20200828232152.205833-3-nsoffer@redhat.com> Signed-off-by: Max Reitz <mreitz@redhat.com>
* qemu-iotests: Fix FilePaths cleanupNir Soffer2020-09-151-4/+4
| | | | | | | | | | | | If os.remove() fails to remove one of the paths, for example if the file was removed by the test, the cleanup loop would exit silently, without removing the rest of the files. Fixes: de263986b5dc Signed-off-by: Nir Soffer <nsoffer@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Message-Id: <20200828232152.205833-2-nsoffer@redhat.com> Signed-off-by: Max Reitz <mreitz@redhat.com>
* iotests: Let complete_and_wait() work with commitMax Reitz2020-09-071-3/+7
| | | | | | | | | complete_and_wait() and wait_ready() currently only work for mirror jobs. Let them work for active commit jobs, too. Signed-off-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com>
* iotests.py: Let wait_migration() return on failureMax Reitz2020-08-211-6/+12
| | | | | | | | | | | | Let wait_migration() return on failure (with the return value indicating whether the migration was completed or has failed), so we can use it for migrations that are expected to fail, too. Signed-off-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Message-Id: <20200820150725.68687-3-mreitz@redhat.com> Signed-off-by: Eric Blake <eblake@redhat.com>
* iotests: Add more qemu_img helpersNir Soffer2020-07-281-0/+6
| | | | | | | | | | | | | | | Add 2 helpers for measuring and checking images: - qemu_img_measure() - qemu_img_check() Both use --output-json and parse the returned json to make easy to use in other tests. I'm going to use them in a new test, and I hope they will be useful in may other tests. Signed-off-by: Nir Soffer <nsoffer@redhat.com> Message-Id: <20200727215846.395443-4-nsoffer@redhat.com> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Signed-off-by: Eric Blake <eblake@redhat.com>
* iotests: Make qemu_nbd_popen() a contextmanagerNir Soffer2020-07-281-2/+26
| | | | | | | | | | | | | | | | | Instead of duplicating the code to wait until the server is ready and remember to terminate the server and wait for it, make it possible to use like this: with qemu_nbd_popen('-k', sock, image): # Access image via qemu-nbd socket... Only test 264 used this helper, but I had to modify the output since it did not consistently when starting and stopping qemu-nbd. Signed-off-by: Nir Soffer <nsoffer@redhat.com> Message-Id: <20200727215846.395443-3-nsoffer@redhat.com> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Signed-off-by: Eric Blake <eblake@redhat.com>
* iotests.py: use qemu.qmp type aliasesJohn Snow2020-07-141-6/+3Star
| | | | | | | | | | iotests.py should use the type definitions from qmp.py instead of its own. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Message-Id: <20200710052220.3306-3-jsnow@redhat.com> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
* iotests.py: filter_testfiles(): filter SOCK_DIR tooVladimir Sementsov-Ogievskiy2020-07-131-2/+3
| | | | | | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Message-Id: <20200701105331.121670-5-vsementsov@virtuozzo.com> Signed-off-by: Eric Blake <eblake@redhat.com>
* iotests.py: QemuIoInteractive: print output on failureVladimir Sementsov-Ogievskiy2020-07-131-1/+7
| | | | | | | | | | Make it simpler to debug when qemu-io fails due to wrong arguments or environment. Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20200701105331.121670-3-vsementsov@virtuozzo.com> Signed-off-by: Eric Blake <eblake@redhat.com>
* iotests: QemuIoInteractive: use qemu_io_args_no_fmtVladimir Sementsov-Ogievskiy2020-07-131-1/+1
| | | | | | | | | | | | The only user (iotest 205) of QemuIoInteractive provides -f argument, so it's a bit inefficient to use qemu_io_args, which contains -f too. And we are going to add one more test, which wants to specify -f by hand. Let's use qemu_io_args_no_fmt. Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20200701105331.121670-2-vsementsov@virtuozzo.com> Signed-off-by: Eric Blake <eblake@redhat.com>
* iotests: Check whether luks worksMax Reitz2020-07-061-0/+5
| | | | | | | | | | | Whenever running an iotest for the luks format, we should check whether luks actually really works. Tests that try to create luks-encrypted qcow2 images should do the same. Signed-off-by: Max Reitz <mreitz@redhat.com> Message-Id: <20200625125548.870061-7-mreitz@redhat.com> Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
* iotests.py: Add (verify|has)_working_luks()Max Reitz2020-07-061-0/+39
| | | | | | | | | Similar to _require_working_luks for bash tests, these functions can be used to check whether our luks driver can actually create images. Signed-off-by: Max Reitz <mreitz@redhat.com> Message-Id: <20200625125548.870061-6-mreitz@redhat.com> Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
* iotests.py: Add qemu_img_pipe_and_status()Max Reitz2020-07-061-20/+20
| | | | | | | | | | | This function will be used by the next patch, which intends to check both the exit code and qemu-img's output. Signed-off-by: Max Reitz <mreitz@redhat.com> Message-Id: <20200625125548.870061-5-mreitz@redhat.com> Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> [mreitz: Rebased on 49438972b8c2e] Signed-off-by: Max Reitz <mreitz@redhat.com>
* iotests.py: Do not wait() before communicate()Max Reitz2020-07-031-17/+17
| | | | | | | | | | | | | | | | Waiting on a process for which we have a pipe will stall if the process outputs more data than fits into the OS-provided buffer. We must use communicate() before wait(), and in fact, communicate() perfectly replaces wait() already. We have to drop the stderr=subprocess.STDOUT parameter from subprocess.Popen() in qemu_nbd_early_pipe(), because stderr is passed on to the child process, so if we do not drop this parameter, communicate() will hang (because the pipe is not closed). Signed-off-by: Max Reitz <mreitz@redhat.com> Message-Id: <20200630083711.40567-1-mreitz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* iotests.py: Add skip_for_formats() decoratorMax Reitz2020-06-171-0/+16
| | | | | | | | | | Sometimes, we want to skip some test methods for certain formats. This decorator allows that. Signed-off-by: Max Reitz <mreitz@redhat.com> Message-Id: <20200617104822.27525-2-mreitz@redhat.com> Tested-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* iotests: log messages from notrun()John Snow2020-05-181-6/+5Star
| | | | | | | | | | | | Shift the logging initialization up to occur prior to validation checks, so that notrun() messages still get printed to console. (Also, remove the "debugging messages active" message, because we don't need to see that hundreds of times per iotest suite run.) Signed-off-by: John Snow <jsnow@redhat.com> Message-Id: <20200514201614.19941-2-jsnow@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* iotests: Fix incomplete type declarationsKevin Wolf2020-05-181-4/+4
| | | | | | | | | | | | We need to fix only a few places so that iotests.py can pass mypy --disallow-incomplete-defs, which seems to be a desirable option to have enabled in the long run. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Message-Id: <20200511163529.349329-2-kwolf@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Reviewed-by: John Snow <jsnow@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* iotests: use python logging for iotests.log()John Snow2020-05-051-23/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We can turn logging on/off globally instead of per-function. Remove use_log from run_job, and use python logging to turn on diffable output when we run through a script entry point. iotest 245 changes output order due to buffering reasons. An extended note on python logging: A NullHandler is added to `qemu.iotests` to stop output from being generated if this code is used as a library without configuring logging. A NullHandler is only needed at the root, so a duplicate handler is not needed for `qemu.iotests.diff_io`. When logging is not configured, messages at the 'WARNING' levels or above are printed with default settings. The NullHandler stops this from occurring, which is considered good hygiene for code used as a library. See https://docs.python.org/3/howto/logging.html#library-config When logging is actually enabled (always at the behest of an explicit call by a client script), a root logger is implicitly created at the root, which allows messages to propagate upwards and be handled/emitted from the root logger with default settings. When we want iotest logging, we attach a handler to the qemu.iotests.diff_io logger and disable propagation to avoid possible double-printing. For more information on python logging infrastructure, I highly recommend downloading the pip package `logging_tree`, which provides convenient visualizations of the hierarchical logging configuration under different circumstances. See https://pypi.org/project/logging_tree/ for more information. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Message-Id: <20200331000014.11581-15-jsnow@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Max Reitz <mreitz@redhat.com>
* iotests: Mark verify functions as privateJohn Snow2020-05-051-10/+13
| | | | | | | | | | | | | | Mark the verify functions as "private" with a leading underscore, to discourage their use. Update type signatures while we're here. (Also, make pending patches not yet using the new entry points fail in a very obvious way.) Signed-off-by: John Snow <jsnow@redhat.com> Message-Id: <20200331000014.11581-14-jsnow@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Max Reitz <mreitz@redhat.com>
* iotests: add script_initializeJohn Snow2020-05-051-26/+50
| | | | | | | | | | | | | | Like script_main, but doesn't require a single point of entry. Replace all existing initialization sections with this drop-in replacement. This brings debug support to all existing script-style iotests. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Message-Id: <20200331000014.11581-12-jsnow@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> [mreitz: Give 274 the same treatment] Signed-off-by: Max Reitz <mreitz@redhat.com>
* iotests: add hmp helper with loggingJohn Snow2020-05-051-15/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Minor cleanup for HMP functions; helps with line length and consolidates HMP helpers through one implementation function. Although we are adding a universal toggle to turn QMP logging on or off, many existing callers to hmp functions don't expect that output to be logged, which causes quite a few changes in the test output. For now, offer a use_log parameter. Typing notes: QMPResponse is just an alias for Dict[str, Any]. It holds no special meanings and it is not a formal subtype of Dict[str, Any]. It is best thought of as a lexical synonym. We may well wish to add stricter subtypes in the future for certain shapes of data that are not formalized as Python objects, at which point we can simply retire the alias and allow mypy to more strictly check usages of the name. Signed-off-by: John Snow <jsnow@redhat.com> Message-Id: <20200331000014.11581-11-jsnow@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Max Reitz <mreitz@redhat.com>
* iotests: limit line length to 79 charsJohn Snow2020-05-051-22/+42
| | | | | | | | | | | 79 is the PEP8 recommendation. This recommendation works well for reading patch diffs in TUI email clients. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Message-Id: <20200331000014.11581-10-jsnow@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Max Reitz <mreitz@redhat.com>
* iotests: touch up log function signatureJohn Snow2020-05-051-3/+11
| | | | | | | | | | | | | | | | | | | | | | | | Representing nested, recursive data structures in mypy is notoriously difficult; the best we can reliably do right now is denote the leaf types as "Any" while describing the general shape of the data. Regardless, this fully annotates the log() function. Typing notes: TypeVar is a Type variable that can optionally be constrained by a sequence of possible types. This variable is bound to a specific type per-invocation, like a Generic. log() behaves as log<Msg>() now, where the incoming type informs the signature it expects for any filter arguments passed in. If Msg is a str, then filter should take and return a str. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Message-Id: <20200331000014.11581-9-jsnow@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Max Reitz <mreitz@redhat.com>
* iotests: drop pre-Python 3.4 compatibility codeJohn Snow2020-05-051-4/+1Star
| | | | | | | | | | | We no longer need to accommodate <3.4, drop this code. (The lines were > 79 chars and it stood out.) Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Message-Id: <20200331000014.11581-8-jsnow@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Max Reitz <mreitz@redhat.com>
* iotests: alphabetize standard importsJohn Snow2020-05-051-9/+9
| | | | | | | | | | | | I had to fix a merge conflict, so do this tiny harmless thing while I'm here. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Message-Id: <20200331000014.11581-7-jsnow@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Max Reitz <mreitz@redhat.com>
* iotests: replace mutable list default argsJohn Snow2020-05-051-12/+12
| | | | | | | | | | | | | | | It's bad hygiene: if we modify this list, it will be modified across all invocations. (Remaining bad usages are fixed in a subsequent patch which changes the function signature anyway.) Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Message-Id: <20200331000014.11581-5-jsnow@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Max Reitz <mreitz@redhat.com>
* iotests: ignore import warnings from pylintJohn Snow2020-05-051-0/+1
| | | | | | | | | | | | | | | The right way to solve this is to come up with a virtual environment infrastructure that sets all the paths correctly, and/or to create installable python modules that can be imported normally. That's hard, so just silence this error for now. Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Signed-off-by: John Snow <jsnow@redhat.com> Message-Id: <20200331000014.11581-4-jsnow@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Max Reitz <mreitz@redhat.com>
* iotests: don't use 'format' for drive_addJohn Snow2020-05-051-3/+3
| | | | | | | | | | | | It shadows (with a different type) the built-in format. Use something else. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Message-Id: <20200331000014.11581-3-jsnow@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Max Reitz <mreitz@redhat.com>
* iotests: do a light delintingJohn Snow2020-05-051-40/+43
| | | | | | | | | | | | | | | | This doesn't fix everything in here, but it does help clean up the pylint report considerably. This should be 100% style changes only; the intent is to make pylint more useful by working on establishing a baseline for iotests that we can gate against in the future. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Message-Id: <20200331000014.11581-2-jsnow@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Max Reitz <mreitz@redhat.com>
* iotests: Filter testfiles out in filter_img_info()Kevin Wolf2020-04-301-2/+3
| | | | | | | | | | | | | | | We want to keep TEST_IMG for the full path of the main test image, but filter_testfiles() must be called for other test images before replacing other things like the image format because the test directory path could contain the format as a substring. Insert a filter_testfiles() call between both. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Message-Id: <20200424125448.63318-9-kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>