From patchwork Thu Nov 20 02:55:44 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 737 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=o1OnQ8rYZbzIsUogn+8z6xdQjtfpa6twBtrAYsO5DFs=; 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=g8S4kpiSeYOnPAkBfHW0GnX2BnBgQj5E/6S0tNNsK2gARG0MztNVWt+fh5CTS/CNd kBq1jshqm6ywf8SLIE8Uc7Ebl3EzpHlgyTkgfM4hlmjqrcf6QmvIhbFnEaNp+qtz44 aINSWCyz9V/iM3vczvi5Y5Ri429and2CcjNHQo5RuVPa1qeSWw/4c8DRCrRZLUxLKE 7nJ6rATgwhJXwmJNI5ZkEAI1+NYonXk1AlFeWLQ3BXHAqn3x0VgC2Xmsrvo8JZYywm bKJ5nNox6puEgVXgYpILNW9vAKU5wKJelYRuM/1fIs7FQ5Zzk/lTnXlTh99ci/coGx 06oQcLd+fvzKQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7B86D686DF 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 gx0gEQq6mN2P 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=1763607412; bh=o1OnQ8rYZbzIsUogn+8z6xdQjtfpa6twBtrAYsO5DFs=; 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=g8S4kpiSeYOnPAkBfHW0GnX2BnBgQj5E/6S0tNNsK2gARG0MztNVWt+fh5CTS/CNd kBq1jshqm6ywf8SLIE8Uc7Ebl3EzpHlgyTkgfM4hlmjqrcf6QmvIhbFnEaNp+qtz44 aINSWCyz9V/iM3vczvi5Y5Ri429and2CcjNHQo5RuVPa1qeSWw/4c8DRCrRZLUxLKE 7nJ6rATgwhJXwmJNI5ZkEAI1+NYonXk1AlFeWLQ3BXHAqn3x0VgC2Xmsrvo8JZYywm bKJ5nNox6puEgVXgYpILNW9vAKU5wKJelYRuM/1fIs7FQ5Zzk/lTnXlTh99ci/coGx 06oQcLd+fvzKQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4C5F568668 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=1763607409; bh=gFXrV3iz/vPfPa4JyFtXm/UoVHk7oIgZiFSXrqBSDEI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VwLjhSmsC55LP9UtII8e9Gpk7WclrfkYbS2BOKTdRakdwKsL5QT6xSwONZuuTZUMP 39JQusShZWbtG379grs8siH7rsGejdlv8MXq+8wB0P1h9MncNHtFRHF+z/nGpOXVeL FcBEB6KB1wfnPbD41aBfpoGnX9zv9kvG30nDiqBI7GScWSpuN+gbj0YbTfsGP3ee4k ZYRnu7aXjZaMyAk0ZtoEgcWkzLy2DlD80Dnx9LUWlfTHoLuYFCSDWEeoeavlcsukvv toWYbhGKLtTacS8kmFjMGIKMmWoDjFZa+r+FT8bJOPFTJSvaoipMwMtIiTwDzEMKVf rpi78NPBiKBPg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 35AE05E7DA; Wed, 19 Nov 2025 19:56:49 -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 XIW2u9DSs9n2; Wed, 19 Nov 2025 19:56:49 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607405; bh=Wx+rczd1+iTToggcXFxl9f7mDrGUEkb947IvmXkCAHM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OgImhq6hePR/RW8pa5VdcJdgyQE9E31V4k9Vw9QZEdQlGObdt+O2EzmD7y0Yxz75r PLfoZkH5SgU/AyJgJ9wgPinWh6HeHjpBhRfKx/SoUN1CLoaK7ELKxDoHlj1Bk7COn4 CrMr8v2vo43OLdslR+gT6Gst3U2eZa9/+qrrQ4WL38RV7aU/xObbQGduPW9P9ivYS+ snY9nVgoiZtzbezjEBDpPlBHHM4YbYJEiVLMgHnI6QxsYTpq72M93b5eoFUoPMnuti vifosEyerboh1zL3XaR+uF2yNVzQyj7oVXDmH1AJb+wvttahOKbkYe2e4WKIb8acEF ZV5xLdFlCgBpg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id EB6A1686EC; Wed, 19 Nov 2025 19:56:44 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Wed, 19 Nov 2025 19:55:44 -0700 Message-ID: <20251120025614.2215587-10-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: NZJREG272RGUV3YGIWJ37GO5ALDDFMDZ X-Message-ID-Hash: NZJREG272RGUV3YGIWJ37GO5ALDDFMDZ 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 09/30] test: fit: Add test for missing FIT description 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 test to verify that fit_print_contents() correctly handles a FIT image with a missing description property. To handle this a new FIT created with the description removed after mkimage has processed it, since mkimage will fail if the description is missing. Co-developed-by: Claude Signed-off-by: Simon Glass --- test/boot/fit_print.c | 32 ++++++++++++++++++++++++ test/py/tests/test_fit_print.py | 43 +++++++++++++++++++++++++++------ 2 files changed, 68 insertions(+), 7 deletions(-) diff --git a/test/boot/fit_print.c b/test/boot/fit_print.c index 856cbfc6613..8e8d81e7f6b 100644 --- a/test/boot/fit_print.c +++ b/test/boot/fit_print.c @@ -158,3 +158,35 @@ static int test_fit_print_norun(struct unit_test_state *uts) return 0; } BOOTSTD_TEST(test_fit_print_norun, UTF_CONSOLE | UTF_MANUAL); + +/* Test fit_print_contents() with missing FIT description */ +static int test_fit_print_no_desc_norun(struct unit_test_state *uts) +{ + char fname[256]; + void *fit; + void *buf; + ulong addr; + int size; + + /* Load the FIT created by the Python test (with deleted description) */ + ut_assertok(os_persistent_file(fname, sizeof(fname), + "test-fit-nodesc.fit")); + ut_assertok(os_read_file(fname, &buf, &size)); + + /* Copy to address 0x10000 and print from there */ + addr = 0x10000; + fit = map_sysmem(addr, size); + memcpy(fit, buf, size); + + /* Print it and check just the first line */ + console_record_reset_enable(); + fit_print_contents(fit); + + /* Check the first line shows unavailable */ + ut_assert_nextline(" FIT description: unavailable"); + + os_free(buf); + + return 0; +} +BOOTSTD_TEST(test_fit_print_no_desc_norun, UTF_CONSOLE | UTF_MANUAL); diff --git a/test/py/tests/test_fit_print.py b/test/py/tests/test_fit_print.py index 25fada7d468..0ab8c0d4769 100644 --- a/test/py/tests/test_fit_print.py +++ b/test/py/tests/test_fit_print.py @@ -134,12 +134,14 @@ PRINT_ITS = ''' }; ''' -@pytest.mark.boardspec('sandbox') -@pytest.mark.buildconfigspec('fit_print') -@pytest.mark.requiredtool('dtc') -@pytest.mark.requiredtool('openssl') -def test_fit_print(ubman): - """Test fit_print_contents() via C unit test""" +def build_test_fit(ubman, fit): + """Build a test FIT image with all components + + Args: + ubman (ConsoleBase): U-Boot manager object + fit (str): Path where the FIT file should be created + """ + # pylint: disable=too-many-locals mkimage = os.path.join(ubman.config.build_dir, 'tools/mkimage') # Create test files (make kernel ~6.3K) @@ -189,7 +191,6 @@ def test_fit_print(ubman): } env = os.environ.copy() env['SOURCE_DATE_EPOCH'] = '1234567890' # 2009-02-13 23:31:30 UTC - fit = os.path.join(ubman.config.persistent_data_dir, 'test-fit.fit') its = fit_util.make_its(ubman, PRINT_ITS, params) utils.run_and_log(ubman, [mkimage, '-f', its, fit], env=env) @@ -247,7 +248,35 @@ S0n8gbs0Ht/ZckLk8mPclbk= utils.run_and_log(ubman, ['fdtput', '-d', fit, '/images/script/hash-1', 'algo']) + +@pytest.mark.boardspec('sandbox') +@pytest.mark.buildconfigspec('fit_print') +@pytest.mark.requiredtool('dtc') +@pytest.mark.requiredtool('openssl') +def test_fit_print(ubman): + """Test fit_print_contents() via C unit test""" + fit = os.path.join(ubman.config.persistent_data_dir, 'test-fit.fit') + build_test_fit(ubman, fit) + # 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 $?') assert '0' == result + + +@pytest.mark.boardspec('sandbox') +@pytest.mark.buildconfigspec('fit_print') +@pytest.mark.requiredtool('dtc') +@pytest.mark.requiredtool('openssl') +def test_fit_print_no_desc(ubman): + """Test fit_print_contents() with missing FIT description""" + fit = os.path.join(ubman.config.persistent_data_dir, 'test-fit-nodesc.fit') + build_test_fit(ubman, fit) + + # Delete the description property + utils.run_and_log(ubman, ['fdtput', '-d', fit, '/', 'description']) + + # Run the C test to check the missing description + ubman.run_command('ut -f bootstd test_fit_print_no_desc_norun') + result = ubman.run_command('echo $?') + assert '0' == result