On 11/25/25 3:52 PM, Marek Vasut wrote:
On 11/25/25 11:50 AM, Quentin Schulz wrote:
Hello Quentin,
On 11/24/25 8:40 PM, Marek Vasut wrote:
[...]
[...]
+ """Generate fitImage and test for expected entries.
+
+ Generate a fitImage and test whether suitable entries are
part of
+ the generated fitImage. Test whether checksums and
signatures are
+ part of the generated fitImage.
Would be nice to have documentation on what the parameters represent
and what this returns/raises. Not a blocker though, I see we already
don't do it for other functions.
I am not that deep in python, so if you could tell me how to do that or
share an example, I can do that.
Just follow binman's example I guess. If it's wrong, we'll need to fix
the format everywhere anyway at some point (e.g. when someone manages to
setup rST doc generation from docstring, maybe with [1]?).
"""Get the operation referenced by a subnode
Args:
node (Node): Subnode (of the FIT) to check
Returns:
int: Operation to perform
Raises:
ValueError: Invalid operation name
This seems to follow Google-Style Docstrings format, c.f.
https://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings
[1] https://www.sphinx-doc.org/en/master/usage/extensions/napoleon.html
+ """
+ mkimage = ubman.config.build_dir + '/tools/mkimage'
+ utils.run_and_log(ubman, mkimage + cmd)
+
+ fit = SignedFitHelper(ubman, fit_file)
+ if fit.build_nodes_sets() == 0:
+ raise ValueError('FIT-1 has no "/image" nor "/
configuration" nodes')
+
Only downside is that this exception will be raised with the same
string for all callers. We call it multiple times in the same test so
it might be difficult to identify which one actually failed. We could
try..except the exception, use the content of the exception with
try:
generate_and_check_fit_image(...)
except Exception as e:
pytest.fail(f'FIT-X failed: {str(e)}')
maybe? (NOT TESTED!)
Maybe it would be better to simply print the test configuration ?
Like this:
raise ValueError(f'FIT has no "/image" nor "/configuration" nodes, test
settings: cmd={cmd} crc={crc} simgs={simgs} scfgs={scfgs}
bl31present={bl31present} teepresent={teepresent} key_name={key_name}
sign_algo={sign_algo} verifier={verifier}')
Considering that the only arguments used before this is raised are the
mkimage cmd arguments, I think it'd be enough to just print that? But
yes, that would work.
Cheers,
Quentin