diff options
author | Adrian Freihofer <adrian.freihofer@siemens.com> | 2024-07-04 09:09:41 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2024-07-13 23:28:30 +0100 |
commit | a285dac7bc99f2ad4a8ff3debcdd0d48d4fc22f8 (patch) | |
tree | 64d69afcb79e8a82e00feb1a5767d450cc6007b3 /meta/lib | |
parent | f2579285ce2c2d1094e9739bbc5964fc42a6f0c2 (diff) | |
download | poky-a285dac7bc99f2ad4a8ff3debcdd0d48d4fc22f8.tar.gz |
oe-selftest: fitimage fix test_initramfs_bundle
It looks like most of the assertions of this tests were by-passed
because of combinations of invalid regexes and inverted assert
statement. Try to fix.
Use the variables from the kernel recipe instead of potentially invalid
values from get_bb_vars with undefined recipe. Use one get_bb_vars
statement instead of many seaparate calls mainly to improve the duration
of this test case.
Make the test working for an its file with an absolute path to the
kernel binary. This will be needed with one of the following commits and
does not harm in general.
(From OE-Core rev: 741f0cfa4f0025a2823581cab09e0bf14382e54d)
Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib')
-rw-r--r-- | meta/lib/oeqa/selftest/cases/fitimage.py | 57 |
1 files changed, 32 insertions, 25 deletions
diff --git a/meta/lib/oeqa/selftest/cases/fitimage.py b/meta/lib/oeqa/selftest/cases/fitimage.py index ee688c7909..0b5f4602fb 100644 --- a/meta/lib/oeqa/selftest/cases/fitimage.py +++ b/meta/lib/oeqa/selftest/cases/fitimage.py | |||
@@ -774,23 +774,25 @@ FIT_HASH_ALG = "sha256" | |||
774 | # fitImage is created as part of linux recipe | 774 | # fitImage is created as part of linux recipe |
775 | bitbake("virtual/kernel") | 775 | bitbake("virtual/kernel") |
776 | 776 | ||
777 | image_type = get_bb_var('INITRAMFS_IMAGE') | 777 | bb_vars = get_bb_vars([ |
778 | deploy_dir_image = get_bb_var('DEPLOY_DIR_IMAGE') | 778 | 'DEPLOY_DIR_IMAGE', |
779 | machine = get_bb_var('MACHINE') | 779 | 'FIT_HASH_ALG', |
780 | fitimage_its_path = os.path.join(deploy_dir_image, | 780 | 'FIT_KERNEL_COMP_ALG', |
781 | "fitImage-its-%s-%s-%s" % (image_type, machine, machine)) | 781 | 'INITRAMFS_IMAGE', |
782 | fitimage_path = os.path.join(deploy_dir_image,"fitImage") | 782 | 'MACHINE', |
783 | 'UBOOT_ARCH', | ||
784 | 'UBOOT_ENTRYPOINT', | ||
785 | 'UBOOT_LOADADDRESS', | ||
786 | 'UBOOT_MKIMAGE_KERNEL_TYPE' | ||
787 | ], | ||
788 | 'virtual/kernel') | ||
789 | fitimage_its_path = os.path.join(bb_vars['DEPLOY_DIR_IMAGE'], | ||
790 | "fitImage-its-%s-%s-%s" % (bb_vars['INITRAMFS_IMAGE'], bb_vars['MACHINE'], bb_vars['MACHINE'])) | ||
791 | fitimage_path = os.path.join(bb_vars['DEPLOY_DIR_IMAGE'],"fitImage") | ||
783 | 792 | ||
784 | self.assertExists(fitimage_its_path, "%s image tree source doesn't exist" % (fitimage_its_path)) | 793 | self.assertExists(fitimage_its_path, "%s image tree source doesn't exist" % (fitimage_its_path)) |
785 | self.assertExists(fitimage_path, "%s FIT image doesn't exist" % (fitimage_path)) | 794 | self.assertExists(fitimage_path, "%s FIT image doesn't exist" % (fitimage_path)) |
786 | 795 | ||
787 | kernel_load = str(get_bb_var('UBOOT_LOADADDRESS')) | ||
788 | kernel_entry = str(get_bb_var('UBOOT_ENTRYPOINT')) | ||
789 | kernel_type = str(get_bb_var('UBOOT_MKIMAGE_KERNEL_TYPE')) | ||
790 | kernel_compression = str(get_bb_var('FIT_KERNEL_COMP_ALG')) | ||
791 | uboot_arch = str(get_bb_var('UBOOT_ARCH')) | ||
792 | fit_hash_alg = str(get_bb_var('FIT_HASH_ALG')) | ||
793 | |||
794 | its_file = open(fitimage_its_path) | 796 | its_file = open(fitimage_its_path) |
795 | 797 | ||
796 | its_lines = [line.strip() for line in its_file.readlines()] | 798 | its_lines = [line.strip() for line in its_file.readlines()] |
@@ -799,14 +801,14 @@ FIT_HASH_ALG = "sha256" | |||
799 | 'kernel-1 {', | 801 | 'kernel-1 {', |
800 | 'description = "Linux kernel";', | 802 | 'description = "Linux kernel";', |
801 | 'data = /incbin/("linux.bin");', | 803 | 'data = /incbin/("linux.bin");', |
802 | 'type = "' + kernel_type + '";', | 804 | 'type = "' + str(bb_vars['UBOOT_MKIMAGE_KERNEL_TYPE']) + '";', |
803 | 'arch = "' + uboot_arch + '";', | 805 | 'arch = "' + str(bb_vars['UBOOT_ARCH']) + '";', |
804 | 'os = "linux";', | 806 | 'os = "linux";', |
805 | 'compression = "' + kernel_compression + '";', | 807 | 'compression = "' + str(bb_vars['FIT_KERNEL_COMP_ALG']) + '";', |
806 | 'load = <' + kernel_load + '>;', | 808 | 'load = <' + str(bb_vars['UBOOT_LOADADDRESS']) + '>;', |
807 | 'entry = <' + kernel_entry + '>;', | 809 | 'entry = <' + str(bb_vars['UBOOT_ENTRYPOINT']) + '>;', |
808 | 'hash-1 {', | 810 | 'hash-1 {', |
809 | 'algo = "' + fit_hash_alg +'";', | 811 | 'algo = "' + str(bb_vars['FIT_HASH_ALG']) +'";', |
810 | '};', | 812 | '};', |
811 | '};' | 813 | '};' |
812 | ] | 814 | ] |
@@ -818,6 +820,11 @@ FIT_HASH_ALG = "sha256" | |||
818 | 820 | ||
819 | node_start_idx = its_lines.index(node_str) | 821 | node_start_idx = its_lines.index(node_str) |
820 | node = its_lines[node_start_idx:(node_start_idx + len(exp_node_lines))] | 822 | node = its_lines[node_start_idx:(node_start_idx + len(exp_node_lines))] |
823 | |||
824 | # Remove the absolute path. This refers to WORKDIR which is not always predictable. | ||
825 | re_data = re.compile(r'^data = /incbin/\(.*/linux\.bin"\);$') | ||
826 | node = [re.sub(re_data, 'data = /incbin/("linux.bin");', cfg_str) for cfg_str in node] | ||
827 | |||
821 | self.assertEqual(node, exp_node_lines, "kernel node does not match expectation") | 828 | self.assertEqual(node, exp_node_lines, "kernel node does not match expectation") |
822 | 829 | ||
823 | rx_configs = re.compile("^conf-.*") | 830 | rx_configs = re.compile("^conf-.*") |
@@ -834,14 +841,14 @@ FIT_HASH_ALG = "sha256" | |||
834 | 841 | ||
835 | node = its_lines[cfg_start_idx:line_idx] | 842 | node = its_lines[cfg_start_idx:line_idx] |
836 | print("checking configuration " + cfg_str.rstrip(" {")) | 843 | print("checking configuration " + cfg_str.rstrip(" {")) |
837 | rx_desc_line = re.compile("^description.*1 Linux kernel.*") | 844 | rx_desc_line = re.compile(r'^description = ".*Linux kernel.*') |
838 | self.assertNotEqual(len(list(filter(rx_desc_line.match, node))), 1, "kernel keyword not found in the description line") | 845 | self.assertEqual(len(list(filter(rx_desc_line.match, node))), 1, "kernel keyword not found in the description line") |
839 | 846 | ||
840 | self.assertNotIn('kernel = "kernel-1";', node) | 847 | self.assertIn('kernel = "kernel-1";', node) |
841 | 848 | ||
842 | rx_sign_line = re.compile("^sign-images.*kernel.*") | 849 | rx_sign_line = re.compile(r'^sign-images = .*kernel.*') |
843 | self.assertNotEqual(len(list(filter(rx_sign_line.match, node))), 1, "kernel hash not signed") | 850 | self.assertEqual(len(list(filter(rx_sign_line.match, node))), 1, "kernel hash not signed") |
844 | 851 | ||
845 | # Verify the signature | 852 | # Verify the signature |
846 | uboot_tools_sysroot_native = self._setup_uboot_tools_native() | 853 | uboot_tools_sysroot_native = self._setup_uboot_tools_native() |
847 | self._verify_fit_image_signature(uboot_tools_sysroot_native, fitimage_path, os.path.join(deploy_dir_image, 'am335x-bone.dtb')) | 854 | self._verify_fit_image_signature(uboot_tools_sysroot_native, fitimage_path, os.path.join(bb_vars['DEPLOY_DIR_IMAGE'], 'am335x-bone.dtb')) |