Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | // 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 <asm/global_data.h> #include <dm/test.h> #include <test/cmd.h> #include <test/ut.h> DECLARE_GLOBAL_DATA_PTR; /* 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("%8lx %8x %3x %-56s", 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); /* Test 'qfw dump' command */ static int cmd_test_qfw_dump(struct unit_test_state *uts) { if (IS_ENABLED(CONFIG_SANDBOX)) return -EAGAIN; ut_assertok(run_command("qfw dump", 0)); ut_assert_nextline("signature = QEMU"); ut_assert_nextlinen("id"); ut_assert_nextlinen("uuid = 00000000-0000-0000-0000-000000000000"); ut_assert_nextline("ram_size = %#.*lx", 2 * (int)sizeof(ulong), (ulong)gd->ram_size); ut_assert_skip_to_linen("file dir le ="); ut_assert_console_end(); return 0; } CMD_TEST(cmd_test_qfw_dump, UTF_CONSOLE); /* Test 'qfw table' command */ static int cmd_test_qfw_table(struct unit_test_state *uts) { if (IS_ENABLED(CONFIG_SANDBOX)) return -EAGAIN; ut_assertok(run_command("qfw table", 0)); ut_assert_nextline(" 0 alloc: align 10 zone fseg name 'etc/acpi/rsdp'"); ut_assert_nextline(" 1 alloc: align 40 zone high name 'etc/acpi/tables'"); /* * we can't really test anything else as it may vary, so just check that * there is more output after this */ ut_asserteq(true, ut_check_console_end(uts)); return 0; } CMD_TEST(cmd_test_qfw_table, UTF_CONSOLE); /* Test 'qfw arch' command */ static int cmd_test_qfw_arch(struct unit_test_state *uts) { /* * this test is really only useful on x86, which has some entries, but * since the implementation of the 'qfw arch' command is generic, we can * expect that it works on ARM too */ ut_assertok(run_command("qfw arch", 0)); if (IS_ENABLED(CONFIG_X86)) { ut_assert_nextline("acpi tables = 0x00000000"); ut_asserteq(true, ut_check_console_end(uts)); } return 0; } CMD_TEST(cmd_test_qfw_arch, UTF_CONSOLE); /* Test 'qfw read' command */ static int cmd_test_qfw_read(struct unit_test_state *uts) { char *ptr = map_sysmem(0x1000, 0x100); if (IS_ENABLED(CONFIG_SANDBOX)) return -EAGAIN; ut_assertok(run_command("qfw read 1000 etc/acpi/rsdp", 0)); ut_asserteq_strn("RSD PTR ", ptr); return 0; } CMD_TEST(cmd_test_qfw_read, UTF_CONSOLE); /* Test 'qfw e820' command */ static int cmd_test_qfw_e820(struct unit_test_state *uts) { int ret; ret = run_command("qfw e820", 0); if (!IS_ENABLED(CONFIG_X86)) { ut_asserteq(1, ret); return 0; } ut_assertok(ret); ut_assert_nextline(" Addr Size Type"); return 0; } CMD_TEST(cmd_test_qfw_e820, UTF_CONSOLE); |