]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
test: Add tests for the bootmeth set command
authorMartyn Welch <martyn.welch@collabora.com>
Wed, 9 Oct 2024 13:15:41 +0000 (14:15 +0100)
committerTom Rini <trini@konsulko.com>
Tue, 15 Oct 2024 17:38:43 +0000 (11:38 -0600)
We have added a "set" sub command to bootmeth, add some tests to check
it's operation.

Signed-off-by: Martyn Welch <martyn.welch@collabora.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
test/boot/bootmeth.c

index 518d99c4a27bbbc3a6bbc702b442f1c775f91633..18ae6d7fe136b00fa8ae2708cf97bcaf65e6ba83 100644 (file)
@@ -127,6 +127,53 @@ static int bootmeth_cmd_order_glob(struct unit_test_state *uts)
 }
 BOOTSTD_TEST(bootmeth_cmd_order_glob, UTF_DM | UTF_SCAN_FDT | UTF_CONSOLE);
 
+/* 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, UTF_DM | UTF_SCAN_FDT);
+
 /* Check 'bootmeths' env var */
 static int bootmeth_env(struct unit_test_state *uts)
 {