qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: qemu-devel@nongnu.org
Cc: fam@euphon.net, berrange@redhat.com, stefanb@linux.vnet.ibm.com,
	"Alex Bennée" <alex.bennee@linaro.org>,
	richard.henderson@linaro.org, f4bug@amsat.org,
	"Philippe Mathieu-Daudé" <philmd@redhat.com>,
	cota@braap.org, stefanha@redhat.com, marcandre.lureau@redhat.com,
	pbonzini@redhat.com, aurelien@aurel32.net
Subject: [PATCH  v1 6/6] tests/vm: support sites with sha512 checksums
Date: Mon,  4 Nov 2019 17:36:54 +0000	[thread overview]
Message-ID: <20191104173654.30125-7-alex.bennee@linaro.org> (raw)
In-Reply-To: <20191104173654.30125-1-alex.bennee@linaro.org>

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>
---
 tests/vm/basevm.py | 10 ++++++++--
 tests/vm/netbsd    |  3 ++-
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py
index 086bfb2c66d..91a9226026d 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"],
diff --git a/tests/vm/netbsd b/tests/vm/netbsd
index 33779402dd1..89390e99fdd 100755
--- a/tests/vm/netbsd
+++ b/tests/vm/netbsd
@@ -23,6 +23,7 @@ class NetBSDVM(basevm.BaseVM):
     arch = "x86_64"
 
     link = "https://cdn.netbsd.org/pub/NetBSD/NetBSD-8.1/images/NetBSD-8.1-amd64.iso"
+    csum = "718f275b7e0879599bdac95630c5e3f2184700032fdb6cdebf3bdd63687898c48ff3f08f57b89f4437a86cdd8ea07c01a39d432dbb37e1e4b008f4985f98da3f"
     size = "20G"
     pkgs = [
         # tools
@@ -70,7 +71,7 @@ class NetBSDVM(basevm.BaseVM):
     ipv6 = False
 
     def build_image(self, img):
-        cimg = self._download_with_cache(self.link)
+        cimg = self._download_with_cache(self.link, sha512sum=self.csum)
         img_tmp = img + ".tmp"
         iso = img + ".install.iso"
 
-- 
2.20.1



  parent reply	other threads:[~2019-11-04 17:43 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-04 17:36 [PATCH v1 0/6] testing/next (netbsd stuff) Alex Bennée
2019-11-04 17:36 ` [PATCH v1 1/6] tests/vm: netbsd autoinstall, using serial console Alex Bennée
2019-11-04 18:44   ` Philippe Mathieu-Daudé
2019-11-04 18:57   ` Philippe Mathieu-Daudé
2019-11-11 14:20   ` Thomas Huth
2019-11-04 17:36 ` [PATCH v1 2/6] tests/vm: add console_consume helper Alex Bennée
2019-11-04 18:44   ` Philippe Mathieu-Daudé
2019-11-04 17:36 ` [PATCH v1 3/6] tests/vm: use console_consume for netbsd Alex Bennée
2019-11-04 18:46   ` Philippe Mathieu-Daudé
2019-11-04 19:43     ` Alex Bennée
2019-11-04 17:36 ` [PATCH v1 4/6] tests/vm: update netbsd to version 8.1 Alex Bennée
2019-11-04 18:45   ` Philippe Mathieu-Daudé
2019-11-04 17:36 ` [PATCH v1 5/6] tests: only run ipmi-bt-test if CONFIG_LINUX Alex Bennée
2019-11-04 18:36   ` Corey Minyard
2019-11-04 19:42     ` Alex Bennée
2019-11-04 17:36 ` Alex Bennée [this message]
2019-11-04 18:50   ` [PATCH v1 6/6] tests/vm: support sites with sha512 checksums Philippe Mathieu-Daudé
2019-11-07 17:46 ` [PATCH v1 0/6] testing/next (netbsd stuff) Peter Maydell
2019-11-07 17:53   ` Kamil Rytarowski
2019-11-07 17:58     ` Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191104173654.30125-7-alex.bennee@linaro.org \
    --to=alex.bennee@linaro.org \
    --cc=aurelien@aurel32.net \
    --cc=berrange@redhat.com \
    --cc=cota@braap.org \
    --cc=f4bug@amsat.org \
    --cc=fam@euphon.net \
    --cc=marcandre.lureau@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=philmd@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=stefanb@linux.vnet.ibm.com \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).