[PATCH 2/2] testsuite: Add tests for installer image

4 views
Skip to first unread message

Uladzimir Bely

unread,
Feb 11, 2025, 9:18:04 AM2/11/25
to isar-...@googlegroups.com
The idea is to pass to qemu two wic files (hard drives):
- sda: empty wic file;
- sdb: the image with installer.

When run, first boot is done from sdb (since sda is empty), then
installer flashes target image to sda and reboots the system.

Second boot is automatically done from sda drive just written.

Signed-off-by: Uladzimir Bely <ub...@ilbers.de>
---
testsuite/cibase.py | 36 ++++++++++++++++++++++++++++++++++++
testsuite/citest.py | 20 ++++++++++++++++++++
2 files changed, 56 insertions(+)

diff --git a/testsuite/cibase.py b/testsuite/cibase.py
index 075535b1..6c66a193 100755
--- a/testsuite/cibase.py
+++ b/testsuite/cibase.py
@@ -77,6 +77,42 @@ class CIBaseTest(CIBuilder):
process.run('gpgconf --kill gpg-agent')
shutil.rmtree(gnupg_home, True)

+ def perform_installer_build_test(self, target, distro, machine, **kwargs):
+ self.configure(**kwargs)
+
+ # append ci_build.conf
+ with open(self.build_dir + '/conf/ci_build.conf', 'a') as f:
+ f.write('\n#Installer mage build configuration\n')
+ f.write(f'DISTRO ?= "{distro}"\n');
+ f.write(f'MACHINE ?= "{machine}"\n');
+ f.write('BBMULTICONFIG += "isar-installer installer-target"\n')
+ f.write('INSTALLER_TARGET_IMAGE = "isar-image-ci"\n')
+ f.write('INSTALLER_UNATTENDED = "1"\n')
+ f.write('INSTALLER_TARGET_DEVICE = "/dev/sda"\n')
+ f.write('INSTALLER_TARGET_OVERWRITE = "OVERWRITE"\n')
+
+ self.log.info("Starting build...")
+
+ self.bitbake(target, **kwargs)
+
+ def perform_installer_run_test(self, arch, distro, **kwargs):
+ install_target = CIUtils.getVars('DEPLOY_DIR_IMAGE') + '/install.wic'
+
+ # Create empty file installer will write to
+ with open(install_target, 'w') as f:
+ size = 4294967296 # 4GiB should be enough for the target
+ f.write("\0" * size)
+
+ # append ci_build.conf
+ with open(self.build_dir + '/conf/ci_build.conf', 'a') as f:
+ f.write('\n#Installer image boot configuration\n')
+ f.write(f'QEMU_DISK_ARGS = "-bios /usr/share/ovmf/OVMF.fd"\n')
+ f.write(f'QEMU_DISK_ARGS += "-hda {install_target}"\n')
+ f.write(f'QEMU_DISK_ARGS += "-hdb ##ROOTFS_IMAGE##"\n')
+
+ # Machine boots from sdb, writes image to sda and reboots to sda then
+ self.vm_start(arch, distro, image='isar-image-installer')
+
def perform_ccache_test(self, targets, **kwargs):
def ccache_stats(dir, field):
# Look ccache source's 'src/core/Statistic.hpp' for field meanings
diff --git a/testsuite/citest.py b/testsuite/citest.py
index ee965278..2de547ad 100755
--- a/testsuite/citest.py
+++ b/testsuite/citest.py
@@ -122,6 +122,26 @@ class CcacheTest(CIBaseTest):
self.perform_ccache_test(targets)


+class InstallerTest(CIBaseTest):
+
+ """
+ Installer test
+
+ :avocado: tags=installer,full
+ """
+
+ def test_installer_build(self):
+ self.init()
+ target = "mc:isar-installer:isar-image-installer"
+ distro = "debian-bookworm"
+ machine = "qemuamd64"
+ self.perform_installer_build_test(target, distro, machine)
+
+ def test_installer_run(self):
+ self.init()
+ self.perform_installer_run_test('amd64', 'bookworm')
+
+
class CrossTest(CIBaseTest):

"""
--
2.45.3

Uladzimir Bely

unread,
Feb 13, 2025, 6:20:58 AM2/13/25
to isar-...@googlegroups.com
The idea is to pass to qemu two wic files (hard drives):
- sda: empty wic file;
- sdb: the image with installer.

When run, first boot is done from sdb (since sda is empty), then
installer flashes target image to sda and reboots the system.

Second boot is automatically done from sda drive just written.

Signed-off-by: Uladzimir Bely <ub...@ilbers.de>
---
testsuite/cibase.py | 28 ++++++++++++++++++++++++++++
testsuite/citest.py | 26 ++++++++++++++++++++++++++
2 files changed, 54 insertions(+)

diff --git a/testsuite/cibase.py b/testsuite/cibase.py
index 075535b1..c4fa7510 100755
--- a/testsuite/cibase.py
+++ b/testsuite/cibase.py
@@ -77,6 +77,34 @@ class CIBaseTest(CIBuilder):
process.run('gpgconf --kill gpg-agent')
shutil.rmtree(gnupg_home, True)

+ def perform_installer_build_test(self, target, distro, machine, **kwargs):
+ self.configure(**kwargs)
+
+ install_target = self.build_dir + '/installer.wic'
+
+ # Create empty file installer will write to
+ with open(install_target, 'w') as f:
+ size = 4294967296 # 4GiB should be enough for the target
+ f.write("\0" * size)
+
+ # append ci_build.conf
+ with open(self.build_dir + '/conf/ci_build.conf', 'a') as f:
+ f.write('\n#Installer image configuration\n')
+ f.write('BBMULTICONFIG += "isar-installer installer-target"\n')
+ f.write('INSTALLER_TARGET_IMAGE = "isar-image-ci"\n')
+ f.write('INSTALLER_UNATTENDED = "1"\n')
+ f.write('INSTALLER_TARGET_DEVICE = "/dev/sda"\n')
+ f.write('INSTALLER_TARGET_OVERWRITE = "OVERWRITE"\n')
+ f.write(f'DISTRO ?= "{distro}"\n');
+ f.write(f'MACHINE ?= "{machine}"\n');
+ f.write(f'QEMU_DISK_ARGS = "-bios /usr/share/ovmf/OVMF.fd"\n')
+ f.write(f'QEMU_DISK_ARGS += "-hda {install_target}"\n')
+ f.write(f'QEMU_DISK_ARGS += "-hdb ##ROOTFS_IMAGE##"\n')
+
+ self.log.info("Starting build...")
+
+ self.bitbake(target, **kwargs)
+
def perform_ccache_test(self, targets, **kwargs):
def ccache_stats(dir, field):
# Look ccache source's 'src/core/Statistic.hpp' for field meanings
diff --git a/testsuite/citest.py b/testsuite/citest.py
index ee965278..6104f99e 100755
--- a/testsuite/citest.py
+++ b/testsuite/citest.py
@@ -122,6 +122,32 @@ class CcacheTest(CIBaseTest):
self.perform_ccache_test(targets)


+class InstallerTest(CIBaseTest):
+
+ """
+ Installer test
+
+ :avocado: tags=installer,full
+ """
+
+ def test_installer_build(self):
+ self.init()
+ target = "mc:isar-installer:isar-image-installer"
+ distro = "debian-bookworm"
+ machine = "qemuamd64"
+ self.perform_installer_build_test(target, distro, machine)
+
+ def test_installer_run(self):
+ self.init()
+ self.vm_start('amd64', 'bookworm', image='isar-image-installer',
+ keep=True)
+
+ def test_installer_root_partition(self):
+ self.init()
+ self.vm_start('amd64', 'bookworm', image='isar-image-installer',
+ cmd='findmnt -n -o SOURCE / | grep -q sda2')
Reply all
Reply to author
Forward
0 new messages