mirror of https://github.com/xemu-project/xemu.git
tests/acceptance: refactor boot_linux to allow code reuse
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>
This commit is contained in:
parent
12121c496f
commit
1c80c87c8c
|
@ -26,22 +26,8 @@ KVM_NOT_AVAILABLE = ACCEL_NOT_AVAILABLE_FMT % "KVM"
|
||||||
TCG_NOT_AVAILABLE = ACCEL_NOT_AVAILABLE_FMT % "TCG"
|
TCG_NOT_AVAILABLE = ACCEL_NOT_AVAILABLE_FMT % "TCG"
|
||||||
|
|
||||||
|
|
||||||
class BootLinux(Test):
|
class BootLinuxBase(Test):
|
||||||
"""
|
def download_boot(self):
|
||||||
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):
|
|
||||||
self.log.debug('Looking for and selecting a qemu-img binary to be '
|
self.log.debug('Looking for and selecting a qemu-img binary to be '
|
||||||
'used to create the bootable snapshot image')
|
'used to create the bootable snapshot image')
|
||||||
# If qemu-img has been built, use it, otherwise the system wide one
|
# If qemu-img has been built, use it, otherwise the system wide one
|
||||||
|
@ -60,17 +46,17 @@ class BootLinux(Test):
|
||||||
if image_arch == 'ppc64':
|
if image_arch == 'ppc64':
|
||||||
image_arch = 'ppc64le'
|
image_arch = 'ppc64le'
|
||||||
try:
|
try:
|
||||||
self.boot = vmimage.get(
|
boot = vmimage.get(
|
||||||
'fedora', arch=image_arch, version='31',
|
'fedora', arch=image_arch, version='31',
|
||||||
checksum=self.chksum,
|
checksum=self.chksum,
|
||||||
algorithm='sha256',
|
algorithm='sha256',
|
||||||
cache_dir=self.cache_dirs[0],
|
cache_dir=self.cache_dirs[0],
|
||||||
snapshot_dir=self.workdir)
|
snapshot_dir=self.workdir)
|
||||||
self.vm.add_args('-drive', 'file=%s' % self.boot.path)
|
|
||||||
except:
|
except:
|
||||||
self.cancel('Failed to download/prepare boot image')
|
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')
|
self.log.info('Preparing cloudinit image')
|
||||||
try:
|
try:
|
||||||
cloudinit_iso = os.path.join(self.workdir, 'cloudinit.iso')
|
cloudinit_iso = os.path.join(self.workdir, 'cloudinit.iso')
|
||||||
|
@ -81,9 +67,32 @@ class BootLinux(Test):
|
||||||
# QEMU's hard coded usermode router address
|
# QEMU's hard coded usermode router address
|
||||||
phone_home_host='10.0.2.2',
|
phone_home_host='10.0.2.2',
|
||||||
phone_home_port=self.phone_home_port)
|
phone_home_port=self.phone_home_port)
|
||||||
self.vm.add_args('-drive', 'file=%s,format=raw' % cloudinit_iso)
|
|
||||||
except Exception:
|
except Exception:
|
||||||
self.cancel('Failed to prepared cloudinit image')
|
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):
|
def launch_and_wait(self):
|
||||||
self.vm.set_console()
|
self.vm.set_console()
|
||||||
|
|
Loading…
Reference in New Issue