All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] oeqa/selftest/imagefeatures: Add testcase for fitImage
@ 2020-07-29 14:41 Usama Arif
  2020-07-29 14:47 ` Usama Arif
  0 siblings, 1 reply; 2+ messages in thread
From: Usama Arif @ 2020-07-29 14:41 UTC (permalink / raw)
  To: openembedded-core; +Cc: nd, Usama Arif, Richard Purdie

This testcase generates the Image Tree Source and
the corresponding fitImage containing a kernel and
a ramdisk. It then checks if the these files exist
and if the right fields are present in the right
order in the Image Tree Source.

Tested with: oe-selftest -r  imagefeatures.ImageFeatures.test_fit_image

Signed-off-by: Usama Arif <usama.arif@arm.com>
Cc: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/lib/oeqa/selftest/cases/imagefeatures.py | 74 +++++++++++++++++++
 1 file changed, 74 insertions(+)

diff --git a/meta/lib/oeqa/selftest/cases/imagefeatures.py b/meta/lib/oeqa/selftest/cases/imagefeatures.py
index dea519e6df..f7a2533746 100644
--- a/meta/lib/oeqa/selftest/cases/imagefeatures.py
+++ b/meta/lib/oeqa/selftest/cases/imagefeatures.py
@@ -263,6 +263,80 @@ PNBLACKLIST[busybox] = "Don't build this"
 
         bitbake("--graphviz core-image-sato")
 
+    def test_fit_image(self):
+        """
+        Summary:     Check if FIT image and Image Tree Source (its) are built
+                     and the Image Tree Source has the correct fields.
+        Expected:    1. fitImage and fitImage-its can be built
+                     2. The type, load address, entrypoint address and
+                     default values of kernel and ramdisk are as expected
+                     in the Image Tree Source. Not all the fields are tested,
+                     only the key fields that wont vary between different
+                     architectures.
+        Product:     oe-core
+        Author:      Usama Arif <usama.arif@arm.com>
+        """
+        config = """
+# Enable creation of fitImage
+KERNEL_IMAGETYPE = "Image"
+KERNEL_IMAGETYPES += " fitImage "
+KERNEL_CLASSES = " kernel-fitimage "
+
+# RAM disk variables including load address and entrypoint for kernel and RAM disk
+IMAGE_FSTYPES += "cpio.gz"
+INITRAMFS_IMAGE = "core-image-minimal"
+UBOOT_RD_LOADADDRESS = "0x88000000"
+UBOOT_RD_ENTRYPOINT = "0x88000000"
+UBOOT_LOADADDRESS = "0x80080000"
+UBOOT_ENTRYPOINT = "0x80080000"
+"""
+        self.write_config(config)
+
+        # fitImage is created as part of linux recipe
+        bitbake("virtual/kernel")
+
+        image_type = "core-image-minimal"
+        deploy_dir_image = get_bb_var('DEPLOY_DIR_IMAGE')
+        machine = get_bb_var('MACHINE')
+        fitimage_its_path = os.path.join(deploy_dir_image,
+            "fitImage-its-%s-%s-%s" % (image_type, machine, machine))
+        fitimage_path = os.path.join(deploy_dir_image,
+            "fitImage-%s-%s-%s" % (image_type, machine, machine))
+
+        self.assertTrue(os.path.exists(fitimage_its_path),
+            "%s image tree source doesn't exist" % (fitimage_its_path))
+        self.assertTrue(os.path.exists(fitimage_path),
+            "%s FIT image doesn't exist" % (fitimage_path))
+
+        # Check that the type, load address, entrypoint address and default
+        # values for kernel and ramdisk in Image Tree Source are as expected.
+        # The order of fields in the below array is important. Not all the
+        # fields are tested, only the key fields that wont vary between
+        # different architectures.
+        its_field_check = ['type = "kernel";',
+            'load = <0x80080000>;',
+            'entry = <0x80080000>;',
+            'type = "ramdisk";',
+            'load = <0x88000000>;',
+            'entry = <0x88000000>;',
+            'default = "conf@1";',
+            'kernel = "kernel@1";',
+            'ramdisk = "ramdisk@1";'
+            ]
+
+        with open(fitimage_its_path) as its_file:
+            field_index = 0
+            for line in its_file:
+                if field_index == len(its_field_check):
+                    break
+                if its_field_check[field_index] in line:
+                    field_index +=1
+
+        if field_index != len(its_field_check): # if its equal, the test passed
+            self.assertTrue(field_index == len(its_field_check),
+                "Fields in Image Tree Source File %s did not match, error in finding %s"
+                % (fitimage_its_path, its_field_check[field_index]))
+
     def test_image_gen_debugfs(self):
         """
         Summary:     Check debugfs generation
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] oeqa/selftest/imagefeatures: Add testcase for fitImage
  2020-07-29 14:41 [PATCH] oeqa/selftest/imagefeatures: Add testcase for fitImage Usama Arif
@ 2020-07-29 14:47 ` Usama Arif
  0 siblings, 0 replies; 2+ messages in thread
From: Usama Arif @ 2020-07-29 14:47 UTC (permalink / raw)
  To: openembedded-core; +Cc: nd, Richard Purdie



On 29/07/2020 15:41, Usama Arif wrote:
> This testcase generates the Image Tree Source and
> the corresponding fitImage containing a kernel and
> a ramdisk. It then checks if the these files exist
> and if the right fields are present in the right
> order in the Image Tree Source.
> 
> Tested with: oe-selftest -r  imagefeatures.ImageFeatures.test_fit_image
> 
> Signed-off-by: Usama Arif <usama.arif@arm.com>
> Cc: Richard Purdie <richard.purdie@linuxfoundation.org>
> ---
>   meta/lib/oeqa/selftest/cases/imagefeatures.py | 74 +++++++++++++++++++
>   1 file changed, 74 insertions(+)
> 
> diff --git a/meta/lib/oeqa/selftest/cases/imagefeatures.py b/meta/lib/oeqa/selftest/cases/imagefeatures.py
> index dea519e6df..f7a2533746 100644
> --- a/meta/lib/oeqa/selftest/cases/imagefeatures.py
> +++ b/meta/lib/oeqa/selftest/cases/imagefeatures.py
> @@ -263,6 +263,80 @@ PNBLACKLIST[busybox] = "Don't build this"
>   
>           bitbake("--graphviz core-image-sato")
>   
> +    def test_fit_image(self):
> +        """
> +        Summary:     Check if FIT image and Image Tree Source (its) are built
> +                     and the Image Tree Source has the correct fields.
> +        Expected:    1. fitImage and fitImage-its can be built
> +                     2. The type, load address, entrypoint address and
> +                     default values of kernel and ramdisk are as expected
> +                     in the Image Tree Source. Not all the fields are tested,
> +                     only the key fields that wont vary between different
> +                     architectures.
> +        Product:     oe-core
> +        Author:      Usama Arif <usama.arif@arm.com>
> +        """
> +        config = """
> +# Enable creation of fitImage
> +KERNEL_IMAGETYPE = "Image"
> +KERNEL_IMAGETYPES += " fitImage "
> +KERNEL_CLASSES = " kernel-fitimage "
> +
> +# RAM disk variables including load address and entrypoint for kernel and RAM disk
> +IMAGE_FSTYPES += "cpio.gz"
> +INITRAMFS_IMAGE = "core-image-minimal"
> +UBOOT_RD_LOADADDRESS = "0x88000000"
> +UBOOT_RD_ENTRYPOINT = "0x88000000"
> +UBOOT_LOADADDRESS = "0x80080000"
> +UBOOT_ENTRYPOINT = "0x80080000"
> +"""
> +        self.write_config(config)
> +
> +        # fitImage is created as part of linux recipe
> +        bitbake("virtual/kernel")
> +
> +        image_type = "core-image-minimal"
> +        deploy_dir_image = get_bb_var('DEPLOY_DIR_IMAGE')
> +        machine = get_bb_var('MACHINE')
> +        fitimage_its_path = os.path.join(deploy_dir_image,
> +            "fitImage-its-%s-%s-%s" % (image_type, machine, machine))
> +        fitimage_path = os.path.join(deploy_dir_image,
> +            "fitImage-%s-%s-%s" % (image_type, machine, machine))
> +
> +        self.assertTrue(os.path.exists(fitimage_its_path),
> +            "%s image tree source doesn't exist" % (fitimage_its_path))
> +        self.assertTrue(os.path.exists(fitimage_path),
> +            "%s FIT image doesn't exist" % (fitimage_path))
> +
> +        # Check that the type, load address, entrypoint address and default
> +        # values for kernel and ramdisk in Image Tree Source are as expected.
> +        # The order of fields in the below array is important. Not all the
> +        # fields are tested, only the key fields that wont vary between
> +        # different architectures.
> +        its_field_check = ['type = "kernel";',
> +            'load = <0x80080000>;',
> +            'entry = <0x80080000>;',
> +            'type = "ramdisk";',
> +            'load = <0x88000000>;',
> +            'entry = <0x88000000>;',
> +            'default = "conf@1";',
> +            'kernel = "kernel@1";',
> +            'ramdisk = "ramdisk@1";'
> +            ]
> +
> +        with open(fitimage_its_path) as its_file:
> +            field_index = 0
> +            for line in its_file:
> +                if field_index == len(its_field_check):
> +                    break
> +                if its_field_check[field_index] in line:
> +                    field_index +=1
> +
> +        if field_index != len(its_field_check): # if its equal, the test passed
> +            self.assertTrue(field_index == len(its_field_check),
> +                "Fields in Image Tree Source File %s did not match, error in finding %s"
> +                % (fitimage_its_path, its_field_check[field_index]))
> +
>       def test_image_gen_debugfs(self):
>           """
>           Summary:     Check debugfs generation
> 


Hi

This test assumes that the case for a single kernel and single
RAM disk with no dtb is supported by kernel-fitimage.bbclass.
https://lists.openembedded.org/g/openembedded-core/message/140810 adds
support for this combination of usecase and the test wont pass without 
the usecase being supported.

Thanks,
Usama

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-07-29 14:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-29 14:41 [PATCH] oeqa/selftest/imagefeatures: Add testcase for fitImage Usama Arif
2020-07-29 14:47 ` Usama Arif

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.