From patchwork Wed Oct 2 13:26:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martyn Welch X-Patchwork-Id: 1992015 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=collabora.com header.i=@collabora.com header.a=rsa-sha256 header.s=mail header.b=YMMdCf2e; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XJbFb3B9Qz1xtY for ; Wed, 2 Oct 2024 23:27:15 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6689F890AD; Wed, 2 Oct 2024 15:26:49 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=collabora.com 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; unprotected) header.d=collabora.com header.i=@collabora.com header.b="YMMdCf2e"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 98F1488FEC; Wed, 2 Oct 2024 15:26:47 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from bali.collaboradmins.com (bali.collaboradmins.com [148.251.105.195]) (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 45A75890A8 for ; Wed, 2 Oct 2024 15:26:44 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=martyn.welch@collabora.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1727875604; bh=KWmsyL/D8qj0AmCLMpLXCLu1GP3j1nu+qvVEqeU8zFk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YMMdCf2ewt5H/tjermz4W6w5B8z6CVvnsGDtCFvaGXu2tIEjglEkER/ZpvzuFn8PF rDzn4EXF6gEu/6DupLI6cD4A4Zlf6jQiJ5FBPXKyLXTVRoooGKHxwcjnd116WFCa9M ZBOUGaAfGalM7G63u6QREvwJCaO4qi8dBXbuDAXnRA3U7cuhI6dIsAs35pgAxk+Pf0 1pxH1gp/vcqsaPS+QkHkPX21xFbZxHoj263muK+LCHlTZLNOxEt84az4/ZTJc3gr2L z6QKwXOwjDVlqe5wD4VG8/euGkh4hAZdLgupIffNJgvq1NmbWN2RaXkWUE6DHolGmX q+DEo4wpaLrHw== Received: from pan.lan (unknown [IPv6:2a00:23c6:c32f:9100::16d]) (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) (Authenticated sender: martyn) by bali.collaboradmins.com (Postfix) with ESMTPSA id B8FBE17E35F3; Wed, 2 Oct 2024 15:26:43 +0200 (CEST) From: Martyn Welch To: Simon Glass , Tom Rini Cc: u-boot@lists.denx.de, Martyn Welch Subject: [PATCH 4/4] test: Add tests for the bootmeth set command Date: Wed, 2 Oct 2024 14:26:33 +0100 Message-ID: <20241002132633.246942-4-martyn.welch@collabora.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241002132633.246942-1-martyn.welch@collabora.com> References: <20241002132633.246942-1-martyn.welch@collabora.com> MIME-Version: 1.0 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 We have added a "set" sub command to bootmeth, add some tests to check it's operation. Signed-off-by: Martyn Welch --- test/boot/bootmeth.c | 47 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/test/boot/bootmeth.c b/test/boot/bootmeth.c index 113b789ea7..659f386228 100644 --- a/test/boot/bootmeth.c +++ b/test/boot/bootmeth.c @@ -130,6 +130,53 @@ static int bootmeth_cmd_order_glob(struct unit_test_state *uts) } BOOTSTD_TEST(bootmeth_cmd_order_glob, UT_TESTF_DM | UT_TESTF_SCAN_FDT); +/* Check 'bootmeth set' command */ +static int bootmeth_cmd_set(struct unit_test_state *uts) +{ + /* Check we can enable extlinux fallback */ + console_record_reset_enable(); + ut_assertok(run_command("bootmeth set extlinux fallback 1", 0)); + ut_assert_console_end(); + + /* Check we can disable extlinux fallback */ + console_record_reset_enable(); + ut_assertok(run_command("bootmeth set extlinux fallback 0", 0)); + ut_assert_console_end(); + + /* Check extlinux fallback unexpected value */ + console_record_reset_enable(); + ut_asserteq(1, run_command("bootmeth set extlinux fallback fred", 0)); + ut_assert_nextline("Unexpected value 'fred'"); + ut_assert_nextline("Failed (err=-22)"); + ut_assert_console_end(); + + /* Check that we need to provide right number of parameters */ + ut_asserteq(1, run_command("bootmeth set extlinux fallback", 0)); + ut_assert_nextline("Required parameters not provided"); + ut_assert_console_end(); + + /* Check that we need to provide a valid bootmethod */ + ut_asserteq(1, run_command("bootmeth set fred fallback 0", 0)); + ut_assert_nextline("Unknown bootmeth 'fred'"); + ut_assert_nextline("Failed (err=-19)"); + ut_assert_console_end(); + + /* Check that we need to provide a valid property */ + ut_asserteq(1, run_command("bootmeth set extlinux fred 0", 0)); + ut_assert_nextline("Invalid option"); + ut_assert_nextline("Failed (err=-22)"); + ut_assert_console_end(); + + /* Check that we need to provide a bootmeth that supports properties */ + ut_asserteq(1, run_command("bootmeth set efi fallback 0", 0)); + ut_assert_nextline("set_property not found"); + ut_assert_nextline("Failed (err=-19)"); + ut_assert_console_end(); + + return 0; +} +BOOTSTD_TEST(bootmeth_cmd_set, UT_TESTF_DM | UT_TESTF_SCAN_FDT); + /* Check 'bootmeths' env var */ static int bootmeth_env(struct unit_test_state *uts) {