[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 48/77] tests/acceptance: refactor boot_linux to allow code reuse
From: |
Michael Roth |
Subject: |
[PATCH 48/77] tests/acceptance: refactor boot_linux to allow code reuse |
Date: |
Thu, 3 Sep 2020 15:59:06 -0500 |
From: Pavel Dovgalyuk <Pavel.Dovgaluk@gmail.com>
This patch moves image downloading functions to the separate class to allow
reusing them from record/replay tests.
Signed-off-by: Pavel Dovgalyuk <Pavel.Dovgaluk@ispras.ru>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <159073593167.20809.17582679291556188984.stgit@pasha-ThinkPad-X280>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
(cherry picked from commit 1c80c87c8c2489e4318c93c844aa29bc1d014146)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
---
tests/acceptance/boot_linux.py | 49 ++++++++++++++++++++--------------
1 file changed, 29 insertions(+), 20 deletions(-)
diff --git a/tests/acceptance/boot_linux.py b/tests/acceptance/boot_linux.py
index 075a386300..3aa57e88b0 100644
--- a/tests/acceptance/boot_linux.py
+++ b/tests/acceptance/boot_linux.py
@@ -26,22 +26,8 @@ KVM_NOT_AVAILABLE = ACCEL_NOT_AVAILABLE_FMT % "KVM"
TCG_NOT_AVAILABLE = ACCEL_NOT_AVAILABLE_FMT % "TCG"
-class BootLinux(Test):
- """
- Boots a Linux system, checking for a successful initialization
- """
-
- timeout = 900
- chksum = None
-
- def setUp(self):
- super(BootLinux, self).setUp()
- self.vm.add_args('-smp', '2')
- self.vm.add_args('-m', '1024')
- self.prepare_boot()
- self.prepare_cloudinit()
-
- def prepare_boot(self):
+class BootLinuxBase(Test):
+ def download_boot(self):
self.log.debug('Looking for and selecting a qemu-img binary to be '
'used to create the bootable snapshot image')
# If qemu-img has been built, use it, otherwise the system wide one
@@ -60,17 +46,17 @@ class BootLinux(Test):
if image_arch == 'ppc64':
image_arch = 'ppc64le'
try:
- self.boot = vmimage.get(
+ boot = vmimage.get(
'fedora', arch=image_arch, version='31',
checksum=self.chksum,
algorithm='sha256',
cache_dir=self.cache_dirs[0],
snapshot_dir=self.workdir)
- self.vm.add_args('-drive', 'file=%s' % self.boot.path)
except:
self.cancel('Failed to download/prepare boot image')
+ return boot.path
- def prepare_cloudinit(self):
+ def download_cloudinit(self):
self.log.info('Preparing cloudinit image')
try:
cloudinit_iso = os.path.join(self.workdir, 'cloudinit.iso')
@@ -81,9 +67,32 @@ class BootLinux(Test):
# QEMU's hard coded usermode router address
phone_home_host='10.0.2.2',
phone_home_port=self.phone_home_port)
- self.vm.add_args('-drive', 'file=%s,format=raw' % cloudinit_iso)
except Exception:
self.cancel('Failed to prepared cloudinit image')
+ return cloudinit_iso
+
+class BootLinux(BootLinuxBase):
+ """
+ Boots a Linux system, checking for a successful initialization
+ """
+
+ timeout = 900
+ chksum = None
+
+ def setUp(self):
+ super(BootLinux, self).setUp()
+ self.vm.add_args('-smp', '2')
+ self.vm.add_args('-m', '1024')
+ self.prepare_boot()
+ self.prepare_cloudinit()
+
+ def prepare_boot(self):
+ path = self.download_boot()
+ self.vm.add_args('-drive', 'file=%s' % path)
+
+ def prepare_cloudinit(self):
+ cloudinit_iso = self.download_cloudinit()
+ self.vm.add_args('-drive', 'file=%s,format=raw' % cloudinit_iso)
def launch_and_wait(self):
self.vm.set_console()
--
2.17.1
- [PATCH 35/77] virtiofsd: Whitelist fchmod, (continued)
- [PATCH 35/77] virtiofsd: Whitelist fchmod, Michael Roth, 2020/09/03
- [PATCH 38/77] error: Use error_reportf_err() where appropriate, Michael Roth, 2020/09/03
- [PATCH 41/77] chardev/tcp: Fix error message double free error, Michael Roth, 2020/09/03
- [PATCH 42/77] qga: fix assert regression on guest-shutdown, Michael Roth, 2020/09/03
- [PATCH 36/77] hw/audio/gus: Fix registers 32-bit access, Michael Roth, 2020/09/03
- [PATCH 37/77] net/virtio: Fix failover_replug_primary() return value regression, Michael Roth, 2020/09/03
- [PATCH 43/77] util: Introduce qemu_get_host_name(), Michael Roth, 2020/09/03
- [PATCH 44/77] qga: Use qemu_get_host_name() instead of g_get_host_name(), Michael Roth, 2020/09/03
- [PATCH 45/77] docs/orangepi: Add instructions for resizing SD image to power of two, Michael Roth, 2020/09/03
- [PATCH 46/77] tests/acceptance/boot_linux: Tag tests using a SD card with 'device:sd', Michael Roth, 2020/09/03
- [PATCH 48/77] tests/acceptance: refactor boot_linux to allow code reuse,
Michael Roth <=
- [PATCH 53/77] hw/sd/sdcard: Do not allow invalid SD card sizes, Michael Roth, 2020/09/03
- [PATCH 49/77] tests/acceptance: refactor boot_linux_console test to allow code reuse, Michael Roth, 2020/09/03
- [PATCH 47/77] tests/acceptance: allow console interaction with specific VMs, Michael Roth, 2020/09/03
- [PATCH 50/77] tests/acceptance/boot_linux: Expand SD card image to power of 2, Michael Roth, 2020/09/03
- [PATCH 51/77] hw/sd/sdcard: Restrict Class 6 commands to SCSD cards, Michael Roth, 2020/09/03
- [PATCH 52/77] hw/sd/sdcard: Simplify realize() a bit, Michael Roth, 2020/09/03
- [PATCH 04/77] 9p: Lock directory streams with a CoMutex, Michael Roth, 2020/09/03
- [PATCH 54/77] hw/sd/sdcard: Update coding style to make checkpatch.pl happy, Michael Roth, 2020/09/03
- [PATCH 55/77] hw/sd/sdcard: Do not switch to ReceivingData if address is invalid, Michael Roth, 2020/09/03
- [PATCH 56/77] target/hppa: Free some temps in do_sub, Michael Roth, 2020/09/03