This commit adds two tests to the wic plugin to verify that the kernel is installed correctly when `skip-kernel-install` is not provided and not installed when `skip-kernel-install=true`. These tests ensure that the wic plugin is working correctly and will help catch any future issues with kernel installation.
Signed-off-by: Kareem Zarka <kareem.za...@huawei.com> --- meta/lib/oeqa/selftest/cases/wic.py | 71 +++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/meta/lib/oeqa/selftest/cases/wic.py b/meta/lib/oeqa/selftest/cases/wic.py index ca1abb970a..40188a866a 100644 --- a/meta/lib/oeqa/selftest/cases/wic.py +++ b/meta/lib/oeqa/selftest/cases/wic.py @@ -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 @@ -220,6 +221,76 @@ class Wic(WicTestCase): result = runCmd("wic ls %s:1/ -n %s" % (images[0], sysroot)) self.assertIn("kernel",result.output) + def test_skip_kernel_install(self): + """Test skip_kernel_install in wic plugin""" + # create a temporary file for the WKS content + with NamedTemporaryFile("w", suffix=".wks") as wks: + # write the WKS content to the temporary file + wks.writelines([ + 'part --source bootimg-efi \ + --sourceparams="loader=grub-efi,skip-kernal-install=true"\ + --label boot --active' + ]) + 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)) + + # extract the content of the disk image to the temporary directory + cmd = "wic cp %s:1 %s" % (out[0], tmpdir) + runCmd(cmd) + + # check if the kernel is installed or not + kimgtype = get_bb_var('KERNEL_IMAGETYPE', 'core-image-minimal') + for file in os.listdir(tmpdir): + if file == kimgtype : + raise AssertionError( + "The kernel image '{}' was found in\ + the partition".format(kimgtype) + ) + + def test_kernel_installation(self): + """Test kernel installation in wic plugin""" + # create a temporary file for the WKS content + with NamedTemporaryFile("w", suffix=".wks") as wks: + # write the WKS content to the temporary file + wks.writelines([ + 'part --source bootimg-efi \ + --sourceparams="loader=grub-efi"\ + --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)) + + # extract the content of the disk image to the temporary directory + cmd = "wic cp %s:1 %s" % (out[0], tmpdir) + runCmd(cmd) + + # check if the kernel is installed or not + kimgtype = get_bb_var('KERNEL_IMAGETYPE', 'core-image-minimal') + for file in os.listdir(tmpdir): + if file == kimgtype : + found = True + break + self.assertTrue( + found,"The kernel image was not found\ + in the boot prtition".format(kimgtype) + ) + def test_sdimage_bootpart(self): """Test creation of sdimage-bootpart image""" cmd = "wic create sdimage-bootpart -e core-image-minimal -o %s" % self.resultdir -- 2.25.1
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#176795): https://lists.openembedded.org/g/openembedded-core/message/176795 Mute This Topic: https://lists.openembedded.org/mt/96791017/21656 Group Owner: openembedded-core+ow...@lists.openembedded.org Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-