From patchwork Tue Sep 30 23:25:41 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 455 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=1759274803; bh=4FVS1NioSIAehLUxZ79JKhQKuYJzelLfc7SXc1p1JGs=; 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=osPqNwprbf/qiyXijkcz/gXBhGOsIWv80fO+X0fvLAF77O/XbGm8Ik2HUGaXs130a KMn2rEfytGYZ7Ev1PujI7KQIftUEb0sLLJKyapaCPWYAUGm0P8rw9lu9yl2varmCIE AHRgcoaO98ZFUVcsjTzYOAFvNSDHN1l7dOxv5IGR0KRMGDRvjwxPjGl/IRRRL4mPWT 0fyv10oFkEh2HEFQJ0ytHuPm1HKlx+hQL3K0PA/KYpAV+SnifO13sYaYjLtUDesbWm 57ZdDAdNtDdgRJawnBIdDSFCW5uPoGbwayj1yLaXrQrMVVwwifXDSeke5uau16j3gN 00YPbQg9gtOgw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B69FB67E2F for ; Tue, 30 Sep 2025 17:26:43 -0600 (MDT) 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 UMZ0o8gCkQnb for ; Tue, 30 Sep 2025 17:26:43 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759274803; bh=4FVS1NioSIAehLUxZ79JKhQKuYJzelLfc7SXc1p1JGs=; 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=osPqNwprbf/qiyXijkcz/gXBhGOsIWv80fO+X0fvLAF77O/XbGm8Ik2HUGaXs130a KMn2rEfytGYZ7Ev1PujI7KQIftUEb0sLLJKyapaCPWYAUGm0P8rw9lu9yl2varmCIE AHRgcoaO98ZFUVcsjTzYOAFvNSDHN1l7dOxv5IGR0KRMGDRvjwxPjGl/IRRRL4mPWT 0fyv10oFkEh2HEFQJ0ytHuPm1HKlx+hQL3K0PA/KYpAV+SnifO13sYaYjLtUDesbWm 57ZdDAdNtDdgRJawnBIdDSFCW5uPoGbwayj1yLaXrQrMVVwwifXDSeke5uau16j3gN 00YPbQg9gtOgw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A154F67B7A for ; Tue, 30 Sep 2025 17:26:43 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759274801; bh=8J13CLY6z7tjlARlmfYz7Y+b3aqU7lDFEHlXTVK+8go=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XtW2W63u2KpMIia6k9xf2l/oQz8uwltCSSJyRXT+qcrmUlkZz1UYbEQO6aAhJnp0A dNjEjGP8MyBQ8ZdMnUqHjAwamISEM7TRSV8gok+QoGQH8hinvPjA1J9QWqo6PWJjT1 hK0vmFXO6NT50rYhA4KHKuzvbLy2Ew/n5/IXvXTDi0HGjoBsFYLU6NmacvW2VtIKMI nlQ5OVy3P9pn+eJv60xOSFFU6Wwx0q5DCXfUxqYjGUyOwrkNrSLu0mocV/0rbn6nUJ pEGSLlT9EEQx4pJElA6zFrVRi6pKi03AemPWfxXlNhVY8z/IzEFRuwb96FAUF85u57 eDqMsKs+88FaA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7DAE367B7A; Tue, 30 Sep 2025 17:26:41 -0600 (MDT) 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 X2D13m2i1Ax9; Tue, 30 Sep 2025 17:26:41 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759274797; bh=wcXOjhbV8ZhYzEAqGL+qZv+Z2DUaq9DJMfb8+LAfFPs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vf9c+zmp9F1/gum5ou9ESzOWP8Ab5miafo7DKa1mdqrTLzQq3yJFwWXOWYqquMnDT bZCtiCbwqwwhsghM3QKPF8oyisCGLH7RW2wBfuIl4+F+OBO15Y4W96ttb9Bvarkto3 pY0iZghC1fGey/tTEDmLysrhz+rjdVq5mNjksxQtMvAh5dL517ptAbnamUcfdmV6rT Yi5uyrYX1pE8OaaNOwnUVrYS6PV19UlB6/U6guKgWrxWzOuvUj0MnqzieQLJbHT3Vo 65JizVXd5qKKQ7n8h9GifqIQaEUkgFilx6gh2GETZaUJqFvi0ZBQz7gAWXpsTM+Ish y93ml5FXU/JqA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 329BA67E2E; Tue, 30 Sep 2025 17:26:37 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Tue, 30 Sep 2025 17:25:41 -0600 Message-ID: <20250930232611.1564850-5-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250930232611.1564850-1-sjg@u-boot.org> References: <20250930232611.1564850-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: KNSIPMXLB4ZTX4QQWRBOSF3CAUKSWMWB X-Message-ID-Hash: KNSIPMXLB4ZTX4QQWRBOSF3CAUKSWMWB 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH v2 04/15] boot: Add a new test for global bootmeths 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 These have different behaviour from normal bootmeths and we are about to enhance it. So add a test and also an extra check in bootflow_iter() Signed-off-by: Simon Glass --- (no changes since v1) test/boot/bootflow.c | 45 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c index be85032985d..69a965dfa4b 100644 --- a/test/boot/bootflow.c +++ b/test/boot/bootflow.c @@ -313,6 +313,8 @@ static int bootflow_iter(struct unit_test_state *uts) ut_asserteq(0, iter.max_part); ut_asserteq_str("extlinux", iter.method->name); ut_asserteq(0, bflow.err); + ut_assert(!iter.doing_global); + ut_asserteq(-1, iter.first_glob_method); /* * This shows MEDIA even though there is none, since in @@ -426,6 +428,49 @@ static int bootflow_iter(struct unit_test_state *uts) BOOTSTD_TEST(bootflow_iter, UTF_DM | UTF_SCAN_FDT | UTF_CONSOLE); #if defined(CONFIG_SANDBOX) && defined(CONFIG_BOOTMETH_GLOBAL) + +/* Check iterating through available bootflows to test global bootmeths */ +static int bootflow_iter_glob(struct unit_test_state *uts) +{ + struct bootflow_iter iter; + struct bootflow bflow; + + bootstd_clear_glob(); + + /* we should get the global bootmeth initially */ + ut_asserteq(-EINVAL, + bootflow_scan_first(NULL, NULL, &iter, BOOTFLOWIF_ALL | + BOOTFLOWIF_SHOW, &bflow)); + bootflow_show(0, &bflow, true); + ut_asserteq(4, iter.num_methods); + ut_assert(iter.doing_global); + ut_asserteq(3, iter.first_glob_method); + + ut_asserteq(3, iter.cur_method); + ut_asserteq(0, iter.part); + ut_asserteq(0, iter.max_part); + ut_asserteq_str("firmware0", iter.method->name); + ut_asserteq(0, bflow.err); + bootflow_free(&bflow); + + /* next we should get the first non-global bootmeth */ + ut_asserteq(-EPROTONOSUPPORT, bootflow_scan_next(&iter, &bflow)); + + /* at this point the global bootmeths are stranded above num_methods */ + ut_asserteq(3, iter.num_methods); + ut_asserteq(3, iter.first_glob_method); + ut_assert(!iter.doing_global); + + ut_asserteq(0, iter.cur_method); + ut_asserteq(0, iter.part); + ut_asserteq(0, iter.max_part); + ut_asserteq_str("extlinux", iter.method->name); + ut_asserteq(0, bflow.err); + + return 0; +} +BOOTSTD_TEST(bootflow_iter_glob, UTF_DM | UTF_SCAN_FDT); + /* Check using the system bootdev */ static int bootflow_system(struct unit_test_state *uts) {