提交 c215b8c0 编写于 作者: X Xu Tian 提交者: GitHub

Merge pull request #842 from pingl2016/1395550

qemu.tests: Add case for qemu-img compare
- qemu_disk_img_compare:
virt_test_type = qemu
type = qemu_disk_img_convert
kill_vm = yes
kill_vm_before_test = yes
start_vm = no
image_size = 20G
force_create_image = no
backup_image_before_testing = yes
restore_image_before_testing = yes
option_verified = "format"
image_convert = "image1"
convert_name_image1 = "images/image1_to_raw"
convert_format_image1 = "raw"
compare_mode_list = "default strict"
md5sum_bin = "md5sum"
tmp_dir = /var/tmp
tmp_file_name = ${tmp_dir}/test.img
file_create_cmd = "dd if=/dev/urandom of=%s bs=4k count=250"
Windows:
guest_file_name = "c:\test.img"
x86_64:
sync_bin = WIN_UTILS:\Sync\sync64.exe /accepteula
i386, i686:
sync_bin = WIN_UTILS:\Sync\sync.exe /accepteula
Linux:
guest_file_name = "${tmp_dir}/test.img"
......@@ -4,6 +4,9 @@ from autotest.client import utils
from autotest.client.shared import error
from virttest import storage
from virttest import error_context
from avocado.core import exceptions
from qemu.tests import qemu_disk_img
......@@ -33,6 +36,28 @@ class ConvertTest(qemu_disk_img.QemuImgTest):
self.trash.append(converted)
return params
@error_context.context_aware
def compare_test(self, t_params):
"""
Compare images.
:param t_params: Dictionary with the test parameters
"""
for mode in t_params.objects("compare_mode_list"):
error_context.context("Compare images in %s mode" % mode,
logging.info)
cmd_result = None
is_strict = ("strict" == mode)
image1 = self.image_filename
image2 = storage.get_image_filename(t_params, self.data_dir)
try:
cmd_result = self.compare_images(image1, image2, is_strict)
except (exceptions.TestFail, exceptions.TestError), detail:
if not is_strict:
raise
if is_strict and cmd_result:
raise error.TestFail("images are identical in strict mode")
def run(test, params, env):
"""
......@@ -58,6 +83,7 @@ def run(test, params, env):
raise error.TestError("Fail to save tmp file")
convert_test.destroy_vm()
n_params = convert_test.convert()
convert_test.compare_test(n_params)
convert_test.verify_info(n_params)
convert_test.start_vm(n_params)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册