summary refs log tree commit diff stats
path: root/tests/vm/basevm.py
diff options
context:
space:
mode:
authorAlex Bennée <alex.bennee@linaro.org>2019-11-04 17:31:44 +0000
committerAlex Bennée <alex.bennee@linaro.org>2019-11-12 14:32:55 +0000
commit5b4b4865f44ed27d6aeea1d05e8314fce9cdc136 (patch)
treea054e55daab5d0465a817da283a620eb9895e22b /tests/vm/basevm.py
parent860eacec5852e66ac1425ab636ea245afcfa9283 (diff)
downloadfocaccia-qemu-5b4b4865f44ed27d6aeea1d05e8314fce9cdc136.tar.gz
focaccia-qemu-5b4b4865f44ed27d6aeea1d05e8314fce9cdc136.zip
tests/vm: support sites with sha512 checksums
The NetBSD project uses SHA512 for its checksums so lets support that
in the download helper.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Diffstat (limited to 'tests/vm/basevm.py')
-rwxr-xr-xtests/vm/basevm.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py
index 086bfb2c66..91a9226026 100755
--- a/tests/vm/basevm.py
+++ b/tests/vm/basevm.py
@@ -95,19 +95,25 @@ class BaseVM(object):
             logging.info("KVM not available, not using -enable-kvm")
         self._data_args = []
 
-    def _download_with_cache(self, url, sha256sum=None):
+    def _download_with_cache(self, url, sha256sum=None, sha512sum=None):
         def check_sha256sum(fname):
             if not sha256sum:
                 return True
             checksum = subprocess.check_output(["sha256sum", fname]).split()[0]
             return sha256sum == checksum.decode("utf-8")
 
+        def check_sha512sum(fname):
+            if not sha512sum:
+                return True
+            checksum = subprocess.check_output(["sha512sum", fname]).split()[0]
+            return sha512sum == checksum.decode("utf-8")
+
         cache_dir = os.path.expanduser("~/.cache/qemu-vm/download")
         if not os.path.exists(cache_dir):
             os.makedirs(cache_dir)
         fname = os.path.join(cache_dir,
                              hashlib.sha1(url.encode("utf-8")).hexdigest())
-        if os.path.exists(fname) and check_sha256sum(fname):
+        if os.path.exists(fname) and check_sha256sum(fname) and check_sha512sum(fname):
             return fname
         logging.debug("Downloading %s to %s...", url, fname)
         subprocess.check_call(["wget", "-c", url, "-O", fname + ".download"],