From patchwork Thu Nov 20 02:55:43 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 736 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607412; bh=hQw2z5uKIvVcnaJsMIkrvrQQL9lHype5T1jLHmjj0uo=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=FqnVZ21uF7Tazh/u7m+kAFRfFIy+gQHNxziRrr6bGPnP0wUQ6fmYZQxTyB+alxf54 jsgsTXl7QFzvlRxoj2dgbQt3gFzc0GG1vrtHvLbrw3QrHrdxdyYVP82/RugdLdnIxH dthN/sZlNrVF4NAZZ4mNgTbVJCePBkSCLq33lgSlmi+UrOt0jCHFZK/2T8QOuMwve2 xP+o5OiyKQd22yC6yv/bG118gJpMw4CeeXD4ze9U1o6in/fV/LcoAfD5rGWwmfM4tQ ocEkO5cTe/5plEo0obDfLa2xMthJzM0hEJLykzoDV2eAoOHjAshHwMZQHGnU/bapML wrl8jrL+GUQIg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3B93968654 for ; Wed, 19 Nov 2025 19:56:52 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id Op6ihxtcIzGR for ; Wed, 19 Nov 2025 19:56:52 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607411; bh=hQw2z5uKIvVcnaJsMIkrvrQQL9lHype5T1jLHmjj0uo=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=YsgPF9mrHLcEvzy++TP3JxtuR/XQx+4E2IGBftUAAAQ4SzSs/v7IEnKefM2iyvpK7 wMUzJm+bVdRdVw3z2LZMEuEijEFPPEsr9SwsFstoaZwOTbhWAlQyePbBPO4eXCh/Ve hO/wtnjbCLB5an2DG0BZZTrfPCG278xM4azbHS/uukfBjihppRaMjmz7vrzwjflJf6 lZqO+jjvz9S/kWwEz0s8B02UyJDLV5PSRhJQYnsp2p/m3EhTwCtByK8mBeWGYH19tF 2ptzhA4fUSLfWhrJ0iasAT/PxlEMD/oN17QHgbWeqqp0aQ7QvlRSTdklB60Wk9YAT2 mblPL/BjiCx8w== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8456968631 for ; Wed, 19 Nov 2025 19:56:51 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607408; bh=dzkOXE6cZhMxqlS9xyLvgQh+teBLGmEMLER5BEn/fdk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cRQFW5cS1nWqElHMKbbsobgjx1Ah6b79YKeX9K32admwCRAfIx4Vq2FzhMPfuR1kI 1SrbI2Cl0G5U7/57X8tAhL9Y2B/5wPhvhxQMu0oemYOXhTrls5szjtZieujSWyQ2fO 0s4ycJe6eltnpiW4HrPzvafL3+6cKYmkAlcqF8YVP5FyHvR3iVcxAg6jsrnDNjAw7k fDCktxdf7yRFuy7YCnlloZ1rqF/QGyuCGx+msVNEcUtlId54lBXyyONVC30Y4BwqHp Si0GCJUZnp0n0tQWnd2fRlJQm4t6SVNvHAUtNLKeS97TR4mMbWHqX7fQcD9qsZtDkj ZdMi6jpDLOHaA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6E2FA68654; Wed, 19 Nov 2025 19:56:48 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id 3koqBm0JVoes; Wed, 19 Nov 2025 19:56:48 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607404; bh=Dh/2PVg0ZNG8dCRWWBA/VPHYqS3RJ6MXzD78qt926fU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KtsJ4O3AAmFVAHDBJyHMlkEq0wfmO02LOT0331z7gEI8VXqQ2ebHc7FTbktJDhzHw mSfq/grwif/JJVIdDhFpZ9tDcUJnkEct4/vo+hsKvWHULiAL3zc+y7S17hyeUBld22 GzbpdFLRxaoMPLsf7Py/aG56tDdy98CtHMNJctYKbCtR7XIN4Onkc3KzzUkGvONPrt QRdnBaBF1K/hL7kEzrAjW2iw7JSWeQl0BTMGlBIgxmNQcXhgjs+bwLv/KVoG/puwbB RiR4xVaZyW5ezqXrjyk1BLZmHDqitWXmgPRoNXdpgLn3m4+P3Wj7b3qqWy4iRE1gA2 TADq5Ag2sUN9g== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id E71C0686E3; Wed, 19 Nov 2025 19:56:43 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Wed, 19 Nov 2025 19:55:43 -0700 Message-ID: <20251120025614.2215587-9-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251120025614.2215587-1-sjg@u-boot.org> References: <20251120025614.2215587-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 36DFQROEC26BR64WBW4YXALBG6FM2KON X-Message-ID-Hash: 36DFQROEC26BR64WBW4YXALBG6FM2KON X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 08/30] test: fit: Test the remaining features and edge cases List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Add support for testing the loadables, fpga, compatible properties and unavailable/error conditions in FIT configurations. With this, most of the FIT-printing code is covered by tests. Co-developed-by: Claude Signed-off-by: Simon Glass --- test/boot/fit_print.c | 54 ++++++++++++++++++++++++++++++- test/py/tests/test_fit_print.py | 57 +++++++++++++++++++++++++++++++++ 2 files changed, 110 insertions(+), 1 deletion(-) diff --git a/test/boot/fit_print.c b/test/boot/fit_print.c index 69ab2ecf081..856cbfc6613 100644 --- a/test/boot/fit_print.c +++ b/test/boot/fit_print.c @@ -84,21 +84,73 @@ static int test_fit_print_norun(struct unit_test_state *uts) ut_assert_nextline(" Architecture: Sandbox"); ut_assert_nextline(" Hash algo: sha256"); ut_assert_nextline(" Hash value: 3a07e37c76dd48c2a17927981f0959758ac6fd0d649e2032143c5afeea9a98a4"); + ut_assert_nextline(" Image 4 (firmware-1)"); + ut_assert_nextline(" Description: Test Firmware 1"); + ut_assert_nextline(" Created: 2009-02-13 23:31:30 UTC"); + ut_assert_nextline(" Type: Firmware"); + ut_assert_nextline(" Compression: uncompressed"); + ut_assert_nextline(" Data Start: 0x000107e8"); + ut_assert_nextline(" Data Size: 3891 Bytes = 3.8 KiB"); + ut_assert_nextline(" Architecture: Sandbox"); + ut_assert_nextline(" OS: Unknown OS"); + ut_assert_nextline(" Load Address: unavailable"); + ut_assert_nextline(" Hash algo: sha256"); + ut_assert_nextline(" Hash value: 53f1358540a556282764ceaf2912e701d2e25902a6b069b329e57e3c59148414"); + ut_assert_nextline(" Image 5 (firmware-2)"); + ut_assert_nextline(" Description: Test Firmware 2"); + ut_assert_nextline(" Created: 2009-02-13 23:31:30 UTC"); + ut_assert_nextline(" Type: Firmware"); + ut_assert_nextline(" Compression: uncompressed"); + ut_assert_nextline(" Data Start: 0x000117e8"); + ut_assert_nextline(" Data Size: 3891 Bytes = 3.8 KiB"); + ut_assert_nextline(" Architecture: Sandbox"); + ut_assert_nextline(" OS: Unknown OS"); + ut_assert_nextline(" Load Address: unavailable"); + ut_assert_nextline(" Hash algo: sha256"); + ut_assert_nextline(" Hash value: 6a12ac2283f3c9605113b5c2287e983da5671d8d0015381009d75169526676f1"); + ut_assert_nextline(" Image 6 (fpga)"); + ut_assert_nextline(" Description: Test FPGA"); + ut_assert_nextline(" Created: 2009-02-13 23:31:30 UTC"); + ut_assert_nextline(" Type: FPGA Image"); + ut_assert_nextline(" Compression: uncompressed"); + ut_assert_nextline(" Data Start: 0x000127e0"); + ut_assert_nextline(" Data Size: 4291 Bytes = 4.2 KiB"); + ut_assert_nextline(" Load Address: unavailable"); + ut_assert_nextline(" Hash algo: sha256"); + ut_assert_nextline(" Hash value: 2f588e50e95abc7f9d6afd1d5b3f2bf285cccd55efcf52f47a975dbff3265622"); + ut_assert_nextline(" Image 7 (script)"); + ut_assert_nextline(" Description: unavailable"); + ut_assert_nextline(" Created: 2009-02-13 23:31:30 UTC"); + ut_assert_nextline(" Type: Script"); + ut_assert_nextline(" Compression: uncompressed"); + ut_assert_nextline(" Data Start: 0x0001394c"); + ut_assert_nextline(" Data Size: 3791 Bytes = 3.7 KiB"); + ut_assert_nextline(" Hash algo: invalid/unsupported"); 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-1"); + ut_assert_nextline(" Compatible: vendor,board-1.0"); + ut_assert_nextline(" vendor,board"); ut_assert_nextline(" Sign algo: sha256,rsa2048:test-key"); ut_assert_nextline(" Sign padding: pkcs-1.5"); - ut_assert_nextlinen(" Sign value: 6b1cc88f8b3b7f2f148d"); + ut_assert_nextlinen(" Sign value: c20f64d9bf79ddb0b1a6"); 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-1"); ut_assert_nextline(" fdt-2"); + ut_assert_nextline(" FPGA: fpga"); + ut_assert_nextline(" Loadables: firmware-1"); + ut_assert_nextline(" firmware-2"); + ut_assert_nextline(" Compatible: vendor,board-2.0"); + ut_assert_nextline(" Configuration 2 (conf-3)"); + ut_assert_nextline(" Description: unavailable"); + ut_assert_nextline(" Kernel: unavailable"); + ut_assert_nextline(" Loadables: script"); 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 5127fc6f8f0..25fada7d468 100644 --- a/test/py/tests/test_fit_print.py +++ b/test/py/tests/test_fit_print.py @@ -65,6 +65,44 @@ PRINT_ITS = ''' algo = "sha256"; }; }; + firmware-1 { + description = "Test Firmware 1"; + data = /incbin/("%(firmware1)s"); + type = "firmware"; + arch = "sandbox"; + compression = "none"; + hash-1 { + algo = "sha256"; + }; + }; + firmware-2 { + description = "Test Firmware 2"; + data = /incbin/("%(firmware2)s"); + type = "firmware"; + arch = "sandbox"; + compression = "none"; + hash-1 { + algo = "sha256"; + }; + }; + fpga { + description = "Test FPGA"; + data = /incbin/("%(fpga)s"); + type = "fpga"; + arch = "sandbox"; + compression = "none"; + hash-1 { + algo = "sha256"; + }; + }; + script { + data = /incbin/("%(script)s"); + type = "script"; + compression = "none"; + hash-1 { + algo = "sha256"; + }; + }; }; configurations { default = "conf-1"; @@ -73,6 +111,7 @@ PRINT_ITS = ''' kernel = "kernel"; fdt = "fdt-1"; ramdisk = "ramdisk"; + compatible = "vendor,board-1.0", "vendor,board"; signature { algo = "sha256,rsa2048"; padding = "pkcs-1.5"; @@ -84,6 +123,12 @@ PRINT_ITS = ''' description = "Alternate configuration"; kernel = "kernel"; fdt = "fdt-1", "fdt-2"; + fpga = "fpga"; + loadables = "firmware-1", "firmware-2"; + compatible = "vendor,board-2.0"; + }; + conf-3 { + loadables = "script"; }; }; }; @@ -121,7 +166,11 @@ def test_fit_print(ubman): model = "Test FDT 2"; }; ''', 'test-fdt-2') + firmware1 = fit_util.make_kernel(ubman, 'test-firmware-1.bin', 'firmware 1') + firmware2 = fit_util.make_kernel(ubman, 'test-firmware-2.bin', 'firmware 2') + fpga = fit_util.make_kernel(ubman, 'test-fpga.bin', 'fpga bitstream') ramdisk = fit_util.make_kernel(ubman, 'test-ramdisk.bin', 'ramdisk') + script = fit_util.make_kernel(ubman, 'test-script.bin', 'echo test') # Compress the ramdisk (with -n to avoid timestamps for reproducibility) ramdisk_gz = ramdisk + '.gz' @@ -132,7 +181,11 @@ def test_fit_print(ubman): 'kernel': kernel_gz, 'fdt1': fdt1, 'fdt2': fdt2, + 'firmware1': firmware1, + 'firmware2': firmware2, + 'fpga': fpga, 'ramdisk': ramdisk_gz, + 'script': script, } env = os.environ.copy() env['SOURCE_DATE_EPOCH'] = '1234567890' # 2009-02-13 23:31:30 UTC @@ -190,6 +243,10 @@ S0n8gbs0Ht/ZckLk8mPclbk= '-r', fit, '-c', 'Configuration signing'], env=env) + # Delete the algo property from the hash-1 node to test invalid/unsupported + utils.run_and_log(ubman, ['fdtput', '-d', fit, '/images/script/hash-1', + 'algo']) + # Run the C test which will load and verify this FIT ubman.run_command('ut -f bootstd test_fit_print_norun') result = ubman.run_command('echo $?')