diff mbox series

[3/3] oe-selftest: add test_bootimg_pcbios_grub_install

Message ID 20250721010939.3561904-3-vince@underview.tech
State New
Headers show
Series [1/3] bootimg_pcbios: support grub legacy bios boot | expand

Commit Message

Vincent Davis Jr July 21, 2025, 1:09 a.m. UTC
Signed-off-by: Vincent Davis Jr <vince@underview.tech>
---
 meta/lib/oeqa/selftest/cases/wic.py           | 43 ++++++++++++++++++-
 .../lib/wic/plugins/source/bootimg_pcbios.py  | 30 ++++++-------
 2 files changed, 54 insertions(+), 19 deletions(-)

Comments

patchtest@automation.yoctoproject.org July 21, 2025, 1:33 a.m. UTC | #1
Thank you for your submission. Patchtest identified one
or more issues with the patch. Please see the log below for
more information:

---
Testing patch /home/patchtest/share/mboxes/3-3-oe-selftest-add-test_bootimg_pcbios_grub_install.patch

FAIL: test commit message presence: Please include a commit message on your patch explaining the change (test_mbox.TestMbox.test_commit_message_presence)

PASS: pretest pylint (test_python_pylint.PyLint.pretest_pylint)
PASS: test Signed-off-by presence (test_mbox.TestMbox.test_signed_off_by_presence)
PASS: test author valid (test_mbox.TestMbox.test_author_valid)
PASS: test commit message user tags (test_mbox.TestMbox.test_commit_message_user_tags)
PASS: test max line length (test_metadata.TestMetadata.test_max_line_length)
PASS: test mbox format (test_mbox.TestMbox.test_mbox_format)
PASS: test non-AUH upgrade (test_mbox.TestMbox.test_non_auh_upgrade)
PASS: test pylint (test_python_pylint.PyLint.test_pylint)
PASS: test shortlog format (test_mbox.TestMbox.test_shortlog_format)
PASS: test shortlog length (test_mbox.TestMbox.test_shortlog_length)
PASS: test target mailing list (test_mbox.TestMbox.test_target_mailing_list)

SKIP: pretest src uri left files: No modified recipes, skipping pretest (test_metadata.TestMetadata.pretest_src_uri_left_files)
SKIP: test CVE check ignore: No modified recipes or older target branch, skipping test (test_metadata.TestMetadata.test_cve_check_ignore)
SKIP: test CVE tag format: No new CVE patches introduced (test_patch.TestPatch.test_cve_tag_format)
SKIP: test Signed-off-by presence: No new CVE patches introduced (test_patch.TestPatch.test_signed_off_by_presence)
SKIP: test Upstream-Status presence: No new CVE patches introduced (test_patch.TestPatch.test_upstream_status_presence_format)
SKIP: test bugzilla entry format: No bug ID found (test_mbox.TestMbox.test_bugzilla_entry_format)
SKIP: test lic files chksum modified not mentioned: No modified recipes, skipping test (test_metadata.TestMetadata.test_lic_files_chksum_modified_not_mentioned)
SKIP: test lic files chksum presence: No added recipes, skipping test (test_metadata.TestMetadata.test_lic_files_chksum_presence)
SKIP: test license presence: No added recipes, skipping test (test_metadata.TestMetadata.test_license_presence)
SKIP: test series merge on head: Merge test is disabled for now (test_mbox.TestMbox.test_series_merge_on_head)
SKIP: test src uri left files: No modified recipes, skipping pretest (test_metadata.TestMetadata.test_src_uri_left_files)
SKIP: test summary presence: No added recipes, skipping test (test_metadata.TestMetadata.test_summary_presence)

---

Please address the issues identified and
submit a new revision of the patch, or alternatively, reply to this
email with an explanation of why the patch should be accepted. If you
believe these results are due to an error in patchtest, please submit a
bug at https://bugzilla.yoctoproject.org/ (use the 'Patchtest' category
under 'Yocto Project Subprojects'). For more information on specific
failures, see: https://wiki.yoctoproject.org/wiki/Patchtest. Thank
you!
diff mbox series

Patch

diff --git a/meta/lib/oeqa/selftest/cases/wic.py b/meta/lib/oeqa/selftest/cases/wic.py
index 680f99d381..91d9d31da1 100644
--- a/meta/lib/oeqa/selftest/cases/wic.py
+++ b/meta/lib/oeqa/selftest/cases/wic.py
@@ -215,6 +215,47 @@  class Wic(WicTestCase):
                     found, "The kernel image '{}' was not found in the boot partition".format(kimgtype)
                 )
 
+    @skipIfNotArch(['x86_64'])
+    def test_bootimg_pcbios_grub_install(self):
+        """
+        Test the installation of the grub modules + config
+        into the boot directory in the wic plugin.
+        """
+
+        # create a temporary file for the WKS content
+        with NamedTemporaryFile("w", suffix=".wks") as wks:
+            wks.write(
+                'part --source bootimg_pcbios --sourceparams="loader-bios=grub" '
+                '--offset 1024 --fixed-size 78M --label boot --active\n'
+                'bootloader --ptable msdos --source bootimg_pcbios\n'
+            )
+            wks.flush()
+            # create a temporary directory to extract the disk image to
+            with TemporaryDirectory() as tmpdir:
+                img = "core-image-minimal"
+                config = 'DEPENDS:pn-%s += "grub-native grub"' % (img)
+
+                self.append_config(config)
+                bitbake(img)
+                self.remove_config(config)
+
+                cmd = "wic create %s -e %s -o %s" % (wks.name, img, self.resultdir)
+                runCmd(cmd)
+
+                wksname = os.path.splitext(os.path.basename(wks.name))[0]
+                out = glob(os.path.join(self.resultdir, "%s-*.direct" % wksname))
+                self.assertEqual(1, len(out))
+
+                sysroot = get_bb_var('RECIPE_SYSROOT_NATIVE', 'wic-tools')
+
+                # Check if grub.cfg is installed
+                result = runCmd("wic ls %s:1/boot/grub -n %s" % (out[0], sysroot))
+                self.assertIn('grub', result.output)
+
+                # Check if normal.mod is installed
+                result = runCmd("wic ls %s:1/boot/grub/i386-pc -n %s" % (out[0], sysroot))
+                self.assertIn('normal', result.output)
+
     def test_build_image_name(self):
         """Test wic create wictestdisk --image-name=core-image-minimal"""
         cmd = "wic create wictestdisk --image-name=core-image-minimal -o %s" % self.resultdir
@@ -1405,7 +1446,7 @@  run_wic_cmd() {
 
         img = 'core-image-minimal'
         with NamedTemporaryFile("w", suffix=".wks") as wks:
-            wks.writelines(['part /boot --active --source bootimg_biosplusefi --sourceparams="loader=grub-efi"\n',
+            wks.writelines(['part /boot --active --source bootimg_biosplusefi --sourceparams="loader=grub-efi,loader-bios=syslinux"\n',
                             'part / --source rootfs --fstype=ext4 --align 1024 --use-uuid\n'\
                             'bootloader --timeout=0 --append="console=ttyS0,115200n8"\n'])
             wks.flush()
diff --git a/scripts/lib/wic/plugins/source/bootimg_pcbios.py b/scripts/lib/wic/plugins/source/bootimg_pcbios.py
index 97687edc71..2582ce1164 100644
--- a/scripts/lib/wic/plugins/source/bootimg_pcbios.py
+++ b/scripts/lib/wic/plugins/source/bootimg_pcbios.py
@@ -113,7 +113,7 @@  class BootimgPcbiosPlugin(SourcePlugin):
         hdddir = "%s/hdd" % cr_workdir
         bootloader = creator.ks.bootloader
 
-        grub_cfg = cls._get_bootloader_config(creator, 'grub')
+        grub_conf = cls._get_bootloader_config(creator, 'grub')
 
         grub_prefix_path = get_bitbake_var('GRUB_PREFIX_PATH')
         if not grub_prefix_path:
@@ -123,7 +123,7 @@  class BootimgPcbiosPlugin(SourcePlugin):
         install_cmd = "install -d %s" % grub_path
         exec_cmd(install_cmd)
 
-        if not grub_cfg:
+        if not grub_conf:
             grub_conf = 'serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1\n'
             grub_conf += 'set gfxmode=auto\n'
             grub_conf += 'set gfxpayload=keep\n\n'
@@ -138,25 +138,22 @@  class BootimgPcbiosPlugin(SourcePlugin):
             grub_conf += '\tlinux %s root=PARTUUID=$partuuid %s\n}\n' % \
                     (kernel, bootloader.append if bootloader.append else '')
 
-            logger.debug("Writing grub config %s/grub.cfg", grub_path)
-            cfg = open("%s/grub.cfg" % grub_path, "w")
-            cfg.write(grub_conf)
-            cfg.close()
-        else:
-            logger.debug("Copying grub config to %s/grub.cfg", grub_path)
-            shutil.copy2(grub_cfg, "%s/grub.cfg" % grub_path)
+        logger.debug("Writing grub config %s/grub.cfg", grub_path)
+        cfg = open("%s/grub.cfg" % grub_path, "w")
+        cfg.write(grub_conf)
+        cfg.close()
 
     @classmethod
     def _do_configure_syslinux_cfg(cls, creator, cr_workdir, bootimg_dir):
         hdddir = "%s/hdd/boot" % cr_workdir
         bootloader = creator.ks.bootloader
 
-        syslinux_cfg = cls._get_bootloader_config(creator, 'syslinux')
+        syslinux_conf = cls._get_bootloader_config(creator, 'syslinux')
 
         install_cmd = "install -d %s" % hdddir
         exec_cmd(install_cmd)
 
-        if not syslinux_cfg:
+        if not syslinux_conf:
             # Create syslinux configuration using parameters from wks file
             splash = os.path.join(hdddir, "/splash.jpg")
             if os.path.exists(splash):
@@ -182,13 +179,10 @@  class BootimgPcbiosPlugin(SourcePlugin):
             syslinux_conf += "APPEND label=boot root=%s %s\n" % \
                              (creator.rootdev, bootloader.append)
 
-            logger.debug("Writing syslinux config %s/syslinux.cfg", hdddir)
-            cfg = open("%s/syslinux.cfg" % hdddir, "w")
-            cfg.write(syslinux_conf)
-            cfg.close()
-        else:
-            logger.debug("Copying syslinux config to %s/syslinux.cfg", hdddir)
-            shutil.copy2(syslinux_cfg, "%s/syslinux.cfg" % hdddir)
+        logger.debug("Writing syslinux config %s/syslinux.cfg", hdddir)
+        cfg = open("%s/syslinux.cfg" % hdddir, "w")
+        cfg.write(syslinux_conf)
+        cfg.close()
 
     @classmethod
     def do_configure_partition(cls, part, source_params, creator, cr_workdir,