mirror of
git://git.yoctoproject.org/poky.git
synced 2025-07-19 12:59:02 +02:00
oeqa/selftest/wic: Add tests for kernel image installation
- test_skip_kernel_install: This test verifies that the kernel is not installed in the boot partition when the 'install-kernel-into-boot-dir' parameter is set to false. - test_kernel_install: This test verifies that the kernel is installed in the boot partition when the 'install-kernel-into-boot-dir' parameter is set to true. Both tests use a WKS (Kickstart) file to specify the desired configuration, build a disk image using WIC, and extract the disk image to a temporary directory to verify the results. (From OE-Core rev: a99bc5ed8bf67f171be24c0e2220aae6cccf230e) Signed-off-by: Kareem Zarka <kareem.zarka@huawei.com> Signed-off-by: Christian Taedcke <christian.taedcke@weidmueller.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
parent
0a39f1aa09
commit
95d8a12b31
|
@ -16,6 +16,7 @@ import hashlib
|
|||
from glob import glob
|
||||
from shutil import rmtree, copy
|
||||
from tempfile import NamedTemporaryFile
|
||||
from tempfile import TemporaryDirectory
|
||||
|
||||
from oeqa.selftest.case import OESelftestTestCase
|
||||
from oeqa.core.decorator import OETestTag
|
||||
|
@ -146,6 +147,73 @@ class CLITests(OESelftestTestCase):
|
|||
self.assertEqual(1, runCmd('wic', ignore_status=True).status)
|
||||
|
||||
class Wic(WicTestCase):
|
||||
def test_skip_kernel_install(self):
|
||||
"""Test the functionality of not installing the kernel in the boot directory using the wic plugin"""
|
||||
# create a temporary file for the WKS content
|
||||
with NamedTemporaryFile("w", suffix=".wks") as wks:
|
||||
wks.write(
|
||||
'part --source bootimg-efi '
|
||||
'--sourceparams="loader=grub-efi,install-kernel-into-boot-dir=false" '
|
||||
'--label boot --active\n'
|
||||
)
|
||||
wks.flush()
|
||||
# create a temporary directory to extract the disk image to
|
||||
with TemporaryDirectory() as tmpdir:
|
||||
img = 'core-image-minimal'
|
||||
# build the image using the WKS file
|
||||
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')
|
||||
# extract the content of the disk image to the temporary directory
|
||||
cmd = "wic cp %s:1 %s -n %s" % (out[0], tmpdir, sysroot)
|
||||
runCmd(cmd)
|
||||
# check if the kernel is installed or not
|
||||
kimgtype = get_bb_var('KERNEL_IMAGETYPE', img)
|
||||
for file in os.listdir(tmpdir):
|
||||
if file == kimgtype:
|
||||
raise AssertionError(
|
||||
"The kernel image '{}' was found in the partition".format(kimgtype)
|
||||
)
|
||||
|
||||
def test_kernel_install(self):
|
||||
"""Test the installation of the kernel to 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-efi '
|
||||
'--sourceparams="loader=grub-efi,install-kernel-into-boot-dir=true" '
|
||||
'--label boot --active\n'
|
||||
)
|
||||
wks.flush()
|
||||
# create a temporary directory to extract the disk image to
|
||||
with TemporaryDirectory() as tmpdir:
|
||||
img = 'core-image-minimal'
|
||||
# build the image using the WKS file
|
||||
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')
|
||||
# extract the content of the disk image to the temporary directory
|
||||
cmd = "wic cp %s:1 %s -n %s" % (out[0], tmpdir, sysroot)
|
||||
runCmd(cmd)
|
||||
# check if the kernel is installed or not
|
||||
kimgtype = get_bb_var('KERNEL_IMAGETYPE', img)
|
||||
found = False
|
||||
for file in os.listdir(tmpdir):
|
||||
if file == kimgtype:
|
||||
found = True
|
||||
break
|
||||
self.assertTrue(
|
||||
found, "The kernel image '{}' was not found in the boot partition".format(kimgtype)
|
||||
)
|
||||
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue
Block a user