summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2023-01-17 20:47:33 +0300
committerTom Rini <trini@konsulko.com>2023-01-24 02:11:40 +0300
commitbd90b092882099afa3786829036c82d6a4241fc8 (patch)
tree062539871ab4506554a1c6251b1cfca9ebb6e6e5 /test
parent3722cc973f092a6fd1724ea06bd18b205e678ddf (diff)
downloadu-boot-bd90b092882099afa3786829036c82d6a4241fc8.tar.xz
bootstd: Add the concept of a bootdev hunter
Some bootdevs must be enumerated before they appear. For example, USB bootdevs are not visible until USB is enumerated. With standard boot this needs to happen automatically, since we only want to enumerate a bus if it is needed. Add a way to define bootdev 'hunters' which can be used to hunt for bootdevs of a given type. Track which ones have been used and add a command to list them. Include a clang work-around which seems to be needed. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'test')
-rw-r--r--test/boot/bootdev.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/test/boot/bootdev.c b/test/boot/bootdev.c
index 1c2a79fb10..a8ca12a3c8 100644
--- a/test/boot/bootdev.c
+++ b/test/boot/bootdev.c
@@ -221,3 +221,55 @@ static int bootdev_test_prio(struct unit_test_state *uts)
return 0;
}
BOOTSTD_TEST(bootdev_test_prio, UT_TESTF_DM | UT_TESTF_SCAN_FDT);
+
+/* Check listing hunters */
+static int bootdev_test_hunter(struct unit_test_state *uts)
+{
+ struct bootstd_priv *std;
+
+ /* get access to the used hunters */
+ ut_assertok(bootstd_get_priv(&std));
+
+ console_record_reset_enable();
+ bootdev_list_hunters(std);
+ ut_assert_nextline("Prio Used Uclass Hunter");
+ ut_assert_nextlinen("----");
+ ut_assert_nextline("(total hunters: 0)");
+ ut_assert_console_end();
+
+ return 0;
+}
+BOOTSTD_TEST(bootdev_test_hunter, UT_TESTF_DM | UT_TESTF_SCAN_FDT);
+
+/* Check 'bootdev hunt' command */
+static int bootdev_test_cmd_hunt(struct unit_test_state *uts)
+{
+ struct bootstd_priv *std;
+
+ /* get access to the used hunters */
+ ut_assertok(bootstd_get_priv(&std));
+
+ console_record_reset_enable();
+ ut_assertok(run_command("bootdev hunt -l", 0));
+ ut_assert_nextline("Prio Used Uclass Hunter");
+ ut_assert_nextlinen("----");
+ ut_assert_nextline("(total hunters: 0)");
+ ut_assert_console_end();
+
+ /* Scan all hunters */
+ ut_assertok(run_command("bootdev hunt", 0));
+ ut_assert_console_end();
+
+ /* List available hunters */
+ ut_assertok(run_command("bootdev hunt -l", 0));
+ ut_assert_nextlinen("Prio");
+ ut_assert_nextlinen("----");
+ ut_assert_nextline("(total hunters: 0)");
+ ut_assert_console_end();
+
+ ut_asserteq(0, std->hunters_used);
+
+ return 0;
+}
+BOOTSTD_TEST(bootdev_test_cmd_hunt, UT_TESTF_DM | UT_TESTF_SCAN_FDT |
+ UT_TESTF_ETH_BOOTDEV);