diff options
Diffstat (limited to 'meta/lib/oeqa/selftest/cases/fitimage.py')
-rw-r--r-- | meta/lib/oeqa/selftest/cases/fitimage.py | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/meta/lib/oeqa/selftest/cases/fitimage.py b/meta/lib/oeqa/selftest/cases/fitimage.py new file mode 100644 index 0000000000..2c3803d5be --- /dev/null +++ b/meta/lib/oeqa/selftest/cases/fitimage.py | |||
@@ -0,0 +1,84 @@ | |||
1 | # | ||
2 | # SPDX-License-Identifier: MIT | ||
3 | # | ||
4 | |||
5 | from oeqa.selftest.case import OESelftestTestCase | ||
6 | from oeqa.utils.commands import runCmd, bitbake, get_bb_var, runqemu | ||
7 | import os | ||
8 | import json | ||
9 | |||
10 | class FitImageTests(OESelftestTestCase): | ||
11 | |||
12 | def test_fit_image(self): | ||
13 | """ | ||
14 | Summary: Check if FIT image and Image Tree Source (its) are built | ||
15 | and the Image Tree Source has the correct fields. | ||
16 | Expected: 1. fitImage and fitImage-its can be built | ||
17 | 2. The type, load address, entrypoint address and | ||
18 | default values of kernel and ramdisk are as expected | ||
19 | in the Image Tree Source. Not all the fields are tested, | ||
20 | only the key fields that wont vary between different | ||
21 | architectures. | ||
22 | Product: oe-core | ||
23 | Author: Usama Arif <usama.arif@arm.com> | ||
24 | """ | ||
25 | config = """ | ||
26 | # Enable creation of fitImage | ||
27 | KERNEL_IMAGETYPE = "Image" | ||
28 | KERNEL_IMAGETYPES += " fitImage " | ||
29 | KERNEL_CLASSES = " kernel-fitimage " | ||
30 | |||
31 | # RAM disk variables including load address and entrypoint for kernel and RAM disk | ||
32 | IMAGE_FSTYPES += "cpio.gz" | ||
33 | INITRAMFS_IMAGE = "core-image-minimal" | ||
34 | UBOOT_RD_LOADADDRESS = "0x88000000" | ||
35 | UBOOT_RD_ENTRYPOINT = "0x88000000" | ||
36 | UBOOT_LOADADDRESS = "0x80080000" | ||
37 | UBOOT_ENTRYPOINT = "0x80080000" | ||
38 | """ | ||
39 | self.write_config(config) | ||
40 | |||
41 | # fitImage is created as part of linux recipe | ||
42 | bitbake("virtual/kernel") | ||
43 | |||
44 | image_type = "core-image-minimal" | ||
45 | deploy_dir_image = get_bb_var('DEPLOY_DIR_IMAGE') | ||
46 | machine = get_bb_var('MACHINE') | ||
47 | fitimage_its_path = os.path.join(deploy_dir_image, | ||
48 | "fitImage-its-%s-%s-%s" % (image_type, machine, machine)) | ||
49 | fitimage_path = os.path.join(deploy_dir_image, | ||
50 | "fitImage-%s-%s-%s" % (image_type, machine, machine)) | ||
51 | |||
52 | self.assertTrue(os.path.exists(fitimage_its_path), | ||
53 | "%s image tree source doesn't exist" % (fitimage_its_path)) | ||
54 | self.assertTrue(os.path.exists(fitimage_path), | ||
55 | "%s FIT image doesn't exist" % (fitimage_path)) | ||
56 | |||
57 | # Check that the type, load address, entrypoint address and default | ||
58 | # values for kernel and ramdisk in Image Tree Source are as expected. | ||
59 | # The order of fields in the below array is important. Not all the | ||
60 | # fields are tested, only the key fields that wont vary between | ||
61 | # different architectures. | ||
62 | its_field_check = ['type = "kernel";', | ||
63 | 'load = <0x80080000>;', | ||
64 | 'entry = <0x80080000>;', | ||
65 | 'type = "ramdisk";', | ||
66 | 'load = <0x88000000>;', | ||
67 | 'entry = <0x88000000>;', | ||
68 | 'default = "conf@1";', | ||
69 | 'kernel = "kernel@1";', | ||
70 | 'ramdisk = "ramdisk@1";' | ||
71 | ] | ||
72 | |||
73 | with open(fitimage_its_path) as its_file: | ||
74 | field_index = 0 | ||
75 | for line in its_file: | ||
76 | if field_index == len(its_field_check): | ||
77 | break | ||
78 | if its_field_check[field_index] in line: | ||
79 | field_index +=1 | ||
80 | |||
81 | if field_index != len(its_field_check): # if its equal, the test passed | ||
82 | self.assertTrue(field_index == len(its_field_check), | ||
83 | "Fields in Image Tree Source File %s did not match, error in finding %s" | ||
84 | % (fitimage_its_path, its_field_check[field_index])) | ||