summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAristo Chen <[email protected]>2026-05-08 21:32:00 +0000
committerTom Rini <[email protected]>2026-05-25 13:44:10 -0600
commitb31f551bfcf05cec628fc79af5d12a601e0a1f48 (patch)
treedac6388ff3737d1e823116167cc6a462f7e462a8
parent646be6d5cd37dc9f1e79f4c6677b872932605a2b (diff)
test: fit: regression test for default-config print with reversed node order
Add a test that builds a FIT whose /configurations node is defined before /images in the source, runs iminfo, and asserts that the "Default Configuration: '<name>'" line appears in the output. Before the fix in the preceding commit ("boot/fit: read default-config property from the configurations node"), fit_print_contents() read the default-config property using the loop variable left over from iterating /images children. With /images defined first that variable accidentally pointed at /configurations and the line printed correctly; with /configurations defined first the read returned NULL and the line was silently omitted. The new test exercises the latter layout, which had no coverage. iminfo and the fit_print_contents() path had no test coverage at all before this commit. Signed-off-by: Aristo Chen <[email protected]> Reviewed-by: Simon Glass <[email protected]>
-rwxr-xr-xtest/py/tests/test_fit.py53
1 files changed, 53 insertions, 0 deletions
diff --git a/test/py/tests/test_fit.py b/test/py/tests/test_fit.py
index bcaaa6a5fc4..a526307ea7a 100755
--- a/test/py/tests/test_fit.py
+++ b/test/py/tests/test_fit.py
@@ -438,3 +438,56 @@ class TestFitImage:
output = ubman.run_command_list(cmds)
assert "can't get kernel image!" in '\n'.join(output)
+
+ def test_fit_iminfo_configs_first(self, ubman, fsetup):
+ """Regression: iminfo prints "Default Configuration" even when
+ /configurations is defined before /images in the source.
+
+ fit_print_contents() in boot/image-fit.c used to read the default
+ configuration name from whatever offset libfdt happened to return
+ after iterating /images children. With /images defined first that
+ offset accidentally landed on /configurations; with /configurations
+ defined first the read returned NULL and the line silently went
+ missing. Fixed in commit "boot/fit: read default-config property
+ from the configurations node".
+ """
+ configs_first_its = '''
+/dts-v1/;
+
+/ {
+ description = "FIT with /configurations before /images";
+ #address-cells = <1>;
+
+ configurations {
+ default = "conf-1";
+ conf-1 {
+ description = "first config";
+ kernel = "kernel-1";
+ };
+ };
+
+ images {
+ kernel-1 {
+ description = "first image";
+ data = /incbin/("%(kernel)s");
+ type = "kernel";
+ arch = "sandbox";
+ os = "linux";
+ compression = "none";
+ load = <0x40000>;
+ entry = <0x40000>;
+ };
+ };
+};
+'''
+ fit = fit_util.make_fit(ubman, fsetup['mkimage'], configs_first_its,
+ fsetup, basename='configs-first.fit')
+ cmds = [
+ 'host load hostfs 0 %#x %s' % (fsetup['fit_addr'], fit),
+ 'iminfo %#x' % fsetup['fit_addr'],
+ ]
+ output = '\n'.join(ubman.run_command_list(cmds))
+ assert "Default Configuration: 'conf-1'" in output, (
+ 'iminfo output is missing the "Default Configuration" line for a '
+ 'FIT whose /configurations node precedes /images. Output was:\n'
+ + output)