diff options
Diffstat (limited to 'test/cmd')
| -rw-r--r-- | test/cmd/Makefile | 4 | ||||
| -rw-r--r-- | test/cmd/acpi.c | 52 | ||||
| -rw-r--r-- | test/cmd/bdinfo.c | 15 | ||||
| -rw-r--r-- | test/cmd/fdt.c | 31 | ||||
| -rw-r--r-- | test/cmd/qfw.c | 40 | ||||
| -rw-r--r-- | test/cmd/temperature.c | 2 |
6 files changed, 133 insertions, 11 deletions
diff --git a/test/cmd/Makefile b/test/cmd/Makefile index e71c80a5b2e..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 @@ -27,6 +30,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/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); diff --git a/test/cmd/bdinfo.c b/test/cmd/bdinfo.c index 09f44ee41ed..28d448a0866 100644 --- a/test/cmd/bdinfo.c +++ b/test/cmd/bdinfo.c @@ -161,9 +161,9 @@ static int bdinfo_test_all(struct unit_test_state *uts) ut_assertok(bdinfo_check_mem(uts)); /* CONFIG_SYS_HAS_SRAM testing not supported */ - ut_assertok(test_num_l(uts, "flashstart", 0)); - ut_assertok(test_num_l(uts, "flashsize", 0)); - ut_assertok(test_num_l(uts, "flashoffset", 0)); + ut_check_console_linen(uts, "flashstart"); + ut_check_console_linen(uts, "flashsize"); + ut_check_console_linen(uts, "flashoffset"); ut_assert_nextline("baudrate = %lu bps", env_get_ulong("baudrate", 10, 1234)); ut_assertok(test_num_l(uts, "relocaddr", gd->relocaddr)); @@ -215,8 +215,15 @@ static int bdinfo_test_all(struct unit_test_state *uts) ut_assertok(test_num_l(uts, "malloc base", gd_malloc_start())); } + /* Check arch_print_bdinfo() output */ if (IS_ENABLED(CONFIG_X86)) - ut_check_skip_to_linen(uts, " high end ="); + ut_check_skip_to_linen(uts, "tsc"); + +#ifdef CONFIG_RISCV + ut_check_console_linen(uts, "boot hart"); + if (gd->arch.firmware_fdt_addr) + ut_check_console_linen(uts, "firmware fdt"); +#endif return 0; } diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c index 96a8488e172..4c3c6308ab4 100644 --- a/test/cmd/fdt.c +++ b/test/cmd/fdt.c @@ -10,6 +10,7 @@ #include <fdt_support.h> #include <mapmem.h> #include <asm/global_data.h> +#include <dm/uclass.h> #include <linux/libfdt.h> #include <test/ut.h> @@ -264,7 +265,7 @@ FDT_TEST(fdt_test_addr_resize, UTF_CONSOLE); static int fdt_test_move(struct unit_test_state *uts) { char fdt[256]; - ulong addr, newaddr = 0x10000; + ulong addr, newaddr; const int size = sizeof(fdt); uint32_t ts; void *buf; @@ -274,8 +275,10 @@ static int fdt_test_move(struct unit_test_state *uts) ts = fdt_totalsize(fdt); /* Moved target DT location */ - buf = map_sysmem(newaddr, size); + buf = memalign(8, size); + ut_assertnonnull(buf); memset(buf, 0, size); + newaddr = map_to_sysmem(buf); /* Test moving the working FDT to a new location */ ut_assertok(run_commandf("fdt move %08lx %08lx %x", addr, newaddr, ts)); @@ -287,6 +290,8 @@ static int fdt_test_move(struct unit_test_state *uts) ut_assert_nextline("Total of %d byte(s) were the same", ts); ut_assert_console_end(); + free(buf); + return 0; } FDT_TEST(fdt_test_move, UTF_CONSOLE); @@ -1267,6 +1272,7 @@ static int fdt_test_chosen(struct unit_test_state *uts) { const char *env_bootargs = env_get("bootargs"); char fdt[8192]; + struct udevice *dev; ulong addr; ut_assertok(make_test_fdt(uts, fdt, sizeof(fdt), &addr)); @@ -1280,11 +1286,16 @@ static int fdt_test_chosen(struct unit_test_state *uts) /* Test add new chosen node without initrd */ ut_assertok(run_commandf("fdt chosen")); ut_assertok(run_commandf("fdt print /chosen")); - ut_assert_nextline("chosen {"); + ut_assert(0 < console_record_readline(uts->actual_str, + sizeof(uts->actual_str))); + if (!strcmp("No RNG device", uts->actual_str)) + ut_assert(0 < console_record_readline(uts->actual_str, + sizeof(uts->actual_str))); + ut_asserteq_str("chosen {", uts->actual_str); ut_assert_nextlinen("\tu-boot,version = "); /* Ignore the version string */ if (env_bootargs) ut_assert_nextline("\tbootargs = \"%s\";", env_bootargs); - if (IS_ENABLED(CONFIG_DM_RNG) && + if (!uclass_get_device(UCLASS_RNG, 0, &dev) && !IS_ENABLED(CONFIG_MEASURED_BOOT) && !IS_ENABLED(CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT)) ut_assert_nextlinen("\tkaslr-seed = "); @@ -1294,7 +1305,12 @@ static int fdt_test_chosen(struct unit_test_state *uts) /* Test add new chosen node with initrd */ ut_assertok(run_commandf("fdt chosen 0x1234 0x5678")); ut_assertok(run_commandf("fdt print /chosen")); - ut_assert_nextline("chosen {"); + ut_assert(0 < console_record_readline(uts->actual_str, + sizeof(uts->actual_str))); + if (!strcmp("No RNG device", uts->actual_str)) + ut_assert(0 < console_record_readline(uts->actual_str, + sizeof(uts->actual_str))); + ut_asserteq_str("chosen {", uts->actual_str); ut_assert_nextline("\tlinux,initrd-end = <0x%08x 0x%08x>;", upper_32_bits(0x1234 + 0x5678 - 1), lower_32_bits(0x1234 + 0x5678 - 1)); @@ -1303,7 +1319,7 @@ static int fdt_test_chosen(struct unit_test_state *uts) ut_assert_nextlinen("\tu-boot,version = "); /* Ignore the version string */ if (env_bootargs) ut_assert_nextline("\tbootargs = \"%s\";", env_bootargs); - if (IS_ENABLED(CONFIG_DM_RNG) && + if (!uclass_get_device(UCLASS_RNG, 0, &dev) && !IS_ENABLED(CONFIG_MEASURED_BOOT) && !IS_ENABLED(CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT)) ut_assert_nextlinen("\tkaslr-seed = "); @@ -1319,6 +1335,9 @@ static int fdt_test_apply(struct unit_test_state *uts) char fdt[8192], fdto[8192]; ulong addr, addro; + if (!IS_ENABLED(CONFIG_OF_LIBFDT_OVERLAY)) + return -EAGAIN; + /* Create base DT with __symbols__ node */ ut_assertok(fdt_create(fdt, sizeof(fdt))); ut_assertok(fdt_finish_reservemap(fdt)); 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 <sjg@chromium.org> + */ + +#include <console.h> +#include <dm.h> +#include <mapmem.h> +#include <qfw.h> +#include <dm/test.h> +#include <test/cmd.h> +#include <test/ut.h> + +/* 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); diff --git a/test/cmd/temperature.c b/test/cmd/temperature.c index 309693aa1e8..464d055b94d 100644 --- a/test/cmd/temperature.c +++ b/test/cmd/temperature.c @@ -27,7 +27,7 @@ static int dm_test_cmd_temperature(struct unit_test_state *uts) /* Test that "temperature get thermal" returns expected value */ console_record_reset(); ut_assertok(run_command("temperature get thermal", 0)); - ut_assert_nextline("thermal: 100 C"); + ut_assert_nextline("thermal: 100000 mC"); ut_assert_console_end(); return 0; |
