[3/3] testsuite: add 'customizations' test

Message ID 20250311210939.4090-4-chris.larson@siemens.com
State Accepted, archived
Headers show
Series Add 'customization' package support | expand

Commit Message

chris.larson March 11, 2025, 9:09 p.m. UTC
From: Christopher Larson <chris.larson@siemens.com>

This test builds isar-image-ci with the hostname customization enabled, and
verifies that the customization applied correctly.

Signed-off-by: Christopher Larson <chris.larson@siemens.com>
---
 testsuite/cibuilder.py |  9 +++++++++
 testsuite/citest.py    | 21 +++++++++++++++++++++
 2 files changed, 30 insertions(+)

Patch

diff --git a/testsuite/cibuilder.py b/testsuite/cibuilder.py
index b5b6a093..1746171e 100755
--- a/testsuite/cibuilder.py
+++ b/testsuite/cibuilder.py
@@ -109,6 +109,7 @@  def configure(
         source_date_epoch=None,
         use_apt_snapshot=False,
         image_install=None,
+        customizations=None,
         **kwargs,
     ):
         # write configuration file and set bitbake_args
@@ -155,6 +156,7 @@  def configure(
             f"  sstate_dir = {sstate_dir}\n"
             f"  ccache_dir = {ccache_dir}\n"
             f"  image_install = {image_install}\n"
+            f"  customizations = {customizations}\n"
             f"==================================================="
         )
 
@@ -216,6 +218,13 @@  def configure(
                 f.write('IMAGE_INSTALL = "%s"\n' % image_install)
             if fail_on_cleanup == '1':
                 f.write('ISAR_FAIL_ON_CLEANUP = "1"\n')
+            if customizations is not None:
+                if not isinstance(customizations, str):
+                    customizations = ' '.join(customizations)
+                f.write('CUSTOMIZATIONS = "%s"\n' % customizations)
+                f.write('CUSTOMIZATION_VARS:append = " ${IMAGE}"\n')
+                f.write('CUSTOMIZATION_FOR_IMAGES:append = " isar-image-ci"\n')
+                f.write('HOSTNAME:isar-image-ci = "isar-ci"\n')
 
         # include ci_build.conf in local.conf
         with open(self.build_dir + '/conf/local.conf', 'r+') as f:
diff --git a/testsuite/citest.py b/testsuite/citest.py
index 47f49263..66b39334 100755
--- a/testsuite/citest.py
+++ b/testsuite/citest.py
@@ -345,6 +345,27 @@  def test_container_sdk(self):
         )
 
 
+class CustomizationsTest(CIBaseTest):
+    """
+    Test image customizations using the hostname-customizations package.
+
+    :avocado: tags=customizations,single,full
+    """
+
+    def test_single_customization(self):
+        self.init()
+        machine = self.params.get("machine", default="qemuamd64")
+        distro = self.params.get("distro", default="bullseye")
+
+        self.perform_build_test("mc:%s-%s:%s" % (machine, distro, "isar-image-ci"), customizations="hostname", image_install="")
+        self.vm_start(
+            machine.removeprefix('qemu'),
+            distro,
+            image="isar-image-ci",
+            cmd="hostname | grep isar-ci"
+        )
+
+
 class SignatureTest(CIBaseTest):
 
     """