提交 366d160b 编写于 作者: S suqinhuang 提交者: GitHub

Merge pull request #731 from pingl2016/amend_case

Add cases for subcommand amend of qemu-img
......@@ -86,3 +86,31 @@
- commit: install setup image_copy unattended_install.cdrom
no vmdk raw qed
subcommand = commit
- amend:
only Host_RHEL.m7
subcommand = amend
start_vm = no
images += " stg"
image_name_stg = "images/stg"
force_create_image_stg = yes
remove_image_stg = yes
check_image_stg = no
variants:
- upgrade:
image_extra_params_stg = "compat=0.10,"
qemu_img_options = compat
compat = 1.1
- downgrade:
image_extra_params_stg = "compat=1.1,"
qemu_img_options = compat
compat = 0.10
variants:
- @default:
- refcount_bits:
variants:
- refcount_bits_32:
image_extra_params_stg += "refcount_bits=32,"
check_output = stderr
command_result_pattern = "(compat=0.10 requires refcount_bits=16)"
- refcount_bits_16:
image_extra_params_stg += "refcount_bits=16,"
......@@ -264,6 +264,9 @@ def run(test, params, env):
sub_info += ": (.*)"
matches = re.findall(sub_info, output)
if "virtual size" in sub_info:
p = re.compile(r'\.0*(G|K)$')
return p.sub(r'\1', matches[0].split()[0])
if matches:
return matches[0]
return None
......@@ -498,6 +501,60 @@ def run(test, params, env):
remove(sn2)
remove(sn1)
def _amend(cmd, img_name, img_fmt, options):
"""
Simple wrapper of 'qemu-img amend'.
:param cmd: qemu-img base command
:param img_name: image name that should be amended
:param img_fmt: image format
:param options: a comma separated list of format specific options
"""
msg = "Amend '%s' with options '%s'" % (img_name, options)
cmd += " amend"
if img_fmt:
cmd += " -f %s" % img_fmt
cache = params.get("cache_mode", '')
if cache:
cmd += " -t %s" % cache
if options:
cmd += " -o "
for option in options:
cmd += "%s=%s," % (option, params.get(option))
cmd = cmd.rstrip(',')
cmd += " %s" % img_name
error.context(msg, logging.info)
check_command_output(utils.run(cmd, ignore_status=True))
def amend_test(cmd):
"""
Subcommand 'qemu-img amend' test
Amend the image format specific options for the image file
:param cmd: qemu-img base command.
"""
img_name = params.get("image_name_stg")
img_fmt = params.get("image_format_stg", "qcow2")
options = params.get("qemu_img_options", "").split()
check_output = params.get("check_output", "exit_status")
img = _get_image_filename(img_name, img_fmt=img_fmt)
_amend(cmd, img, img_fmt, options)
if check_output == "exit_status":
for option in options:
expect = params.get(option)
if option == "size":
option = "virtual size"
actual = _info(cmd, img, option)
if actual is not None and actual != expect:
msg = "Get wrong %s from image %s!" % (option, img_name)
msg += "Expect: %s, actual: %s" % (expect, actual)
raise error.TestFail(msg)
status, output = _check(cmd, img)
if not status:
raise error.TestFail("Check image '%s' failed after rebase;"
"got error: %s" % (img, output))
def _boot(img_name, img_fmt):
"""
Boot test:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册