[Concept,07/30] test: fit: Test printing a FIT with multiple FDTs

Message ID 20251120025614.2215587-8-sjg@u-boot.org
State New
Headers
Series fit: Improve and test the code to print FIT info |

Commit Message

Simon Glass Nov. 20, 2025, 2:55 a.m. UTC
  From: Simon Glass <simon.glass@canonical.com>

Update the FDT fdt to include two separate FDT images, referenced by the
two configurations.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
---

 test/boot/fit_print.c           | 27 ++++++++++++++++-------
 test/py/tests/test_fit_print.py | 39 ++++++++++++++++++++++++---------
 2 files changed, 48 insertions(+), 18 deletions(-)
  

Patch

diff --git a/test/boot/fit_print.c b/test/boot/fit_print.c
index 8aa1de3a6c4..69ab2ecf081 100644
--- a/test/boot/fit_print.c
+++ b/test/boot/fit_print.c
@@ -64,30 +64,41 @@  static int test_fit_print_norun(struct unit_test_state *uts)
 	ut_assert_nextline("     Entry Point:  unavailable");
 	ut_assert_nextline("     Hash algo:    sha256");
 	ut_assert_nextline("     Hash value:   53e2a65d92ad890dcd89d83a1f95ad6b8206e0e4889548b035062fc494e7f655");
-	ut_assert_nextline("    Image 2 (fdt)");
-	ut_assert_nextline("     Description:  Test FDT");
+	ut_assert_nextline("    Image 2 (fdt-1)");
+	ut_assert_nextline("     Description:  Test FDT 1");
 	ut_assert_nextline("     Created:      2009-02-13  23:31:30 UTC");
 	ut_assert_nextline("     Type:         Flat Device Tree");
 	ut_assert_nextline("     Compression:  uncompressed");
-	ut_assert_nextline("     Data Start:   0x00010514");
-	ut_assert_nextline("     Data Size:    157 Bytes = 157 Bytes");
+	ut_assert_nextline("     Data Start:   0x00010518");
+	ut_assert_nextline("     Data Size:    161 Bytes = 161 Bytes");
 	ut_assert_nextline("     Architecture: Sandbox");
 	ut_assert_nextline("     Hash algo:    sha256");
-	ut_assert_nextline("     Hash value:   51918524b06745cae06331047c7e566909431bf71338e5f703dffba1823274f4");
+	ut_assert_nextline("     Hash value:   1264bc4619a1162736fdca8e63e44a1b009fbeaaa259c356b555b91186257ffb");
+	ut_assert_nextline("    Image 3 (fdt-2)");
+	ut_assert_nextline("     Description:  Test FDT 2");
+	ut_assert_nextline("     Created:      2009-02-13  23:31:30 UTC");
+	ut_assert_nextline("     Type:         Flat Device Tree");
+	ut_assert_nextline("     Compression:  uncompressed");
+	ut_assert_nextline("     Data Start:   0x0001067c");
+	ut_assert_nextline("     Data Size:    161 Bytes = 161 Bytes");
+	ut_assert_nextline("     Architecture: Sandbox");
+	ut_assert_nextline("     Hash algo:    sha256");
+	ut_assert_nextline("     Hash value:   3a07e37c76dd48c2a17927981f0959758ac6fd0d649e2032143c5afeea9a98a4");
 	ut_assert_nextline("    Default Configuration: 'conf-1'");
 	ut_assert_nextline("    Configuration 0 (conf-1)");
 	ut_assert_nextline("     Description:  Test configuration");
 	ut_assert_nextline("     Kernel:       kernel");
 	ut_assert_nextline("     Init Ramdisk: ramdisk");
-	ut_assert_nextline("     FDT:          fdt");
+	ut_assert_nextline("     FDT:          fdt-1");
 	ut_assert_nextline("     Sign algo:    sha256,rsa2048:test-key");
 	ut_assert_nextline("     Sign padding: pkcs-1.5");
-	ut_assert_nextlinen("     Sign value:   9ed5738204714c0ecf46");
+	ut_assert_nextlinen("     Sign value:   6b1cc88f8b3b7f2f148d");
 	ut_assert_nextline("     Timestamp:    2009-02-13  23:31:30 UTC");
 	ut_assert_nextline("    Configuration 1 (conf-2)");
 	ut_assert_nextline("     Description:  Alternate configuration");
 	ut_assert_nextline("     Kernel:       kernel");
-	ut_assert_nextline("     FDT:          fdt");
+	ut_assert_nextline("     FDT:          fdt-1");
+	ut_assert_nextline("                   fdt-2");
 	ut_assert_console_end();
 
 	os_free(buf);
diff --git a/test/py/tests/test_fit_print.py b/test/py/tests/test_fit_print.py
index de52bbb61a4..5127fc6f8f0 100644
--- a/test/py/tests/test_fit_print.py
+++ b/test/py/tests/test_fit_print.py
@@ -45,9 +45,19 @@  PRINT_ITS = '''
 				algo = "sha256";
 			};
 		};
-		fdt {
-			description = "Test FDT";
-			data = /incbin/("%(fdt)s");
+		fdt-1 {
+			description = "Test FDT 1";
+			data = /incbin/("%(fdt1)s");
+			type = "flat_dt";
+			arch = "sandbox";
+			compression = "none";
+			hash-1 {
+				algo = "sha256";
+			};
+		};
+		fdt-2 {
+			description = "Test FDT 2";
+			data = /incbin/("%(fdt2)s");
 			type = "flat_dt";
 			arch = "sandbox";
 			compression = "none";
@@ -61,19 +71,19 @@  PRINT_ITS = '''
 		conf-1 {
 			description = "Test configuration";
 			kernel = "kernel";
-			fdt = "fdt";
+			fdt = "fdt-1";
 			ramdisk = "ramdisk";
 			signature {
 				algo = "sha256,rsa2048";
 				padding = "pkcs-1.5";
 				key-name-hint = "test-key";
-				sign-images = "fdt", "kernel", "ramdisk";
+				sign-images = "fdt-1", "kernel", "ramdisk";
 			};
 		};
 		conf-2 {
 			description = "Alternate configuration";
 			kernel = "kernel";
-			fdt = "fdt";
+			fdt = "fdt-1", "fdt-2";
 		};
 	};
 };
@@ -95,14 +105,22 @@  def test_fit_print(ubman):
     kernel_gz = kernel + '.gz'
     utils.run_and_log(ubman, ['gzip', '-f', '-n', '-k', kernel])
 
-    fdt = fit_util.make_dtb(ubman, '''
+    fdt1 = fit_util.make_dtb(ubman, '''
+/dts-v1/;
+/ {
+	#address-cells = <1>;
+	#size-cells = <0>;
+	model = "Test FDT 1";
+};
+''', 'test-fdt-1')
+    fdt2 = fit_util.make_dtb(ubman, '''
 /dts-v1/;
 / {
 	#address-cells = <1>;
 	#size-cells = <0>;
-	model = "Test";
+	model = "Test FDT 2";
 };
-''', 'test-fdt')
+''', 'test-fdt-2')
     ramdisk = fit_util.make_kernel(ubman, 'test-ramdisk.bin', 'ramdisk')
 
     # Compress the ramdisk (with -n to avoid timestamps for reproducibility)
@@ -112,7 +130,8 @@  def test_fit_print(ubman):
     # Create FIT image with fixed timestamp for reproducible output
     params = {
         'kernel': kernel_gz,
-        'fdt': fdt,
+        'fdt1': fdt1,
+        'fdt2': fdt2,
         'ramdisk': ramdisk_gz,
     }
     env = os.environ.copy()