iotests: use python logging
PATCH v3 3/4 iotests: add protocol support to initialization info
In reply to John SnowThis will add supported_protocols and unsupported_protocols to all of iotests.main, iotests.script_main, and iotests.script_initialize.
--- tests/qemu-iotests/207 | 4 ++-- tests/qemu-iotests/210 | 4 ++-- tests/qemu-iotests/211 | 4 ++-- tests/qemu-iotests/212 | 4 ++-- tests/qemu-iotests/213 | 4 ++-- tests/qemu-iotests/iotests.py | 5 ++++- 6 files changed, 14 insertions(+), 11 deletions(-)
tests/qemu-iotests/207 +2 -2
@@ -24,8 +24,8 @@ import iotests import subprocess import re -iotests.script_initialize(supported_fmts=['raw']) -iotests.verify_protocol(supported=['ssh']) +iotests.script_initialize(supported_fmts=['raw'], + supported_protocols=['ssh']) def filter_hash(qmsg): def _filter(key, value):
tests/qemu-iotests/210 +2 -2
@@ -23,8 +23,8 @@ import iotests from iotests import imgfmt -iotests.script_initialize(supported_fmts=['luks']) -iotests.verify_protocol(supported=['file']) +iotests.script_initialize(supported_fmts=['luks'], + supported_protocols=['file']) def blockdev_create(vm, options): result = vm.qmp_log('blockdev-create', job_id='job0', options=options,
tests/qemu-iotests/211 +2 -2
@@ -23,8 +23,8 @@ import iotests from iotests import imgfmt -iotests.script_initialize(supported_fmts=['vdi']) -iotests.verify_protocol(supported=['file']) +iotests.script_initialize(supported_fmts=['vdi'], + supported_protocols=['file']) def blockdev_create(vm, options): result = vm.qmp_log('blockdev-create', job_id='job0', options=options,
tests/qemu-iotests/212 +2 -2
@@ -23,8 +23,8 @@ import iotests from iotests import imgfmt -iotests.script_initialize(supported_fmts=['parallels']) -iotests.verify_protocol(supported=['file']) +iotests.script_initialize(supported_fmts=['parallels'], + supported_protocols=['file']) def blockdev_create(vm, options): result = vm.qmp_log('blockdev-create', job_id='job0', options=options,
tests/qemu-iotests/213 +2 -2
@@ -23,8 +23,8 @@ import iotests from iotests import imgfmt -iotests.script_initialize(supported_fmts=['vhdx']) -iotests.verify_protocol(supported=['file']) +iotests.script_initialize(supported_fmts=['vhdx'], + supported_protocols=['file']) def blockdev_create(vm, options): result = vm.qmp_log('blockdev-create', job_id='job0', options=options,
tests/qemu-iotests/iotests.py +4 -1
@@ -925,7 +925,9 @@ def execute_unittest(debug=False): def execute_setup_common(supported_fmts=[], supported_oses=['linux'], supported_cache_modes=[], - unsupported_fmts=[]): + unsupported_fmts=[], + supported_protocols=[], + unsupported_protocols=[]): """ Perform necessary setup for either script-style or unittest-style tests. """
@@ -941,6 +943,7 @@ def execute_setup_common(supported_fmts=[], verify_image_format(supported_fmts, unsupported_fmts) verify_platform(supported_oses) verify_cache_mode(supported_cache_modes) + verify_protocol(supported_protocols, unsupported_protocols) debug = '-d' in sys.argv if debug:
Signature · 1 line
2.21.0
PATCH v3 1/4 iotests: add script_initialize
In reply to John SnowLike 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.
Note: supported_oses=['linux'] was omitted, as it is a default argument.
--- tests/qemu-iotests/149 | 3 +- tests/qemu-iotests/194 | 3 +- tests/qemu-iotests/202 | 3 +- tests/qemu-iotests/203 | 3 +- tests/qemu-iotests/206 | 2 +- tests/qemu-iotests/207 | 2 +- tests/qemu-iotests/208 | 2 +- tests/qemu-iotests/209 | 2 +- tests/qemu-iotests/210 | 2 +- tests/qemu-iotests/211 | 2 +- tests/qemu-iotests/212 | 2 +- tests/qemu-iotests/213 | 2 +- tests/qemu-iotests/216 | 3 +- tests/qemu-iotests/218 | 2 +- tests/qemu-iotests/219 | 2 +- tests/qemu-iotests/222 | 5 ++- tests/qemu-iotests/224 | 3 +- tests/qemu-iotests/228 | 3 +- tests/qemu-iotests/234 | 3 +- tests/qemu-iotests/235 | 4 +-- tests/qemu-iotests/236 | 2 +- tests/qemu-iotests/237 | 2 +- tests/qemu-iotests/238 | 2 ++ tests/qemu-iotests/242 | 2 +- tests/qemu-iotests/246 | 2 +- tests/qemu-iotests/248 | 2 +- tests/qemu-iotests/254 | 2 +- tests/qemu-iotests/255 | 2 +- tests/qemu-iotests/256 | 2 +- tests/qemu-iotests/262 | 3 +- tests/qemu-iotests/iotests.py | 58 +++++++++++++++++++++++------------ 31 files changed, 71 insertions(+), 61 deletions(-)
tests/qemu-iotests/149 +1 -2
@@ -383,8 +383,7 @@ def test_once(config, qemu_img=False): # Obviously we only work with the luks image format -iotests.verify_image_format(supported_fmts=['luks']) -iotests.verify_platform() +iotests.script_initialize(supported_fmts=['luks']) # We need sudo in order to run cryptsetup to create # dm-crypt devices. This is safe to use on any
tests/qemu-iotests/194 +1 -2
@@ -21,8 +21,7 @@ import iotests -iotests.verify_image_format(supported_fmts=['qcow2', 'qed', 'raw']) -iotests.verify_platform(['linux']) +iotests.script_initialize(supported_fmts=['qcow2', 'qed', 'raw']) with iotests.FilePath('source.img') as source_img_path, \ iotests.FilePath('dest.img') as dest_img_path, \
tests/qemu-iotests/202 +1 -2
@@ -24,8 +24,7 @@ import iotests -iotests.verify_image_format(supported_fmts=['qcow2']) -iotests.verify_platform(['linux']) +iotests.script_initialize(supported_fmts=['qcow2']) with iotests.FilePath('disk0.img') as disk0_img_path, \ iotests.FilePath('disk1.img') as disk1_img_path, \
tests/qemu-iotests/203 +1 -2
@@ -24,8 +24,7 @@ import iotests -iotests.verify_image_format(supported_fmts=['qcow2']) -iotests.verify_platform(['linux']) +iotests.script_initialize(supported_fmts=['qcow2']) with iotests.FilePath('disk0.img') as disk0_img_path, \ iotests.FilePath('disk1.img') as disk1_img_path, \
tests/qemu-iotests/206 +1 -1
@@ -23,7 +23,7 @@ import iotests from iotests import imgfmt -iotests.verify_image_format(supported_fmts=['qcow2']) +iotests.script_initialize(supported_fmts=['qcow2']) def blockdev_create(vm, options): result = vm.qmp_log('blockdev-create',
tests/qemu-iotests/207 +1 -1
@@ -24,7 +24,7 @@ import iotests import subprocess import re -iotests.verify_image_format(supported_fmts=['raw']) +iotests.script_initialize(supported_fmts=['raw']) iotests.verify_protocol(supported=['ssh']) def filter_hash(qmsg):
tests/qemu-iotests/208 +1 -1
@@ -22,7 +22,7 @@ import iotests -iotests.verify_image_format(supported_fmts=['generic']) +iotests.script_initialize(supported_fmts=['generic']) with iotests.FilePath('disk.img') as disk_img_path, \ iotests.FilePath('disk-snapshot.img') as disk_snapshot_img_path, \
tests/qemu-iotests/209 +1 -1
@@ -22,7 +22,7 @@ import iotests from iotests import qemu_img_create, qemu_io, qemu_img_verbose, qemu_nbd, \ file_path -iotests.verify_image_format(supported_fmts=['qcow2']) +iotests.script_initialize(supported_fmts=['qcow2']) disk, nbd_sock = file_path('disk', 'nbd-sock') nbd_uri = 'nbd+unix:///exp?socket=' + nbd_sock
tests/qemu-iotests/210 +1 -1
@@ -23,7 +23,7 @@ import iotests from iotests import imgfmt -iotests.verify_image_format(supported_fmts=['luks']) +iotests.script_initialize(supported_fmts=['luks']) iotests.verify_protocol(supported=['file']) def blockdev_create(vm, options):
tests/qemu-iotests/211 +1 -1
@@ -23,7 +23,7 @@ import iotests from iotests import imgfmt -iotests.verify_image_format(supported_fmts=['vdi']) +iotests.script_initialize(supported_fmts=['vdi']) iotests.verify_protocol(supported=['file']) def blockdev_create(vm, options):
tests/qemu-iotests/212 +1 -1
@@ -23,7 +23,7 @@ import iotests from iotests import imgfmt -iotests.verify_image_format(supported_fmts=['parallels']) +iotests.script_initialize(supported_fmts=['parallels']) iotests.verify_protocol(supported=['file']) def blockdev_create(vm, options):
tests/qemu-iotests/213 +1 -1
@@ -23,7 +23,7 @@ import iotests from iotests import imgfmt -iotests.verify_image_format(supported_fmts=['vhdx']) +iotests.script_initialize(supported_fmts=['vhdx']) iotests.verify_protocol(supported=['file']) def blockdev_create(vm, options):
tests/qemu-iotests/216 +1 -2
@@ -23,8 +23,7 @@ import iotests from iotests import log, qemu_img, qemu_io_silent # Need backing file support -iotests.verify_image_format(supported_fmts=['qcow2', 'qcow', 'qed', 'vmdk']) -iotests.verify_platform(['linux']) +iotests.script_initialize(supported_fmts=['qcow2', 'qcow', 'qed', 'vmdk']) log('') log('=== Copy-on-read across nodes ===')
tests/qemu-iotests/218 +1 -1
@@ -29,7 +29,7 @@ import iotests from iotests import log, qemu_img, qemu_io_silent -iotests.verify_image_format(supported_fmts=['qcow2', 'raw']) +iotests.script_initialize(supported_fmts=['qcow2', 'raw']) # Launches the VM, adds two null-co nodes (source and target), and
tests/qemu-iotests/219 +1 -1
@@ -21,7 +21,7 @@ import iotests -iotests.verify_image_format(supported_fmts=['qcow2']) +iotests.script_initialize(supported_fmts=['qcow2']) img_size = 4 * 1024 * 1024
tests/qemu-iotests/222 +2 -3
@@ -24,9 +24,8 @@ import iotests from iotests import log, qemu_img, qemu_io, qemu_io_silent -iotests.verify_platform(['linux']) -iotests.verify_image_format(supported_fmts=['qcow2', 'qcow', 'qed', 'vmdk', - 'vhdx', 'raw']) +iotests.script_initialize(supported_fmts=['qcow2', 'qcow', 'qed', 'vmdk', + 'vhdx', 'raw']) patterns = [("0x5d", "0", "64k"), ("0xd5", "1M", "64k"),
tests/qemu-iotests/224 +1 -2
@@ -26,8 +26,7 @@ from iotests import log, qemu_img, qemu_io_silent, filter_qmp_testfiles, \ import json # Need backing file support (for arbitrary backing formats) -iotests.verify_image_format(supported_fmts=['qcow2', 'qcow', 'qed']) -iotests.verify_platform(['linux']) +iotests.script_initialize(supported_fmts=['qcow2', 'qcow', 'qed']) # There are two variations of this test:
tests/qemu-iotests/228 +1 -2
@@ -25,8 +25,7 @@ from iotests import log, qemu_img, filter_testfiles, filter_imgfmt, \ filter_qmp_testfiles, filter_qmp_imgfmt # Need backing file and change-backing-file support -iotests.verify_image_format(supported_fmts=['qcow2', 'qed']) -iotests.verify_platform(['linux']) +iotests.script_initialize(supported_fmts=['qcow2', 'qed']) def log_node_info(node):
tests/qemu-iotests/234 +1 -2
@@ -23,8 +23,7 @@ import iotests import os -iotests.verify_image_format(supported_fmts=['qcow2']) -iotests.verify_platform(['linux']) +iotests.script_initialize(supported_fmts=['qcow2']) with iotests.FilePath('img') as img_path, \ iotests.FilePath('backing') as backing_path, \
tests/qemu-iotests/235 +2 -2
@@ -27,6 +27,8 @@ sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python')) from qemu.machine import QEMUMachine +iotests.script_initialize(supported_fmts=['qcow2']) + # Note: # This test was added to check that mirror dead-lock was fixed (see previous # commit before this test addition).
@@ -40,8 +42,6 @@ from qemu.machine import QEMUMachine size = 1 * 1024 * 1024 * 1024 -iotests.verify_image_format(supported_fmts=['qcow2']) - disk = file_path('disk') # prepare source image
tests/qemu-iotests/236 +1 -1
@@ -22,7 +22,7 @@ import iotests from iotests import log -iotests.verify_image_format(supported_fmts=['generic']) +iotests.script_initialize(supported_fmts=['generic']) size = 64 * 1024 * 1024 granularity = 64 * 1024
tests/qemu-iotests/237 +1 -1
@@ -24,7 +24,7 @@ import math import iotests from iotests import imgfmt -iotests.verify_image_format(supported_fmts=['vmdk']) +iotests.script_initialize(supported_fmts=['vmdk']) def blockdev_create(vm, options): result = vm.qmp_log('blockdev-create', job_id='job0', options=options,
tests/qemu-iotests/238 +2 -0
@@ -23,6 +23,8 @@ import os import iotests from iotests import log +iotests.script_initialize() + virtio_scsi_device = iotests.get_virtio_scsi_device() vm = iotests.VM()
tests/qemu-iotests/242 +1 -1
@@ -24,7 +24,7 @@ import struct from iotests import qemu_img_create, qemu_io, qemu_img_pipe, \ file_path, img_info_log, log, filter_qemu_io -iotests.verify_image_format(supported_fmts=['qcow2']) +iotests.script_initialize(supported_fmts=['qcow2']) disk = file_path('disk') chunk = 256 * 1024
tests/qemu-iotests/246 +1 -1
@@ -22,7 +22,7 @@ import iotests from iotests import log -iotests.verify_image_format(supported_fmts=['qcow2']) +iotests.script_initialize(supported_fmts=['qcow2']) size = 64 * 1024 * 1024 * 1024 gran_small = 32 * 1024 gran_large = 128 * 1024
tests/qemu-iotests/248 +1 -1
@@ -21,7 +21,7 @@ import iotests from iotests import qemu_img_create, qemu_io, file_path, filter_qmp_testfiles -iotests.verify_image_format(supported_fmts=['qcow2']) +iotests.script_initialize(supported_fmts=['qcow2']) source, target = file_path('source', 'target') size = 5 * 1024 * 1024
tests/qemu-iotests/254 +1 -1
@@ -21,7 +21,7 @@ import iotests from iotests import qemu_img_create, file_path, log -iotests.verify_image_format(supported_fmts=['qcow2']) +iotests.script_initialize(supported_fmts=['qcow2']) disk, top = file_path('disk', 'top') size = 1024 * 1024
tests/qemu-iotests/255 +1 -1
@@ -23,7 +23,7 @@ import iotests from iotests import imgfmt -iotests.verify_image_format(supported_fmts=['qcow2']) +iotests.script_initialize(supported_fmts=['qcow2']) def blockdev_create(vm, options): result = vm.qmp_log('blockdev-create',
tests/qemu-iotests/256 +1 -1
@@ -23,7 +23,7 @@ import os import iotests from iotests import log -iotests.verify_image_format(supported_fmts=['qcow2']) +iotests.script_initialize(supported_fmts=['qcow2']) size = 64 * 1024 * 1024 with iotests.FilePath('img0') as img0_path, \
tests/qemu-iotests/262 +1 -2
@@ -23,8 +23,7 @@ import iotests import os -iotests.verify_image_format(supported_fmts=['qcow2']) -iotests.verify_platform(['linux']) +iotests.script_initialize(supported_fmts=['qcow2']) with iotests.FilePath('img') as img_path, \ iotests.FilePath('mig_fifo') as fifo, \
tests/qemu-iotests/iotests.py +38 -20
96 lines not on this page · raw message
Signature · 1 line
2.21.0
PATCH v3 2/4 iotest 258: use script_main
In reply to John SnowSince this one is nicely factored to use a single entry point, use script_main to run the tests.
--- tests/qemu-iotests/258 | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
tests/qemu-iotests/258 +2 -6
@@ -23,11 +23,6 @@ import iotests from iotests import log, qemu_img, qemu_io_silent, \ filter_qmp_testfiles, filter_qmp_imgfmt -# Need backing file and change-backing-file support -iotests.verify_image_format(supported_fmts=['qcow2', 'qed']) -iotests.verify_platform(['linux']) - - # Returns a node for blockdev-add def node(node_name, path, backing=None, fmt=None, throttle=None): if fmt is None:
@@ -160,4 +155,5 @@ def main(): test_concurrent_finish(False) if __name__ == '__main__': - main() + # Need backing file and change-backing-file support + iotests.script_main(main, supported_fmts=['qcow2', 'qed'])
Signature · 1 line
2.21.0
v3 cover iotests: use python logging
This series uses python logging to enable output conditionally on iotests.log(). We unify an initialization call (which also enables debugging output for those tests with -d) and then make the switch inside of iotests.
It will help alleviate the need to create logged/unlogged versions of all the various helpers we have made.
V3:
- Rebased for 4.1+; now based on main branch.
V2:
- Added all of the other python tests I missed to use script_initialize
- Refactored the common setup as per Ehabkost's suggestion
- Added protocol arguments to common initialization,
but this isn't strictly required.
John Snow (4):
iotests: add script_initialize
iotest 258: use script_main
iotests: add protocol support to initialization info
iotests: use python logging for iotests.log()
tests/qemu-iotests/030 | 4 +- tests/qemu-iotests/149 | 3 +- tests/qemu-iotests/194 | 3 +- tests/qemu-iotests/202 | 3 +- tests/qemu-iotests/203 | 3 +- tests/qemu-iotests/206 | 2 +- tests/qemu-iotests/207 | 4 +- tests/qemu-iotests/208 | 2 +- tests/qemu-iotests/209 | 2 +- tests/qemu-iotests/210 | 4 +- tests/qemu-iotests/211 | 4 +- tests/qemu-iotests/212 | 4 +- tests/qemu-iotests/213 | 4 +- tests/qemu-iotests/216 | 3 +- tests/qemu-iotests/218 | 2 +- tests/qemu-iotests/219 | 2 +- tests/qemu-iotests/222 | 5 +- tests/qemu-iotests/224 | 3 +- tests/qemu-iotests/228 | 3 +- tests/qemu-iotests/234 | 3 +- tests/qemu-iotests/235 | 4 +- tests/qemu-iotests/236 | 2 +- tests/qemu-iotests/237 | 2 +- tests/qemu-iotests/238 | 2 + tests/qemu-iotests/242 | 2 +- tests/qemu-iotests/245 | 1 + tests/qemu-iotests/245.out | 24 ++++---- tests/qemu-iotests/246 | 2 +- tests/qemu-iotests/248 | 2 +- tests/qemu-iotests/254 | 2 +- tests/qemu-iotests/255 | 2 +- tests/qemu-iotests/256 | 2 +- tests/qemu-iotests/258 | 8 +-- tests/qemu-iotests/262 | 3 +- tests/qemu-iotests/iotests.py | 108 ++++++++++++++++++++++------------ 35 files changed, 124 insertions(+), 105 deletions(-)
Signature · 1 line
2.21.0
PATCH v3 4/4 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.
--- tests/qemu-iotests/030 | 4 +-- tests/qemu-iotests/245 | 1 + tests/qemu-iotests/245.out | 24 +++++++++--------- tests/qemu-iotests/iotests.py | 47 +++++++++++++++++++++-------------- 4 files changed, 43 insertions(+), 33 deletions(-)
tests/qemu-iotests/030 +2 -2
@@ -411,8 +411,8 @@ class TestParallelOps(iotests.QMPTestCase): result = self.vm.qmp('block-job-set-speed', device='drive0', speed=0) self.assert_qmp(result, 'return', {}) - self.vm.run_job(job='drive0', auto_dismiss=True, use_log=False) - self.vm.run_job(job='node4', auto_dismiss=True, use_log=False) + self.vm.run_job(job='drive0', auto_dismiss=True) + self.vm.run_job(job='node4', auto_dismiss=True) self.assert_no_active_block_jobs() # Test a block-stream and a block-commit job in parallel
tests/qemu-iotests/245 +1 -0
@@ -1000,4 +1000,5 @@ class TestBlockdevReopen(iotests.QMPTestCase): self.reopen(opts, {'backing': 'hd2'}) if __name__ == '__main__': + iotests.activate_logging() iotests.main(supported_fmts=["qcow2"])
tests/qemu-iotests/245.out +12 -12
@@ -1,17 +1,17 @@ +{"execute": "job-finalize", "arguments": {"id": "commit0"}} +{"return": {}} +{"data": {"id": "commit0", "type": "commit"}, "event": "BLOCK_JOB_PENDING", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} +{"data": {"device": "commit0", "len": 3145728, "offset": 3145728, "speed": 0, "type": "commit"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} +{"execute": "job-finalize", "arguments": {"id": "stream0"}} +{"return": {}} +{"data": {"id": "stream0", "type": "stream"}, "event": "BLOCK_JOB_PENDING", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} +{"data": {"device": "stream0", "len": 3145728, "offset": 3145728, "speed": 0, "type": "stream"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} +{"execute": "job-finalize", "arguments": {"id": "stream0"}} +{"return": {}} +{"data": {"id": "stream0", "type": "stream"}, "event": "BLOCK_JOB_PENDING", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} +{"data": {"device": "stream0", "len": 3145728, "offset": 3145728, "speed": 0, "type": "stream"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} .................. ---------------------------------------------------------------------- Ran 18 tests OK -{"execute": "job-finalize", "arguments": {"id": "commit0"}} -{"return": {}} -{"data": {"id": "commit0", "type": "commit"}, "event": "BLOCK_JOB_PENDING", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} -{"data": {"device": "commit0", "len": 3145728, "offset": 3145728, "speed": 0, "type": "commit"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} -{"execute": "job-finalize", "arguments": {"id": "stream0"}} -{"return": {}} -{"data": {"id": "stream0", "type": "stream"}, "event": "BLOCK_JOB_PENDING", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} -{"data": {"device": "stream0", "len": 3145728, "offset": 3145728, "speed": 0, "type": "stream"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} -{"execute": "job-finalize", "arguments": {"id": "stream0"}} -{"return": {}} -{"data": {"id": "stream0", "type": "stream"}, "event": "BLOCK_JOB_PENDING", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} -{"data": {"device": "stream0", "len": 3145728, "offset": 3145728, "speed": 0, "type": "stream"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
tests/qemu-iotests/iotests.py +28 -19
110 lines not on this page · raw message
Signature · 1 line
2.21.0
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series seems to have some coding style problems. See output below for more information:
Type: series
Subject: [Qemu-devel] [PATCH v3 0/4] iotests: use python logging
Message-id: [email protected]
=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
* [new tag] patchew/[email protected] -> patchew/[email protected]
Submodule 'capstone' (https://git.qemu.org/git/capstone.git) registered for path 'capstone'
Submodule 'dtc' (https://git.qemu.org/git/dtc.git) registered for path 'dtc'
Submodule 'roms/QemuMacDrivers' (https://git.qemu.org/git/QemuMacDrivers.git) registered for path 'roms/QemuMacDrivers' Submodule 'roms/SLOF' (https://git.qemu.org/git/SLOF.git) registered for path 'roms/SLOF'
Submodule 'roms/edk2' (https://git.qemu.org/git/edk2.git) registered for path 'roms/edk2'
Submodule 'roms/ipxe' (https://git.qemu.org/git/ipxe.git) registered for path 'roms/ipxe'
Submodule 'roms/openbios' (https://git.qemu.org/git/openbios.git) registered for path 'roms/openbios'
Submodule 'roms/openhackware' (https://git.qemu.org/git/openhackware.git) registered for path 'roms/openhackware'
Submodule 'roms/opensbi' (https://git.qemu.org/git/opensbi.git) registered for path 'roms/opensbi'
Submodule 'roms/qemu-palcode' (https://git.qemu.org/git/qemu-palcode.git) registered for path 'roms/qemu-palcode'
Submodule 'roms/seabios' (https://git.qemu.org/git/seabios.git/) registered for path 'roms/seabios'
Submodule 'roms/seabios-hppa' (https://git.qemu.org/git/seabios-hppa.git) registered for path 'roms/seabios-hppa'
Submodule 'roms/sgabios' (https://git.qemu.org/git/sgabios.git) registered for path 'roms/sgabios'
Submodule 'roms/skiboot' (https://git.qemu.org/git/skiboot.git) registered for path 'roms/skiboot'
Submodule 'roms/u-boot' (https://git.qemu.org/git/u-boot.git) registered for path 'roms/u-boot'
Submodule 'roms/u-boot-sam460ex' (https://git.qemu.org/git/u-boot-sam460ex.git) registered for path 'roms/u-boot-sam460ex' Submodule 'slirp' (https://git.qemu.org/git/libslirp.git) registered for path 'slirp'
Submodule 'tests/fp/berkeley-softfloat-3' (https://git.qemu.org/git/berkeley-softfloat-3.git) registered for path 'tests/fp/berkeley-softfloat-3' Submodule 'tests/fp/berkeley-testfloat-3' (https://git.qemu.org/git/berkeley-testfloat-3.git) registered for path 'tests/fp/berkeley-testfloat-3' Submodule 'ui/keycodemapdb' (https://git.qemu.org/git/keycodemapdb.git) registered for path 'ui/keycodemapdb'
Cloning into 'capstone'...
Submodule path 'capstone': checked out '22ead3e0bfdb87516656453336160e0a37b066bf'
Cloning into 'dtc'...
Submodule path 'dtc': checked out '88f18909db731a627456f26d779445f84e449536'
Cloning into 'roms/QemuMacDrivers'...
Submodule path 'roms/QemuMacDrivers': checked out '90c488d5f4a407342247b9ea869df1c2d9c8e266'
Cloning into 'roms/SLOF'...
Submodule path 'roms/SLOF': checked out 'ba1ab360eebe6338bb8d7d83a9220ccf7e213af3'
Cloning into 'roms/edk2'...
Submodule path 'roms/edk2': checked out '20d2e5a125e34fc8501026613a71549b2a1a3e54'
Submodule 'SoftFloat' (https://github.com/ucb-bar/berkeley-softfloat-3.git) registered for path 'ArmPkg/Library/ArmSoftFloatLib/berkeley-softfloat-3' Submodule 'CryptoPkg/Library/OpensslLib/openssl' (https://github.com/openssl/openssl) registered for path 'CryptoPkg/Library/OpensslLib/openssl' Cloning into 'ArmPkg/Library/ArmSoftFloatLib/berkeley-softfloat-3'...
Submodule path 'roms/edk2/ArmPkg/Library/ArmSoftFloatLib/berkeley-softfloat-3': checked out 'b64af41c3276f97f0e181920400ee056b9c88037' Cloning into 'CryptoPkg/Library/OpensslLib/openssl'...
Submodule path 'roms/edk2/CryptoPkg/Library/OpensslLib/openssl': checked out '50eaac9f3337667259de725451f201e784599687' Submodule 'boringssl' (https://boringssl.googlesource.com/boringssl) registered for path 'boringssl'
Submodule 'krb5' (https://github.com/krb5/krb5) registered for path 'krb5'
Submodule 'pyca.cryptography' (https://github.com/pyca/cryptography.git) registered for path 'pyca-cryptography'
Cloning into 'boringssl'...
Submodule path 'roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl': checked out '2070f8ad9151dc8f3a73bffaa146b5e6937a583f' Cloning into 'krb5'...
Submodule path 'roms/edk2/CryptoPkg/Library/OpensslLib/openssl/krb5': checked out 'b9ad6c49505c96a088326b62a52568e3484f2168' Cloning into 'pyca-cryptography'...
Submodule path 'roms/edk2/CryptoPkg/Library/OpensslLib/openssl/pyca-cryptography': checked out '09403100de2f6f1cdd0d484dcb8e620f1c335c8f' Cloning into 'roms/ipxe'...
Submodule path 'roms/ipxe': checked out 'de4565cbe76ea9f7913a01f331be3ee901bb6e17'
Cloning into 'roms/openbios'...
Submodule path 'roms/openbios': checked out 'c79e0ecb84f4f1ee3f73f521622e264edd1bf174'
Cloning into 'roms/openhackware'...
Submodule path 'roms/openhackware': checked out 'c559da7c8eec5e45ef1f67978827af6f0b9546f5'
Cloning into 'roms/opensbi'...
Submodule path 'roms/opensbi': checked out 'ce228ee0919deb9957192d723eecc8aaae2697c6'
Cloning into 'roms/qemu-palcode'...
Submodule path 'roms/qemu-palcode': checked out 'bf0e13698872450164fa7040da36a95d2d4b326f'
Cloning into 'roms/seabios'...
Submodule path 'roms/seabios': checked out 'a5cab58e9a3fb6e168aba919c5669bea406573b4'
Cloning into 'roms/seabios-hppa'...
Submodule path 'roms/seabios-hppa': checked out '0f4fe84658165e96ce35870fd19fc634e182e77b'
Cloning into 'roms/sgabios'...
Submodule path 'roms/sgabios': checked out 'cbaee52287e5f32373181cff50a00b6c4ac9015a'
Cloning into 'roms/skiboot'...
Submodule path 'roms/skiboot': checked out '261ca8e779e5138869a45f174caa49be6a274501'
Cloning into 'roms/u-boot'...
Submodule path 'roms/u-boot': checked out 'd3689267f92c5956e09cc7d1baa4700141662bff'
Cloning into 'roms/u-boot-sam460ex'...
Submodule path 'roms/u-boot-sam460ex': checked out '60b3916f33e617a815973c5a6df77055b2e3a588'
Cloning into 'slirp'...
Submodule path 'slirp': checked out '126c04acbabd7ad32c2b018fe10dfac2a3bc1210'
Cloning into 'tests/fp/berkeley-softfloat-3'...
Submodule path 'tests/fp/berkeley-softfloat-3': checked out 'b64af41c3276f97f0e181920400ee056b9c88037'
Cloning into 'tests/fp/berkeley-testfloat-3'...
Submodule path 'tests/fp/berkeley-testfloat-3': checked out '5a59dcec19327396a011a17fd924aed4fec416b3'
Cloning into 'ui/keycodemapdb'...
Submodule path 'ui/keycodemapdb': checked out '6b3d716e2b6472eb7189d3220552280ef3d832ce'
Switched to a new branch 'test'
4313fed iotests: use python logging for iotests.log()
931c048 iotests: add protocol support to initialization info
0ab5b9c iotest 258: use script_main
d74dc52 iotests: add script_initialize
=== OUTPUT BEGIN ===
1/4 Checking commit d74dc52c7465 (iotests: add script_initialize)
ERROR: Missing Signed-off-by: line(s)
total: 1 errors, 0 warnings, 356 lines checked
Patch 1/4 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
2/4 Checking commit 0ab5b9cea52b (iotest 258: use script_main)
ERROR: Missing Signed-off-by: line(s)
total: 1 errors, 0 warnings, 17 lines checked
Patch 2/4 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
3/4 Checking commit 931c0485c36f (iotests: add protocol support to initialization info)
ERROR: Missing Signed-off-by: line(s)
total: 1 errors, 0 warnings, 67 lines checked
Patch 3/4 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
4/4 Checking commit 4313fed9d4d0 (iotests: use python logging for iotests.log())
ERROR: Missing Signed-off-by: line(s)
total: 1 errors, 0 warnings, 141 lines checked
Patch 4/4 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
=== OUTPUT END ===
Test command exited with code: 1
The full log is available at
http://patchew.org/logs/[email protected]/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]
Quoted 4 lines · On 8/20/19 8:10 PM, [email protected] wrote:
Patchew URL: https://patchew.org/QEMU/[email protected]/
Quoted 9 lines
Hi,
This series seems to have some coding style problems. See output below for more information:
Type: series
Subject: [Qemu-devel] [PATCH v3 0/4] iotests: use python logging
Message-id: [email protected]
I have to remember that apparently git-publish does not seem to "save" my setting for adding my signed-off-by if I don't explicitly request it.
Sorry about that. You may assume:
for all patches in this series.
Gentle ping. This should be fairly easy to review, I hope; the worst of it is making sure that no tests remain that don't engage an entry point in iotests.py anymore.
Quoted 60 lines · John Snow
This series uses python logging to enable output conditionally on
iotests.log(). We unify an initialization call (which also enables debugging output for those tests with -d) and then make the switch inside of iotests.It will help alleviate the need to create logged/unlogged versions of all the various helpers we have made.
V3:
- Rebased for 4.1+; now based on main branch.V2:
- Added all of the other python tests I missed to usescript_initialize
- Refactored the common setup as per Ehabkost's suggestion
- Added protocol arguments to common initialization,
but this isn't strictly required.John Snow (4):
iotests: addscript_initialize
iotest 258: usescript_main
iotests: add protocol support to initialization info
iotests: use python logging foriotests.log()tests/qemu-iotests/030 | 4 +- tests/qemu-iotests/149 | 3 +- tests/qemu-iotests/194 | 3 +- tests/qemu-iotests/202 | 3 +- tests/qemu-iotests/203 | 3 +- tests/qemu-iotests/206 | 2 +- tests/qemu-iotests/207 | 4 +- tests/qemu-iotests/208 | 2 +- tests/qemu-iotests/209 | 2 +- tests/qemu-iotests/210 | 4 +- tests/qemu-iotests/211 | 4 +- tests/qemu-iotests/212 | 4 +- tests/qemu-iotests/213 | 4 +- tests/qemu-iotests/216 | 3 +- tests/qemu-iotests/218 | 2 +- tests/qemu-iotests/219 | 2 +- tests/qemu-iotests/222 | 5 +- tests/qemu-iotests/224 | 3 +- tests/qemu-iotests/228 | 3 +- tests/qemu-iotests/234 | 3 +- tests/qemu-iotests/235 | 4 +- tests/qemu-iotests/236 | 2 +- tests/qemu-iotests/237 | 2 +- tests/qemu-iotests/238 | 2 + tests/qemu-iotests/242 | 2 +- tests/qemu-iotests/245 | 1 + tests/qemu-iotests/245.out | 24 ++++---- tests/qemu-iotests/246 | 2 +- tests/qemu-iotests/248 | 2 +- tests/qemu-iotests/254 | 2 +- tests/qemu-iotests/255 | 2 +- tests/qemu-iotests/256 | 2 +- tests/qemu-iotests/258 | 8 +-- tests/qemu-iotests/262 | 3 +- tests/qemu-iotests/iotests.py | 108 ++++++++++++++++++++++------------ 35 files changed, 124 insertions(+), 105 deletions(-)
Re: [Qemu-devel] [PATCH v3 1/4] iotests: add script_initialize
In reply to John SnowQuoted 351 lines · John Snow
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.
Note: supported_oses=['linux'] was omitted, as it is a default argument.
--- tests/qemu-iotests/149 | 3 +- tests/qemu-iotests/194 | 3 +- tests/qemu-iotests/202 | 3 +- tests/qemu-iotests/203 | 3 +- tests/qemu-iotests/206 | 2 +- tests/qemu-iotests/207 | 2 +- tests/qemu-iotests/208 | 2 +- tests/qemu-iotests/209 | 2 +- tests/qemu-iotests/210 | 2 +- tests/qemu-iotests/211 | 2 +- tests/qemu-iotests/212 | 2 +- tests/qemu-iotests/213 | 2 +- tests/qemu-iotests/216 | 3 +- tests/qemu-iotests/218 | 2 +- tests/qemu-iotests/219 | 2 +- tests/qemu-iotests/222 | 5 ++- tests/qemu-iotests/224 | 3 +- tests/qemu-iotests/228 | 3 +- tests/qemu-iotests/234 | 3 +- tests/qemu-iotests/235 | 4 +-- tests/qemu-iotests/236 | 2 +- tests/qemu-iotests/237 | 2 +- tests/qemu-iotests/238 | 2 ++ tests/qemu-iotests/242 | 2 +- tests/qemu-iotests/246 | 2 +- tests/qemu-iotests/248 | 2 +- tests/qemu-iotests/254 | 2 +- tests/qemu-iotests/255 | 2 +- tests/qemu-iotests/256 | 2 +- tests/qemu-iotests/262 | 3 +- tests/qemu-iotests/iotests.py | 58 +++++++++++++++++++++++------------ 31 files changed, 71 insertions(+), 61 deletions(-)tests/qemu-iotests/149 +1
-2@@ -383,8 +383,7 @@ def test_once(config, qemu_img=False): # Obviously we only work with the luks image format -iotests.verify_image_format(supported_fmts=['luks']) -iotests.verify_platform() +iotests.script_initialize(supported_fmts=['luks']) # We need sudo in order to run cryptsetup to create # dm-crypt devices. This is safe to use on anytests/qemu-iotests/194 +1
-2@@ -21,8 +21,7 @@ import iotests -iotests.verify_image_format(supported_fmts=['qcow2', 'qed', 'raw']) -iotests.verify_platform(['linux']) +iotests.script_initialize(supported_fmts=['qcow2', 'qed', 'raw']) with iotests.FilePath('source.img') as source_img_path, \ iotests.FilePath('dest.img') as dest_img_path, \tests/qemu-iotests/202 +1
-2@@ -24,8 +24,7 @@ import iotests -iotests.verify_image_format(supported_fmts=['qcow2']) -iotests.verify_platform(['linux']) +iotests.script_initialize(supported_fmts=['qcow2']) with iotests.FilePath('disk0.img') as disk0_img_path, \ iotests.FilePath('disk1.img') as disk1_img_path, \tests/qemu-iotests/203 +1
-2@@ -24,8 +24,7 @@ import iotests -iotests.verify_image_format(supported_fmts=['qcow2']) -iotests.verify_platform(['linux']) +iotests.script_initialize(supported_fmts=['qcow2']) with iotests.FilePath('disk0.img') as disk0_img_path, \ iotests.FilePath('disk1.img') as disk1_img_path, \tests/qemu-iotests/206 +1
-1@@ -23,7 +23,7 @@ import iotests from iotests import imgfmt -iotests.verify_image_format(supported_fmts=['qcow2']) +iotests.script_initialize(supported_fmts=['qcow2']) def blockdev_create(vm, options): result = vm.qmp_log('blockdev-create',tests/qemu-iotests/207 +1
-1@@ -24,7 +24,7 @@ import iotests import subprocess import re -iotests.verify_image_format(supported_fmts=['raw']) +iotests.script_initialize(supported_fmts=['raw']) iotests.verify_protocol(supported=['ssh']) def filter_hash(qmsg):tests/qemu-iotests/208 +1
-1@@ -22,7 +22,7 @@ import iotests -iotests.verify_image_format(supported_fmts=['generic']) +iotests.script_initialize(supported_fmts=['generic']) with iotests.FilePath('disk.img') as disk_img_path, \ iotests.FilePath('disk-snapshot.img') as disk_snapshot_img_path, \tests/qemu-iotests/209 +1
-1@@ -22,7 +22,7 @@ import iotests from iotests import qemu_img_create, qemu_io, qemu_img_verbose, qemu_nbd, \ file_path -iotests.verify_image_format(supported_fmts=['qcow2']) +iotests.script_initialize(supported_fmts=['qcow2']) disk, nbd_sock = file_path('disk', 'nbd-sock') nbd_uri = 'nbd+unix:///exp?socket=' + nbd_socktests/qemu-iotests/210 +1
-1@@ -23,7 +23,7 @@ import iotests from iotests import imgfmt -iotests.verify_image_format(supported_fmts=['luks']) +iotests.script_initialize(supported_fmts=['luks']) iotests.verify_protocol(supported=['file']) def blockdev_create(vm, options):tests/qemu-iotests/211 +1
-1@@ -23,7 +23,7 @@ import iotests from iotests import imgfmt -iotests.verify_image_format(supported_fmts=['vdi']) +iotests.script_initialize(supported_fmts=['vdi']) iotests.verify_protocol(supported=['file']) def blockdev_create(vm, options):tests/qemu-iotests/212 +1
-1@@ -23,7 +23,7 @@ import iotests from iotests import imgfmt -iotests.verify_image_format(supported_fmts=['parallels']) +iotests.script_initialize(supported_fmts=['parallels']) iotests.verify_protocol(supported=['file']) def blockdev_create(vm, options):tests/qemu-iotests/213 +1
-1@@ -23,7 +23,7 @@ import iotests from iotests import imgfmt -iotests.verify_image_format(supported_fmts=['vhdx']) +iotests.script_initialize(supported_fmts=['vhdx']) iotests.verify_protocol(supported=['file']) def blockdev_create(vm, options):tests/qemu-iotests/216 +1
-2@@ -23,8 +23,7 @@ import iotests from iotests import log, qemu_img, qemu_io_silent # Need backing file support -iotests.verify_image_format(supported_fmts=['qcow2', 'qcow', 'qed', 'vmdk']) -iotests.verify_platform(['linux']) +iotests.script_initialize(supported_fmts=['qcow2', 'qcow', 'qed', 'vmdk']) log('') log('=== Copy-on-read across nodes ===')tests/qemu-iotests/218 +1
-1@@ -29,7 +29,7 @@ import iotests from iotests import log, qemu_img, qemu_io_silent -iotests.verify_image_format(supported_fmts=['qcow2', 'raw']) +iotests.script_initialize(supported_fmts=['qcow2', 'raw']) # Launches the VM, adds two null-co nodes (source and target), andtests/qemu-iotests/219 +1
-1@@ -21,7 +21,7 @@ import iotests -iotests.verify_image_format(supported_fmts=['qcow2']) +iotests.script_initialize(supported_fmts=['qcow2']) img_size = 4 * 1024 * 1024tests/qemu-iotests/222 +2
-3@@ -24,9 +24,8 @@ import iotests from iotests import log, qemu_img, qemu_io, qemu_io_silent -iotests.verify_platform(['linux']) -iotests.verify_image_format(supported_fmts=['qcow2', 'qcow', 'qed', 'vmdk', - 'vhdx', 'raw']) +iotests.script_initialize(supported_fmts=['qcow2', 'qcow', 'qed', 'vmdk', + 'vhdx', 'raw']) patterns = [("0x5d", "0", "64k"), ("0xd5", "1M", "64k"),tests/qemu-iotests/224 +1
-2@@ -26,8 +26,7 @@ from iotests import log, qemu_img, qemu_io_silent, filter_qmp_testfiles, \ import json # Need backing file support (for arbitrary backing formats) -iotests.verify_image_format(supported_fmts=['qcow2', 'qcow', 'qed']) -iotests.verify_platform(['linux']) +iotests.script_initialize(supported_fmts=['qcow2', 'qcow', 'qed']) # There are two variations of this test:tests/qemu-iotests/228 +1
-2@@ -25,8 +25,7 @@ from iotests import log, qemu_img, filter_testfiles, filter_imgfmt, \ filter_qmp_testfiles, filter_qmp_imgfmt # Need backing file and change-backing-file support -iotests.verify_image_format(supported_fmts=['qcow2', 'qed']) -iotests.verify_platform(['linux']) +iotests.script_initialize(supported_fmts=['qcow2', 'qed']) def log_node_info(node):tests/qemu-iotests/234 +1
-2@@ -23,8 +23,7 @@ import iotests import os -iotests.verify_image_format(supported_fmts=['qcow2']) -iotests.verify_platform(['linux']) +iotests.script_initialize(supported_fmts=['qcow2']) with iotests.FilePath('img') as img_path, \ iotests.FilePath('backing') as backing_path, \tests/qemu-iotests/235 +2
-2@@ -27,6 +27,8 @@ sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python')) from qemu.machine import QEMUMachine +iotests.script_initialize(supported_fmts=['qcow2']) + # Note: # This test was added to check that mirror dead-lock was fixed (see previous # commit before this test addition).@@ -40,8 +42,6 @@ from qemu.machine import QEMUMachine size = 1 * 1024 * 1024 * 1024 -iotests.verify_image_format(supported_fmts=['qcow2']) - disk = file_path('disk') # prepare source imagetests/qemu-iotests/236 +1
-1@@ -22,7 +22,7 @@ import iotests from iotests import log -iotests.verify_image_format(supported_fmts=['generic']) +iotests.script_initialize(supported_fmts=['generic']) size = 64 * 1024 * 1024 granularity = 64 * 1024tests/qemu-iotests/237 +1
-1@@ -24,7 +24,7 @@ import math import iotests from iotests import imgfmt -iotests.verify_image_format(supported_fmts=['vmdk']) +iotests.script_initialize(supported_fmts=['vmdk']) def blockdev_create(vm, options): result = vm.qmp_log('blockdev-create', job_id='job0', options=options,tests/qemu-iotests/238 +0
-0
tests/qemu-iotests/238 import os · line 26
Quoted 4 lines
tests/qemu-iotests/238 +1
-0@@ -23,6 +23,8 @@ import os import iotests from iotests import log +iotests.script_initialize()
This restrict test 208 to the Linux platform, is this OK?
The rest looks good.
Quoted 200 lines
tests/qemu-iotests/238 +1
-0+ virtio_scsi_device = iotests.get_virtio_scsi_device() vm = iotests.VM()tests/qemu-iotests/242 +1
-1@@ -24,7 +24,7 @@ import struct from iotests import qemu_img_create, qemu_io, qemu_img_pipe, \ file_path, img_info_log, log, filter_qemu_io -iotests.verify_image_format(supported_fmts=['qcow2']) +iotests.script_initialize(supported_fmts=['qcow2']) disk = file_path('disk') chunk = 256 * 1024tests/qemu-iotests/246 +1
-1@@ -22,7 +22,7 @@ import iotests from iotests import log -iotests.verify_image_format(supported_fmts=['qcow2']) +iotests.script_initialize(supported_fmts=['qcow2']) size = 64 * 1024 * 1024 * 1024 gran_small = 32 * 1024 gran_large = 128 * 1024tests/qemu-iotests/248 +1
-1@@ -21,7 +21,7 @@ import iotests from iotests import qemu_img_create, qemu_io, file_path, filter_qmp_testfiles -iotests.verify_image_format(supported_fmts=['qcow2']) +iotests.script_initialize(supported_fmts=['qcow2']) source, target = file_path('source', 'target') size = 5 * 1024 * 1024tests/qemu-iotests/254 +1
-1@@ -21,7 +21,7 @@ import iotests from iotests import qemu_img_create, file_path, log -iotests.verify_image_format(supported_fmts=['qcow2']) +iotests.script_initialize(supported_fmts=['qcow2']) disk, top = file_path('disk', 'top') size = 1024 * 1024tests/qemu-iotests/255 +1
-1@@ -23,7 +23,7 @@ import iotests from iotests import imgfmt -iotests.verify_image_format(supported_fmts=['qcow2']) +iotests.script_initialize(supported_fmts=['qcow2']) def blockdev_create(vm, options): result = vm.qmp_log('blockdev-create',tests/qemu-iotests/256 +1
-1@@ -23,7 +23,7 @@ import os import iotests from iotests import log -iotests.verify_image_format(supported_fmts=['qcow2']) +iotests.script_initialize(supported_fmts=['qcow2']) size = 64 * 1024 * 1024 with iotests.FilePath('img0') as img0_path, \tests/qemu-iotests/262 +1
-2@@ -23,8 +23,7 @@ import iotests import os -iotests.verify_image_format(supported_fmts=['qcow2']) -iotests.verify_platform(['linux']) +iotests.script_initialize(supported_fmts=['qcow2']) with iotests.FilePath('img') as img_path, \ iotests.FilePath('mig_fifo') as fifo, \tests/qemu-iotests/iotests.py +38
-20@@ -895,7 +895,20 @@ def skip_if_unsupported(required_formats=[], read_only=False): return func_wrapper return skip_test_decorator -def execute_unittest(output, verbosity, debug): +def execute_unittest(debug=False): + """Executes unittests within the calling module.""" + + verbosity = 2 if debug else 1 + + if debug: + output = sys.stdout + elif sys.version_info.major >= 3: + output = io.StringIO() + else: + # io.StringIO is for unicode strings, which is not what + # 2.x's test runner emits. + output = io.BytesIO() + runner = unittest.TextTestRunner(stream=output, descriptions=True, verbosity=verbosity) try:@@ -903,14 +916,19 @@ def execute_unittest(output, verbosity, debug): # exception unittest.main(testRunner=runner) finally: + # We need to filter out the time taken from the output so that + # qemu-iotest can reliably diff the results against master output. if not debug: sys.stderr.write(re.sub(r'Ran (\d+) tests? in [\d.]+s', r'Ran \1 tests', output.getvalue())) -def execute_test(test_function=None, - supported_fmts=[], supported_oses=['linux'], - supported_cache_modes=[], unsupported_fmts=[]): - """Run either unittest or script-style tests.""" +def execute_setup_common(supported_fmts=[], + supported_oses=['linux'], + supported_cache_modes=[], + unsupported_fmts=[]): + """ + Perform necessary setup for either script-style or unittest-style tests. + """ # We are using TEST_DIR and QEMU_DEFAULT_MACHINE as proxies to # indicate that we're not being run via "check". There may be@@ -920,37 +938,37 @@ def execute_test(test_function=None, sys.stderr.write('Please run this test via the "check" script\n') sys.exit(os.EX_USAGE) - debug = '-d' in sys.argv - verbosity = 1 verify_image_format(supported_fmts, unsupported_fmts) verify_platform(supported_oses) verify_cache_mode(supported_cache_modes) + debug = '-d' in sys.argv if debug: - output = sys.stdout - verbosity = 2 sys.argv.remove('-d') - else: - # We need to filter out the time taken from the output so that - # qemu-iotest can reliably diff the results against master output. - if sys.version_info.major >= 3: - output = io.StringIO() - else: - # io.StringIO is for unicode strings, which is not what - # 2.x's test runner emits. - output = io.BytesIO() - logging.basicConfig(level=(logging.DEBUG if debug else logging.WARN)) + return debug + +def execute_test(test_function=None, *args, **kwargs): + """Run either unittest or script-style tests.""" + + debug = execute_setup_common(*args, **kwargs) if not test_function: - execute_unittest(output, verbosity, debug) + execute_unittest(debug) else: test_function() +# This is called from script-style iotests without a single point of entry +def script_initialize(*args, **kwargs): + """Initialize script-style tests without running any tests.""" + execute_setup_common(*args, **kwargs) + +# This is called from script-style iotests with a single point of entry def script_main(test_function, *args, **kwargs): """Run script-style tests outside of the unittest framework""" execute_test(test_function, *args, **kwargs) +# This is called from unittest style iotests def main(*args, **kwargs): """Run tests using the unittest framework""" execute_test(None, *args, **kwargs)
Re: [Qemu-devel] [PATCH v3 3/4] iotests: add protocol support to initialization info
In reply to John SnowQuoted 2 lines · John Snow
This will add
supported_protocolsandunsupported_protocolsto all of iotests.main, iotests.script_main, and iotests.script_initialize.
With your Signed-off-by:
Quoted 108 lines
--- tests/qemu-iotests/207 | 4 ++-- tests/qemu-iotests/210 | 4 ++-- tests/qemu-iotests/211 | 4 ++-- tests/qemu-iotests/212 | 4 ++-- tests/qemu-iotests/213 | 4 ++-- tests/qemu-iotests/iotests.py | 5 ++++- 6 files changed, 14 insertions(+), 11 deletions(-)tests/qemu-iotests/207 +2
-2@@ -24,8 +24,8 @@ import iotests import subprocess import re -iotests.script_initialize(supported_fmts=['raw']) -iotests.verify_protocol(supported=['ssh']) +iotests.script_initialize(supported_fmts=['raw'], + supported_protocols=['ssh']) def filter_hash(qmsg): def _filter(key, value):tests/qemu-iotests/210 +2
-2@@ -23,8 +23,8 @@ import iotests from iotests import imgfmt -iotests.script_initialize(supported_fmts=['luks']) -iotests.verify_protocol(supported=['file']) +iotests.script_initialize(supported_fmts=['luks'], + supported_protocols=['file']) def blockdev_create(vm, options): result = vm.qmp_log('blockdev-create', job_id='job0', options=options,tests/qemu-iotests/211 +2
-2@@ -23,8 +23,8 @@ import iotests from iotests import imgfmt -iotests.script_initialize(supported_fmts=['vdi']) -iotests.verify_protocol(supported=['file']) +iotests.script_initialize(supported_fmts=['vdi'], + supported_protocols=['file']) def blockdev_create(vm, options): result = vm.qmp_log('blockdev-create', job_id='job0', options=options,tests/qemu-iotests/212 +2
-2@@ -23,8 +23,8 @@ import iotests from iotests import imgfmt -iotests.script_initialize(supported_fmts=['parallels']) -iotests.verify_protocol(supported=['file']) +iotests.script_initialize(supported_fmts=['parallels'], + supported_protocols=['file']) def blockdev_create(vm, options): result = vm.qmp_log('blockdev-create', job_id='job0', options=options,tests/qemu-iotests/213 +2
-2@@ -23,8 +23,8 @@ import iotests from iotests import imgfmt -iotests.script_initialize(supported_fmts=['vhdx']) -iotests.verify_protocol(supported=['file']) +iotests.script_initialize(supported_fmts=['vhdx'], + supported_protocols=['file']) def blockdev_create(vm, options): result = vm.qmp_log('blockdev-create', job_id='job0', options=options,tests/qemu-iotests/iotests.py +4
-1@@ -925,7 +925,9 @@ def execute_unittest(debug=False): def execute_setup_common(supported_fmts=[], supported_oses=['linux'], supported_cache_modes=[], - unsupported_fmts=[]): + unsupported_fmts=[], + supported_protocols=[], + unsupported_protocols=[]): """ Perform necessary setup for either script-style or unittest-style tests. """@@ -941,6 +943,7 @@ def execute_setup_common(supported_fmts=[], verify_image_format(supported_fmts, unsupported_fmts) verify_platform(supported_oses) verify_cache_mode(supported_cache_modes) + verify_protocol(supported_protocols, unsupported_protocols) debug = '-d' in sys.argv if debug:
Re: [Qemu-devel] [PATCH v3 2/4] iotest 258: use script_main
In reply to John SnowQuoted 2 lines · John Snow
Since this one is nicely factored to use a single entry point, use
script_mainto run the tests.
With your Signed-off-by:
Quoted 28 lines
--- tests/qemu-iotests/258 | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)tests/qemu-iotests/258 +2
-6@@ -23,11 +23,6 @@ import iotests from iotests import log, qemu_img, qemu_io_silent, \ filter_qmp_testfiles, filter_qmp_imgfmt -# Need backing file and change-backing-file support -iotests.verify_image_format(supported_fmts=['qcow2', 'qed']) -iotests.verify_platform(['linux']) - - # Returns a node for blockdev-add def node(node_name, path, backing=None, fmt=None, throttle=None): if fmt is None:@@ -160,4 +155,5 @@ def main(): test_concurrent_finish(False) if __name__ == '__main__': - main() + # Need backing file and change-backing-file support + iotests.script_main(main, supported_fmts=['qcow2', 'qed'])
Re: [Qemu-devel] [PATCH v3 4/4] iotests: use python logging for iotests.log()
In reply to John SnowQuoted 33 lines · John Snow
We can turn logging on/off globally instead of per-function.
Remove
use_logfromrun_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.
--- tests/qemu-iotests/030 | 4 +-- tests/qemu-iotests/245 | 1 + tests/qemu-iotests/245.out | 24 +++++++++--------- tests/qemu-iotests/iotests.py | 47 +++++++++++++++++++++-------------- 4 files changed, 43 insertions(+), 33 deletions(-)tests/qemu-iotests/030 +2
-2@@ -411,8 +411,8 @@ class TestParallelOps(iotests.QMPTestCase): result = self.vm.qmp('block-job-set-speed', device='drive0', speed=0) self.assert_qmp(result, 'return', {}) - self.vm.run_job(job='drive0', auto_dismiss=True, use_log=False) - self.vm.run_job(job='node4', auto_dismiss=True, use_log=False) + self.vm.run_job(job='drive0', auto_dismiss=True) + self.vm.run_job(job='node4', auto_dismiss=True) self.assert_no_active_block_jobs() # Test a block-stream and a block-commit job in paralleltests/qemu-iotests/245 +0
-0
tests/qemu-iotests/245 class TestBlockdevReopen(iotests.QMPTestCase): · line 1004
Quoted 5 lines
tests/qemu-iotests/245 +1
-0@@ -1000,4 +1000,5 @@ class TestBlockdevReopen(iotests.QMPTestCase): self.reopen(opts, {'backing': 'hd2'}) if __name__ == '__main__': + iotests.activate_logging() iotests.main(supported_fmts=["qcow2"])
Why not use:
iotests.script_main(iotests.main, supported_fmts=['qcow2')
Quoted 157 lines
tests/qemu-iotests/245.out +12
-12@@ -1,17 +1,17 @@ +{"execute": "job-finalize", "arguments": {"id": "commit0"}} +{"return": {}} +{"data": {"id": "commit0", "type": "commit"}, "event": "BLOCK_JOB_PENDING", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} +{"data": {"device": "commit0", "len": 3145728, "offset": 3145728, "speed": 0, "type": "commit"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} +{"execute": "job-finalize", "arguments": {"id": "stream0"}} +{"return": {}} +{"data": {"id": "stream0", "type": "stream"}, "event": "BLOCK_JOB_PENDING", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} +{"data": {"device": "stream0", "len": 3145728, "offset": 3145728, "speed": 0, "type": "stream"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} +{"execute": "job-finalize", "arguments": {"id": "stream0"}} +{"return": {}} +{"data": {"id": "stream0", "type": "stream"}, "event": "BLOCK_JOB_PENDING", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} +{"data": {"device": "stream0", "len": 3145728, "offset": 3145728, "speed": 0, "type": "stream"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} ---------------------------------------------------------------------- Ran 18 tests OK -{"execute": "job-finalize", "arguments": {"id": "commit0"}} -{"return": {}} -{"data": {"id": "commit0", "type": "commit"}, "event": "BLOCK_JOB_PENDING", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} -{"data": {"device": "commit0", "len": 3145728, "offset": 3145728, "speed": 0, "type": "commit"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} -{"execute": "job-finalize", "arguments": {"id": "stream0"}} -{"return": {}} -{"data": {"id": "stream0", "type": "stream"}, "event": "BLOCK_JOB_PENDING", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} -{"data": {"device": "stream0", "len": 3145728, "offset": 3145728, "speed": 0, "type": "stream"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} -{"execute": "job-finalize", "arguments": {"id": "stream0"}} -{"return": {}} -{"data": {"id": "stream0", "type": "stream"}, "event": "BLOCK_JOB_PENDING", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} -{"data": {"device": "stream0", "len": 3145728, "offset": 3145728, "speed": 0, "type": "stream"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}tests/qemu-iotests/iotests.py +28
-19@@ -35,6 +35,13 @@ from collections import OrderedDict sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python')) from qemu import qtest +# Use this logger for logging messages directly from the iotests module +logger = logging.getLogger(__name__) +logger.addHandler(logging.NullHandler()) + +# Use this logger for messages that ought to be used for diff output. +test_logger = logging.getLogger('.'.join((__name__, 'iotest'))) +test_logger.addHandler(logging.NullHandler()) # This will not work if arguments contain spaces but is necessary if we # want to support the override options that ./check supports.@@ -343,10 +350,10 @@ def log(msg, filters=[], indent=None): separators = (', ', ': ') if indent is None else (',', ': ') # Don't sort if it's already sorted do_sort = not isinstance(msg, OrderedDict) - print(json.dumps(msg, sort_keys=do_sort, - indent=indent, separators=separators)) + test_logger.info(json.dumps(msg, sort_keys=do_sort, + indent=indent, separators=separators)) else: - print(msg) + test_logger.info(msg) class Timeout: def __init__(self, seconds, errmsg = "Timeout"):@@ -559,7 +566,7 @@ class VM(qtest.QEMUQtestMachine): # Returns None on success, and an error string on failure def run_job(self, job, auto_finalize=True, auto_dismiss=False, - pre_finalize=None, cancel=False, use_log=True, wait=60.0): + pre_finalize=None, cancel=False, wait=60.0): """ run_job moves a job from creation through to dismissal.@@ -572,7 +579,6 @@ class VM(qtest.QEMUQtestMachine): invoked prior to issuing job-finalize, if any. :param cancel: Bool. When true, cancels the job after the pre_finalize callback. - :param use_log: Bool. When false, does not log QMP messages. :param wait: Float. Timeout value specifying how long to wait for any event, in seconds. Defaults to 60.0. """@@ -590,8 +596,7 @@ class VM(qtest.QEMUQtestMachine): while True: ev = filter_qmp_event(self.events_wait(events)) if ev['event'] != 'JOB_STATUS_CHANGE': - if use_log: - log(ev) + log(ev) continue status = ev['data']['status'] if status == 'aborting':@@ -599,24 +604,16 @@ class VM(qtest.QEMUQtestMachine): for j in result['return']: if j['id'] == job: error = j['error'] - if use_log: - log('Job failed: %s' % (j['error'])) + log('Job failed: %s' % (j['error'])) elif status == 'pending' and not auto_finalize: if pre_finalize: pre_finalize() - if cancel and use_log: + if cancel: self.qmp_log('job-cancel', id=job) - elif cancel: - self.qmp('job-cancel', id=job) - elif use_log: + else: self.qmp_log('job-finalize', id=job) - else: - self.qmp('job-finalize', id=job) elif status == 'concluded' and not auto_dismiss: - if use_log: - self.qmp_log('job-dismiss', id=job) - else: - self.qmp('job-dismiss', id=job) + self.qmp_log('job-dismiss', id=job) elif status == 'null': return error@@ -949,6 +946,7 @@ def execute_setup_common(supported_fmts=[], if debug: sys.argv.remove('-d') logging.basicConfig(level=(logging.DEBUG if debug else logging.WARN)) + logger.debug("iotests debugging messages active") return debug@@ -961,14 +959,25 @@ def execute_test(test_function=None, *args, **kwargs): else: test_function() +def activate_logging(): + """Activate iotests.log() output to stdout for script-style tests.""" + handler = logging.StreamHandler(stream=sys.stdout) + formatter = logging.Formatter('%(message)s') + handler.setFormatter(formatter) + test_logger.addHandler(handler) + test_logger.setLevel(logging.INFO) + test_logger.propagate = False + # This is called from script-style iotests without a single point of entry def script_initialize(*args, **kwargs): """Initialize script-style tests without running any tests.""" + activate_logging() execute_setup_common(*args, **kwargs) # This is called from script-style iotests with a single point of entry def script_main(test_function, *args, **kwargs): """Run script-style tests outside of the unittest framework""" + activate_logging() execute_test(test_function, *args, **kwargs) # This is called from unittest style iotests
Re: [Qemu-devel] [PATCH v3 1/4] iotests: add script_initialize
In reply to Philippe Mathieu-DaudéQuoted 3 lines · Philippe Mathieu-Daudé
This restrict test 208 to the Linux platform, is this OK?
The rest looks good.
I forgot about that, so good catch.
I don't know. We seem to already restrict a LOT of tests to the Linux platform. Does this one actually work on other platforms?
Actually, I can't see any other supported oses/supported platforms calls anywhere in iotests that don't just specify Linux or leave it the default (...which is also linux.)
There isn't a way to engage the old-style python unittest framework without implying Linux; you have to manually override it if so.
For new tests, MOST of them specified Linux in some way or another, as you saw.
So either:
- 208 was an oversight, or
- Many tests are accidentally limiting to Linux and could be loosened.
Which is it? Dunno. Guess I'll look at the VM tests to see if I can co-opt some of that... stay tuned?
--js
Re: [Qemu-devel] [PATCH v3 4/4] iotests: use python logging for iotests.log()
In reply to Philippe Mathieu-DaudéQuoted 36 lines · Philippe Mathieu-Daudé
Quoted 35 lines · John Snow
We can turn logging on/off globally instead of per-function.
Remove
use_logfromrun_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.
--- tests/qemu-iotests/030 | 4 +-- tests/qemu-iotests/245 | 1 + tests/qemu-iotests/245.out | 24 +++++++++--------- tests/qemu-iotests/iotests.py | 47 +++++++++++++++++++++-------------- 4 files changed, 43 insertions(+), 33 deletions(-)tests/qemu-iotests/030 +2
-2@@ -411,8 +411,8 @@ class TestParallelOps(iotests.QMPTestCase): result = self.vm.qmp('block-job-set-speed', device='drive0', speed=0) self.assert_qmp(result, 'return', {}) - self.vm.run_job(job='drive0', auto_dismiss=True, use_log=False) - self.vm.run_job(job='node4', auto_dismiss=True, use_log=False) + self.vm.run_job(job='drive0', auto_dismiss=True) + self.vm.run_job(job='node4', auto_dismiss=True) self.assert_no_active_block_jobs() # Test a block-stream and a block-commit job in paralleltests/qemu-iotests/245 +0
-0@@ -1000,4 +1000,5 @@ class TestBlockdevReopen(iotests.QMPTestCase): self.reopen(opts, {'backing': 'hd2'})
Quoted 8 lines
tests/qemu-iotests/245 class TestBlockdevReopen(iotests.QMPTestCase): · line 1004
Quoted 3 lines
tests/qemu-iotests/245 +1
-0if __name__ == '__main__': + iotests.activate_logging() iotests.main(supported_fmts=["qcow2"])Why not use:
iotests.script_main(iotests.main, supported_fmts=['qcow2')
Well, that'd call iotests.execute_test twice and it'd perform setup twice, too.
Usually, we want logging on for "script-style" tests, but we want logging off for unittest-style ones. This test has opted to use both.
(Or more likely: just wanted to use run_job and just dealt with the extramodal output.)
OK; we can turn on logging as we see fit.
--js
Re: [Qemu-devel] [PATCH v3 1/4] iotests: add script_initialize
In reply to John SnowQuoted 10 lines · John Snow
Quoted 3 lines · Philippe Mathieu-Daudé
This restrict test 208 to the Linux platform, is this OK?
The rest looks good.
I forgot about that, so good catch.
I don't know. We seem to already restrict a LOT of tests to the Linux platform. Does this one actually work on other platforms?
Quoted 6 lines
Actually, I can't see any other supported oses/supported platforms calls anywhere in iotests that don't just specify Linux or leave it the default (...which is also linux.)
There isn't a way to engage the old-style python unittest framework without implying Linux; you have to manually override it if so.
Then let's use:
iotests.script_initialize(supported_oses=[])
and call it a day?
Quoted 7 lines
For new tests, MOST of them specified Linux in some way or another, as you saw.
So either:
- 208 was an oversight, or
- Many tests are accidentally limiting to Linux and could be loosened.
This can stay in your TODO for after this painful series.
Quoted 5 lines
Which is it? Dunno. Guess I'll look at the VM tests to see if I can co-opt some of that... stay tuned?
--js
Re: [Qemu-devel] [PATCH v3 1/4] iotests: add script_initialize
Quoted 15 lines · Philippe Mathieu-Daudé
Quoted 14 lines · John Snow
Quoted 3 lines · Philippe Mathieu-Daudé
This restrict test 208 to the Linux platform, is this OK?
The rest looks good.
I forgot about that, so good catch.
I don't know. We seem to already restrict a LOT of tests to the Linux platform. Does this one actually work on other platforms?
Actually, I can't see any other supported oses/supported platforms calls anywhere in iotests that don't just specify Linux or leave it the default (...which is also linux.)
Quoted 9 lines
Quoted 2 lines
There isn't a way to engage the old-style python unittest framework without implying Linux; you have to manually override it if so.
Then let's use:
iotests.script_initialize(supported_oses=[])and call it a day?
*whines*
The even lazier thing to do is to do more work to come up with some excuse to avoid re-spinning the series:
commit bc521696607c5348fcd8a9e57b408d0ac0dbe2f8
Author: Fam Zheng <[email protected]> Date: Sun Jan 4 09:53:52 2015 +0800
qemu-iotests: Add supported os parameter for python tests
If I understand correctly, qemu-iotests never meant to be portable. We only support Linux for all the shell cases, but didn't specify it for python tests. Now add this and default all the python tests as Linux only. If we cares enough later, we can override the parameter in individual cases.
I think it's only an oversight that this one test didn't specify a platform. It's certainly the only one. If someone feels strongly that other platforms are supported, let them send the patch.
--js