Hi Jérémie,

On 2026-09-11T16:35:05, 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                              | 85 ++++++++++++++++++++++
>  tools/binman/test/vendor/nxp_imx93_csf.dts         | 18 +++++
>  .../binman/test/vendor/nxp_imx93_csf_imagename.dts | 24 ++++++
>  3 files changed, 127 insertions(+)

> diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
> @@ -8152,6 +8153,90 @@ 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)
> +        self._MakeInputFile('imx93-container.bin', bytes(ele_data))
> +
> +        with terminal.capture() as (_, stderr):
> +            self._DoTestFile('vendor/nxp_imx93_csf.dts',
> +                             force_missing_bintools='cst')
> +        err = stderr.getvalue()
> +        self.assertRegex(err, "Image 'image'.*missing bintools.*: cst")

These tests execute the lines but do not check the result of the only
real logic in BuildSectionData(): the header-address detection and the
signing-offset computation. Since write_config() runs before run_cst()
records the missing bintool, the generated config is available even in
this case, so please can you check it, e.g.:

    cfg = tools.read_file(tools.get_output_filename(
        'nxp.csf-config-txt.nxp-imx93cst'), binary=False)
    self.assertIn('Offsets = 0x400 0x490', cfg)

and similarly '0x0 0x90' in testNxpImx93cstNormal. Without that, a
mistake in the hdr_addr handling would go unnoticed.

> diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
> @@ -8152,6 +8153,90 @@ fdt         fdtmap                Extract the 
> devicetree blob from the fdtmap
> +        # Mock run_cmd() so that when cst is invoked, it creates a fake
> +        # output blob and returns success, thus covering the signing path
> +        original = bintool.Bintool.run_cmd
> +
> +        def fake_cst_run_cmd(self_tool, *args, binary=False):
> +            if self_tool.name == 'cst':
> +                arg_list = list(args)
> +                if '-o' in arg_list:
> +                    idx = arg_list.index('-o')
> +                    tools.write_file(arg_list[idx + 1], b'\x00' * 32)
> +                return 'fake cst output'
> +            return original(self_tool, *args, binary=binary)

This is a copy of the mock in testNxpImx8mCSTSigned(). Please can you
move it into a small helper (or a context-manager method on the test
class) and use it from both tests?

> diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
> @@ -8152,6 +8153,90 @@ fdt         fdtmap                Extract the 
> devicetree blob from the fdtmap
> +        self._DoTestFile('vendor/nxp_imx93_csf_imagename.dts',
> +                         force_missing_bintools='mkimage')

Just to check, is 'mkimage' needed here? The nxp-imx93cst etype
overrides BuildSectionData() so mkimage is never invoked, unlike the
nxp-imx8mimage etype used by testNxpImx8ImageSizeNone(), which this
appears to be modelled on. If it is not needed, please drop it so the
test does not suggest otherwise.

Regards,
Simon

Reply via email to