From patchwork Thu Nov 20 02:55:45 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 738 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=1763607416; bh=50oLvQH5NhIT35zs7l0UQpSM19RRs+ojN9fsQmwz78g=; 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=IoA2iYtepaDCnFsVfQL75f1flydK1Cf1BTSf8N4hwuP3KcaSAYAmDmFIFxOJaxS/l Ux21zVU0AdYdZXaF8onLJK0yFSyBbJ3qi3MplCYJxSy0mmEFLnjRnbG1At8NK4DbiM P4IobOwdnRbdg95CftPuG2jTdPQ3tTl4hq34xOvv+hdMhqGWeAXGMZujjoYsdtmIfK RILh6eyAJOUAjuB+mH2hi7WUB9059mn2/rdybR/eHhIVMxG5KyrfBoITQkD2tlDKZL jWP/GqBg+NlesLJwPmLI67lWwB59WAgMKEd1F9OsFkl0mYGXZsHwyxRyYiSzqHSyeF cUDgLOXtfKhUA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E932268631 for ; Wed, 19 Nov 2025 19:56:56 -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 p_83h_Ew2W0l for ; Wed, 19 Nov 2025 19:56:56 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607416; bh=50oLvQH5NhIT35zs7l0UQpSM19RRs+ojN9fsQmwz78g=; 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=IoA2iYtepaDCnFsVfQL75f1flydK1Cf1BTSf8N4hwuP3KcaSAYAmDmFIFxOJaxS/l Ux21zVU0AdYdZXaF8onLJK0yFSyBbJ3qi3MplCYJxSy0mmEFLnjRnbG1At8NK4DbiM P4IobOwdnRbdg95CftPuG2jTdPQ3tTl4hq34xOvv+hdMhqGWeAXGMZujjoYsdtmIfK RILh6eyAJOUAjuB+mH2hi7WUB9059mn2/rdybR/eHhIVMxG5KyrfBoITQkD2tlDKZL jWP/GqBg+NlesLJwPmLI67lWwB59WAgMKEd1F9OsFkl0mYGXZsHwyxRyYiSzqHSyeF cUDgLOXtfKhUA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D664D68662 for ; Wed, 19 Nov 2025 19:56:56 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607414; bh=zoyK20CpY1f9+vP92YIim36oiArxif/d5V+Hs89Cw6A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hmfL2FPpKVDsP4CyI2/U12QSbQW6VjKU8aSrzzn05TwtSfE952VC+tdywGb9poimx 4/nPmsWCnys1W5XYMDjnrlzQh7YuZOSBg5sqOsnnCeq1TeiNvgRjZAA309fnv7vU6g nva3bICuolUiNQzw30ukt3521Z+8uY0T8ERhlBY8RXIrnWEKPkxWD8fvcthUBXIk5l eX0/JeXH4Ggl2OXzUEsA1rafm3IWEZ0Z7oqahHej/0Ev8DTrZvUZrV0dvXglwb0lDL 7PhnNHEn7F4M4j84zbQ9RRI/ONAGJxhb8cDuoWIx4yiKUJhpCJtRPuqM4sGziYPnIq WPBVikYbqI2UQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id DBD9968631; Wed, 19 Nov 2025 19:56:54 -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 7Pi3eT8WLZ39; Wed, 19 Nov 2025 19:56:54 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607409; bh=DJTgUufkbd07bCzNZe+6UgJScwaT2V32G6YfbmVVzHY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=spXtcAWY6EBC5ayvc6BoOtr9jmRCLmXymRUG3jCSgixrq6tfFb6yHATi1KoRTg7eV f99P86IuRDZypfCNwzLWETO+PXyg7AlqHLbSIr8La51j8r7MRyMNbfNUw7+4sXeSad 3bic0rZ05ymdlaXocwFgrljkScCbcpA3+hkeXk8zObaabvrFp0KqesBtd7IOBlys4Z 3IvFqP6StEAyfhr+vEuZGpUkNcQW1XvuFtgX9+shCkMFsC2eeJAE+srcw0Ux+kEXus GOQs+iCcd+lzBLobvkQajEh7U0dZX/SdHwc/QsLudJeRh1pVfZcDMfALlLaKQWv/kc U8UD1krA3xV8A== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 7AD7468662; Wed, 19 Nov 2025 19:56:49 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Wed, 19 Nov 2025 19:55:45 -0700 Message-ID: <20251120025614.2215587-11-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: 4AHIIQGUAAUZQ2YXC2BU5NULQ7YP47AI X-Message-ID-Hash: 4AHIIQGUAAUZQ2YXC2BU5NULQ7YP47AI 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 10/30] test: fit: Add pytest for mkimage output 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 a new pytest to check the output of 'mkimage -l' on the test FIT. Only check the first 80 chars as the signature lines can be very long. The timestamps are quite annoying, since we need the test to pass on whatever CI machine is used. Obtain the first timestamp and use that to check the rest, after some sanity checks. Co-developed-by: Claude Signed-off-by: Simon Glass --- test/py/tests/test_fit_print.py | 149 ++++++++++++++++++++++++++++++++ 1 file changed, 149 insertions(+) diff --git a/test/py/tests/test_fit_print.py b/test/py/tests/test_fit_print.py index 0ab8c0d4769..180467fba72 100644 --- a/test/py/tests/test_fit_print.py +++ b/test/py/tests/test_fit_print.py @@ -5,6 +5,8 @@ """Test for FIT image printing""" import os +import re +import time import pytest @@ -280,3 +282,150 @@ def test_fit_print_no_desc(ubman): ubman.run_command('ut -f bootstd test_fit_print_no_desc_norun') result = ubman.run_command('echo $?') assert '0' == result + +@pytest.mark.boardspec('sandbox') +@pytest.mark.buildconfigspec('fit_print') +@pytest.mark.requiredtool('dtc') +@pytest.mark.requiredtool('openssl') +def test_fit_print_mkimage(ubman): + """Test 'mkimage -l' output on FIT image""" + mkimage = os.path.join(ubman.config.build_dir, 'tools/mkimage') + fit = fit_util.make_fname(ubman, 'test-fit-mkimage.fit') + build_test_fit(ubman, fit) + + # Run mkimage -l and capture output + output = utils.run_and_log(ubman, [mkimage, '-l', fit]) + + # Extract the actual timestamp from mkimage output to avoid timezone issues + # mkimage uses localtime() which can vary based on system timezone + match = re.search(r'Created:\s+(.+)', output) + if not match: + raise ValueError("Could not find Created: line in mkimage output") + timestamp_str = match.group(1).strip() + + expected_timestamp = 1234567890 + # Validate timestamp is reasonable (SOURCE_DATE_EPOCH) + parsed_time = time.strptime(timestamp_str, '%a %b %d %H:%M:%S %Y') + parsed_timestamp = time.mktime(parsed_time) + time_diff = abs(parsed_timestamp - expected_timestamp) + + # Check it is within 24 hours (86400 seconds) + assert time_diff < 86400, \ + f"Timestamp {timestamp_str} is more than 24 hours from expected" + + # Expected output (complete output from mkimage -l) + expected = f''' +FIT description: Test FIT image for printing +Created: {timestamp_str} + Image 0 (kernel) + Description: Test kernel + Created: {timestamp_str} + Type: Kernel Image + Compression: gzip compressed + Data Size: 327 Bytes = 0.32 KiB = 0.00 MiB + Architecture: Sandbox + OS: Linux + Load Address: 0x01000000 + Entry Point: 0x01000000 + Hash algo: sha256 + Hash value: fad998b94ef12fdac0c347915d8b9b6069a4011399e1a2097638a2cb33244cee + Image 1 (ramdisk) + Description: Test ramdisk + Created: {timestamp_str} + Type: RAMDisk Image + Compression: uncompressed + Data Size: 301 Bytes = 0.29 KiB = 0.00 MiB + Architecture: Sandbox + OS: Linux + Load Address: 0x02000000 + Entry Point: unavailable + Hash algo: sha256 + Hash value: 53e2a65d92ad890dcd89d83a1f95ad6b8206e0e4889548b035062fc494e7f655 + Image 2 (fdt-1) + Description: Test FDT 1 + Created: {timestamp_str} + Type: Flat Device Tree + Compression: uncompressed + Data Size: 161 Bytes = 0.16 KiB = 0.00 MiB + Architecture: Sandbox + Hash algo: sha256 + Hash value: 1264bc4619a1162736fdca8e63e44a1b009fbeaaa259c356b555b91186257ffb + Image 3 (fdt-2) + Description: Test FDT 2 + Created: {timestamp_str} + Type: Flat Device Tree + Compression: uncompressed + Data Size: 161 Bytes = 0.16 KiB = 0.00 MiB + Architecture: Sandbox + Hash algo: sha256 + Hash value: 3a07e37c76dd48c2a17927981f0959758ac6fd0d649e2032143c5afeea9a98a4 + Image 4 (firmware-1) + Description: Test Firmware 1 + Created: {timestamp_str} + Type: Firmware + Compression: uncompressed + Data Size: 3891 Bytes = 3.80 KiB = 0.00 MiB + Architecture: Sandbox + OS: Unknown OS + Load Address: unavailable + Hash algo: sha256 + Hash value: 53f1358540a556282764ceaf2912e701d2e25902a6b069b329e57e3c59148414 + Image 5 (firmware-2) + Description: Test Firmware 2 + Created: {timestamp_str} + Type: Firmware + Compression: uncompressed + Data Size: 3891 Bytes = 3.80 KiB = 0.00 MiB + Architecture: Sandbox + OS: Unknown OS + Load Address: unavailable + Hash algo: sha256 + Hash value: 6a12ac2283f3c9605113b5c2287e983da5671d8d0015381009d75169526676f1 + Image 6 (fpga) + Description: Test FPGA + Created: {timestamp_str} + Type: FPGA Image + Compression: uncompressed + Data Size: 4291 Bytes = 4.19 KiB = 0.00 MiB + Load Address: unavailable + Hash algo: sha256 + Hash value: 2f588e50e95abc7f9d6afd1d5b3f2bf285cccd55efcf52f47a975dbff3265622 + Image 7 (script) + Description: unavailable + Created: {timestamp_str} + Type: Script + Compression: uncompressed + Data Size: 3791 Bytes = 3.70 KiB = 0.00 MiB + Hash algo: invalid/unsupported + Default Configuration: 'conf-1' + Configuration 0 (conf-1) + Description: Test configuration + Kernel: kernel + Init Ramdisk: ramdisk + FDT: fdt-1 + Compatible: vendor,board-1.0 + vendor,board + Sign algo: sha256,rsa2048:test-key + Sign padding: pkcs-1.5 + Sign value: c20f64d9bf79ddb0b1a69293b2375ad88e70536684705a9577f2156e6da4df6d + Timestamp: {timestamp_str} + Configuration 1 (conf-2) + Description: Alternate configuration + Kernel: kernel + FDT: fdt-1 + fdt-2 + FPGA: fpga + Loadables: firmware-1 + firmware-2 + Compatible: vendor,board-2.0 + Configuration 2 (conf-3) + Description: unavailable + Kernel: unavailable + Loadables: script +'''.strip().split('\n') + + lines = output.split('\n') + for seq, (expected, line) in enumerate(zip(expected, lines)): + exp = expected[:80] + act = line[:80] + assert exp == act, f"line {seq + 1}: expect '{exp}' got '{act}'"