diff options
author | Kareem Zarka <zarkakareem@gmail.com> | 2023-12-01 15:03:32 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-12-04 11:23:37 +0000 |
commit | 95d8a12b315c34d496228da188bc30568e724ee4 (patch) | |
tree | a8a0b943ab1519d2a063b22075bf54e8bc936de5 | |
parent | 0a39f1aa09108edc919b82ba47417616052b530e (diff) | |
download | poky-95d8a12b315c34d496228da188bc30568e724ee4.tar.gz |
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>
-rw-r--r-- | meta/lib/oeqa/selftest/cases/wic.py | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/meta/lib/oeqa/selftest/cases/wic.py b/meta/lib/oeqa/selftest/cases/wic.py index ab248c5898..4ebcb76cc4 100644 --- a/meta/lib/oeqa/selftest/cases/wic.py +++ b/meta/lib/oeqa/selftest/cases/wic.py | |||
@@ -16,6 +16,7 @@ import hashlib | |||
16 | from glob import glob | 16 | from glob import glob |
17 | from shutil import rmtree, copy | 17 | from shutil import rmtree, copy |
18 | from tempfile import NamedTemporaryFile | 18 | from tempfile import NamedTemporaryFile |
19 | from tempfile import TemporaryDirectory | ||
19 | 20 | ||
20 | from oeqa.selftest.case import OESelftestTestCase | 21 | from oeqa.selftest.case import OESelftestTestCase |
21 | from oeqa.core.decorator import OETestTag | 22 | from oeqa.core.decorator import OETestTag |
@@ -146,6 +147,73 @@ class CLITests(OESelftestTestCase): | |||
146 | self.assertEqual(1, runCmd('wic', ignore_status=True).status) | 147 | self.assertEqual(1, runCmd('wic', ignore_status=True).status) |
147 | 148 | ||
148 | class Wic(WicTestCase): | 149 | class Wic(WicTestCase): |
150 | def test_skip_kernel_install(self): | ||
151 | """Test the functionality of not installing the kernel in the boot directory using the wic plugin""" | ||
152 | # create a temporary file for the WKS content | ||
153 | with NamedTemporaryFile("w", suffix=".wks") as wks: | ||
154 | wks.write( | ||
155 | 'part --source bootimg-efi ' | ||
156 | '--sourceparams="loader=grub-efi,install-kernel-into-boot-dir=false" ' | ||
157 | '--label boot --active\n' | ||
158 | ) | ||
159 | wks.flush() | ||
160 | # create a temporary directory to extract the disk image to | ||
161 | with TemporaryDirectory() as tmpdir: | ||
162 | img = 'core-image-minimal' | ||
163 | # build the image using the WKS file | ||
164 | cmd = "wic create %s -e %s -o %s" % ( | ||
165 | wks.name, img, self.resultdir) | ||
166 | runCmd(cmd) | ||
167 | wksname = os.path.splitext(os.path.basename(wks.name))[0] | ||
168 | out = glob(os.path.join( | ||
169 | self.resultdir, "%s-*.direct" % wksname)) | ||
170 | self.assertEqual(1, len(out)) | ||
171 | sysroot = get_bb_var('RECIPE_SYSROOT_NATIVE', 'wic-tools') | ||
172 | # extract the content of the disk image to the temporary directory | ||
173 | cmd = "wic cp %s:1 %s -n %s" % (out[0], tmpdir, sysroot) | ||
174 | runCmd(cmd) | ||
175 | # check if the kernel is installed or not | ||
176 | kimgtype = get_bb_var('KERNEL_IMAGETYPE', img) | ||
177 | for file in os.listdir(tmpdir): | ||
178 | if file == kimgtype: | ||
179 | raise AssertionError( | ||
180 | "The kernel image '{}' was found in the partition".format(kimgtype) | ||
181 | ) | ||
182 | |||
183 | def test_kernel_install(self): | ||
184 | """Test the installation of the kernel to the boot directory in the wic plugin""" | ||
185 | # create a temporary file for the WKS content | ||
186 | with NamedTemporaryFile("w", suffix=".wks") as wks: | ||
187 | wks.write( | ||
188 | 'part --source bootimg-efi ' | ||
189 | '--sourceparams="loader=grub-efi,install-kernel-into-boot-dir=true" ' | ||
190 | '--label boot --active\n' | ||
191 | ) | ||
192 | wks.flush() | ||
193 | # create a temporary directory to extract the disk image to | ||
194 | with TemporaryDirectory() as tmpdir: | ||
195 | img = 'core-image-minimal' | ||
196 | # build the image using the WKS file | ||
197 | cmd = "wic create %s -e %s -o %s" % (wks.name, img, self.resultdir) | ||
198 | runCmd(cmd) | ||
199 | wksname = os.path.splitext(os.path.basename(wks.name))[0] | ||
200 | out = glob(os.path.join(self.resultdir, "%s-*.direct" % wksname)) | ||
201 | self.assertEqual(1, len(out)) | ||
202 | sysroot = get_bb_var('RECIPE_SYSROOT_NATIVE', 'wic-tools') | ||
203 | # extract the content of the disk image to the temporary directory | ||
204 | cmd = "wic cp %s:1 %s -n %s" % (out[0], tmpdir, sysroot) | ||
205 | runCmd(cmd) | ||
206 | # check if the kernel is installed or not | ||
207 | kimgtype = get_bb_var('KERNEL_IMAGETYPE', img) | ||
208 | found = False | ||
209 | for file in os.listdir(tmpdir): | ||
210 | if file == kimgtype: | ||
211 | found = True | ||
212 | break | ||
213 | self.assertTrue( | ||
214 | found, "The kernel image '{}' was not found in the boot partition".format(kimgtype) | ||
215 | ) | ||
216 | |||
149 | def test_build_image_name(self): | 217 | def test_build_image_name(self): |
150 | """Test wic create wictestdisk --image-name=core-image-minimal""" | 218 | """Test wic create wictestdisk --image-name=core-image-minimal""" |
151 | cmd = "wic create wictestdisk --image-name=core-image-minimal -o %s" % self.resultdir | 219 | cmd = "wic create wictestdisk --image-name=core-image-minimal -o %s" % self.resultdir |