diff mbox series

[2/2] selftest: uboot: Test UBOOT_ELF_SREC

Message ID 20261129000720.272757-2-marek.vasut@mailbox.org
State New
Headers show
Series [1/2] selftest: uboot: Test UBOOT_ELF | expand

Commit Message

Marek Vasut Nov. 29, 2026, 12:07 a.m. UTC
Test handling of UBOOT_ELF_SREC , which is a configuration that ships
u-boot-elf.srec alongside U-Boot build artifacts. The u-boot.elf may
not be built by default, so build it explicitly via UBOOT_MAKE_TARGET.
Test for the u-boot-elf.srec file existence after the build and confirm
that it is an S-record file by matching on the leading Sn characters
that must be present in an S-record file.

Signed-off-by: Marek Vasut <marek.vasut@mailbox.org>
---
Cc: Fabio Estevam <festevam@gmail.com>
Cc: Ross Burton <ross.burton@arm.com>
Cc: Ryan Eatmon <reatmon@ti.com>
Cc: Yoann Congal <yoann.congal@smile.fr>
---
DEPENDS: https://lists.openembedded.org/g/openembedded-core/message/250303
         https://patchwork.yoctoproject.org/project/oe-core/patch/20261116011833.2775540-1-marek.vasut@mailbox.org/
---
 meta/lib/oeqa/selftest/cases/uboot.py | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
diff mbox series

Patch

diff --git a/meta/lib/oeqa/selftest/cases/uboot.py b/meta/lib/oeqa/selftest/cases/uboot.py
index fc2aea7d03a..556b1277330 100644
--- a/meta/lib/oeqa/selftest/cases/uboot.py
+++ b/meta/lib/oeqa/selftest/cases/uboot.py
@@ -6,7 +6,9 @@ 
 #
 
 import os
+import re
 import textwrap
+import oeqa.utils.ftools as ftools
 
 from oeqa.selftest.case import OESelftestTestCase
 from oeqa.utils.commands import bitbake, runqemu, get_bb_var, get_bb_vars
@@ -118,6 +120,30 @@  QB_DRIVE_TYPE = "/dev/vd"
 
         self.assertExists(uboot_elf_binary_path)
 
+    def test_uboot_elf_srec_binary(self):
+        """
+        Tests building the U-Boot u-boot-elf.srec file.
+        """
+
+        self.write_config(textwrap.dedent("""
+            UBOOT_MAKE_TARGET = "u-boot-elf.srec"
+            UBOOT_ELF_SREC = "u-boot-elf.srec"
+        """))
+
+        bitbake("u-boot")
+
+        bb_vars = get_bb_vars(["DEPLOYDIR", "UBOOT_ELF_SREC_BINARY"], "u-boot")
+
+        uboot_elf_srec_binary_path = os.path.realpath(os.path.join(
+            bb_vars["DEPLOYDIR"], bb_vars["UBOOT_ELF_SREC_BINARY"]
+        ))
+
+        self.assertExists(uboot_elf_srec_binary_path)
+
+        contents = ftools.read_file(uboot_elf_srec_binary_path)
+        find_in_contents = re.search(r"^S[0-9]", contents)
+        self.assertTrue(find_in_contents, msg = "Generated %s is not an S-record" % uboot_elf_srec_binary_path)
+
     def test_uboot_initial_env_binary(self):
         """
         Tests building the initial U-Boot environment in binary format with