Hi Jérémie,
On 2026-09-30T13:42:33, Jérémie Dautheribes (Schneider Electric)
<[email protected]> wrote:
> binman: test: add code coverage for nxp_imx93cst etype
>
> Add test methods to cover all code paths of the nxp_imx93cst etype,
> reusing the pattern of the nxp_imx8mcst as done in commit 0cab35362d77
> ("binman: test: Fix code coverage for iMX8 and cst bintool") by Simon
> Glass.
>
> This brings nxp_imx93cst to 100% coverage.
>
> Signed-off-by: Jérémie Dautheribes (Schneider Electric)
> <[email protected]>
>
> tools/binman/ftest.py | 78 ++++++++++++++++++++++
> tools/binman/test/vendor/nxp_imx93_csf.dts | 18 +++++
> .../binman/test/vendor/nxp_imx93_csf_imagename.dts | 24 +++++++
> 3 files changed, 120 insertions(+)
> diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
> @@ -8158,6 +8159,83 @@ fdt fdtmap Extract the
> devicetree blob from the fdtmap
> + def testNxpImx93ImageSizeNone(self):
> + """Test SetImagePos() early return when an entry has no size"""
> + # The imagename entry is in GetEntries() but not packed, so has
> + # size=None, which triggers the early-return guard in SetImagePos()
> + self._DoTestFile('vendor/nxp_imx93_csf_imagename.dts')
SetImagePos() is now in the nxp_imxcst base class and
testNxpImx8ImageSizeNone() already covers it. Running the other four
new tests with testNxpImx8mCSTSigned and testNxpImx8ImageSizeNone
under coverage gives 100% for nxp_imxcst.py - the only line missed in
nxp_imx93cst.py is the 'too short' guard in BuildSectionData():
if len(data) < flags_offset + 4:
return data
This test only hits that line by accident, since the u-boot entry
content is U_BOOT_DATA, which is just 4 bytes. So the docstring and
comment don't describe what the test actually covers. Please can you
replace it with an explicit short-input test, e.g. write a short
imx93-container.bin with the existing nxp_imx93_csf.dts and check that
the data passes through unchanged? Then nxp_imx93_csf_imagename.dts
can be dropped.
> diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
> @@ -8158,6 +8159,83 @@ fdt fdtmap Extract the
> devicetree blob from the fdtmap
> + ele_data = bytearray(0x410)
> + ele_data[3] = nxp_imx93cst.CONTAINER_HDR_TAG
> + ele_data[40:44] = struct.pack('<I', 0x866)
> + ele_data[0x400 + 3] = nxp_imx93cst.CONTAINER_HDR_TAG
> + ele_data[0x400 + 12:0x400 + 14] = struct.pack('<H', 0x90)
Minor: the signature block is at 0x490, past the end of this
0x410-byte buffer. It doesn't matter while cst is missing, but sizing
the buffer to cover it (e.g. 0x500) would make the fake image
self-consistent. Also, nxp_imx93cst.SPL_CONTAINER_OFFSET would be
clearer than a bare 0x400.
> diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
> @@ -8158,6 +8159,83 @@ fdt fdtmap Extract the
> devicetree blob from the fdtmap
> + def testNxpImx93cstSigned(self):
> + """Test CST-signing-success path with mocked cst invocation"""
> + spl_data = bytearray(64)
> + spl_data[3] = nxp_imx93cst.CONTAINER_HDR_TAG
> + spl_data[12:14] = struct.pack('<H', 0x90)
> + spl_data[40:44] = struct.pack('<I', 0x123)
This duplicates the setup in testNxpImx93cstNormal(). Please can you
move it into a small helper, e.g. _MakeImx93SplContainer(), which the
ELE test could also use with an offset?
Regards,
Simon