From: Pierre-Loup GOSSE <[email protected]>

This adds two new selftest cases `test_uboot_initial_env_binary` and
`test_uboot_config_initial_env_binary` to verify the build of the U-Boot
initial env binary with the mkimage tool.

Signed-off-by: Pierre-Loup GOSSE <[email protected]>
---
changes in v2:
- add tests

changes in v3:
- fix UBOOT_CONFIG[test] with the correct UBOOT_MACHINE
---
 meta/lib/oeqa/selftest/cases/uboot.py | 54 +++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)

diff --git a/meta/lib/oeqa/selftest/cases/uboot.py 
b/meta/lib/oeqa/selftest/cases/uboot.py
index 980ea327f0..28169514f5 100644
--- a/meta/lib/oeqa/selftest/cases/uboot.py
+++ b/meta/lib/oeqa/selftest/cases/uboot.py
@@ -5,6 +5,9 @@
 # SPDX-License-Identifier: MIT
 #
 
+import os
+import textwrap
+
 from oeqa.selftest.case import OESelftestTestCase
 from oeqa.utils.commands import bitbake, runqemu, get_bb_var, get_bb_vars, 
runCmd
 from oeqa.core.decorator.data import skipIfNotArch, skipIfNotBuildArch
@@ -96,3 +99,54 @@ QB_DRIVE_TYPE = "/dev/vd"
             self.assertTrue("Machine model: linux,dummy-virt" in output, 
msg=output)
             # with KVM enabled
             self.assertTrue("KVM: hypervisor services detected" in output, 
msg=output)
+
+    def test_uboot_initial_env_binary(self):
+        """
+        Tests building the initial U-Boot environment in binary format with
+        the U-Boot mkimage tool.
+        We assume that the uboot-mkenvimage tool generates a correct binary.
+        """
+
+        self.write_config(textwrap.dedent("""
+            UBOOT_INITIAL_ENV_BINARY = "1"
+            UBOOT_INITIAL_ENV_BINARY_SIZE = "0x4000"
+            UBOOT_INITIAL_ENV_BINARY_REDUND = "1"
+        """))
+
+        bitbake("u-boot")
+
+        bb_vars = get_bb_vars(["DEPLOYDIR", "UBOOT_INITIAL_ENV"], "u-boot")
+
+        uboot_initial_env_binary_path = os.path.realpath(os.path.join(
+            bb_vars["DEPLOYDIR"], "%s.bin" % bb_vars["UBOOT_INITIAL_ENV"]
+        ))
+
+        self.assertExists(uboot_initial_env_binary_path)
+
+    def test_uboot_config_initial_env_binary(self):
+        """
+        Tests building the initial U-Boot environment in binary format with
+        the U-Boot mkimage tool for a U-Boot config.
+        We assume that the uboot-mkenvimage tool generates a correct binary.
+        """
+
+        uboot_machine = get_bb_var("UBOOT_MACHINE", "u-boot")
+
+        self.write_config(textwrap.dedent(f"""
+            UBOOT_CONFIG = "test"
+            UBOOT_CONFIG[test] := "{uboot_machine}"
+            UBOOT_MACHINE = ""
+            UBOOT_INITIAL_ENV_BINARY = "1"
+            UBOOT_INITIAL_ENV_BINARY_SIZE = "0x4000"
+            UBOOT_INITIAL_ENV_BINARY_REDUND = "1"
+        """))
+
+        bitbake("u-boot")
+
+        bb_vars = get_bb_vars(["DEPLOYDIR", "UBOOT_INITIAL_ENV"], "u-boot")
+
+        uboot_initial_env_binary_path = os.path.realpath(os.path.join(
+            bb_vars["DEPLOYDIR"], "%s-test.bin" % bb_vars["UBOOT_INITIAL_ENV"]
+        ))
+
+        self.assertExists(uboot_initial_env_binary_path)
-- 
2.34.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#226654): 
https://lists.openembedded.org/g/openembedded-core/message/226654
Mute This Topic: https://lists.openembedded.org/mt/116405113/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to