oe-selftest: add wic.Wic.test_grub_install_pcbios

wic.Wic.test_grub_install_pcbios test

Test updates to the bootimg_pcbios plugin that
enables support for installing grub directly
to the resulting wic image.

The test checks to see if the wics plugin
generates a wic image. Then see's if normal.mod
and grub.cfg are located in the boot partition.

(From OE-Core rev: 23b2a406c7d83f7b81aed85819b4643b93978ac9)

Signed-off-by: Vincent Davis Jr <vince@underview.tech>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Vincent Davis Jr 2025-08-14 00:25:52 -04:00 committed by Richard Purdie
parent c74dfd8f81
commit f9e0afedea

View File

@ -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_grub_install_pcbios(self):
"""
Test the installation of the grub modules + config
into the boot directory in the resulting wic image.
"""
# 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