diff --git a/qemu/tests/cfg/commit_snapshot_to_raw_backing.cfg b/qemu/tests/cfg/commit_snapshot_to_raw_backing.cfg index dd517ceb940b4e56f8a407efd3ad4ecff490ac7a..4a78d71c61929378f3308de7c103da772018d3ab 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 22deed08b30dda5c7d8927104389670dbf0bcbe5..51413d13add0a282f599bf708b1c3150ba268d41 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()