summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorTom Rini <[email protected]>2026-05-25 13:44:28 -0600
committerTom Rini <[email protected]>2026-05-25 13:44:28 -0600
commit77efd55f89e406d49a8697fd5475b6ab2ba6497c (patch)
tree03fd04d4d446dbf134331651c1ea3a232273b412 /test
parenta219f64c2794135b44ab9aa9b808c5c25d18262c (diff)
parent2c9b117aa4811d583f2832b37a69f25c761ffc86 (diff)
Merge patch series "boot/fit: use fdt_for_each_subnode() in image-fit.c"
Aristo Chen <[email protected]> says: This series ends with replacing the verbose fdt_next_node() + ndepth idiom in boot/image-fit.c with fdt_for_each_subnode(), bringing the file in line with boot/image-fit-sig.c. Six of the seven sites in image-fit.c predate the macro by 2-6 years; the seventh was copy-pasted from a neighbour in 2015 just after the macro landed. The old idiom is legacy, not a deliberate technical choice. Converting straight to the macro turned out to need a prerequisite, which is patch 1. fit_print_contents() reads the default-config property using the loop variable left over after iterating /images children. With /images defined first in the source (the conventional layout) libfdt's walker happens to leave that variable pointing at /configurations and the read works. With /configurations defined first the read returns NULL and the "Default Configuration" line is silently omitted. fdt_for_each_subnode()'s post-loop value is unconditionally a negative error code, so a naive conversion would have made the missing line the unconditional behaviour. Patch 1 reads the property from confs_noffset directly and removes the layout dependency. Patch 2 adds a regression test for the configs-before-images layout, which had no coverage. Patch 3 is the mechanical conversion at all seven sites, equivalence-preserving as described in the per-patch message. Link: https://lore.kernel.org/r/[email protected]
Diffstat (limited to 'test')
-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 4f56a1421e1..1c4bd667d6b 100755
--- a/test/py/tests/test_fit.py
+++ b/test/py/tests/test_fit.py
@@ -426,3 +426,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)