summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorHeinrich Schuchardt <[email protected]>2025-10-31 20:59:30 +0100
committerHeinrich Schuchardt <[email protected]>2025-11-06 23:26:27 +0100
commit893871132e54f0f5bc40ad3eee0bf0388a104b76 (patch)
tree78d7476b69d30f6e47b609368786d233b264734e /test
parent33355013ffce4fe58d552db3dd546ecf197a7a9b (diff)
test: provide test for 'acpi list' command
Check that some mandatory ACPI tables exist: - RSDP - RSDT or XSDT - FADT Reviewed-by: Bin Meng <[email protected]> Signed-off-by: Heinrich Schuchardt <[email protected]>
Diffstat (limited to 'test')
-rw-r--r--test/cmd/Makefile3
-rw-r--r--test/cmd/acpi.c52
2 files changed, 55 insertions, 0 deletions
diff --git a/test/cmd/Makefile b/test/cmd/Makefile
index 98731d9bdff..841763fec02 100644
--- a/test/cmd/Makefile
+++ b/test/cmd/Makefile
@@ -13,6 +13,9 @@ endif
obj-y += exit.o
obj-$(CONFIG_X86) += cpuid.o msr.o
obj-$(CONFIG_CMD_ADDRMAP) += addrmap.o
+ifdef CONFIG_CONSOLE_RECORD
+obj-$(CONFIG_CMD_ACPI) += acpi.o
+endif
obj-$(CONFIG_CMD_BDI) += bdinfo.o
obj-$(CONFIG_COREBOOT_SYSINFO) += coreboot.o
obj-$(CONFIG_CMD_FDT) += fdt.o
diff --git a/test/cmd/acpi.c b/test/cmd/acpi.c
new file mode 100644
index 00000000000..3669060733a
--- /dev/null
+++ b/test/cmd/acpi.c
@@ -0,0 +1,52 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Tests for acpi command
+ */
+
+#include <linux/bitops.h>
+#include <test/cmd.h>
+#include <test/ut.h>
+
+#define HAVE_RSDP BIT(0)
+#define HAVE_XSDT BIT(1)
+#define HAVE_FADT BIT(2)
+#define HAVE_ALL (HAVE_RSDP | HAVE_XSDT | HAVE_FADT)
+
+/**
+ * cmd_test_acpi() - test the acpi command
+ */
+static int cmd_test_acpi(struct unit_test_state *uts)
+{
+ unsigned int actual = 0;
+ int ret;
+
+ /*
+ * Check that some mandatory ACPI tables exist:
+ * - RSDP
+ * - RSDT or XSDT
+ * - FADT
+ */
+ ut_assertok(run_commandf("acpi list"));
+ ut_assert_nextline("Name Base Size Detail");
+ ut_assert_nextline("---- ---------------- ----- ----------------------------");
+ for (;;) {
+ ret = console_record_readline(uts->actual_str, sizeof(uts->actual_str));
+ if (ret == -ENOENT) {
+ ut_asserteq(HAVE_ALL, actual);
+
+ return 0;
+ }
+ if (ret < 0)
+ ut_asserteq(0, ret);
+
+ if (!strncmp("RSDP", uts->actual_str, 4))
+ actual |= HAVE_RSDP;
+ else if (!strncmp("RSDT", uts->actual_str, 4))
+ actual |= HAVE_XSDT;
+ else if (!strncmp("XSDT", uts->actual_str, 4))
+ actual |= HAVE_XSDT;
+ else if (!strncmp("FACP", uts->actual_str, 4))
+ actual |= HAVE_FADT;
+ }
+}
+CMD_TEST(cmd_test_acpi, UTF_CONSOLE);