summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2025-12-05 08:55:19 -0600
committerTom Rini <trini@konsulko.com>2025-12-05 08:55:19 -0600
commitb3835a812fd94501f3d1417f5b099c1c25b24d00 (patch)
treed64e15b8ca888e33b3a1071d3e3f29c19907cdf1 /test
parentff258d03b914357c76cfea401ae4e4af39af521f (diff)
parente3d4ab528693419f809a9dcbbb697a7cd3be7086 (diff)
Merge patch series "test: let UNIT_TEST imply CONSOLE_RECORD"
Heinrich Schuchardt <heinrich.schuchardt@canonical.com> says: Many C unit tests are not executed if CONFIG_CONSOLE_RECORD is not set. Hence Tom suggested to let UNIT_TEST imply CONSOLE_RECORD. The first patch makes the skipped C unit tests visible. The rest of the series deals with hidden bugs in our tests. The 'fdt get value' command returned incorrect values on low-endian systems. So this needed fixing too. Link: https://lore.kernel.org/r/20251123225711.227016-1-heinrich.schuchardt@canonical.com
Diffstat (limited to 'test')
-rw-r--r--test/Kconfig2
-rw-r--r--test/Makefile4
-rw-r--r--test/cmd/Makefile4
-rw-r--r--test/cmd/bdinfo.c62
-rw-r--r--test/cmd/fdt.c2
-rw-r--r--test/cmd/font.c4
-rw-r--r--test/cmd/meminfo.c2
-rw-r--r--test/cmd/msr.c4
-rw-r--r--test/common/cread.c9
-rw-r--r--test/common/print.c53
-rw-r--r--test/py/tests/test_ut.py7
11 files changed, 132 insertions, 21 deletions
diff --git a/test/Kconfig b/test/Kconfig
index 77e7cad3984..24105c13304 100644
--- a/test/Kconfig
+++ b/test/Kconfig
@@ -3,6 +3,8 @@ menu "Testing"
config UNIT_TEST
bool "Unit tests"
depends on CMDLINE
+ imply CONSOLE_RECORD
+ imply HEXDUMP
help
Select this to compile in unit tests for various parts of
U-Boot. Test suites will be subcommands of the "ut" command.
diff --git a/test/Makefile b/test/Makefile
index f7ab9a36b2a..5676bd35963 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -9,7 +9,7 @@ obj-$(CONFIG_$(PHASE_)CMDLINE) += cmd_ut.o
obj-y += dm/
obj-$(CONFIG_FUZZ) += fuzz/
ifndef CONFIG_SANDBOX_VPL
-obj-$(CONFIG_UNIT_TEST) += lib/
+obj-y += lib/
endif
ifneq ($(CONFIG_HUSH_PARSER),)
obj-$(CONFIG_$(PHASE_)CMDLINE) += hush/
@@ -19,7 +19,7 @@ obj-y += ut.o
ifeq ($(CONFIG_XPL_BUILD),)
obj-y += boot/
-obj-$(CONFIG_UNIT_TEST) += common/
+obj-y += common/
obj-$(CONFIG_UT_ENV) += env/
obj-$(CONFIG_UT_FDT_OVERLAY) += fdt_overlay/
obj-y += log/
diff --git a/test/cmd/Makefile b/test/cmd/Makefile
index 841763fec02..2476068aee6 100644
--- a/test/cmd/Makefile
+++ b/test/cmd/Makefile
@@ -10,7 +10,7 @@ endif
ifdef CONFIG_CONSOLE_RECORD
obj-$(CONFIG_CMD_PAUSE) += test_pause.o
endif
-obj-y += exit.o
+obj-$(CONFIG_HUSH_PARSER) += exit.o
obj-$(CONFIG_X86) += cpuid.o msr.o
obj-$(CONFIG_CMD_ADDRMAP) += addrmap.o
ifdef CONFIG_CONSOLE_RECORD
@@ -19,7 +19,6 @@ endif
obj-$(CONFIG_CMD_BDI) += bdinfo.o
obj-$(CONFIG_COREBOOT_SYSINFO) += coreboot.o
obj-$(CONFIG_CMD_FDT) += fdt.o
-obj-$(CONFIG_CONSOLE_TRUETYPE) += font.o
obj-$(CONFIG_CMD_HASH) += hash.o
obj-$(CONFIG_CMD_HISTORY) += history.o
obj-$(CONFIG_CMD_I3C) += i3c.o
@@ -33,6 +32,7 @@ endif
obj-$(CONFIG_CMD_QFW) += qfw.o
obj-$(CONFIG_CMD_SEAMA) += seama.o
ifdef CONFIG_SANDBOX
+obj-$(CONFIG_CONSOLE_TRUETYPE) += font.o
obj-$(CONFIG_CMD_MBR) += mbr.o
obj-$(CONFIG_CMD_PINMUX) += pinmux.o
obj-$(CONFIG_CMD_PWM) += pwm.o
diff --git a/test/cmd/bdinfo.c b/test/cmd/bdinfo.c
index 28d448a0866..2b4866a172e 100644
--- a/test/cmd/bdinfo.c
+++ b/test/cmd/bdinfo.c
@@ -156,7 +156,9 @@ static int bdinfo_check_mem(struct unit_test_state *uts)
static int bdinfo_test_all(struct unit_test_state *uts)
{
- ut_assertok(test_num_l(uts, "boot_params", 0));
+ struct bd_info *bd = gd->bd;
+
+ ut_assertok(test_num_l(uts, "boot_params", bd->bi_boot_params));
ut_assertok(bdinfo_check_mem(uts));
@@ -216,14 +218,68 @@ static int bdinfo_test_all(struct unit_test_state *uts)
}
/* Check arch_print_bdinfo() output */
- if (IS_ENABLED(CONFIG_X86))
- ut_check_skip_to_linen(uts, "tsc");
+ if (IS_ENABLED(CONFIG_PPC)) {
+ ut_check_console_linen(uts, "busfreq");
+ if (IS_ENABLED(CONFIG_MPC8xx) || IS_ENABLED(CONFIG_E500))
+ ut_check_console_linen(uts, "immr_base");
+ ut_check_console_linen(uts, "bootflags");
+ ut_check_console_linen(uts, "intfreq");
+ ut_check_console_linen(uts, "addressing");
+ }
+
+ if (IS_ENABLED(CONFIG_X86)) {
+ ut_check_console_linen(uts, "prev table");
+ ut_check_console_linen(uts, "clock_rate");
+ ut_check_console_linen(uts, "tsc_base");
+ ut_check_console_linen(uts, "vendor");
+ if (!IS_ENABLED(CONFIG_X86_64))
+ ut_check_console_linen(uts, " name");
+ ut_check_console_linen(uts, "model");
+ ut_check_console_linen(uts, "phys_addr in bits");
+ ut_check_console_linen(uts, "table start");
+ ut_check_console_linen(uts, "table end");
+ ut_check_console_linen(uts, " high start");
+ ut_check_console_linen(uts, " high end");
+ ut_check_console_linen(uts, "tsc");
+ if (IS_ENABLED(CONFIG_EFI_STUB)) {
+ ut_check_console_linen(uts, "efi_table");
+ ut_check_console_linen(uts, " revision");
+ }
+ }
#ifdef CONFIG_RISCV
ut_check_console_linen(uts, "boot hart");
if (gd->arch.firmware_fdt_addr)
ut_check_console_linen(uts, "firmware fdt");
#endif
+#ifdef CONFIG_ARM
+ ut_check_console_linen(uts, "arch_number");
+#ifdef CFG_SYS_MEM_RESERVE_SECURE
+ if (gd->arch.secure_ram & MEM_RESERVE_SECURE_SECURED)
+ ut_check_console_linen(uts, "Secure ram");
+#endif
+#ifdef CONFIG_RESV_RAM
+ if (gd->arch.resv_ram)
+ ut_check_console_linen(uts, "Reserved ram");
+#endif
+#if !(CONFIG_IS_ENABLED(SYS_ICACHE_OFF) && CONFIG_IS_ENABLED(SYS_DCACHE_OFF))
+ ut_check_console_linen(uts, "TLB addr");
+#endif
+ ut_check_console_linen(uts, "irq_sp");
+ ut_check_console_linen(uts, "sp start");
+#ifdef CONFIG_CLOCKS
+ ut_check_console_linen(uts, "ARM frequency =");
+ ut_check_console_linen(uts, "DSP frequency =");
+ ut_check_console_linen(uts, "DDR frequency =");
+#endif
+#ifdef CONFIG_BOARD_TYPES
+ ut_check_console_linen(uts, "Board Type =");
+#endif
+#if CONFIG_IS_ENABLED(SYS_MALLOC_F)
+ ut_check_console_linen(uts, "Early malloc usage:");
+#endif
+
+#endif /* CONFIG_ARM */
return 0;
}
diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c
index 4c3c6308ab4..8ce888770ac 100644
--- a/test/cmd/fdt.c
+++ b/test/cmd/fdt.c
@@ -494,7 +494,7 @@ static int fdt_test_get_value_common(struct unit_test_state *uts,
* longer is an error. This is a special case for handling hashes.
*/
ut_assertok(fdt_test_get_value_string(uts, node, "regs", NULL,
- "3412000000100000", 0));
+ "0000123400001000", 0));
/* Test getting 0th element of $node node regs property */
ut_assertok(fdt_test_get_value_string(uts, node, "regs", "0", NULL,
diff --git a/test/cmd/font.c b/test/cmd/font.c
index 7ae648d7395..5c52f359a57 100644
--- a/test/cmd/font.c
+++ b/test/cmd/font.c
@@ -10,10 +10,10 @@
#include <video_console.h>
#include <test/ut.h>
-/* Declare a new fdt test */
+/* Declare a new font test */
#define FONT_TEST(_name, _flags) UNIT_TEST(_name, _flags, font)
-/* Test 'fdt addr' resizing an fdt */
+/* Test the 'font' command */
static int font_test_base(struct unit_test_state *uts)
{
struct udevice *dev;
diff --git a/test/cmd/meminfo.c b/test/cmd/meminfo.c
index 53b41e3b49e..40c3520496e 100644
--- a/test/cmd/meminfo.c
+++ b/test/cmd/meminfo.c
@@ -14,7 +14,7 @@
static int cmd_test_meminfo(struct unit_test_state *uts)
{
ut_assertok(run_command("meminfo", 0));
- ut_assert_nextline("DRAM: 256 MiB");
+ ut_assert_nextlinen("DRAM: ");
ut_assert_nextline_empty();
ut_assert_nextline("Region Base Size End Gap");
diff --git a/test/cmd/msr.c b/test/cmd/msr.c
index e9a152ee5bf..7512c83338a 100644
--- a/test/cmd/msr.c
+++ b/test/cmd/msr.c
@@ -12,14 +12,14 @@
static int cmd_test_msr(struct unit_test_state *uts)
{
ut_assertok(run_commandf("msr read 200"));
- ut_assert_nextline("00000000 ffe00006");
+ ut_assert_nextlinen("0000");
ut_assert_console_end();
/* change the first variable msr and see it reflected in the mtrr cmd */
ut_assertok(run_commandf("mtrr"));
ut_assert_nextline("CPU 65537:");
ut_assert_nextlinen("Reg");
- ut_assert_nextlinen("0 Y Back 00000000ffe00000");
+ ut_assert_nextlinen("0 Y Back");
ut_assertok(console_record_reset_enable());
/* change the type from 6 to 5 */
diff --git a/test/common/cread.c b/test/common/cread.c
index 4926c216803..5afc7397212 100644
--- a/test/common/cread.c
+++ b/test/common/cread.c
@@ -90,13 +90,14 @@ static int cread_test(struct unit_test_state *uts)
ut_asserteq(5, cli_readline_into_buffer("-> ", buf, 1));
ut_asserteq_str("abcXx", buf);
- /* check timeout, should be between 1000 and 1050ms */
+ /* check timeout, should be between 900 and 1100ms */
start = get_timer(0);
*buf = '\0';
ut_asserteq(-2, cli_readline_into_buffer("-> ", buf, 1));
- duration = get_timer(start) - 1000;
- ut_assert(duration >= 0);
- ut_assert(duration < 50);
+ printf("get_timer(start): %ld", get_timer(start));
+ duration = get_timer(start);
+ ut_assert(duration >= 900);
+ ut_assert(duration < 1100);
return 0;
}
diff --git a/test/common/print.c b/test/common/print.c
index f33476a36b4..27fdb444d0d 100644
--- a/test/common/print.c
+++ b/test/common/print.c
@@ -4,6 +4,7 @@
*/
#include <command.h>
+#include <compiler.h>
#include <efi_api.h>
#include <display_options.h>
#include <log.h>
@@ -201,21 +202,38 @@ static int print_display_buffer(struct unit_test_state *uts)
/* 16-bit */
print_buffer(0, buf, 2, 9, 0);
+#ifdef __BIG_ENDIAN
+ ut_assert_nextline("00000000: 0011 2233 4455 6677 8899 aabb ccdd eeff ..\"3DUfw........");
+ ut_assert_nextline("00000010: 1000 ..");
+#else
ut_assert_nextline("00000000: 1100 3322 5544 7766 9988 bbaa ddcc ffee ..\"3DUfw........");
ut_assert_nextline("00000010: 0010 ..");
+#endif
ut_assert_console_end();
/* 32-bit */
print_buffer(0, buf, 4, 5, 0);
+#ifdef __BIG_ENDIAN
+ ut_assert_nextline("00000000: 00112233 44556677 8899aabb ccddeeff ..\"3DUfw........");
+ ut_assert_nextline("00000010: 10000000 ....");
+#else
ut_assert_nextline("00000000: 33221100 77665544 bbaa9988 ffeeddcc ..\"3DUfw........");
ut_assert_nextline("00000010: 00000010 ....");
+#endif
ut_assert_console_end();
/* 64-bit */
- print_buffer(0, buf, 8, 3, 0);
- ut_assert_nextline("00000000: 7766554433221100 ffeeddccbbaa9988 ..\"3DUfw........");
- ut_assert_nextline("00000010: 0000000000000010 ........");
- ut_assert_console_end();
+ if (MEM_SUPPORT_64BIT_DATA) {
+ print_buffer(0, buf, 8, 3, 0);
+#ifdef __BIG_ENDIAN
+ ut_assert_nextline("00000000: 0011223344556677 8899aabbccddeeff ..\"3DUfw........");
+ ut_assert_nextline("00000010: 1000000000000000 ........");
+#else
+ ut_assert_nextline("00000000: 7766554433221100 ffeeddccbbaa9988 ..\"3DUfw........");
+ ut_assert_nextline("00000010: 0000000000000010 ........");
+#endif
+ ut_assert_console_end();
+ }
/* ASCII */
buf[1] = 31;
@@ -268,6 +286,9 @@ static int print_do_hex_dump(struct unit_test_state *uts)
int i;
ulong addr;
+ if (!CONFIG_IS_ENABLED(HEXDUMP))
+ return -EAGAIN;
+
buf = calloc(1, BUF_SIZE);
ut_assertnonnull(buf);
addr = map_to_sysmem(buf);
@@ -307,29 +328,53 @@ static int print_do_hex_dump(struct unit_test_state *uts)
/* 16-bit */
print_hex_dump("", DUMP_PREFIX_ADDRESS, 0, 2, buf, 0x12, true);
+#ifdef __BIG_ENDIAN
+ ut_assert_nextline("%0*lx: 0011 2233 4455 6677 8899 aabb ccdd eeff ..\"3DUfw........",
+ IS_ENABLED(CONFIG_PHYS_64BIT) ? 16 : 8, addr);
+ ut_assert_nextline("%0*lx: 1000 ..",
+ IS_ENABLED(CONFIG_PHYS_64BIT) ? 16 : 8,
+ addr + 0x10UL);
+#else
ut_assert_nextline("%0*lx: 1100 3322 5544 7766 9988 bbaa ddcc ffee ..\"3DUfw........",
IS_ENABLED(CONFIG_PHYS_64BIT) ? 16 : 8, addr);
ut_assert_nextline("%0*lx: 0010 ..",
IS_ENABLED(CONFIG_PHYS_64BIT) ? 16 : 8,
addr + 0x10UL);
+#endif
ut_assert_console_end();
/* 32-bit */
print_hex_dump("", DUMP_PREFIX_ADDRESS, 0, 4, buf, 0x14, true);
+#ifdef __BIG_ENDIAN
+ ut_assert_nextline("%0*lx: 00112233 44556677 8899aabb ccddeeff ..\"3DUfw........",
+ IS_ENABLED(CONFIG_PHYS_64BIT) ? 16 : 8, addr);
+ ut_assert_nextline("%0*lx: 10000000 ....",
+ IS_ENABLED(CONFIG_PHYS_64BIT) ? 16 : 8,
+ addr + 0x10UL);
+#else
ut_assert_nextline("%0*lx: 33221100 77665544 bbaa9988 ffeeddcc ..\"3DUfw........",
IS_ENABLED(CONFIG_PHYS_64BIT) ? 16 : 8, addr);
ut_assert_nextline("%0*lx: 00000010 ....",
IS_ENABLED(CONFIG_PHYS_64BIT) ? 16 : 8,
addr + 0x10UL);
+#endif
ut_assert_console_end();
/* 64-bit */
print_hex_dump("", DUMP_PREFIX_ADDRESS, 16, 8, buf, 0x18, true);
+#ifdef __BIG_ENDIAN
+ ut_assert_nextline("%0*lx: 0011223344556677 8899aabbccddeeff ..\"3DUfw........",
+ IS_ENABLED(CONFIG_PHYS_64BIT) ? 16 : 8, addr);
+ ut_assert_nextline("%0*lx: 1000000000000000 ........",
+ IS_ENABLED(CONFIG_PHYS_64BIT) ? 16 : 8,
+ addr + 0x10UL);
+#else
ut_assert_nextline("%0*lx: 7766554433221100 ffeeddccbbaa9988 ..\"3DUfw........",
IS_ENABLED(CONFIG_PHYS_64BIT) ? 16 : 8, addr);
ut_assert_nextline("%0*lx: 0000000000000010 ........",
IS_ENABLED(CONFIG_PHYS_64BIT) ? 16 : 8,
addr + 0x10UL);
+#endif
ut_assert_console_end();
/* ASCII */
diff --git a/test/py/tests/test_ut.py b/test/py/tests/test_ut.py
index cdf54adc600..6d535b5206d 100644
--- a/test/py/tests/test_ut.py
+++ b/test/py/tests/test_ut.py
@@ -11,6 +11,7 @@ import collections
import gzip
import os
import os.path
+import re
import pytest
import utils
@@ -589,3 +590,9 @@ def test_ut(ubman, ut_subtest):
else:
output = ubman.run_command('ut ' + ut_subtest)
assert output.endswith('failures: 0')
+ lastline = output.splitlines()[-1]
+ if "skipped: 0," not in lastline:
+ match = re.search(r'skipped:\s*(\d+),', lastline)
+ if match:
+ count = match.group(1)
+ pytest.skip(f'Test {ut_subtest} has {count} skipped sub-test(s).')