]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
test: consider endianness in print_display_buffer
authorHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Sun, 23 Nov 2025 22:57:06 +0000 (23:57 +0100)
committerTom Rini <trini@konsulko.com>
Fri, 5 Dec 2025 14:54:44 +0000 (08:54 -0600)
Hexdumps for types other then byte look different in dependence of the
endianness.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
test/common/print.c

index 23109188317fd166a1c78d34f8d619d6f8ce5b4e..27fdb444d0d465797097cb189a05cd39ee9ffdee 100644 (file)
@@ -202,21 +202,36 @@ 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 */
        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();
        }
 
@@ -313,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 */