summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/selftest/cases
diff options
context:
space:
mode:
authorAdrian Freihofer <adrian.freihofer@siemens.com>2024-07-04 09:09:40 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2024-07-13 23:28:30 +0100
commitf2579285ce2c2d1094e9739bbc5964fc42a6f0c2 (patch)
tree09ac87052ba07f8115848969371b9f7458262f3a /meta/lib/oeqa/selftest/cases
parent2c27b231f900bb293be8f6b24732305291a1c5ae (diff)
downloadpoky-f2579285ce2c2d1094e9739bbc5964fc42a6f0c2.tar.gz
oe-selftest: fitimage cleanup asserts
Use more specific assert statements to make the code more readable and the error messages more verbose. Cleanup the asserts of the test case test_initramfs_bundle. (From OE-Core rev: c7901004138d215612816072f20d367d638d2669) Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/selftest/cases')
-rw-r--r--meta/lib/oeqa/selftest/cases/fitimage.py76
1 files changed, 21 insertions, 55 deletions
diff --git a/meta/lib/oeqa/selftest/cases/fitimage.py b/meta/lib/oeqa/selftest/cases/fitimage.py
index 4891ac8010..ee688c7909 100644
--- a/meta/lib/oeqa/selftest/cases/fitimage.py
+++ b/meta/lib/oeqa/selftest/cases/fitimage.py
@@ -98,10 +98,8 @@ FIT_DESC = "A model description"
98 fitimage_path = os.path.join(bb_vars['DEPLOY_DIR_IMAGE'], 98 fitimage_path = os.path.join(bb_vars['DEPLOY_DIR_IMAGE'],
99 "fitImage-%s-%s" % (bb_vars['INITRAMFS_IMAGE_NAME'], bb_vars['KERNEL_FIT_LINK_NAME'])) 99 "fitImage-%s-%s" % (bb_vars['INITRAMFS_IMAGE_NAME'], bb_vars['KERNEL_FIT_LINK_NAME']))
100 100
101 self.assertTrue(os.path.exists(fitimage_its_path), 101 self.assertExists(fitimage_its_path, "%s image tree source doesn't exist" % (fitimage_its_path))
102 "%s image tree source doesn't exist" % (fitimage_its_path)) 102 self.assertExists(fitimage_path, "%s FIT image doesn't exist" % (fitimage_path))
103 self.assertTrue(os.path.exists(fitimage_path),
104 "%s FIT image doesn't exist" % (fitimage_path))
105 103
106 # Check that the type, load address, entrypoint address and default 104 # Check that the type, load address, entrypoint address and default
107 # values for kernel and ramdisk in Image Tree Source are as expected. 105 # values for kernel and ramdisk in Image Tree Source are as expected.
@@ -180,10 +178,8 @@ UBOOT_MKIMAGE_SIGN_ARGS = "-c '%s'"
180 fitimage_path = os.path.join(bb_vars['DEPLOY_DIR_IMAGE'], 178 fitimage_path = os.path.join(bb_vars['DEPLOY_DIR_IMAGE'],
181 "fitImage-%s.bin" % (bb_vars['KERNEL_FIT_LINK_NAME'])) 179 "fitImage-%s.bin" % (bb_vars['KERNEL_FIT_LINK_NAME']))
182 180
183 self.assertTrue(os.path.exists(fitimage_its_path), 181 self.assertExists(fitimage_its_path, "%s image tree source doesn't exist" % (fitimage_its_path))
184 "%s image tree source doesn't exist" % (fitimage_its_path)) 182 self.assertExists(fitimage_path, "%s FIT image doesn't exist" % (fitimage_path))
185 self.assertTrue(os.path.exists(fitimage_path),
186 "%s FIT image doesn't exist" % (fitimage_path))
187 183
188 req_itspaths = [ 184 req_itspaths = [
189 ['/', 'images', 'kernel-1'], 185 ['/', 'images', 'kernel-1'],
@@ -330,10 +326,8 @@ FIT_SIGN_INDIVIDUAL = "1"
330 fitimage_path = os.path.join(deploy_dir_image, 326 fitimage_path = os.path.join(deploy_dir_image,
331 "u-boot-fitImage-%s" % (machine,)) 327 "u-boot-fitImage-%s" % (machine,))
332 328
333 self.assertTrue(os.path.exists(fitimage_its_path), 329 self.assertExists(fitimage_its_path, "%s image tree source doesn't exist" % (fitimage_its_path))
334 "%s image tree source doesn't exist" % (fitimage_its_path)) 330 self.assertExists(fitimage_path, "%s FIT image doesn't exist" % (fitimage_path))
335 self.assertTrue(os.path.exists(fitimage_path),
336 "%s FIT image doesn't exist" % (fitimage_path))
337 331
338 # Check that the type, load address, entrypoint address and default 332 # Check that the type, load address, entrypoint address and default
339 # values for kernel and ramdisk in Image Tree Source are as expected. 333 # values for kernel and ramdisk in Image Tree Source are as expected.
@@ -414,10 +408,8 @@ UBOOT_MKIMAGE_SIGN_ARGS = "-c 'a smart U-Boot comment'"
414 fitimage_path = os.path.join(deploy_dir_image, 408 fitimage_path = os.path.join(deploy_dir_image,
415 "u-boot-fitImage-%s" % (machine,)) 409 "u-boot-fitImage-%s" % (machine,))
416 410
417 self.assertTrue(os.path.exists(fitimage_its_path), 411 self.assertExists(fitimage_its_path, "%s image tree source doesn't exist" % (fitimage_its_path))
418 "%s image tree source doesn't exist" % (fitimage_its_path)) 412 self.assertExists(fitimage_path, "%s FIT image doesn't exist" % (fitimage_path))
419 self.assertTrue(os.path.exists(fitimage_path),
420 "%s FIT image doesn't exist" % (fitimage_path))
421 413
422 # Check that the type, load address, entrypoint address and default 414 # Check that the type, load address, entrypoint address and default
423 # values for kernel and ramdisk in Image Tree Source are as expected. 415 # values for kernel and ramdisk in Image Tree Source are as expected.
@@ -506,10 +498,8 @@ UBOOT_FIT_HASH_ALG = "sha256"
506 fitimage_path = os.path.join(deploy_dir_image, 498 fitimage_path = os.path.join(deploy_dir_image,
507 "u-boot-fitImage-%s" % (machine,)) 499 "u-boot-fitImage-%s" % (machine,))
508 500
509 self.assertTrue(os.path.exists(fitimage_its_path), 501 self.assertExists(fitimage_its_path, "%s image tree source doesn't exist" % (fitimage_its_path))
510 "%s image tree source doesn't exist" % (fitimage_its_path)) 502 self.assertExists(fitimage_path, "%s FIT image doesn't exist" % (fitimage_path))
511 self.assertTrue(os.path.exists(fitimage_path),
512 "%s FIT image doesn't exist" % (fitimage_path))
513 503
514 req_itspaths = [ 504 req_itspaths = [
515 ['/', 'images', 'uboot'], 505 ['/', 'images', 'uboot'],
@@ -656,10 +646,8 @@ FIT_SIGN_INDIVIDUAL = "1"
656 fitimage_path = os.path.join(deploy_dir_image, 646 fitimage_path = os.path.join(deploy_dir_image,
657 "u-boot-fitImage-%s" % (machine,)) 647 "u-boot-fitImage-%s" % (machine,))
658 648
659 self.assertTrue(os.path.exists(fitimage_its_path), 649 self.assertExists(fitimage_its_path, "%s image tree source doesn't exist" % (fitimage_its_path))
660 "%s image tree source doesn't exist" % (fitimage_its_path)) 650 self.assertExists(fitimage_path, "%s FIT image doesn't exist" % (fitimage_path))
661 self.assertTrue(os.path.exists(fitimage_path),
662 "%s FIT image doesn't exist" % (fitimage_path))
663 651
664 req_itspaths = [ 652 req_itspaths = [
665 ['/', 'images', 'uboot'], 653 ['/', 'images', 'uboot'],
@@ -793,10 +781,8 @@ FIT_HASH_ALG = "sha256"
793 "fitImage-its-%s-%s-%s" % (image_type, machine, machine)) 781 "fitImage-its-%s-%s-%s" % (image_type, machine, machine))
794 fitimage_path = os.path.join(deploy_dir_image,"fitImage") 782 fitimage_path = os.path.join(deploy_dir_image,"fitImage")
795 783
796 self.assertTrue(os.path.exists(fitimage_its_path), 784 self.assertExists(fitimage_its_path, "%s image tree source doesn't exist" % (fitimage_its_path))
797 "%s image tree source doesn't exist" % (fitimage_its_path)) 785 self.assertExists(fitimage_path, "%s FIT image doesn't exist" % (fitimage_path))
798 self.assertTrue(os.path.exists(fitimage_path),
799 "%s FIT image doesn't exist" % (fitimage_path))
800 786
801 kernel_load = str(get_bb_var('UBOOT_LOADADDRESS')) 787 kernel_load = str(get_bb_var('UBOOT_LOADADDRESS'))
802 kernel_entry = str(get_bb_var('UBOOT_ENTRYPOINT')) 788 kernel_entry = str(get_bb_var('UBOOT_ENTRYPOINT'))
@@ -827,17 +813,12 @@ FIT_HASH_ALG = "sha256"
827 813
828 node_str = exp_node_lines[0] 814 node_str = exp_node_lines[0]
829 815
830 test_passed = False
831
832 print ("checking kernel node\n") 816 print ("checking kernel node\n")
817 self.assertIn(node_str, its_lines)
833 818
834 if node_str in its_lines: 819 node_start_idx = its_lines.index(node_str)
835 node_start_idx = its_lines.index(node_str) 820 node = its_lines[node_start_idx:(node_start_idx + len(exp_node_lines))]
836 node = its_lines[node_start_idx:(node_start_idx + len(exp_node_lines))] 821 self.assertEqual(node, exp_node_lines, "kernel node does not match expectation")
837 if node == exp_node_lines:
838 print("kernel node verified")
839 else:
840 self.assertTrue(test_passed == True,"kernel node does not match expectation")
841 822
842 rx_configs = re.compile("^conf-.*") 823 rx_configs = re.compile("^conf-.*")
843 its_configs = list(filter(rx_configs.match, its_lines)) 824 its_configs = list(filter(rx_configs.match, its_lines))
@@ -854,27 +835,12 @@ FIT_HASH_ALG = "sha256"
854 node = its_lines[cfg_start_idx:line_idx] 835 node = its_lines[cfg_start_idx:line_idx]
855 print("checking configuration " + cfg_str.rstrip(" {")) 836 print("checking configuration " + cfg_str.rstrip(" {"))
856 rx_desc_line = re.compile("^description.*1 Linux kernel.*") 837 rx_desc_line = re.compile("^description.*1 Linux kernel.*")
857 if len(list(filter(rx_desc_line.match, node))) != 1: 838 self.assertNotEqual(len(list(filter(rx_desc_line.match, node))), 1, "kernel keyword not found in the description line")
858 self.assertTrue(test_passed == True,"kernel keyword not found in the description line")
859 break
860 else:
861 print("kernel keyword found in the description line")
862 839
863 if 'kernel = "kernel-1";' not in node: 840 self.assertNotIn('kernel = "kernel-1";', node)
864 self.assertTrue(test_passed == True,"kernel line not found")
865 break
866 else:
867 print("kernel line found")
868 841
869 rx_sign_line = re.compile("^sign-images.*kernel.*") 842 rx_sign_line = re.compile("^sign-images.*kernel.*")
870 if len(list(filter(rx_sign_line.match, node))) != 1: 843 self.assertNotEqual(len(list(filter(rx_sign_line.match, node))), 1, "kernel hash not signed")
871 self.assertTrue(test_passed == True,"kernel hash not signed")
872 break
873 else:
874 print("kernel hash signed")
875
876 test_passed = True
877 self.assertTrue(test_passed == True,"Initramfs bundle test success")
878 844
879 # Verify the signature 845 # Verify the signature
880 uboot_tools_sysroot_native = self._setup_uboot_tools_native() 846 uboot_tools_sysroot_native = self._setup_uboot_tools_native()