From: Lucas Meneghel Rodrigues Subject: [PATCH 3/3] KVM test: Extend VM.create() method to support SHA1 check Date: Wed, 21 Oct 2009 19:31:47 -0200 Message-ID: <1256160707-4333-3-git-send-email-lmr@redhat.com> References: <1256160707-4333-1-git-send-email-lmr@redhat.com> <1256160707-4333-2-git-send-email-lmr@redhat.com> Cc: kvm@vger.kernel.org, mgoldish@redhat.com, jburke@redhat.com, Lucas Meneghel Rodrigues To: autotest@test.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:49192 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755445AbZJUVbx (ORCPT ); Wed, 21 Oct 2009 17:31:53 -0400 In-Reply-To: <1256160707-4333-2-git-send-email-lmr@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: Also, change variable names and messages to be more generic. Signed-off-by: Lucas Meneghel Rodrigues --- client/tests/kvm/kvm_vm.py | 21 ++++++++++++++------- 1 files changed, 14 insertions(+), 7 deletions(-) diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py index a8d96ca..3d604c4 100755 --- a/client/tests/kvm/kvm_vm.py +++ b/client/tests/kvm/kvm_vm.py @@ -339,20 +339,27 @@ class VM: if params.get("md5sum_1m"): logging.debug("Comparing expected MD5 sum with MD5 sum of " "first MB of ISO file...") - actual_md5sum = kvm_utils.md5sum_file(iso, 1048576) - expected_md5sum = params.get("md5sum_1m") + actual_hash = kvm_utils.md5sum_file(iso, 1048576) + expected_hash = params.get("md5sum_1m") compare = True elif params.get("md5sum"): logging.debug("Comparing expected MD5 sum with MD5 sum of ISO " "file...") - actual_md5sum = kvm_utils.md5sum_file(iso) - expected_md5sum = params.get("md5sum") + actual_hash = kvm_utils.md5sum_file(iso) + expected_hash = params.get("md5sum") + compare = True + elif params.get("sha1sum"): + logging.debug("Comparing expected SHA1 sum with SHA1 sum of " + "ISO file...") + actual_hash = kvm_utils.md5sum_file(iso) + expected_hash = params.get("md5sum") compare = True if compare: - if actual_md5sum == expected_md5sum: - logging.debug("MD5 sums match") + if actual_hash == expected_hash: + logging.debug("Hashes match") else: - logging.error("Actual MD5 sum differs from expected one") + logging.error("Actual hash %s differs from expected " + "one %s", actual_hash, expected_hash) return False # Make sure the following code is not executed by more than one thread -- 1.6.2.5