From: Simon Glass <simon.glass@canonical.com>
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 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
---
test/boot/fit_print.c | 54 ++++++++++++++++++++++++++++++-
test/py/tests/test_fit_print.py | 57 +++++++++++++++++++++++++++++++++
2 files changed, 110 insertions(+), 1 deletion(-)
@@ -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);
@@ -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 $?')