iotests: add script_initialize
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>
This commit is contained in:
parent
239bbcc0ae
commit
7d8140595f
@ -382,8 +382,7 @@ def test_once(config, qemu_img=False):
|
|||||||
|
|
||||||
|
|
||||||
# Obviously we only work with the luks image format
|
# Obviously we only work with the luks image format
|
||||||
iotests.verify_image_format(supported_fmts=['luks'])
|
iotests.script_initialize(supported_fmts=['luks'])
|
||||||
iotests.verify_platform()
|
|
||||||
|
|
||||||
# We need sudo in order to run cryptsetup to create
|
# We need sudo in order to run cryptsetup to create
|
||||||
# dm-crypt devices. This is safe to use on any
|
# dm-crypt devices. This is safe to use on any
|
||||||
|
@ -21,8 +21,8 @@
|
|||||||
|
|
||||||
import iotests
|
import iotests
|
||||||
|
|
||||||
iotests.verify_image_format(supported_fmts=['qcow2', 'qed', 'raw'])
|
iotests.script_initialize(supported_fmts=['qcow2', 'qed', 'raw'],
|
||||||
iotests.verify_platform(['linux'])
|
supported_platforms=['linux'])
|
||||||
|
|
||||||
with iotests.FilePath('source.img') as source_img_path, \
|
with iotests.FilePath('source.img') as source_img_path, \
|
||||||
iotests.FilePath('dest.img') as dest_img_path, \
|
iotests.FilePath('dest.img') as dest_img_path, \
|
||||||
|
@ -24,8 +24,8 @@
|
|||||||
|
|
||||||
import iotests
|
import iotests
|
||||||
|
|
||||||
iotests.verify_image_format(supported_fmts=['qcow2'])
|
iotests.script_initialize(supported_fmts=['qcow2'],
|
||||||
iotests.verify_platform(['linux'])
|
supported_platforms=['linux'])
|
||||||
|
|
||||||
with iotests.FilePath('disk0.img') as disk0_img_path, \
|
with iotests.FilePath('disk0.img') as disk0_img_path, \
|
||||||
iotests.FilePath('disk1.img') as disk1_img_path, \
|
iotests.FilePath('disk1.img') as disk1_img_path, \
|
||||||
|
@ -24,8 +24,8 @@
|
|||||||
|
|
||||||
import iotests
|
import iotests
|
||||||
|
|
||||||
iotests.verify_image_format(supported_fmts=['qcow2'])
|
iotests.script_initialize(supported_fmts=['qcow2'],
|
||||||
iotests.verify_platform(['linux'])
|
supported_platforms=['linux'])
|
||||||
|
|
||||||
with iotests.FilePath('disk0.img') as disk0_img_path, \
|
with iotests.FilePath('disk0.img') as disk0_img_path, \
|
||||||
iotests.FilePath('disk1.img') as disk1_img_path, \
|
iotests.FilePath('disk1.img') as disk1_img_path, \
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
import iotests
|
import iotests
|
||||||
from iotests import imgfmt
|
from iotests import imgfmt
|
||||||
|
|
||||||
iotests.verify_image_format(supported_fmts=['qcow2'])
|
iotests.script_initialize(supported_fmts=['qcow2'])
|
||||||
|
|
||||||
with iotests.FilePath('t.qcow2') as disk_path, \
|
with iotests.FilePath('t.qcow2') as disk_path, \
|
||||||
iotests.FilePath('t.qcow2.base') as backing_path, \
|
iotests.FilePath('t.qcow2.base') as backing_path, \
|
||||||
|
@ -24,8 +24,10 @@ import iotests
|
|||||||
import subprocess
|
import subprocess
|
||||||
import re
|
import re
|
||||||
|
|
||||||
iotests.verify_image_format(supported_fmts=['raw'])
|
iotests.script_initialize(
|
||||||
iotests.verify_protocol(supported=['ssh'])
|
supported_fmts=['raw'],
|
||||||
|
supported_protocols=['ssh'],
|
||||||
|
)
|
||||||
|
|
||||||
def filter_hash(qmsg):
|
def filter_hash(qmsg):
|
||||||
def _filter(key, value):
|
def _filter(key, value):
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
import iotests
|
import iotests
|
||||||
|
|
||||||
iotests.verify_image_format(supported_fmts=['generic'])
|
iotests.script_initialize(supported_fmts=['generic'])
|
||||||
|
|
||||||
with iotests.FilePath('disk.img') as disk_img_path, \
|
with iotests.FilePath('disk.img') as disk_img_path, \
|
||||||
iotests.FilePath('disk-snapshot.img') as disk_snapshot_img_path, \
|
iotests.FilePath('disk-snapshot.img') as disk_snapshot_img_path, \
|
||||||
|
@ -22,7 +22,7 @@ import iotests
|
|||||||
from iotests import qemu_img_create, qemu_io, qemu_img_verbose, qemu_nbd, \
|
from iotests import qemu_img_create, qemu_io, qemu_img_verbose, qemu_nbd, \
|
||||||
file_path
|
file_path
|
||||||
|
|
||||||
iotests.verify_image_format(supported_fmts=['qcow2'])
|
iotests.script_initialize(supported_fmts=['qcow2'])
|
||||||
|
|
||||||
disk = file_path('disk')
|
disk = file_path('disk')
|
||||||
nbd_sock = file_path('nbd-sock', base_dir=iotests.sock_dir)
|
nbd_sock = file_path('nbd-sock', base_dir=iotests.sock_dir)
|
||||||
|
@ -23,8 +23,10 @@
|
|||||||
import iotests
|
import iotests
|
||||||
from iotests import imgfmt
|
from iotests import imgfmt
|
||||||
|
|
||||||
iotests.verify_image_format(supported_fmts=['luks'])
|
iotests.script_initialize(
|
||||||
iotests.verify_protocol(supported=['file'])
|
supported_fmts=['luks'],
|
||||||
|
supported_protocols=['file'],
|
||||||
|
)
|
||||||
|
|
||||||
with iotests.FilePath('t.luks') as disk_path, \
|
with iotests.FilePath('t.luks') as disk_path, \
|
||||||
iotests.VM() as vm:
|
iotests.VM() as vm:
|
||||||
|
@ -23,8 +23,10 @@
|
|||||||
import iotests
|
import iotests
|
||||||
from iotests import imgfmt
|
from iotests import imgfmt
|
||||||
|
|
||||||
iotests.verify_image_format(supported_fmts=['vdi'])
|
iotests.script_initialize(
|
||||||
iotests.verify_protocol(supported=['file'])
|
supported_fmts=['vdi'],
|
||||||
|
supported_protocols=['file'],
|
||||||
|
)
|
||||||
|
|
||||||
def blockdev_create(vm, options):
|
def blockdev_create(vm, options):
|
||||||
error = vm.blockdev_create(options)
|
error = vm.blockdev_create(options)
|
||||||
|
@ -23,8 +23,10 @@
|
|||||||
import iotests
|
import iotests
|
||||||
from iotests import imgfmt
|
from iotests import imgfmt
|
||||||
|
|
||||||
iotests.verify_image_format(supported_fmts=['parallels'])
|
iotests.script_initialize(
|
||||||
iotests.verify_protocol(supported=['file'])
|
supported_fmts=['parallels'],
|
||||||
|
supported_protocols=['file'],
|
||||||
|
)
|
||||||
|
|
||||||
with iotests.FilePath('t.parallels') as disk_path, \
|
with iotests.FilePath('t.parallels') as disk_path, \
|
||||||
iotests.VM() as vm:
|
iotests.VM() as vm:
|
||||||
|
@ -23,8 +23,10 @@
|
|||||||
import iotests
|
import iotests
|
||||||
from iotests import imgfmt
|
from iotests import imgfmt
|
||||||
|
|
||||||
iotests.verify_image_format(supported_fmts=['vhdx'])
|
iotests.script_initialize(
|
||||||
iotests.verify_protocol(supported=['file'])
|
supported_fmts=['vhdx'],
|
||||||
|
supported_protocols=['file'],
|
||||||
|
)
|
||||||
|
|
||||||
with iotests.FilePath('t.vhdx') as disk_path, \
|
with iotests.FilePath('t.vhdx') as disk_path, \
|
||||||
iotests.VM() as vm:
|
iotests.VM() as vm:
|
||||||
|
@ -23,8 +23,8 @@ import iotests
|
|||||||
from iotests import log, qemu_img, qemu_io_silent
|
from iotests import log, qemu_img, qemu_io_silent
|
||||||
|
|
||||||
# Need backing file support
|
# Need backing file support
|
||||||
iotests.verify_image_format(supported_fmts=['qcow2', 'qcow', 'qed', 'vmdk'])
|
iotests.script_initialize(supported_fmts=['qcow2', 'qcow', 'qed', 'vmdk'],
|
||||||
iotests.verify_platform(['linux'])
|
supported_platforms=['linux'])
|
||||||
|
|
||||||
log('')
|
log('')
|
||||||
log('=== Copy-on-read across nodes ===')
|
log('=== Copy-on-read across nodes ===')
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
import iotests
|
import iotests
|
||||||
from iotests import log, qemu_img, qemu_io_silent
|
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
|
# Launches the VM, adds two null-co nodes (source and target), and
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
import iotests
|
import iotests
|
||||||
|
|
||||||
iotests.verify_image_format(supported_fmts=['qcow2'])
|
iotests.script_initialize(supported_fmts=['qcow2'])
|
||||||
|
|
||||||
img_size = 4 * 1024 * 1024
|
img_size = 4 * 1024 * 1024
|
||||||
|
|
||||||
|
@ -24,9 +24,10 @@
|
|||||||
import iotests
|
import iotests
|
||||||
from iotests import log, qemu_img, qemu_io, qemu_io_silent
|
from iotests import log, qemu_img, qemu_io, qemu_io_silent
|
||||||
|
|
||||||
iotests.verify_platform(['linux'])
|
iotests.script_initialize(
|
||||||
iotests.verify_image_format(supported_fmts=['qcow2', 'qcow', 'qed', 'vmdk',
|
supported_fmts=['qcow2', 'qcow', 'qed', 'vmdk', 'vhdx', 'raw'],
|
||||||
'vhdx', 'raw'])
|
supported_platforms=['linux'],
|
||||||
|
)
|
||||||
|
|
||||||
patterns = [("0x5d", "0", "64k"),
|
patterns = [("0x5d", "0", "64k"),
|
||||||
("0xd5", "1M", "64k"),
|
("0xd5", "1M", "64k"),
|
||||||
|
@ -26,8 +26,8 @@ from iotests import log, qemu_img, qemu_io_silent, filter_qmp_testfiles, \
|
|||||||
import json
|
import json
|
||||||
|
|
||||||
# Need backing file support (for arbitrary backing formats)
|
# Need backing file support (for arbitrary backing formats)
|
||||||
iotests.verify_image_format(supported_fmts=['qcow2', 'qcow', 'qed'])
|
iotests.script_initialize(supported_fmts=['qcow2', 'qcow', 'qed'],
|
||||||
iotests.verify_platform(['linux'])
|
supported_platforms=['linux'])
|
||||||
|
|
||||||
|
|
||||||
# There are two variations of this test:
|
# There are two variations of this test:
|
||||||
|
@ -25,8 +25,10 @@ from iotests import log, qemu_img, filter_testfiles, filter_imgfmt, \
|
|||||||
filter_qmp_testfiles, filter_qmp_imgfmt
|
filter_qmp_testfiles, filter_qmp_imgfmt
|
||||||
|
|
||||||
# Need backing file and change-backing-file support
|
# Need backing file and change-backing-file support
|
||||||
iotests.verify_image_format(supported_fmts=['qcow2', 'qed'])
|
iotests.script_initialize(
|
||||||
iotests.verify_platform(['linux'])
|
supported_fmts=['qcow2', 'qed'],
|
||||||
|
supported_platforms=['linux'],
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def log_node_info(node):
|
def log_node_info(node):
|
||||||
|
@ -23,8 +23,8 @@
|
|||||||
import iotests
|
import iotests
|
||||||
import os
|
import os
|
||||||
|
|
||||||
iotests.verify_image_format(supported_fmts=['qcow2'])
|
iotests.script_initialize(supported_fmts=['qcow2'],
|
||||||
iotests.verify_platform(['linux'])
|
supported_platforms=['linux'])
|
||||||
|
|
||||||
with iotests.FilePath('img') as img_path, \
|
with iotests.FilePath('img') as img_path, \
|
||||||
iotests.FilePath('backing') as backing_path, \
|
iotests.FilePath('backing') as backing_path, \
|
||||||
|
@ -27,6 +27,8 @@ sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python'))
|
|||||||
|
|
||||||
from qemu.machine import QEMUMachine
|
from qemu.machine import QEMUMachine
|
||||||
|
|
||||||
|
iotests.script_initialize(supported_fmts=['qcow2'])
|
||||||
|
|
||||||
# Note:
|
# Note:
|
||||||
# This test was added to check that mirror dead-lock was fixed (see previous
|
# This test was added to check that mirror dead-lock was fixed (see previous
|
||||||
# commit before this test addition).
|
# commit before this test addition).
|
||||||
@ -40,8 +42,6 @@ from qemu.machine import QEMUMachine
|
|||||||
|
|
||||||
size = 1 * 1024 * 1024 * 1024
|
size = 1 * 1024 * 1024 * 1024
|
||||||
|
|
||||||
iotests.verify_image_format(supported_fmts=['qcow2'])
|
|
||||||
|
|
||||||
disk = file_path('disk')
|
disk = file_path('disk')
|
||||||
|
|
||||||
# prepare source image
|
# prepare source image
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
import iotests
|
import iotests
|
||||||
from iotests import log
|
from iotests import log
|
||||||
|
|
||||||
iotests.verify_image_format(supported_fmts=['generic'])
|
iotests.script_initialize(supported_fmts=['generic'])
|
||||||
size = 64 * 1024 * 1024
|
size = 64 * 1024 * 1024
|
||||||
granularity = 64 * 1024
|
granularity = 64 * 1024
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ import math
|
|||||||
import iotests
|
import iotests
|
||||||
from iotests import imgfmt
|
from iotests import imgfmt
|
||||||
|
|
||||||
iotests.verify_image_format(supported_fmts=['vmdk'])
|
iotests.script_initialize(supported_fmts=['vmdk'])
|
||||||
|
|
||||||
with iotests.FilePath('t.vmdk') as disk_path, \
|
with iotests.FilePath('t.vmdk') as disk_path, \
|
||||||
iotests.FilePath('t.vmdk.1') as extent1_path, \
|
iotests.FilePath('t.vmdk.1') as extent1_path, \
|
||||||
|
@ -23,6 +23,8 @@ import os
|
|||||||
import iotests
|
import iotests
|
||||||
from iotests import log
|
from iotests import log
|
||||||
|
|
||||||
|
iotests.script_initialize()
|
||||||
|
|
||||||
virtio_scsi_device = iotests.get_virtio_scsi_device()
|
virtio_scsi_device = iotests.get_virtio_scsi_device()
|
||||||
|
|
||||||
vm = iotests.VM()
|
vm = iotests.VM()
|
||||||
|
@ -24,7 +24,7 @@ import struct
|
|||||||
from iotests import qemu_img_create, qemu_io, qemu_img_pipe, \
|
from iotests import qemu_img_create, qemu_io, qemu_img_pipe, \
|
||||||
file_path, img_info_log, log, filter_qemu_io
|
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')
|
disk = file_path('disk')
|
||||||
chunk = 256 * 1024
|
chunk = 256 * 1024
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
import iotests
|
import iotests
|
||||||
from iotests import log
|
from iotests import log
|
||||||
|
|
||||||
iotests.verify_image_format(supported_fmts=['qcow2'])
|
iotests.script_initialize(supported_fmts=['qcow2'])
|
||||||
size = 64 * 1024 * 1024 * 1024
|
size = 64 * 1024 * 1024 * 1024
|
||||||
gran_small = 32 * 1024
|
gran_small = 32 * 1024
|
||||||
gran_large = 128 * 1024
|
gran_large = 128 * 1024
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
import iotests
|
import iotests
|
||||||
from iotests import qemu_img_create, qemu_io, file_path, filter_qmp_testfiles
|
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')
|
source, target = file_path('source', 'target')
|
||||||
size = 5 * 1024 * 1024
|
size = 5 * 1024 * 1024
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
import iotests
|
import iotests
|
||||||
from iotests import qemu_img_create, file_path, log
|
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')
|
disk, top = file_path('disk', 'top')
|
||||||
size = 1024 * 1024
|
size = 1024 * 1024
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
import iotests
|
import iotests
|
||||||
from iotests import imgfmt
|
from iotests import imgfmt
|
||||||
|
|
||||||
iotests.verify_image_format(supported_fmts=['qcow2'])
|
iotests.script_initialize(supported_fmts=['qcow2'])
|
||||||
|
|
||||||
iotests.log('Finishing a commit job with background reads')
|
iotests.log('Finishing a commit job with background reads')
|
||||||
iotests.log('============================================')
|
iotests.log('============================================')
|
||||||
|
@ -23,7 +23,7 @@ import os
|
|||||||
import iotests
|
import iotests
|
||||||
from iotests import log
|
from iotests import log
|
||||||
|
|
||||||
iotests.verify_image_format(supported_fmts=['qcow2'])
|
iotests.script_initialize(supported_fmts=['qcow2'])
|
||||||
size = 64 * 1024 * 1024
|
size = 64 * 1024 * 1024
|
||||||
|
|
||||||
with iotests.FilePath('img0') as img0_path, \
|
with iotests.FilePath('img0') as img0_path, \
|
||||||
|
@ -24,9 +24,10 @@ from iotests import log, qemu_img, qemu_io_silent, \
|
|||||||
filter_qmp_testfiles, filter_qmp_imgfmt
|
filter_qmp_testfiles, filter_qmp_imgfmt
|
||||||
|
|
||||||
# Need backing file and change-backing-file support
|
# Need backing file and change-backing-file support
|
||||||
iotests.verify_image_format(supported_fmts=['qcow2', 'qed'])
|
iotests.script_initialize(
|
||||||
iotests.verify_platform(['linux'])
|
supported_fmts=['qcow2', 'qed'],
|
||||||
|
supported_platforms=['linux'],
|
||||||
|
)
|
||||||
|
|
||||||
# Returns a node for blockdev-add
|
# Returns a node for blockdev-add
|
||||||
def node(node_name, path, backing=None, fmt=None, throttle=None):
|
def node(node_name, path, backing=None, fmt=None, throttle=None):
|
||||||
|
@ -21,7 +21,9 @@
|
|||||||
import iotests
|
import iotests
|
||||||
from iotests import qemu_img_create, file_path, log, filter_qmp_event
|
from iotests import qemu_img_create, file_path, log, filter_qmp_event
|
||||||
|
|
||||||
iotests.verify_image_format(supported_fmts=['qcow2'])
|
iotests.script_initialize(
|
||||||
|
supported_fmts=['qcow2']
|
||||||
|
)
|
||||||
|
|
||||||
base, top = file_path('base', 'top')
|
base, top = file_path('base', 'top')
|
||||||
size = 64 * 1024 * 3
|
size = 64 * 1024 * 3
|
||||||
|
@ -23,8 +23,8 @@
|
|||||||
import iotests
|
import iotests
|
||||||
import os
|
import os
|
||||||
|
|
||||||
iotests.verify_image_format(supported_fmts=['qcow2'])
|
iotests.script_initialize(supported_fmts=['qcow2'],
|
||||||
iotests.verify_platform(['linux'])
|
supported_platforms=['linux'])
|
||||||
|
|
||||||
with iotests.FilePath('img') as img_path, \
|
with iotests.FilePath('img') as img_path, \
|
||||||
iotests.FilePath('mig_fifo') as fifo, \
|
iotests.FilePath('mig_fifo') as fifo, \
|
||||||
|
@ -24,7 +24,9 @@ import iotests
|
|||||||
from iotests import qemu_img_create, qemu_io_silent_check, file_path, \
|
from iotests import qemu_img_create, qemu_io_silent_check, file_path, \
|
||||||
qemu_nbd_popen, log
|
qemu_nbd_popen, log
|
||||||
|
|
||||||
iotests.verify_image_format(supported_fmts=['qcow2'])
|
iotests.script_initialize(
|
||||||
|
supported_fmts=['qcow2'],
|
||||||
|
)
|
||||||
|
|
||||||
disk_a, disk_b, nbd_sock = file_path('disk_a', 'disk_b', 'nbd-sock')
|
disk_a, disk_b, nbd_sock = file_path('disk_a', 'disk_b', 'nbd-sock')
|
||||||
nbd_uri = 'nbd+unix:///?socket=' + nbd_sock
|
nbd_uri = 'nbd+unix:///?socket=' + nbd_sock
|
||||||
|
@ -21,8 +21,8 @@
|
|||||||
|
|
||||||
import iotests
|
import iotests
|
||||||
|
|
||||||
iotests.verify_image_format(supported_fmts=['qcow2'])
|
iotests.script_initialize(supported_fmts=['qcow2'],
|
||||||
iotests.verify_platform(['linux'])
|
supported_platforms=['linux'])
|
||||||
|
|
||||||
size_short = 1 * 1024 * 1024
|
size_short = 1 * 1024 * 1024
|
||||||
size_long = 2 * 1024 * 1024
|
size_long = 2 * 1024 * 1024
|
||||||
|
@ -23,6 +23,8 @@ import subprocess
|
|||||||
import iotests
|
import iotests
|
||||||
from iotests import file_path, log
|
from iotests import file_path, log
|
||||||
|
|
||||||
|
iotests.script_initialize()
|
||||||
|
|
||||||
|
|
||||||
nbd_sock, conf_file = file_path('nbd-sock', 'nbd-fault-injector.conf')
|
nbd_sock, conf_file = file_path('nbd-sock', 'nbd-fault-injector.conf')
|
||||||
|
|
||||||
|
@ -22,9 +22,11 @@
|
|||||||
import iotests
|
import iotests
|
||||||
import os
|
import os
|
||||||
|
|
||||||
iotests.verify_image_format(supported_fmts=['qcow2'])
|
iotests.script_initialize(
|
||||||
iotests.verify_protocol(supported=['file'])
|
supported_fmts=['qcow2'],
|
||||||
iotests.verify_platform(['linux'])
|
supported_protocols=['file'],
|
||||||
|
supported_platforms=['linux'],
|
||||||
|
)
|
||||||
|
|
||||||
with iotests.FilePath('base') as base_path , \
|
with iotests.FilePath('base') as base_path , \
|
||||||
iotests.FilePath('top') as top_path, \
|
iotests.FilePath('top') as top_path, \
|
||||||
|
@ -21,7 +21,9 @@
|
|||||||
import iotests
|
import iotests
|
||||||
|
|
||||||
# The test is unrelated to formats, restrict it to qcow2 to avoid extra runs
|
# The test is unrelated to formats, restrict it to qcow2 to avoid extra runs
|
||||||
iotests.verify_image_format(supported_fmts=['qcow2'])
|
iotests.script_initialize(
|
||||||
|
supported_fmts=['qcow2'],
|
||||||
|
)
|
||||||
|
|
||||||
size = 1024 * 1024
|
size = 1024 * 1024
|
||||||
|
|
||||||
|
@ -28,7 +28,8 @@ import signal
|
|||||||
import struct
|
import struct
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
from typing import (Any, Callable, Dict, Iterable, List, Optional, TypeVar)
|
from typing import (Any, Callable, Dict, Iterable,
|
||||||
|
List, Optional, Sequence, TypeVar)
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
# pylint: disable=import-error, wrong-import-position
|
# pylint: disable=import-error, wrong-import-position
|
||||||
@ -1029,12 +1030,11 @@ def verify_protocol(supported=(), unsupported=()):
|
|||||||
if not_sup or (imgproto in unsupported):
|
if not_sup or (imgproto in unsupported):
|
||||||
notrun('not suitable for this protocol: %s' % imgproto)
|
notrun('not suitable for this protocol: %s' % imgproto)
|
||||||
|
|
||||||
def verify_platform(supported=None, unsupported=None):
|
def verify_platform(supported=(), unsupported=()):
|
||||||
if unsupported is not None:
|
if any((sys.platform.startswith(x) for x in unsupported)):
|
||||||
if any((sys.platform.startswith(x) for x in unsupported)):
|
notrun('not suitable for this OS: %s' % sys.platform)
|
||||||
notrun('not suitable for this OS: %s' % sys.platform)
|
|
||||||
|
|
||||||
if supported is not None:
|
if supported:
|
||||||
if not any((sys.platform.startswith(x) for x in supported)):
|
if not any((sys.platform.startswith(x) for x in supported)):
|
||||||
notrun('not suitable for this OS: %s' % sys.platform)
|
notrun('not suitable for this OS: %s' % sys.platform)
|
||||||
|
|
||||||
@ -1116,7 +1116,18 @@ def skip_if_user_is_root(func):
|
|||||||
return func(*args, **kwargs)
|
return func(*args, **kwargs)
|
||||||
return func_wrapper
|
return func_wrapper
|
||||||
|
|
||||||
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
|
||||||
|
else:
|
||||||
|
# We need to filter out the time taken from the output so that
|
||||||
|
# qemu-iotest can reliably diff the results against master output.
|
||||||
|
output = io.StringIO()
|
||||||
|
|
||||||
runner = unittest.TextTestRunner(stream=output, descriptions=True,
|
runner = unittest.TextTestRunner(stream=output, descriptions=True,
|
||||||
verbosity=verbosity)
|
verbosity=verbosity)
|
||||||
try:
|
try:
|
||||||
@ -1124,6 +1135,8 @@ def execute_unittest(output, verbosity, debug):
|
|||||||
# exception
|
# exception
|
||||||
unittest.main(testRunner=runner)
|
unittest.main(testRunner=runner)
|
||||||
finally:
|
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:
|
if not debug:
|
||||||
out = output.getvalue()
|
out = output.getvalue()
|
||||||
out = re.sub(r'Ran (\d+) tests? in [\d.]+s', r'Ran \1 tests', out)
|
out = re.sub(r'Ran (\d+) tests? in [\d.]+s', r'Ran \1 tests', out)
|
||||||
@ -1135,13 +1148,19 @@ def execute_unittest(output, verbosity, debug):
|
|||||||
|
|
||||||
sys.stderr.write(out)
|
sys.stderr.write(out)
|
||||||
|
|
||||||
def execute_test(test_function=None,
|
def execute_setup_common(supported_fmts: Sequence[str] = (),
|
||||||
supported_fmts=(),
|
supported_platforms: Sequence[str] = (),
|
||||||
supported_platforms=None,
|
supported_cache_modes: Sequence[str] = (),
|
||||||
supported_cache_modes=(), supported_aio_modes=(),
|
supported_aio_modes: Sequence[str] = (),
|
||||||
unsupported_fmts=(), supported_protocols=(),
|
unsupported_fmts: Sequence[str] = (),
|
||||||
unsupported_protocols=()):
|
supported_protocols: Sequence[str] = (),
|
||||||
"""Run either unittest or script-style tests."""
|
unsupported_protocols: Sequence[str] = ()) -> bool:
|
||||||
|
"""
|
||||||
|
Perform necessary setup for either script-style or unittest-style tests.
|
||||||
|
|
||||||
|
:return: Bool; Whether or not debug mode has been requested via the CLI.
|
||||||
|
"""
|
||||||
|
# Note: Python 3.6 and pylint do not like 'Collection' so use 'Sequence'.
|
||||||
|
|
||||||
# We are using TEST_DIR and QEMU_DEFAULT_MACHINE as proxies to
|
# We are using TEST_DIR and QEMU_DEFAULT_MACHINE as proxies to
|
||||||
# indicate that we're not being run via "check". There may be
|
# indicate that we're not being run via "check". There may be
|
||||||
@ -1151,34 +1170,39 @@ def execute_test(test_function=None,
|
|||||||
sys.stderr.write('Please run this test via the "check" script\n')
|
sys.stderr.write('Please run this test via the "check" script\n')
|
||||||
sys.exit(os.EX_USAGE)
|
sys.exit(os.EX_USAGE)
|
||||||
|
|
||||||
debug = '-d' in sys.argv
|
|
||||||
verbosity = 1
|
|
||||||
verify_image_format(supported_fmts, unsupported_fmts)
|
verify_image_format(supported_fmts, unsupported_fmts)
|
||||||
verify_protocol(supported_protocols, unsupported_protocols)
|
verify_protocol(supported_protocols, unsupported_protocols)
|
||||||
verify_platform(supported=supported_platforms)
|
verify_platform(supported=supported_platforms)
|
||||||
verify_cache_mode(supported_cache_modes)
|
verify_cache_mode(supported_cache_modes)
|
||||||
verify_aio_mode(supported_aio_modes)
|
verify_aio_mode(supported_aio_modes)
|
||||||
|
|
||||||
|
debug = '-d' in sys.argv
|
||||||
if debug:
|
if debug:
|
||||||
output = sys.stdout
|
|
||||||
verbosity = 2
|
|
||||||
sys.argv.remove('-d')
|
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.
|
|
||||||
output = io.StringIO()
|
|
||||||
|
|
||||||
logging.basicConfig(level=(logging.DEBUG if debug else logging.WARN))
|
logging.basicConfig(level=(logging.DEBUG if debug else logging.WARN))
|
||||||
|
|
||||||
|
return debug
|
||||||
|
|
||||||
|
def execute_test(*args, test_function=None, **kwargs):
|
||||||
|
"""Run either unittest or script-style tests."""
|
||||||
|
|
||||||
|
debug = execute_setup_common(*args, **kwargs)
|
||||||
if not test_function:
|
if not test_function:
|
||||||
execute_unittest(output, verbosity, debug)
|
execute_unittest(debug)
|
||||||
else:
|
else:
|
||||||
test_function()
|
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):
|
def script_main(test_function, *args, **kwargs):
|
||||||
"""Run script-style tests outside of the unittest framework"""
|
"""Run script-style tests outside of the unittest framework"""
|
||||||
execute_test(test_function, *args, **kwargs)
|
execute_test(*args, test_function=test_function, **kwargs)
|
||||||
|
|
||||||
|
# This is called from unittest style iotests
|
||||||
def main(*args, **kwargs):
|
def main(*args, **kwargs):
|
||||||
"""Run tests using the unittest framework"""
|
"""Run tests using the unittest framework"""
|
||||||
execute_test(None, *args, **kwargs)
|
execute_test(*args, **kwargs)
|
||||||
|
Loading…
Reference in New Issue
Block a user