diff options
author | Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> | 2021-01-19 10:53:03 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-01-20 00:45:05 +0000 |
commit | eef552d273385d5beecfb47e78a0ff7660b58e23 (patch) | |
tree | 53eb28542f4f43315e1b4fb37811603db85d9cbd /meta | |
parent | af6ac324379d8e2c85940b401d488d4d4d0cde94 (diff) | |
download | poky-eef552d273385d5beecfb47e78a0ff7660b58e23.tar.gz |
oeqa/selftest/imagefeatures: adding fitImage initramfs bundle testcase
This commit provides a testcase for the initramfs bundle support implemented
in kernel-fitimage.bbclass
The testcase verifies the content of the initramfs bundle node in the FIT
Image Tree Source (its).
The testcase is self-contained and the configurations are set by the test case itself.
To verify the initramfs bundle support, the testcase uses beaglebone-yocto machine.
This testcase can be run through the following command:
oe-selftest -r fitimage.FitImageTests.test_initramfs_bundle
Change-Id: I8ab8abf2c150ea515fd439784eb20c6b092bfbc5
(From OE-Core rev: 1119d577756b386507f33669fe29dafb5579a1a7)
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r-- | meta/lib/oeqa/selftest/cases/fitimage.py | 132 |
1 files changed, 132 insertions, 0 deletions
diff --git a/meta/lib/oeqa/selftest/cases/fitimage.py b/meta/lib/oeqa/selftest/cases/fitimage.py index 19b9f53ee4..0958036a6f 100644 --- a/meta/lib/oeqa/selftest/cases/fitimage.py +++ b/meta/lib/oeqa/selftest/cases/fitimage.py | |||
@@ -231,3 +231,135 @@ UBOOT_MKIMAGE_SIGN_ARGS = "-c 'a smart comment'" | |||
231 | result = runCmd('grep "### uboot-mkimage signing wrapper message" %s/log.do_assemble_fitimage' % tempdir, ignore_status=True) | 231 | result = runCmd('grep "### uboot-mkimage signing wrapper message" %s/log.do_assemble_fitimage' % tempdir, ignore_status=True) |
232 | self.assertEqual(result.status, 0, 'UBOOT_MKIMAGE_SIGN did not work') | 232 | self.assertEqual(result.status, 0, 'UBOOT_MKIMAGE_SIGN did not work') |
233 | 233 | ||
234 | def test_initramfs_bundle(self): | ||
235 | """ | ||
236 | Summary: Verifies the content of the initramfs bundle node in the FIT Image Tree Source (its) | ||
237 | The FIT settings are set by the test case. | ||
238 | The machine used is beaglebone-yocto. | ||
239 | Expected: 1. The ITS is generated with initramfs bundle support | ||
240 | 2. All the fields in the kernel node are as expected (matching the | ||
241 | conf settings) | ||
242 | 3. The kernel is included in all the available configurations and | ||
243 | its hash is included in the configuration signature | ||
244 | |||
245 | Product: oe-core | ||
246 | Author: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> | ||
247 | """ | ||
248 | |||
249 | config = """ | ||
250 | DISTRO="poky" | ||
251 | MACHINE = "beaglebone-yocto" | ||
252 | INITRAMFS_IMAGE_BUNDLE = "1" | ||
253 | INITRAMFS_IMAGE = "core-image-minimal-initramfs" | ||
254 | INITRAMFS_SCRIPTS = "" | ||
255 | UBOOT_MACHINE = "am335x_evm_defconfig" | ||
256 | KERNEL_CLASSES = " kernel-fitimage " | ||
257 | KERNEL_IMAGETYPES = "fitImage" | ||
258 | UBOOT_SIGN_ENABLE = "1" | ||
259 | UBOOT_SIGN_KEYNAME = "beaglebonekey" | ||
260 | UBOOT_SIGN_KEYDIR ?= "${DEPLOY_DIR_IMAGE}" | ||
261 | UBOOT_DTB_BINARY = "u-boot.dtb" | ||
262 | UBOOT_ENTRYPOINT = "0x80000000" | ||
263 | UBOOT_LOADADDRESS = "0x80000000" | ||
264 | UBOOT_DTB_LOADADDRESS = "0x82000000" | ||
265 | UBOOT_ARCH = "arm" | ||
266 | UBOOT_MKIMAGE_DTCOPTS = "-I dts -O dtb -p 2000" | ||
267 | UBOOT_EXTLINUX = "0" | ||
268 | FIT_GENERATE_KEYS = "1" | ||
269 | KERNEL_IMAGETYPE_REPLACEMENT = "zImage" | ||
270 | FIT_HASH_ALG = "sha256" | ||
271 | """ | ||
272 | self.write_config(config) | ||
273 | |||
274 | # fitImage is created as part of linux recipe | ||
275 | bitbake("virtual/kernel") | ||
276 | |||
277 | image_type = get_bb_var('INITRAMFS_IMAGE') | ||
278 | deploy_dir_image = get_bb_var('DEPLOY_DIR_IMAGE') | ||
279 | machine = get_bb_var('MACHINE') | ||
280 | fitimage_its_path = os.path.join(deploy_dir_image, | ||
281 | "fitImage-its-%s-%s-%s" % (image_type, machine, machine)) | ||
282 | fitimage_path = os.path.join(deploy_dir_image,"fitImage") | ||
283 | |||
284 | self.assertTrue(os.path.exists(fitimage_its_path), | ||
285 | "%s image tree source doesn't exist" % (fitimage_its_path)) | ||
286 | self.assertTrue(os.path.exists(fitimage_path), | ||
287 | "%s FIT image doesn't exist" % (fitimage_path)) | ||
288 | |||
289 | kernel_load = str(get_bb_var('UBOOT_LOADADDRESS')) | ||
290 | kernel_entry = str(get_bb_var('UBOOT_ENTRYPOINT')) | ||
291 | initramfs_bundle_format = str(get_bb_var('KERNEL_IMAGETYPE_REPLACEMENT')) | ||
292 | uboot_arch = str(get_bb_var('UBOOT_ARCH')) | ||
293 | initramfs_bundle = "arch/" + uboot_arch + "/boot/" + initramfs_bundle_format + ".initramfs" | ||
294 | fit_hash_alg = str(get_bb_var('FIT_HASH_ALG')) | ||
295 | |||
296 | its_file = open(fitimage_its_path) | ||
297 | |||
298 | its_lines = [line.strip() for line in its_file.readlines()] | ||
299 | |||
300 | exp_node_lines = [ | ||
301 | 'kernel@1 {', | ||
302 | 'description = "Linux kernel";', | ||
303 | 'data = /incbin/("' + initramfs_bundle + '");', | ||
304 | 'type = "kernel";', | ||
305 | 'arch = "' + uboot_arch + '";', | ||
306 | 'os = "linux";', | ||
307 | 'compression = "none";', | ||
308 | 'load = <' + kernel_load + '>;', | ||
309 | 'entry = <' + kernel_entry + '>;', | ||
310 | 'hash@1 {', | ||
311 | 'algo = "' + fit_hash_alg +'";', | ||
312 | '};', | ||
313 | '};' | ||
314 | ] | ||
315 | |||
316 | node_str = exp_node_lines[0] | ||
317 | |||
318 | test_passed = False | ||
319 | |||
320 | print ("checking kernel node\n") | ||
321 | |||
322 | if node_str in its_lines: | ||
323 | node_start_idx = its_lines.index(node_str) | ||
324 | node = its_lines[node_start_idx:(node_start_idx + len(exp_node_lines))] | ||
325 | if node == exp_node_lines: | ||
326 | print("kernel node verified") | ||
327 | else: | ||
328 | self.assertTrue(test_passed == True,"kernel node does not match expectation") | ||
329 | |||
330 | rx_configs = re.compile("^conf@.*") | ||
331 | its_configs = list(filter(rx_configs.match, its_lines)) | ||
332 | |||
333 | for cfg_str in its_configs: | ||
334 | cfg_start_idx = its_lines.index(cfg_str) | ||
335 | line_idx = cfg_start_idx + 2 | ||
336 | node_end = False | ||
337 | while node_end == False: | ||
338 | if its_lines[line_idx] == "};" and its_lines[line_idx-1] == "};" : | ||
339 | node_end = True | ||
340 | line_idx = line_idx + 1 | ||
341 | |||
342 | node = its_lines[cfg_start_idx:line_idx] | ||
343 | print("checking configuration " + cfg_str.rstrip(" {")) | ||
344 | rx_desc_line = re.compile("^description.*1 Linux kernel.*") | ||
345 | if len(list(filter(rx_desc_line.match, node))) != 1: | ||
346 | self.assertTrue(test_passed == True,"kernel keyword not found in the description line") | ||
347 | break | ||
348 | else: | ||
349 | print("kernel keyword found in the description line") | ||
350 | |||
351 | if 'kernel = "kernel@1";' not in node: | ||
352 | self.assertTrue(test_passed == True,"kernel line not found") | ||
353 | break | ||
354 | else: | ||
355 | print("kernel line found") | ||
356 | |||
357 | rx_sign_line = re.compile("^sign-images.*kernel.*") | ||
358 | if len(list(filter(rx_sign_line.match, node))) != 1: | ||
359 | self.assertTrue(test_passed == True,"kernel hash not signed") | ||
360 | break | ||
361 | else: | ||
362 | print("kernel hash signed") | ||
363 | |||
364 | test_passed = True | ||
365 | self.assertTrue(test_passed == True,"Initramfs bundle test success") | ||