diff options
Diffstat (limited to 'meta')
| -rw-r--r-- | meta/lib/oeqa/selftest/cases/fitimage.py | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/meta/lib/oeqa/selftest/cases/fitimage.py b/meta/lib/oeqa/selftest/cases/fitimage.py index a0ec406a0e..5a400c200f 100644 --- a/meta/lib/oeqa/selftest/cases/fitimage.py +++ b/meta/lib/oeqa/selftest/cases/fitimage.py | |||
| @@ -60,6 +60,32 @@ class FitImageTests(OESelftestTestCase): | |||
| 60 | byte = file.read(1) | 60 | byte = file.read(1) |
| 61 | return found_positions | 61 | return found_positions |
| 62 | 62 | ||
| 63 | def _config_add_uboot_env(self, config): | ||
| 64 | """Generate an u-boot environment | ||
| 65 | |||
| 66 | Create a boot.cmd file that is packed into the FitImage as a source-able text file. | ||
| 67 | """ | ||
| 68 | fit_uenv_file = "boot.cmd" | ||
| 69 | test_files_dir = "test-files" | ||
| 70 | fit_uenv_path = os.path.join(self.builddir, test_files_dir, fit_uenv_file) | ||
| 71 | |||
| 72 | config += '# Add an u-boot script to the fitImage' + os.linesep | ||
| 73 | config += 'FIT_UBOOT_ENV = "%s"' % fit_uenv_file + os.linesep | ||
| 74 | config += 'FILESEXTRAPATHS:prepend := "${TOPDIR}/%s:"' % test_files_dir + os.linesep | ||
| 75 | config += 'SRC_URI:append:pn-linux-yocto = " file://${FIT_UBOOT_ENV}"' + os.linesep | ||
| 76 | |||
| 77 | if not os.path.isdir(test_files_dir): | ||
| 78 | os.mkdir(test_files_dir) | ||
| 79 | self.logger.debug("Writing to: %s" % fit_uenv_path) | ||
| 80 | with open(fit_uenv_path, "w") as f: | ||
| 81 | f.write('echo "hello world"') | ||
| 82 | |||
| 83 | return config | ||
| 84 | |||
| 85 | def _verify_fitimage_uboot_env(self, dumpimage_result): | ||
| 86 | """Check if the boot.cmd script is part of the fitImage""" | ||
| 87 | num_scr_images = len(re.findall(r"^ *Image +[0-9]+ +\(bootscr-boot\.cmd\)$", dumpimage_result.output, re.MULTILINE)) | ||
| 88 | self.assertEqual(1, num_scr_images, msg="Expected exactly 1 bootscr-boot.cmd image section in the fitImage") | ||
| 63 | 89 | ||
| 64 | def test_fit_image(self): | 90 | def test_fit_image(self): |
| 65 | """ | 91 | """ |
| @@ -91,6 +117,7 @@ UBOOT_LOADADDRESS = "0x80080000" | |||
| 91 | UBOOT_ENTRYPOINT = "0x80080000" | 117 | UBOOT_ENTRYPOINT = "0x80080000" |
| 92 | FIT_DESC = "A model description" | 118 | FIT_DESC = "A model description" |
| 93 | """ | 119 | """ |
| 120 | config = self._config_add_uboot_env(config) | ||
| 94 | self.write_config(config) | 121 | self.write_config(config) |
| 95 | 122 | ||
| 96 | # fitImage is created as part of linux recipe | 123 | # fitImage is created as part of linux recipe |
| @@ -137,6 +164,10 @@ FIT_DESC = "A model description" | |||
| 137 | "Fields in Image Tree Source File %s did not match, error in finding %s" | 164 | "Fields in Image Tree Source File %s did not match, error in finding %s" |
| 138 | % (fitimage_its_path, its_field_check[field_index])) | 165 | % (fitimage_its_path, its_field_check[field_index])) |
| 139 | 166 | ||
| 167 | uboot_tools_bindir = self._setup_uboot_tools_native() | ||
| 168 | dumpimage_result = self._run_dumpimage(fitimage_path, uboot_tools_bindir) | ||
| 169 | self._verify_fitimage_uboot_env(dumpimage_result) | ||
| 170 | |||
| 140 | 171 | ||
| 141 | def test_sign_fit_image(self): | 172 | def test_sign_fit_image(self): |
| 142 | """ | 173 | """ |
| @@ -171,6 +202,7 @@ FIT_SIGN_INDIVIDUAL = "1" | |||
| 171 | UBOOT_MKIMAGE_SIGN_ARGS = "-c '%s'" | 202 | UBOOT_MKIMAGE_SIGN_ARGS = "-c '%s'" |
| 172 | """ % a_comment | 203 | """ % a_comment |
| 173 | 204 | ||
| 205 | config = self._config_add_uboot_env(config) | ||
| 174 | self.write_config(config) | 206 | self.write_config(config) |
| 175 | 207 | ||
| 176 | # fitImage is created as part of linux recipe | 208 | # fitImage is created as part of linux recipe |
| @@ -228,7 +260,7 @@ UBOOT_MKIMAGE_SIGN_ARGS = "-c '%s'" | |||
| 228 | reqsigvalues_config = { | 260 | reqsigvalues_config = { |
| 229 | 'algo': '"sha256,rsa2048"', | 261 | 'algo': '"sha256,rsa2048"', |
| 230 | 'key-name-hint': '"cfg-oe-selftest"', | 262 | 'key-name-hint': '"cfg-oe-selftest"', |
| 231 | 'sign-images': '"kernel", "fdt"', | 263 | 'sign-images': '"kernel", "fdt", "bootscr"', |
| 232 | } | 264 | } |
| 233 | 265 | ||
| 234 | for itspath, values in sigs.items(): | 266 | for itspath, values in sigs.items(): |
| @@ -269,10 +301,13 @@ UBOOT_MKIMAGE_SIGN_ARGS = "-c '%s'" | |||
| 269 | value = values.get('Sign value', None) | 301 | value = values.get('Sign value', None) |
| 270 | self.assertEqual(len(value), 512, 'Signature value for section %s not expected length' % signed_section) | 302 | self.assertEqual(len(value), 512, 'Signature value for section %s not expected length' % signed_section) |
| 271 | 303 | ||
| 304 | # Check if the u-boot boot.scr script is in the fitImage | ||
| 305 | self._verify_fitimage_uboot_env(dumpimage_result) | ||
| 306 | |||
| 272 | # Search for the string passed to mkimage: 1 kernel + 3 DTBs + config per DTB = 7 sections | 307 | # Search for the string passed to mkimage: 1 kernel + 3 DTBs + config per DTB = 7 sections |
| 273 | # Looks like mkimage supports to add a comment but does not support to read it back. | 308 | # Looks like mkimage supports to add a comment but does not support to read it back. |
| 274 | found_comments = FitImageTests._find_string_in_bin_file(fitimage_path, a_comment) | 309 | found_comments = FitImageTests._find_string_in_bin_file(fitimage_path, a_comment) |
| 275 | self.assertEqual(found_comments, 7, "Expected 7 signed and commented section in the fitImage.") | 310 | self.assertEqual(found_comments, 8, "Expected 8 signed and commented section in the fitImage.") |
| 276 | 311 | ||
| 277 | # Verify the signature for all configurations = DTBs | 312 | # Verify the signature for all configurations = DTBs |
| 278 | for dtb in ['am335x-bone.dtb', 'am335x-boneblack.dtb', 'am335x-bonegreen.dtb']: | 313 | for dtb in ['am335x-bone.dtb', 'am335x-boneblack.dtb', 'am335x-bonegreen.dtb']: |
| @@ -771,6 +806,7 @@ KERNEL_IMAGETYPE_REPLACEMENT = "zImage" | |||
| 771 | FIT_KERNEL_COMP_ALG = "none" | 806 | FIT_KERNEL_COMP_ALG = "none" |
| 772 | FIT_HASH_ALG = "sha256" | 807 | FIT_HASH_ALG = "sha256" |
| 773 | """ | 808 | """ |
| 809 | config = self._config_add_uboot_env(config) | ||
| 774 | self.write_config(config) | 810 | self.write_config(config) |
| 775 | 811 | ||
| 776 | # fitImage is created as part of linux recipe | 812 | # fitImage is created as part of linux recipe |
| @@ -854,3 +890,7 @@ FIT_HASH_ALG = "sha256" | |||
| 854 | # Verify the signature | 890 | # Verify the signature |
| 855 | uboot_tools_bindir = self._setup_uboot_tools_native() | 891 | uboot_tools_bindir = self._setup_uboot_tools_native() |
| 856 | self._verify_fit_image_signature(uboot_tools_bindir, fitimage_path, os.path.join(bb_vars['DEPLOY_DIR_IMAGE'], 'am335x-bone.dtb')) | 892 | self._verify_fit_image_signature(uboot_tools_bindir, fitimage_path, os.path.join(bb_vars['DEPLOY_DIR_IMAGE'], 'am335x-bone.dtb')) |
| 893 | |||
| 894 | # Check if the u-boot boot.scr script is in the fitImage | ||
| 895 | dumpimage_result = self._run_dumpimage(fitimage_path, uboot_tools_bindir) | ||
| 896 | self._verify_fitimage_uboot_env(dumpimage_result) | ||
