@@ -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
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.zarka@huawei.com> --- meta/lib/oeqa/selftest/cases/wic.py | 71 +++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+)