[PATCH 43/45] vbe: Add docs and a test for the VBE command

Simon Glass sjg at chromium.org
Sun Sep 25 17:02:46 CEST 2022


After further development this seems to be useful for debugging and
testing. Add documentation and a test.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

 doc/usage/cmd/vbe.rst | 90 +++++++++++++++++++++++++++++++++++++++++++
 doc/usage/index.rst   |  1 +
 test/boot/Makefile    |  1 +
 test/boot/vbe.c       | 69 +++++++++++++++++++++++++++++++++
 4 files changed, 161 insertions(+)
 create mode 100644 doc/usage/cmd/vbe.rst
 create mode 100644 test/boot/vbe.c

diff --git a/doc/usage/cmd/vbe.rst b/doc/usage/cmd/vbe.rst
new file mode 100644
index 00000000000..2b5cdd7d411
--- /dev/null
+++ b/doc/usage/cmd/vbe.rst
@@ -0,0 +1,90 @@
+vbe command
+===========
+
+Synopsis
+--------
+
+::
+
+    vbe list
+    vbe select <name_or_id>
+
+Description
+-----------
+
+The vbe command provides a way to interact with :doc:`../../develop/vbe`. It has
+subcommands for different purposes.
+
+vbe list
+~~~~~~~~
+
+Lists the available VBE bootmeths. These are a subset of all bootmeths, as
+accessed via the :doc:`bootmeth`.
+
+The fields are as follows:
+
+#:
+    Shows the bootmeth sequence number, Use the `bootmeth list` command to see
+    all available bootmeths.
+
+Sel:
+    Indicates the selected bootmeth with an asterisk (`*`).
+
+Device:
+    Name of VBE device, which is taken from the name of its device tree node.
+
+Driver:
+    Name of the VBE driver
+
+Description:
+    Description of the VBE driver
+
+
+vbe select
+~~~~~~~~~~
+
+Allows a particular bootmeth to be selected. Either a sequence number or a
+device name can be provided.
+
+Without any arguments, any selected device is deselected.
+
+
+Examples
+--------
+
+This shows listing and selecting devices::
+
+    => vbe list
+      #  Sel  Device           Driver          Description
+    ---  ---  --------------   --------------  -----------
+      2       firmware0        vbe_simple      VBE simple
+    ---  ---  --------------   --------------  -----------
+    => vbe sel 2
+    => vbe list
+      #  Sel  Device           Driver          Description
+    ---  ---  --------------   --------------  -----------
+      2  *    firmware0        vbe_simple      VBE simple
+    ---  ---  --------------   --------------  -----------
+    => vbe sel
+    => vbe list
+      #  Sel  Device           Driver          Description
+    ---  ---  --------------   --------------  -----------
+      2       firmware0        vbe_simple      VBE simple
+    ---  ---  --------------   --------------  -----------
+
+This shows selecting a VBE device by its name::
+
+    => vbe sel firmware0
+    => vbe list
+      #  Sel  Device           Driver          Description
+    ---  ---  --------------   --------------  -----------
+      2  *    firmware0        vbe_simple      VBE simple
+    ---  ---  --------------   --------------  -----------
+    =>
+
+
+Return value
+------------
+
+The return value $? is set to 0 (true) on success, or 1 (failure) if something
+goes wrong, such as failing to find the bootmeth with `vbe select`.
diff --git a/doc/usage/index.rst b/doc/usage/index.rst
index 73966c6e012..62c898c3575 100644
--- a/doc/usage/index.rst
+++ b/doc/usage/index.rst
@@ -68,6 +68,7 @@ Shell commands
    cmd/size
    cmd/true
    cmd/ums
+   cmd/vbe
    cmd/wdt
 
 Booting OS
diff --git a/test/boot/Makefile b/test/boot/Makefile
index d724629d3b0..167629a03ee 100644
--- a/test/boot/Makefile
+++ b/test/boot/Makefile
@@ -9,3 +9,4 @@ ifdef CONFIG_OF_LIVE
 obj-$(CONFIG_BOOTMETH_VBE_SIMPLE) += vbe_simple.o
 endif
 obj-$(CONFIG_BOOTMETH_VBE) += vbe_fixup.o
+obj-$(CONFIG_CMD_VBE) += vbe.o
diff --git a/test/boot/vbe.c b/test/boot/vbe.c
new file mode 100644
index 00000000000..9653ac5d94b
--- /dev/null
+++ b/test/boot/vbe.c
@@ -0,0 +1,69 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Test for `vbe` command
+ *
+ * Copyright 2022 Google LLC
+ * Written by Simon Glass <sjg at chromium.org>
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <vbe.h>
+#include <test/suites.h>
+#include <test/ut.h>
+#include "bootstd_common.h"
+
+/* Check 'vbe list' command */
+static int vbe_cmd_list(struct unit_test_state *uts)
+{
+	console_record_reset_enable();
+	ut_assertok(run_command("vbe list", 0));
+	ut_assert_nextline("  #  Sel  Device           Driver          Description");
+	ut_assert_nextlinen("---");
+	ut_assert_nextline("  2       firmware0        vbe_simple      VBE simple");
+	ut_assert_nextlinen("---");
+	ut_assert_console_end();
+
+	return 0;
+}
+BOOTSTD_TEST(vbe_cmd_list, UT_TESTF_DM | UT_TESTF_SCAN_FDT);
+
+/* Check 'vbe select' command */
+static int vbe_cmd_select(struct unit_test_state *uts)
+{
+	/* select a device */
+	console_record_reset_enable();
+	ut_assertok(run_command("vbe select 2", 0));
+	ut_assert_console_end();
+
+	ut_assertok(run_command("vbe list", 0));
+	ut_assert_nextline("  #  Sel  Device           Driver          Description");
+	ut_assert_nextlinen("---");
+	ut_assert_nextline("  2  *    firmware0        vbe_simple      VBE simple");
+	ut_assert_nextlinen("---");
+	ut_assert_console_end();
+
+	/* deselect it */
+	ut_assertok(run_command("vbe select", 0));
+	ut_assert_console_end();
+	ut_assertok(run_command("vbe list", 0));
+	ut_assert_nextline("  #  Sel  Device           Driver          Description");
+	ut_assert_nextlinen("---");
+	ut_assert_nextline("  2       firmware0        vbe_simple      VBE simple");
+	ut_assert_nextlinen("---");
+	ut_assert_console_end();
+
+	/* select a device by name */
+	console_record_reset_enable();
+	ut_assertok(run_command("vbe select firmware0", 0));
+	ut_assert_console_end();
+	ut_assertok(run_command("vbe list", 0));
+	ut_assert_nextline("  #  Sel  Device           Driver          Description");
+	ut_assert_nextlinen("---");
+	ut_assert_nextline("  2  *    firmware0        vbe_simple      VBE simple");
+	ut_assert_nextlinen("---");
+	ut_assert_console_end();
+
+	return 0;
+}
+BOOTSTD_TEST(vbe_cmd_select, UT_TESTF_DM | UT_TESTF_SCAN_FDT);
-- 
2.37.3.998.g577e59143f-goog



More information about the U-Boot mailing list