From 74545d49c7d1558473118fab0f74de3c5976ee9b Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 29 Oct 2025 15:14:32 +0100 Subject: qfw: Add more fields and a heading to qfw list Update the command to show the size and selected file, since this is useful information at times. Add a heading so it is clear what each field refers to. Add a simple test as well. Signed-off-by: Simon Glass Signed-off-by: Heinrich Schuchardt --- test/cmd/Makefile | 1 + test/cmd/qfw.c | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 test/cmd/qfw.c (limited to 'test/cmd') diff --git a/test/cmd/Makefile b/test/cmd/Makefile index e71c80a5b2e..98731d9bdff 100644 --- a/test/cmd/Makefile +++ b/test/cmd/Makefile @@ -27,6 +27,7 @@ obj-$(CONFIG_CMD_MEM_SEARCH) += mem_search.o ifdef CONFIG_CMD_PCI obj-$(CONFIG_CMD_PCI_MPS) += pci_mps.o endif +obj-$(CONFIG_CMD_QFW) += qfw.o obj-$(CONFIG_CMD_SEAMA) += seama.o ifdef CONFIG_SANDBOX obj-$(CONFIG_CMD_MBR) += mbr.o diff --git a/test/cmd/qfw.c b/test/cmd/qfw.c new file mode 100644 index 00000000000..e615a82b31a --- /dev/null +++ b/test/cmd/qfw.c @@ -0,0 +1,40 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Tests for qfw command + * + * Copyright 2025 Simon Glass + */ + +#include +#include +#include +#include +#include +#include +#include + +/* Test 'qfw list' command */ +static int cmd_test_qfw_list(struct unit_test_state *uts) +{ + struct fw_cfg_file_iter iter; + struct fw_file *file; + struct udevice *dev; + + ut_assertok(uclass_first_device_err(UCLASS_QFW, &dev)); + + ut_assertok(run_command("qfw list", 0)); + ut_assert_nextline(" Addr Size Sel Name"); + ut_assert_nextlinen("--"); + + for (file = qfw_file_iter_init(dev, &iter); !qfw_file_iter_end(&iter); + file = qfw_file_iter_next(&iter)) { + ut_assert_nextline("%16lx %8x %3x %-48s", file->addr, + be32_to_cpu(file->cfg.size), + be16_to_cpu(file->cfg.select), + file->cfg.name); + } + ut_assert_console_end(); + + return 0; +} +CMD_TEST(cmd_test_qfw_list, UTF_CONSOLE); -- cgit v1.3.1 From 893871132e54f0f5bc40ad3eee0bf0388a104b76 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Fri, 31 Oct 2025 20:59:30 +0100 Subject: test: provide test for 'acpi list' command Check that some mandatory ACPI tables exist: - RSDP - RSDT or XSDT - FADT Reviewed-by: Bin Meng Signed-off-by: Heinrich Schuchardt --- test/cmd/Makefile | 3 +++ test/cmd/acpi.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 test/cmd/acpi.c (limited to 'test/cmd') 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 +#include +#include + +#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); -- cgit v1.3.1