From 643c66d2bc2a415e95f07d57e5d6ba3f2c8e74d1 Mon Sep 17 00:00:00 2001 From: lolyu Date: Tue, 24 Mar 2020 16:19:59 +0800 Subject: [PATCH] commit_snapshot_to_raw_backing: add switch for size check if image is a block device, the size check will fail the case because QEMU fails to get correct size info from block device. So add a switch to enable tester to turn off the snapshot size check. Signed-off-by: lolyu --- .../cfg/commit_snapshot_to_raw_backing.cfg | 1 + qemu/tests/commit_snapshot_to_raw_backing.py | 26 +++++++++++-------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/qemu/tests/cfg/commit_snapshot_to_raw_backing.cfg b/qemu/tests/cfg/commit_snapshot_to_raw_backing.cfg index dd517ceb..4a78d71c 100644 --- a/qemu/tests/cfg/commit_snapshot_to_raw_backing.cfg +++ b/qemu/tests/cfg/commit_snapshot_to_raw_backing.cfg @@ -21,6 +21,7 @@ dd_total_size = "${dd_bs_val} * ${dd_bs_count} * 1024 ** 2" file_create_cmd = "dd if=/dev/urandom of=%s bs=${dd_bs_val}M count=${dd_bs_count}" guest_file_name = ${tmp_file_name} + snapshot_size_check_after_commit = yes Windows: guest_file_name = C:\testfile x86_64: diff --git a/qemu/tests/commit_snapshot_to_raw_backing.py b/qemu/tests/commit_snapshot_to_raw_backing.py index 22deed08..51413d13 100644 --- a/qemu/tests/commit_snapshot_to_raw_backing.py +++ b/qemu/tests/commit_snapshot_to_raw_backing.py @@ -82,18 +82,22 @@ def run(test, params, env): else: logging.info("Commit snapshot image %s back to %s.", snapshot, base) - org_size = json.loads(sn_img.info(output="json"))["actual-size"] + size_check = params.get("snapshot_size_check_after_commit") == "yes" + if size_check: + org_size = json.loads(sn_img.info(output="json"))["actual-size"] sn_img.commit(cache_mode=cache_mode) - remain_size = json.loads(sn_img.info(output="json"))["actual-size"] - - """Verify the snapshot file whether emptied after committing""" - logging.info("Verify the snapshot file whether emptied after committing") - commit_size = org_size - remain_size - dd_size = eval(params["dd_total_size"]) - if commit_size >= dd_size: - logging.info("The snapshot file was emptied!") - else: - test.fail("The snapshot file was not emptied, check pls!") + + if size_check: + remain_size = json.loads(sn_img.info(output="json"))["actual-size"] + + # Verify the snapshot file whether emptied after committing + logging.info("Verify the snapshot file whether emptied after committing") + commit_size = org_size - remain_size + dd_size = eval(params["dd_total_size"]) + if commit_size >= dd_size: + logging.info("The snapshot file was emptied!") + else: + test.fail("The snapshot file was not emptied, check pls!") base_qit = QemuImgTest(test, params, env, base) base_qit.start_vm() -- GitLab