Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F3C9FCFD354 for ; Mon, 24 Nov 2025 19:42:14 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2E1C283EC0; Mon, 24 Nov 2025 20:42:13 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.b="D6OD7Lsm"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="kSLCLWeN"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 28B0683EBA; Mon, 24 Nov 2025 20:42:12 +0100 (CET) Received: from mout-p-201.mailbox.org (mout-p-201.mailbox.org [IPv6:2001:67c:2050:0:465::201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 9E92383E62 for ; Mon, 24 Nov 2025 20:42:09 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.vasut@mailbox.org Received: from smtp202.mailbox.org (smtp202.mailbox.org [IPv6:2001:67c:2050:b231:465::202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-201.mailbox.org (Postfix) with ESMTPS id 4dFbnF1hc3z9tDY; Mon, 24 Nov 2025 20:42:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1764013329; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=P3ZJMBthTdVZcpNlmr4NPoNrzATmKOHZc9hDaxYNdp0=; b=D6OD7LsmwSNkOv97iuuxoOzzhcwhhcU7nDoSkTogiwG/bUDnbZp7ZlQvG1lRqtzgcGmCwX AJIZxA0bdO9ViU2pZ4jm1gA6cJ4aChH10tmfhYAAyapg+fbHRw/GCyplaozaH3T0tK0q3x CJvfpd3fudfMB70u5Hv9uyIWEA3chXs9rk1SvPuWvdcx5LwIL+zeTZvED4ojC670q1C6O8 wJ2j+Zkc7tNt+859DqTrHHrvTgbDg9I3wgoDCwYMiLRYpVvAY1lu+fnD721JctYgngf4Qg WnHpq/nHWGvkBAA+lziAzXxbbvqUTx8ucpcKcLBNCwZMR+GYkz2p+6GkWI9cGA== Authentication-Results: outgoing_mbo_mout; dkim=pass header.d=mailbox.org header.s=mail20150812 header.b=kSLCLWeN; spf=pass (outgoing_mbo_mout: domain of marek.vasut@mailbox.org designates 2001:67c:2050:b231:465::202 as permitted sender) smtp.mailfrom=marek.vasut@mailbox.org From: Marek Vasut DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1764013327; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=P3ZJMBthTdVZcpNlmr4NPoNrzATmKOHZc9hDaxYNdp0=; b=kSLCLWeN8r6CjFg1nMoJdhho+/+Abq7wsMi814DLZ2LH7TqsrsGgUy8hwDgMHBqH2TQQKn i7vLjdxcUyq2fz09qKS/fADAUpNNJb4EP/JH1/7BUs9KjXRkjWa11LOf9iH85KdvIGeTw4 HIRLaH4Ui87iKH/ewGNMcsj6Dz13tpNtmIpN0eh04+ktye5oZDo6RVojzAOltRWdh1uV2G EYv33+hdiTh7R+8h7Dctom4Abpeln0peBWnFKUUDdYwD618EwwT0vuYZAMGsH7ZaKhzt0A /DyvUjOhWwApc6Z+RKOjqD1OxoNly09ZCTFSZc80kqeLKVD6aIUN3NZd6Btj0g== To: u-boot@lists.denx.de Cc: Marek Vasut , =?UTF-8?q?Carlos=20L=C3=B3pez?= , Aristo Chen , Ilias Apalodimas , Julien Masson , Mattijs Korpershoek , Mayuresh Chitale , Paul HENRYS , Quentin Schulz , Rasmus Villemoes , Simon Glass , Tom Rini , Wolfgang Wallner , u-boot@dh-electronics.com Subject: [PATCH v2 1/2] test/py: fit: Deduplicate the test Date: Mon, 24 Nov 2025 20:40:24 +0100 Message-ID: <20251124194201.83326-1-marek.vasut@mailbox.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-MBO-RS-META: yn6q9657ucn9hohob1k1q9cqhsfqfduz X-MBO-RS-ID: f36dcc1a9b8106db96e X-Rspamd-Queue-Id: 4dFbnF1hc3z9tDY X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Introduce generate_and_check_fit_image() and call it with various parameters to test various configurations of the fitImage. This is identical to the existing test, expect for the code duplication. Signed-off-by: Marek Vasut --- Cc: "Carlos López" Cc: Aristo Chen Cc: Ilias Apalodimas Cc: Julien Masson Cc: Mattijs Korpershoek Cc: Mayuresh Chitale Cc: Paul HENRYS Cc: Quentin Schulz Cc: Rasmus Villemoes Cc: Simon Glass Cc: Tom Rini Cc: Wolfgang Wallner Cc: u-boot@lists.denx.de Cc: u-boot@dh-electronics.com --- V2: New patch --- test/py/tests/test_fit_auto_signed.py | 98 +++++++++++---------------- 1 file changed, 39 insertions(+), 59 deletions(-) diff --git a/test/py/tests/test_fit_auto_signed.py b/test/py/tests/test_fit_auto_signed.py index 0b5dbd5401c..3895e7d9369 100644 --- a/test/py/tests/test_fit_auto_signed.py +++ b/test/py/tests/test_fit_auto_signed.py @@ -138,6 +138,29 @@ class SignedFitHelper(object): @pytest.mark.buildconfigspec('fit_signature') @pytest.mark.requiredtool('fdtget') def test_fit_auto_signed(ubman): + def generate_and_check_fit_image(cmd, crc=False, simgs=False, scfgs=False, bl31present=False, key_name="", sign_algo="", verifier=""): + """Generate fitImage and test for expected entries. + + Generate a fitImage and test whether suitable entries are part of + the generated fitImage. Test whether checksums and signatures are + part of the generated fitImage. + """ + mkimage = ubman.config.build_dir + '/tools/mkimage' + utils.run_and_log(ubman, mkimage + cmd) + + fit = SignedFitHelper(ubman, fit_file) + if fit.build_nodes_sets() == 0: + raise ValueError('FIT-1 has no "/image" nor "/configuration" nodes') + + if crc: + fit.check_fit_crc32_images() + if simgs: + fit.check_fit_signed_images(key_name, sign_algo, verifier) + if scfgs: + fit.check_fit_signed_confgs(key_name, sign_algo) + + fit.check_fit_loadables(bl31present) + """Test that mkimage generates auto-FIT with signatures/hashes as expected. The mkimage tool can create auto generated (i.e. without an ITS file @@ -150,7 +173,6 @@ def test_fit_auto_signed(ubman): The test does not run the sandbox. It only checks the host tool mkimage. """ - mkimage = ubman.config.build_dir + '/tools/mkimage' tempdir = os.path.join(ubman.config.result_dir, 'auto_fit') os.makedirs(tempdir, exist_ok=True) kernel_file = f'{tempdir}/vmlinuz' @@ -186,39 +208,18 @@ def test_fit_auto_signed(ubman): s_args = " -k" + tempdir + " -g" + key_name + " -o" + sign_algo # 1 - Create auto FIT with images crc32 checksum, and verify it - utils.run_and_log(ubman, mkimage + ' -fauto' + b_args + " " + fit_file) - - fit = SignedFitHelper(ubman, fit_file) - if fit.build_nodes_sets() == 0: - raise ValueError('FIT-1 has no "/image" nor "/configuration" nodes') - - fit.check_fit_crc32_images() - - fit.check_fit_loadables(present=False) + generate_and_check_fit_image(' -fauto' + b_args + " " + fit_file, + crc=True) # 2 - Create auto FIT with signed images, and verify it - utils.run_and_log(ubman, mkimage + ' -fauto' + b_args + s_args + " " + - fit_file) - - fit = SignedFitHelper(ubman, fit_file) - if fit.build_nodes_sets() == 0: - raise ValueError('FIT-2 has no "/image" nor "/configuration" nodes') - - fit.check_fit_signed_images(key_name, sign_algo, verifier) - - fit.check_fit_loadables(present=False) + generate_and_check_fit_image(' -fauto' + b_args + s_args + " " + fit_file, + simgs=True, + key_name=key_name, sign_algo=sign_algo, verifier=verifier) # 3 - Create auto FIT with signed configs and hashed images, and verify it - utils.run_and_log(ubman, mkimage + ' -fauto-conf' + b_args + s_args + " " + - fit_file) - - fit = SignedFitHelper(ubman, fit_file) - if fit.build_nodes_sets() == 0: - raise ValueError('FIT-3 has no "/image" nor "/configuration" nodes') - - fit.check_fit_signed_confgs(key_name, sign_algo) - - fit.check_fit_loadables(present=False) + generate_and_check_fit_image(' -fauto-conf' + b_args + s_args + " " + fit_file, + scfgs=True, + key_name=key_name, sign_algo=sign_algo) # Run the same tests as 1/2/3 above, but this time with TFA BL31 # options -y tfa-bl31.bin -Y 0x12340000 to cover both mkimage with @@ -226,36 +227,15 @@ def test_fit_auto_signed(ubman): b_args = " -d" + kernel_file + " -b" + dt1_file + " -b" + dt2_file + " -y" + tfa_file + " -Y 0x12340000" # 4 - Create auto FIT with images crc32 checksum, and verify it - utils.run_and_log(ubman, mkimage + ' -fauto' + b_args + " " + fit_file) - - fit = SignedFitHelper(ubman, fit_file) - if fit.build_nodes_sets() == 0: - raise ValueError('FIT-4 has no "/image" nor "/configuration" nodes') - - fit.check_fit_crc32_images() - - fit.check_fit_loadables(present=True) + generate_and_check_fit_image(' -fauto' + b_args + " " + fit_file, + crc=True, bl31present=True) # 5 - Create auto FIT with signed images, and verify it - utils.run_and_log(ubman, mkimage + ' -fauto' + b_args + s_args + " " + - fit_file) - - fit = SignedFitHelper(ubman, fit_file) - if fit.build_nodes_sets() == 0: - raise ValueError('FIT-5 has no "/image" nor "/configuration" nodes') - - fit.check_fit_signed_images(key_name, sign_algo, verifier) - - fit.check_fit_loadables(present=True) + generate_and_check_fit_image(' -fauto' + b_args + s_args + " " + fit_file, + simgs=True, bl31present=True, + key_name=key_name, sign_algo=sign_algo, verifier=verifier) # 6 - Create auto FIT with signed configs and hashed images, and verify it - utils.run_and_log(ubman, mkimage + ' -fauto-conf' + b_args + s_args + " " + - fit_file) - - fit = SignedFitHelper(ubman, fit_file) - if fit.build_nodes_sets() == 0: - raise ValueError('FIT-6 has no "/image" nor "/configuration" nodes') - - fit.check_fit_signed_confgs(key_name, sign_algo) - - fit.check_fit_loadables(present=True) + generate_and_check_fit_image(' -fauto-conf' + b_args + s_args + " " + fit_file, + scfgs=True, bl31present=True, + key_name=key_name, sign_algo=sign_algo) -- 2.51.0