From: Simon Glass Date: Sun, 1 Sep 2024 22:26:22 +0000 (-0600) Subject: test: mbr: Adjust test to drop 0x X-Git-Url: http://git.dujemihanovic.xyz/html/static/git-favicon.png?a=commitdiff_plain;h=e7474ac6895a340d81d6ee2706e1dd227331adf7;p=u-boot.git test: mbr: Adjust test to drop 0x U-Boot commands typically don't need 0x to specify hex, since they use hex by default. Adding 0x in this test is confusing since it suggests that it is necessary. Drop it from the file. Also use the %#x construct to get the 0x when needed. Signed-off-by: Simon Glass --- diff --git a/test/cmd/mbr.c b/test/cmd/mbr.c index 98a745df6b..c38199740a 100644 --- a/test/cmd/mbr.c +++ b/test/cmd/mbr.c @@ -267,19 +267,19 @@ static int mbr_test_run(struct unit_test_state *uts) ut_assert_console_end(); /* Make sure mmc6 is 12+ MiB in size */ - ut_assertok(run_commandf("mmc read 0x%lx 0x%lx 1", ra, + ut_assertok(run_commandf("mmc read %lx %lx 1", ra, (ulong)0xbffe00 / 0x200)); /* Test one MBR partition */ init_write_buffers(mbr_wbuf, sizeof(mbr_wbuf), ebr_wbuf, sizeof(ebr_wbuf), __LINE__); ut_assertok(build_mbr_parts(mbr_parts_buf, sizeof(mbr_parts_buf), 1)); - ut_assertok(run_commandf("write mmc 6:0 0x%lx 0 1", mbr_wa)); + ut_assertok(run_commandf("write mmc 6:0 %lx 0 1", mbr_wa)); memset(rbuf, 0, sizeof(rbuf)); - ut_assertok(run_commandf("read mmc 6:0 0x%lx 0 1", ra)); + ut_assertok(run_commandf("read mmc 6:0 %lx 0 1", ra)); ut_assertok(memcmp(mbr_wbuf, rbuf, 512)); - ut_assertok(run_commandf("write mmc 6:0 0x%lx 0x%lx 1", ebr_wa, ebr_blk)); + ut_assertok(run_commandf("write mmc 6:0 %lx %lx 1", ebr_wa, ebr_blk)); memset(rbuf, 0, sizeof(rbuf)); - ut_assertok(run_commandf("read mmc 6:0 0x%lx 0x%lx 1", ra, ebr_blk)); + ut_assertok(run_commandf("read mmc 6:0 %lx %lx 1", ra, ebr_blk)); ut_assertok(memcmp(ebr_wbuf, rbuf, 512)); ut_assertf(0 == run_commandf(mbr_parts_buf), "Invalid partitions string: %s\n", mbr_parts_buf); ut_assertok(run_commandf("mbr write mmc 6")); @@ -288,7 +288,7 @@ static int mbr_test_run(struct unit_test_state *uts) ut_assertok(run_commandf("mbr verify mmc 6")); ut_assert_nextline("MBR: verify success!"); memset(rbuf, 0, sizeof(rbuf)); - ut_assertok(run_commandf("read mmc 6:0 0x%lx 0x%lx 1", ra, ebr_blk)); + ut_assertok(run_commandf("read mmc 6:0 %lx %lx 1", ra, ebr_blk)); ut_assertok(memcmp(ebr_wbuf, rbuf, 512)); ut_assert_console_end(); /* @@ -299,23 +299,23 @@ static int mbr_test_run(struct unit_test_state *uts) 000001f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa |..............U.| */ memset(rbuf, 0, sizeof(rbuf)); - ut_assertok(run_commandf("read mmc 6:0 0x%lx 0 1", ra)); + ut_assertok(run_commandf("read mmc 6:0 %lx 0 1", ra)); for (unsigned i = 0; i < mbr_cmp_size; i++) { ut_assertf(rbuf[mbr_cmp_start + i] == mbr_parts_ref_p1[i], - "1P MBR+0x%04X: expected 0x%02X, actual: 0x%02X\n", + "1P MBR+0x%04X: expected %#02X, actual: %#02X\n", mbr_cmp_start + i, mbr_parts_ref_p1[i], rbuf[mbr_cmp_start + i]); } /* Test two MBR partitions */ init_write_buffers(mbr_wbuf, sizeof(mbr_wbuf), ebr_wbuf, sizeof(ebr_wbuf), __LINE__); ut_assertok(build_mbr_parts(mbr_parts_buf, sizeof(mbr_parts_buf), 2)); - ut_assertok(run_commandf("write mmc 6:0 0x%lx 0 1", mbr_wa)); + ut_assertok(run_commandf("write mmc 6:0 %lx 0 1", mbr_wa)); memset(rbuf, 0, sizeof(rbuf)); - ut_assertok(run_commandf("read mmc 6:0 0x%lx 0 1", ra)); + ut_assertok(run_commandf("read mmc 6:0 %lx 0 1", ra)); ut_assertok(memcmp(mbr_wbuf, rbuf, 512)); - ut_assertok(run_commandf("write mmc 6:0 0x%lx 0x%lx 1", ebr_wa, ebr_blk)); + ut_assertok(run_commandf("write mmc 6:0 %lx %lx 1", ebr_wa, ebr_blk)); memset(rbuf, 0, sizeof(rbuf)); - ut_assertok(run_commandf("read mmc 6:0 0x%lx 0x%lx 1", ra, ebr_blk)); + ut_assertok(run_commandf("read mmc 6:0 %lx %lx 1", ra, ebr_blk)); ut_assertok(memcmp(ebr_wbuf, rbuf, 512)); ut_assertf(0 == run_commandf(mbr_parts_buf), "Invalid partitions string: %s\n", mbr_parts_buf); ut_assertok(run_commandf("mbr write mmc 6")); @@ -323,7 +323,7 @@ static int mbr_test_run(struct unit_test_state *uts) ut_assertok(run_commandf("mbr verify mmc 6")); ut_assert_nextline("MBR: verify success!"); memset(rbuf, 0, sizeof(rbuf)); - ut_assertok(run_commandf("read mmc 6:0 0x%lx 0x%lx 1", ra, ebr_blk)); + ut_assertok(run_commandf("read mmc 6:0 %lx %lx 1", ra, ebr_blk)); ut_assertok(memcmp(ebr_wbuf, rbuf, 512)); ut_assert_console_end(); /* @@ -334,23 +334,23 @@ static int mbr_test_run(struct unit_test_state *uts) 000001f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa |..............U.| */ memset(rbuf, 0, sizeof(rbuf)); - ut_assertok(run_commandf("read mmc 6:0 0x%lx 0 1", ra)); + ut_assertok(run_commandf("read mmc 6:0 %lx 0 1", ra)); for (unsigned i = 0; i < mbr_cmp_size; i++) { ut_assertf(rbuf[mbr_cmp_start + i] == mbr_parts_ref_p2[i], - "2P MBR+0x%04X: expected 0x%02X, actual: 0x%02X\n", + "2P MBR+0x%04X: expected %#02X, actual: %#02X\n", mbr_cmp_start + i, mbr_parts_ref_p2[i], rbuf[mbr_cmp_start + i]); } /* Test three MBR partitions */ init_write_buffers(mbr_wbuf, sizeof(mbr_wbuf), ebr_wbuf, sizeof(ebr_wbuf), __LINE__); ut_assertok(build_mbr_parts(mbr_parts_buf, sizeof(mbr_parts_buf), 3)); - ut_assertok(run_commandf("write mmc 6:0 0x%lx 0 1", mbr_wa)); + ut_assertok(run_commandf("write mmc 6:0 %lx 0 1", mbr_wa)); memset(rbuf, 0, sizeof(rbuf)); - ut_assertok(run_commandf("read mmc 6:0 0x%lx 0 1", ra)); + ut_assertok(run_commandf("read mmc 6:0 %lx 0 1", ra)); ut_assertok(memcmp(mbr_wbuf, rbuf, 512)); - ut_assertok(run_commandf("write mmc 6:0 0x%lx 0x%lx 1", ebr_wa, ebr_blk)); + ut_assertok(run_commandf("write mmc 6:0 %lx %lx 1", ebr_wa, ebr_blk)); memset(rbuf, 0, sizeof(rbuf)); - ut_assertok(run_commandf("read mmc 6:0 0x%lx 0x%lx 1", ra, ebr_blk)); + ut_assertok(run_commandf("read mmc 6:0 %lx %lx 1", ra, ebr_blk)); ut_assertok(memcmp(ebr_wbuf, rbuf, 512)); ut_assertf(0 == run_commandf(mbr_parts_buf), "Invalid partitions string: %s\n", mbr_parts_buf); ut_assertok(run_commandf("mbr write mmc 6")); @@ -358,7 +358,7 @@ static int mbr_test_run(struct unit_test_state *uts) ut_assertok(run_commandf("mbr verify mmc 6")); ut_assert_nextline("MBR: verify success!"); memset(rbuf, 0, sizeof(rbuf)); - ut_assertok(run_commandf("read mmc 6:0 0x%lx 0x%lx 1", ra, ebr_blk)); + ut_assertok(run_commandf("read mmc 6:0 %lx %lx 1", ra, ebr_blk)); ut_assertok(memcmp(ebr_wbuf, rbuf, 512)); ut_assert_console_end(); /* @@ -369,23 +369,23 @@ static int mbr_test_run(struct unit_test_state *uts) 000001f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa |..............U.| */ memset(rbuf, 0, sizeof(rbuf)); - ut_assertok(run_commandf("read mmc 6:0 0x%lx 0 1", ra)); + ut_assertok(run_commandf("read mmc 6:0 %lx 0 1", ra)); for (unsigned i = 0; i < mbr_cmp_size; i++) { ut_assertf(rbuf[mbr_cmp_start + i] == mbr_parts_ref_p3[i], - "3P MBR+0x%04X: expected 0x%02X, actual: 0x%02X\n", + "3P MBR+0x%04X: expected %#02X, actual: %#02X\n", mbr_cmp_start + i, mbr_parts_ref_p3[i], rbuf[mbr_cmp_start + i]); } /* Test four MBR partitions */ init_write_buffers(mbr_wbuf, sizeof(mbr_wbuf), ebr_wbuf, sizeof(ebr_wbuf), __LINE__); ut_assertok(build_mbr_parts(mbr_parts_buf, sizeof(mbr_parts_buf), 4)); - ut_assertok(run_commandf("write mmc 6:0 0x%lx 0 1", mbr_wa)); + ut_assertok(run_commandf("write mmc 6:0 %lx 0 1", mbr_wa)); memset(rbuf, 0, sizeof(rbuf)); - ut_assertok(run_commandf("read mmc 6:0 0x%lx 0 1", ra)); + ut_assertok(run_commandf("read mmc 6:0 %lx 0 1", ra)); ut_assertok(memcmp(mbr_wbuf, rbuf, 512)); - ut_assertok(run_commandf("write mmc 6:0 0x%lx 0x%lx 1", ebr_wa, ebr_blk)); + ut_assertok(run_commandf("write mmc 6:0 %lx %lx 1", ebr_wa, ebr_blk)); memset(rbuf, 0, sizeof(rbuf)); - ut_assertok(run_commandf("read mmc 6:0 0x%lx 0x%lx 1", ra, ebr_blk)); + ut_assertok(run_commandf("read mmc 6:0 %lx %lx 1", ra, ebr_blk)); ut_assertok(memcmp(ebr_wbuf, rbuf, 512)); ut_assertf(0 == run_commandf(mbr_parts_buf), "Invalid partitions string: %s\n", mbr_parts_buf); ut_assertok(run_commandf("mbr write mmc 6")); @@ -393,7 +393,7 @@ static int mbr_test_run(struct unit_test_state *uts) ut_assertok(run_commandf("mbr verify mmc 6")); ut_assert_nextline("MBR: verify success!"); memset(rbuf, 0, sizeof(rbuf)); - ut_assertok(run_commandf("read mmc 6:0 0x%lx 0x%lx 1", ra, ebr_blk)); + ut_assertok(run_commandf("read mmc 6:0 %lx %lx 1", ra, ebr_blk)); ut_assertok(memcmp(ebr_wbuf, rbuf, 512)); ut_assert_console_end(); /* @@ -404,23 +404,23 @@ static int mbr_test_run(struct unit_test_state *uts) 000001f0 26 01 0e 87 06 01 00 58 00 00 00 08 00 00 55 aa |&......X......U.| */ memset(rbuf, 0, sizeof(rbuf)); - ut_assertok(run_commandf("read mmc 6:0 0x%lx 0 1", ra)); + ut_assertok(run_commandf("read mmc 6:0 %lx 0 1", ra)); for (unsigned i = 0; i < mbr_cmp_size; i++) { ut_assertf(rbuf[mbr_cmp_start + i] == mbr_parts_ref_p4[i], - "4P MBR+0x%04X: expected 0x%02X, actual: 0x%02X\n", + "4P MBR+0x%04X: expected %#02X, actual: %#02X\n", mbr_cmp_start + i, mbr_parts_ref_p4[i], rbuf[mbr_cmp_start + i]); } /* Test five MBR partitions */ init_write_buffers(mbr_wbuf, sizeof(mbr_wbuf), ebr_wbuf, sizeof(ebr_wbuf), __LINE__); ut_assertok(build_mbr_parts(mbr_parts_buf, sizeof(mbr_parts_buf), 5)); - ut_assertok(run_commandf("write mmc 6:0 0x%lx 0 1", mbr_wa)); + ut_assertok(run_commandf("write mmc 6:0 %lx 0 1", mbr_wa)); memset(rbuf, 0, sizeof(rbuf)); - ut_assertok(run_commandf("read mmc 6:0 0x%lx 0 1", ra)); + ut_assertok(run_commandf("read mmc 6:0 %lx 0 1", ra)); ut_assertok(memcmp(mbr_wbuf, rbuf, 512)); - ut_assertok(run_commandf("write mmc 6:0 0x%lx 0x%lx 1", ebr_wa, ebr_blk)); + ut_assertok(run_commandf("write mmc 6:0 %lx %lx 1", ebr_wa, ebr_blk)); memset(rbuf, 0, sizeof(rbuf)); - ut_assertok(run_commandf("read mmc 6:0 0x%lx 0x%lx 1", ra, ebr_blk)); + ut_assertok(run_commandf("read mmc 6:0 %lx %lx 1", ra, ebr_blk)); ut_assertok(memcmp(ebr_wbuf, rbuf, 512)); ut_assertf(0 == run_commandf(mbr_parts_buf), "Invalid partitions string: %s\n", mbr_parts_buf); ut_assertf(0 == run_commandf("mbr write mmc 6"), "Invalid partitions string: %s\n", mbr_parts_buf); @@ -436,10 +436,10 @@ static int mbr_test_run(struct unit_test_state *uts) 000001f0 26 01 05 a7 26 01 00 58 00 00 00 10 00 00 55 aa |&...&..X......U.| */ memset(rbuf, 0, sizeof(rbuf)); - ut_assertok(run_commandf("read mmc 6:0 0x%lx 0 1", ra)); + ut_assertok(run_commandf("read mmc 6:0 %lx 0 1", ra)); for (unsigned i = 0; i < mbr_cmp_size; i++) { ut_assertf(rbuf[mbr_cmp_start + i] == mbr_parts_ref_p5[i], - "5P MBR+0x%04X: expected 0x%02X, actual: 0x%02X\n", + "5P MBR+0x%04X: expected %#02X, actual: %#02X\n", mbr_cmp_start + i, mbr_parts_ref_p5[i], rbuf[mbr_cmp_start + i]); } /* @@ -450,10 +450,10 @@ static int mbr_test_run(struct unit_test_state *uts) 00b001f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa |..............U.| */ memset(rbuf, 0, sizeof(rbuf)); - ut_assertok(run_commandf("read mmc 6:0 0x%lx 0x%lx 1", ra, ebr_blk)); + ut_assertok(run_commandf("read mmc 6:0 %lx %lx 1", ra, ebr_blk)); for (unsigned i = 0; i < ebr_cmp_size; i++) { ut_assertf(rbuf[ebr_cmp_start + i] == ebr_parts_ref_p5[i], - "5P EBR+0x%04X: expected 0x%02X, actual: 0x%02X\n", + "5P EBR+0x%04X: expected %#02X, actual: %#02X\n", ebr_cmp_start + i, ebr_parts_ref_p5[i], rbuf[ebr_cmp_start + i]); }