aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorWainer dos Santos Moschetta <wainersm@redhat.com>2019-11-14 08:42:46 -0500
committerAlex Bennée <alex.bennee@linaro.org>2019-12-18 20:17:33 +0000
commit1e48931c0c0c29a30342614edb772fad8e4cff98 (patch)
tree726dd0162e1572597dab113386660cd9562ca064 /tests
parentafc3a8f9f1df09c091f9903eaef82b35c152cacf (diff)
tests/vm: Allow to set qemu-img path
By default VM build test use qemu-img from system's PATH to create the image disk. Due the lack of qemu-img on the system or the desire to simply use a version built with QEMU, it would be nice to allow one to set its path. So this patch makes that possible by reading the path to qemu-img from QEMU_IMG if set, otherwise it fallback to default behavior. Signed-off-by: Wainer dos Santos Moschetta <wainersm@redhat.com> Message-Id: <20191114134246.12073-2-wainersm@redhat.com> Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/vm/Makefile.include1
-rwxr-xr-xtests/vm/basevm.py5
-rwxr-xr-xtests/vm/centos2
-rwxr-xr-xtests/vm/fedora4
-rwxr-xr-xtests/vm/freebsd3
-rwxr-xr-xtests/vm/netbsd3
-rwxr-xr-xtests/vm/openbsd3
-rwxr-xr-xtests/vm/ubuntu.i3862
8 files changed, 12 insertions, 11 deletions
diff --git a/tests/vm/Makefile.include b/tests/vm/Makefile.include
index fea348e845..9e7c46a473 100644
--- a/tests/vm/Makefile.include
+++ b/tests/vm/Makefile.include
@@ -34,6 +34,7 @@ vm-help vm-test:
@echo " DEBUG=1 - Enable verbose output on host and interactive debugging"
@echo " V=1 - Enable verbose ouput on host and guest commands"
@echo " QEMU=/path/to/qemu - Change path to QEMU binary"
+ @echo " QEMU_IMG=/path/to/qemu-img - Change path to qemu-img tool"
vm-build-all: $(addprefix vm-build-, $(IMAGES))
diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py
index 53b9515ee2..ed5dd4f3d0 100755
--- a/tests/vm/basevm.py
+++ b/tests/vm/basevm.py
@@ -152,6 +152,11 @@ class BaseVM(object):
def build_image(self, img):
raise NotImplementedError
+ def exec_qemu_img(self, *args):
+ cmd = [os.environ.get("QEMU_IMG", "qemu-img")]
+ cmd.extend(list(args))
+ subprocess.check_call(cmd)
+
def add_source_dir(self, src_dir):
name = "data-" + hashlib.sha1(src_dir.encode("utf-8")).hexdigest()[:5]
tarfile = os.path.join(self._tmpdir, name + ".tar")
diff --git a/tests/vm/centos b/tests/vm/centos
index b9e851f2d3..f2f0befd84 100755
--- a/tests/vm/centos
+++ b/tests/vm/centos
@@ -68,7 +68,7 @@ class CentosVM(basevm.BaseVM):
sys.stderr.write("Extracting the image...\n")
subprocess.check_call(["ln", "-f", cimg, img_tmp + ".xz"])
subprocess.check_call(["xz", "--keep", "-dvf", img_tmp + ".xz"])
- subprocess.check_call(["qemu-img", "resize", img_tmp, "50G"])
+ self.exec_qemu_img("resize", img_tmp, "50G")
self.boot(img_tmp, extra_args = ["-cdrom", self._gen_cloud_init_iso()])
self.wait_ssh()
self.ssh_root_check("touch /etc/cloud/cloud-init.disabled")
diff --git a/tests/vm/fedora b/tests/vm/fedora
index 7fec1479fb..8e270fc0f0 100755
--- a/tests/vm/fedora
+++ b/tests/vm/fedora
@@ -74,9 +74,7 @@ class FedoraVM(basevm.BaseVM):
self.print_step("Preparing iso and disk image")
subprocess.check_call(["cp", "-f", cimg, iso])
- subprocess.check_call(["qemu-img", "create", "-f", "qcow2",
- img_tmp, self.size])
-
+ self.exec_qemu_img("create", "-f", "qcow2", img_tmp, self.size)
self.print_step("Booting installer")
self.boot(img_tmp, extra_args = [
"-bios", "pc-bios/bios-256k.bin",
diff --git a/tests/vm/freebsd b/tests/vm/freebsd
index 2a19461a90..1825cc5821 100755
--- a/tests/vm/freebsd
+++ b/tests/vm/freebsd
@@ -82,8 +82,7 @@ class FreeBSDVM(basevm.BaseVM):
self.print_step("Preparing iso and disk image")
subprocess.check_call(["cp", "-f", cimg, iso_xz])
subprocess.check_call(["xz", "-dvf", iso_xz])
- subprocess.check_call(["qemu-img", "create", "-f", "qcow2",
- img_tmp, self.size])
+ self.exec_qemu_img("create", "-f", "qcow2", img_tmp, self.size)
self.print_step("Booting installer")
self.boot(img_tmp, extra_args = [
diff --git a/tests/vm/netbsd b/tests/vm/netbsd
index 611e6cc5b5..ec6f3563b2 100755
--- a/tests/vm/netbsd
+++ b/tests/vm/netbsd
@@ -77,8 +77,7 @@ class NetBSDVM(basevm.BaseVM):
self.print_step("Preparing iso and disk image")
subprocess.check_call(["ln", "-f", cimg, iso])
- subprocess.check_call(["qemu-img", "create", "-f", "qcow2",
- img_tmp, self.size])
+ self.exec_qemu_img("create", "-f", "qcow2", img_tmp, self.size)
self.print_step("Booting installer")
self.boot(img_tmp, extra_args = [
diff --git a/tests/vm/openbsd b/tests/vm/openbsd
index b92c39f89a..6df5162dbf 100755
--- a/tests/vm/openbsd
+++ b/tests/vm/openbsd
@@ -73,8 +73,7 @@ class OpenBSDVM(basevm.BaseVM):
self.print_step("Preparing iso and disk image")
subprocess.check_call(["cp", "-f", cimg, iso])
- subprocess.check_call(["qemu-img", "create", "-f", "qcow2",
- img_tmp, self.size])
+ self.exec_qemu_img("create", "-f", "qcow2", img_tmp, self.size)
self.print_step("Booting installer")
self.boot(img_tmp, extra_args = [
diff --git a/tests/vm/ubuntu.i386 b/tests/vm/ubuntu.i386
index f611bebdc9..3834cd7a8d 100755
--- a/tests/vm/ubuntu.i386
+++ b/tests/vm/ubuntu.i386
@@ -70,7 +70,7 @@ class UbuntuX86VM(basevm.BaseVM):
sha256sum="28969840626d1ea80bb249c08eef1a4533e8904aa51a327b40f37ac4b4ff04ef")
img_tmp = img + ".tmp"
subprocess.check_call(["cp", "-f", cimg, img_tmp])
- subprocess.check_call(["qemu-img", "resize", img_tmp, "50G"])
+ self.exec_qemu_img("resize", img_tmp, "50G")
self.boot(img_tmp, extra_args = ["-cdrom", self._gen_cloud_init_iso()])
self.wait_ssh()
self.ssh_root_check("touch /etc/cloud/cloud-init.disabled")