aboutsummaryrefslogtreecommitdiff
path: root/tests/qemu-iotests/245
diff options
context:
space:
mode:
authorJohn Snow <jsnow@redhat.com>2020-03-30 20:00:14 -0400
committerMax Reitz <mreitz@redhat.com>2020-05-05 13:17:36 +0200
commit52ea799e9631ff00c230f1fed50986246149d8f2 (patch)
tree92338491f7d9490434ae1a0a31121ef22c581e9f /tests/qemu-iotests/245
parent59c29869e0c5e8875edc50a0e3073eeaa8fe6143 (diff)
downloadqemu-52ea799e9631ff00c230f1fed50986246149d8f2.zip
qemu-52ea799e9631ff00c230f1fed50986246149d8f2.tar.gz
qemu-52ea799e9631ff00c230f1fed50986246149d8f2.tar.bz2
iotests: use python logging for iotests.log()
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>
Diffstat (limited to 'tests/qemu-iotests/245')
-rwxr-xr-xtests/qemu-iotests/2451
1 files changed, 1 insertions, 0 deletions
diff --git a/tests/qemu-iotests/245 b/tests/qemu-iotests/245
index 1001275..4f5f0bb 100755
--- a/tests/qemu-iotests/245
+++ b/tests/qemu-iotests/245
@@ -1027,5 +1027,6 @@ class TestBlockdevReopen(iotests.QMPTestCase):
self.run_test_iothreads(None, 'iothread0')
if __name__ == '__main__':
+ iotests.activate_logging()
iotests.main(supported_fmts=["qcow2"],
supported_protocols=["file"])