From patchwork Tue Sep 30 00:51:20 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 440 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=1759193529; bh=+q5D60luvvpUdNRuVgCwMs/BHRYTSXuy+y4NyNYF+U4=; 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=S6Jn+nIdMpJiJIhFYpGw75a0MGRZn+5dvtOI0YOOmVeUyjdSgUR+DtzFYgfza/MbR 11H3pbRUANM+UuClYpl8xICgovJd9SNWsYSTiB9lnPn3kvrWUA2FEtPaEQhBwb+q6o qIytmeAv19IDFJXiE34Ofl+y0tBfuRXn6rT/rqcXnCYQ2EN7aaaYcIVhmb+MJfVzOq wAZClYVPhB7TRrby8sVv2ZS8kuBJTi10H2s54bu5qGg6UaOo5WHEwOyg1MXj1OXeHv ELemQ/cL2yI1fIZcUxp3hZNjuCKkGizDTgq5m7+Z6UYspp4j+XjXIpV9i8XC/cJDMc 62hJnVcDjDRgA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3267C67E58 for ; Mon, 29 Sep 2025 18:52:09 -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 Yeyf6AarbW3N for ; Mon, 29 Sep 2025 18:52:09 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193527; bh=+q5D60luvvpUdNRuVgCwMs/BHRYTSXuy+y4NyNYF+U4=; 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=wjywsxd9fsmyJfupLlhAjucIBVY2MOjf5vdH4YFU2CIjP9deeNMEkUX2l+UADIiHv hell0A2HlHEd9fEt7pb8z+HUzKWMTyx+muP/kYqSvYV564gNnRxMw21lJyY4tzTm8f AIhHVJZqAicnUnTlqYYruDrZ/UAEjP76obTZL6GwzcECgFS1Gh+a0kF5QdYGsAiAsX vS7BcK7kqyrHqtI3emSQdSUMl04Ol7cYYQ7y178HdMKOnuNh9OlhwZ364+arQRFUDb jPSJWAzq8Fxtoo+Q6CrtShEMLwtFMNyx8yD7NsR8iUObUIPaOyd9KUeYZuRl2VwTkw UOG9hnZNc5owA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 5BD0267E31 for ; Mon, 29 Sep 2025 18:52:07 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193524; bh=fnaE2Mkfp7R6C4jl/Ia/Gdz2unY6ryieVx3BA7M3fHc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K9SJe0gkDCAEZO9pE3dESyxFLUBxycgBWZ00r/EiBFvSW5u72DvmrmH51BIYevQSJ UZVfovBQCTNtLWkgbPtO6tHj4PRtAplSs7/C/vu1u0K8Ji+SNCawUyqHDSfg9Sw3Ti 2Si1cx2y2W6K1fc2+QeEXGgQ7zszQbo+Q4hNIpPeETXdwTiCU3iqifP+OTBq9INanf m4hvwJ/LsCEQAS09eYdbcSKYUdzafm+8c2O6p+3QnyiAe3j7bJ1mk5hwmUFLhKeU4q l5tk7WMlldWX7A/k9NHuTuQRzQ8L+cGKayFROOJyqQdTjgi+A77MLl7Vwp/W9MWkEU EuPkb2qSbsEOQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id BE5A767E03; Mon, 29 Sep 2025 18:52:04 -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 2srPisFW8rWt; Mon, 29 Sep 2025 18:52:04 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193523; bh=gbXQhbC8CnvNMbDQwm7n6+vAP5FODcnYEoYlHkQzTXY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=v9qI02ek4wAxYS/RsrIFefv6hci/vTurGabHerYKYV4kFnIJ414zKMLLfrHdroGgU vVItNHKqKp82LokQi7aT6vQyFfv0kI69XPfAF8AQyM+4eJNjVHYzYG5Zr/fXtXaQiR 3YM4Mug6/FX06FBwD3jK9dvQNsh63Hnqb7vc/rQiyUcRyPS6wJDzZK1ZbgvoqZo+4x 5drM9sPlSg1ICcGRTs2luQVjLcBdUF+w2gMc/EWKrW/3/hGBztv+qbnp8wqhuNCxzv qDhjQCaRoKjRddpvLl9OYezroMZXXRt4RmrUOB29nyQMEQFNZFUxVqTd7UmhPoKMjl M/uxFT3fJN2Ig== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id BF25C67E5D; Mon, 29 Sep 2025 18:52:02 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 29 Sep 2025 18:51:20 -0600 Message-ID: <20250930005137.3650600-5-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250930005137.3650600-1-sjg@u-boot.org> References: <20250930005137.3650600-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 6BSH4OFOJHM3GNGI3ZLJXULOWHONUHGE X-Message-ID-Hash: 6BSH4OFOJHM3GNGI3ZLJXULOWHONUHGE 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 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 --- 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) {