diff options
Diffstat (limited to 'meta/lib/oeqa/selftest/cases/fitimage.py')
| -rw-r--r-- | meta/lib/oeqa/selftest/cases/fitimage.py | 80 | 
1 files changed, 59 insertions, 21 deletions
diff --git a/meta/lib/oeqa/selftest/cases/fitimage.py b/meta/lib/oeqa/selftest/cases/fitimage.py index 9c2e10dd2b..8df5e92a34 100644 --- a/meta/lib/oeqa/selftest/cases/fitimage.py +++ b/meta/lib/oeqa/selftest/cases/fitimage.py  | |||
| @@ -9,7 +9,6 @@ import re | |||
| 9 | import shlex | 9 | import shlex | 
| 10 | import logging | 10 | import logging | 
| 11 | import pprint | 11 | import pprint | 
| 12 | import tempfile | ||
| 13 | 12 | ||
| 14 | import oe.fitimage | 13 | import oe.fitimage | 
| 15 | 14 | ||
| @@ -47,10 +46,11 @@ class FitImageTestCase(OESelftestTestCase): | |||
| 47 | # Check if the its file contains the expected paths and attributes. | 46 | # Check if the its file contains the expected paths and attributes. | 
| 48 | # The _get_req_* functions are implemented by more specific chield classes. | 47 | # The _get_req_* functions are implemented by more specific chield classes. | 
| 49 | self._check_its_file() | 48 | self._check_its_file() | 
| 50 | req_its_paths = self._get_req_its_paths() | 49 | req_its_paths, not_req_its_paths = self._get_req_its_paths() | 
| 51 | req_sigvalues_config = self._get_req_sigvalues_config() | 50 | req_sigvalues_config = self._get_req_sigvalues_config() | 
| 52 | req_sigvalues_image = self._get_req_sigvalues_image() | 51 | req_sigvalues_image = self._get_req_sigvalues_image() | 
| 53 | # Compare the its file against req_its_paths, req_sigvalues_config, req_sigvalues_image | 52 | # Compare the its file against req_its_paths, not_req_its_paths, | 
| 53 | # req_sigvalues_config, req_sigvalues_image | ||
| 54 | 54 | ||
| 55 | # Call the dumpimage utiliy and check that it prints all the expected paths and attributes | 55 | # Call the dumpimage utiliy and check that it prints all the expected paths and attributes | 
| 56 | # The _get_req_* functions are implemented by more specific chield classes. | 56 | # The _get_req_* functions are implemented by more specific chield classes. | 
| @@ -198,7 +198,7 @@ class FitImageTestCase(OESelftestTestCase): | |||
| 198 | # Support only the test recipe which provides 1 devicetree and 1 devicetree overlay | 198 | # Support only the test recipe which provides 1 devicetree and 1 devicetree overlay | 
| 199 | pref_prov_dtb = bb_vars.get('PREFERRED_PROVIDER_virtual/dtb') | 199 | pref_prov_dtb = bb_vars.get('PREFERRED_PROVIDER_virtual/dtb') | 
| 200 | if pref_prov_dtb == "bbb-dtbs-as-ext": | 200 | if pref_prov_dtb == "bbb-dtbs-as-ext": | 
| 201 | all_dtbs += ["am335x-bonegreen-ext.dtb", "BBORG_RELAY-00A2.dtbo"] | 201 | all_dtbs += ["BBORG_RELAY-00A2.dtbo", "am335x-bonegreen-ext.dtb"] | 
| 202 | dtb_symlinks.append("am335x-bonegreen-ext-alias.dtb") | 202 | dtb_symlinks.append("am335x-bonegreen-ext-alias.dtb") | 
| 203 | return (all_dtbs, dtb_symlinks) | 203 | return (all_dtbs, dtb_symlinks) | 
| 204 | 204 | ||
| @@ -234,8 +234,9 @@ class FitImageTestCase(OESelftestTestCase): | |||
| 234 | self.logger.debug("its file: %s" % its_file.read()) | 234 | self.logger.debug("its file: %s" % its_file.read()) | 
| 235 | 235 | ||
| 236 | # Generate a list of expected paths in the its file | 236 | # Generate a list of expected paths in the its file | 
| 237 | req_its_paths = self._get_req_its_paths(bb_vars) | 237 | req_its_paths, not_req_its_paths = self._get_req_its_paths(bb_vars) | 
| 238 | self.logger.debug("req_its_paths:\n%s\n" % pprint.pformat(req_its_paths, indent=4)) | 238 | self.logger.debug("req_its_paths:\n%s\n" % pprint.pformat(req_its_paths, indent=4)) | 
| 239 | self.logger.debug("not_req_its_paths:\n%s\n" % pprint.pformat(not_req_its_paths, indent=4)) | ||
| 239 | 240 | ||
| 240 | # Generate a dict of expected configuration signature nodes | 241 | # Generate a dict of expected configuration signature nodes | 
| 241 | req_sigvalues_config = self._get_req_sigvalues_config(bb_vars) | 242 | req_sigvalues_config = self._get_req_sigvalues_config(bb_vars) | 
| @@ -275,6 +276,11 @@ class FitImageTestCase(OESelftestTestCase): | |||
| 275 | if not req_path in its_paths: | 276 | if not req_path in its_paths: | 
| 276 | self.fail('Missing path in its file: %s (%s)' % (req_path, its_file_path)) | 277 | self.fail('Missing path in its file: %s (%s)' % (req_path, its_file_path)) | 
| 277 | 278 | ||
| 279 | # check if all not expected paths are absent in the its file | ||
| 280 | for not_req_path in not_req_its_paths: | ||
| 281 | if not_req_path in its_paths: | ||
| 282 | self.fail('Unexpected path found in its file: %s (%s)' % (not_req_path, its_file_path)) | ||
| 283 | |||
| 278 | # Check if all the expected singnature nodes (images and configurations) are found | 284 | # Check if all the expected singnature nodes (images and configurations) are found | 
| 279 | self.logger.debug("sigs:\n%s\n" % pprint.pformat(sigs, indent=4)) | 285 | self.logger.debug("sigs:\n%s\n" % pprint.pformat(sigs, indent=4)) | 
| 280 | if req_sigvalues_config or req_sigvalues_image: | 286 | if req_sigvalues_config or req_sigvalues_image: | 
| @@ -353,7 +359,7 @@ class FitImageTestCase(OESelftestTestCase): | |||
| 353 | 359 | ||
| 354 | def _get_req_its_paths(self, bb_vars): | 360 | def _get_req_its_paths(self, bb_vars): | 
| 355 | self.logger.error("This function needs to be implemented") | 361 | self.logger.error("This function needs to be implemented") | 
| 356 | return [] | 362 | return ([], []) | 
| 357 | 363 | ||
| 358 | def _get_req_its_fields(self, bb_vars): | 364 | def _get_req_its_fields(self, bb_vars): | 
| 359 | self.logger.error("This function needs to be implemented") | 365 | self.logger.error("This function needs to be implemented") | 
| @@ -499,7 +505,7 @@ class KernelFitImageBase(FitImageTestCase): | |||
| 499 | return (fitimage_its_path, fitimage_path) | 505 | return (fitimage_its_path, fitimage_path) | 
| 500 | 506 | ||
| 501 | def _get_req_its_paths(self, bb_vars): | 507 | def _get_req_its_paths(self, bb_vars): | 
| 502 | """Generate a list of expected paths in the its file | 508 | """Generate a list of expected and a list of not expected paths in the its file | 
| 503 | 509 | ||
| 504 | Example: | 510 | Example: | 
| 505 | [ | 511 | [ | 
| @@ -515,15 +521,26 @@ class KernelFitImageBase(FitImageTestCase): | |||
| 515 | uboot_sign_enable = bb_vars.get('UBOOT_SIGN_ENABLE') | 521 | uboot_sign_enable = bb_vars.get('UBOOT_SIGN_ENABLE') | 
| 516 | 522 | ||
| 517 | # image nodes | 523 | # image nodes | 
| 518 | images = [ 'kernel-1' ] | 524 | images = ['kernel-1'] | 
| 525 | not_images = [] | ||
| 526 | |||
| 519 | if dtb_files: | 527 | if dtb_files: | 
| 520 | images += [ 'fdt-' + dtb for dtb in dtb_files ] | 528 | images += [ 'fdt-' + dtb for dtb in dtb_files ] | 
| 529 | |||
| 521 | if fit_uboot_env: | 530 | if fit_uboot_env: | 
| 522 | images.append('bootscr-' + fit_uboot_env) | 531 | images.append('bootscr-' + fit_uboot_env) | 
| 532 | else: | ||
| 533 | not_images.append('bootscr-boot.cmd') | ||
| 534 | |||
| 523 | if bb_vars['MACHINE'] == "qemux86-64": # Not really the right if | 535 | if bb_vars['MACHINE'] == "qemux86-64": # Not really the right if | 
| 524 | images.append('setup-1') | 536 | images.append('setup-1') | 
| 537 | else: | ||
| 538 | not_images.append('setup-1') | ||
| 539 | |||
| 525 | if initramfs_image and initramfs_image_bundle != "1": | 540 | if initramfs_image and initramfs_image_bundle != "1": | 
| 526 | images.append('ramdisk-1') | 541 | images.append('ramdisk-1') | 
| 542 | else: | ||
| 543 | not_images.append('ramdisk-1') | ||
| 527 | 544 | ||
| 528 | # configuration nodes (one per DTB and also one per symlink) | 545 | # configuration nodes (one per DTB and also one per symlink) | 
| 529 | if dtb_files: | 546 | if dtb_files: | 
| @@ -541,7 +558,12 @@ class KernelFitImageBase(FitImageTestCase): | |||
| 541 | req_its_paths.append(['/', 'configurations', configuration, 'hash-1']) | 558 | req_its_paths.append(['/', 'configurations', configuration, 'hash-1']) | 
| 542 | if uboot_sign_enable == "1": | 559 | if uboot_sign_enable == "1": | 
| 543 | req_its_paths.append(['/', 'configurations', configuration, 'signature-1']) | 560 | req_its_paths.append(['/', 'configurations', configuration, 'signature-1']) | 
| 544 | return req_its_paths | 561 | |
| 562 | not_req_its_paths = [] | ||
| 563 | for image in not_images: | ||
| 564 | not_req_its_paths.append(['/', 'images', image]) | ||
| 565 | |||
| 566 | return (req_its_paths, not_req_its_paths) | ||
| 545 | 567 | ||
| 546 | def _get_req_its_fields(self, bb_vars): | 568 | def _get_req_its_fields(self, bb_vars): | 
| 547 | initramfs_image = bb_vars['INITRAMFS_IMAGE'] | 569 | initramfs_image = bb_vars['INITRAMFS_IMAGE'] | 
| @@ -572,10 +594,23 @@ class KernelFitImageBase(FitImageTestCase): | |||
| 572 | fit_conf_prefix = bb_vars.get('FIT_CONF_PREFIX', "conf-") | 594 | fit_conf_prefix = bb_vars.get('FIT_CONF_PREFIX', "conf-") | 
| 573 | its_field_check.append('default = "' + fit_conf_prefix + fit_conf_default_dtb + '";') | 595 | its_field_check.append('default = "' + fit_conf_prefix + fit_conf_default_dtb + '";') | 
| 574 | 596 | ||
| 575 | its_field_check.append('kernel = "kernel-1";') | 597 | # configuration nodes (one per DTB and also one per symlink) | 
| 598 | dtb_files, dtb_symlinks = FitImageTestCase._get_dtb_files(bb_vars) | ||
| 599 | if dtb_files: | ||
| 600 | for dtb in dtb_files: | ||
| 601 | its_field_check.append('kernel = "kernel-1";') | ||
| 602 | its_field_check.append('fdt = "fdt-%s";' % dtb) | ||
| 603 | for dtb in dtb_symlinks: | ||
| 604 | its_field_check.append('kernel = "kernel-1";') | ||
| 605 | # Works only for tests were the symlink is with -alias suffix | ||
| 606 | its_field_check.append('fdt = "fdt-%s";' % dtb.replace('-alias', '')) | ||
| 576 | 607 | ||
| 577 | if initramfs_image and initramfs_image_bundle != "1": | 608 | if initramfs_image and initramfs_image_bundle != "1": | 
| 578 | its_field_check.append('ramdisk = "ramdisk-1";') | 609 | its_field_check.append('ramdisk = "ramdisk-1";') | 
| 610 | else: | ||
| 611 | its_field_check.append('kernel = "kernel-1";') | ||
| 612 | if initramfs_image and initramfs_image_bundle != "1": | ||
| 613 | its_field_check.append('ramdisk = "ramdisk-1";') | ||
| 579 | 614 | ||
| 580 | return its_field_check | 615 | return its_field_check | 
| 581 | 616 | ||
| @@ -1032,20 +1067,21 @@ class FitImagePyTests(KernelFitImageBase): | |||
| 1032 | # Provide variables without calling bitbake | 1067 | # Provide variables without calling bitbake | 
| 1033 | bb_vars = { | 1068 | bb_vars = { | 
| 1034 | # image-fitimage.conf | 1069 | # image-fitimage.conf | 
| 1070 | 'FIT_ADDRESS_CELLS': "1", | ||
| 1071 | 'FIT_CONF_DEFAULT_DTB': "", | ||
| 1072 | 'FIT_CONF_PREFIX': "conf-", | ||
| 1035 | 'FIT_DESC': "Kernel fitImage for a dummy distro", | 1073 | 'FIT_DESC': "Kernel fitImage for a dummy distro", | 
| 1036 | 'FIT_HASH_ALG': "sha256", | ||
| 1037 | 'FIT_SIGN_ALG': "rsa2048", | ||
| 1038 | 'FIT_PAD_ALG': "pkcs-1.5", | ||
| 1039 | 'FIT_GENERATE_KEYS': "0", | 1074 | 'FIT_GENERATE_KEYS': "0", | 
| 1040 | 'FIT_SIGN_NUMBITS': "2048", | 1075 | 'FIT_HASH_ALG': "sha256", | 
| 1041 | 'FIT_KEY_GENRSA_ARGS': "-F4", | 1076 | 'FIT_KEY_GENRSA_ARGS': "-F4", | 
| 1042 | 'FIT_KEY_REQ_ARGS': "-batch -new", | 1077 | 'FIT_KEY_REQ_ARGS': "-batch -new", | 
| 1043 | 'FIT_KEY_SIGN_PKCS': "-x509", | 1078 | 'FIT_KEY_SIGN_PKCS': "-x509", | 
| 1079 | 'FIT_LINUX_BIN': "linux.bin", | ||
| 1080 | 'FIT_PAD_ALG': "pkcs-1.5", | ||
| 1081 | 'FIT_SIGN_ALG': "rsa2048", | ||
| 1044 | 'FIT_SIGN_INDIVIDUAL': "0", | 1082 | 'FIT_SIGN_INDIVIDUAL': "0", | 
| 1045 | 'FIT_CONF_PREFIX': "conf-", | 1083 | 'FIT_SIGN_NUMBITS': "2048", | 
| 1046 | 'FIT_SUPPORTED_INITRAMFS_FSTYPES': "cpio.lz4 cpio.lzo cpio.lzma cpio.xz cpio.zst cpio.gz ext2.gz cpio", | 1084 | 'FIT_SUPPORTED_INITRAMFS_FSTYPES': "cpio.lz4 cpio.lzo cpio.lzma cpio.xz cpio.zst cpio.gz ext2.gz cpio", | 
| 1047 | 'FIT_CONF_DEFAULT_DTB': "", | ||
| 1048 | 'FIT_ADDRESS_CELLS': "1", | ||
| 1049 | 'FIT_UBOOT_ENV': "", | 1085 | 'FIT_UBOOT_ENV': "", | 
| 1050 | # kernel.bbclass | 1086 | # kernel.bbclass | 
| 1051 | 'UBOOT_ENTRYPOINT': "0x20008000", | 1087 | 'UBOOT_ENTRYPOINT': "0x20008000", | 
| @@ -1072,6 +1108,9 @@ class FitImagePyTests(KernelFitImageBase): | |||
| 1072 | } | 1108 | } | 
| 1073 | if bb_vars_overrides: | 1109 | if bb_vars_overrides: | 
| 1074 | bb_vars.update(bb_vars_overrides) | 1110 | bb_vars.update(bb_vars_overrides) | 
| 1111 | if logging.DEBUG >= self.logger.level: | ||
| 1112 | debug_output = "\n".join([f"{key} = {value}" for key, value in bb_vars_overrides.items()]) | ||
| 1113 | self.logger.debug("bb_vars overrides:\n%s" % debug_output) | ||
| 1075 | 1114 | ||
| 1076 | root_node = oe.fitimage.ItsNodeRootKernel( | 1115 | root_node = oe.fitimage.ItsNodeRootKernel( | 
| 1077 | bb_vars["FIT_DESC"], bb_vars["FIT_ADDRESS_CELLS"], | 1116 | bb_vars["FIT_DESC"], bb_vars["FIT_ADDRESS_CELLS"], | 
| @@ -1204,7 +1243,7 @@ class UBootFitImageTests(FitImageTestCase): | |||
| 1204 | req_its_paths.append(['/', 'images', image, 'signature']) | 1243 | req_its_paths.append(['/', 'images', image, 'signature']) | 
| 1205 | for configuration in configurations: | 1244 | for configuration in configurations: | 
| 1206 | req_its_paths.append(['/', 'configurations', configuration]) | 1245 | req_its_paths.append(['/', 'configurations', configuration]) | 
| 1207 | return req_its_paths | 1246 | return (req_its_paths, []) | 
| 1208 | 1247 | ||
| 1209 | def _get_req_its_fields(self, bb_vars): | 1248 | def _get_req_its_fields(self, bb_vars): | 
| 1210 | loadables = ["uboot"] | 1249 | loadables = ["uboot"] | 
| @@ -1730,4 +1769,3 @@ UBOOT_FIT_GENERATE_KEYS = "1" | |||
| 1730 | self.write_config(config) | 1769 | self.write_config(config) | 
| 1731 | bb_vars = self._fit_get_bb_vars() | 1770 | bb_vars = self._fit_get_bb_vars() | 
| 1732 | self._test_fitimage(bb_vars) | 1771 | self._test_fitimage(bb_vars) | 
| 1733 | |||
