[PATCH v3 12/40] test: mbr: Adjust test to drop 0x
Simon Glass
sjg at chromium.org
Sun Aug 11 16:51:41 CEST 2024
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 <sjg at chromium.org>
---
(no changes since v1)
test/cmd/mbr.c | 74 +++++++++++++++++++++++++-------------------------
1 file changed, 37 insertions(+), 37 deletions(-)
diff --git a/test/cmd/mbr.c b/test/cmd/mbr.c
index 4c884af10c7..1a35ba3351c 100644
--- a/test/cmd/mbr.c
+++ b/test/cmd/mbr.c
@@ -268,19 +268,19 @@ static int mbr_test_run(struct unit_test_state *uts)
ut_assertok(ut_check_console_end(uts));
/* 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_assertok(console_record_reset_enable());
ut_assertf(0 == run_commandf(mbr_parts_buf), "Invalid partitions string: %s\n", mbr_parts_buf);
@@ -289,7 +289,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_assertok(ut_check_console_end(uts));
/*
@@ -300,23 +300,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_assertok(console_record_reset_enable());
ut_assertf(0 == run_commandf(mbr_parts_buf), "Invalid partitions string: %s\n", mbr_parts_buf);
@@ -325,7 +325,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_assertok(ut_check_console_end(uts));
/*
@@ -336,23 +336,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_assertok(console_record_reset_enable());
ut_assertf(0 == run_commandf(mbr_parts_buf), "Invalid partitions string: %s\n", mbr_parts_buf);
@@ -361,7 +361,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_assertok(ut_check_console_end(uts));
/*
@@ -372,23 +372,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_assertok(console_record_reset_enable());
ut_assertf(0 == run_commandf(mbr_parts_buf), "Invalid partitions string: %s\n", mbr_parts_buf);
@@ -397,7 +397,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_assertok(ut_check_console_end(uts));
/*
@@ -408,23 +408,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_assertok(console_record_reset_enable());
ut_assertf(0 == run_commandf(mbr_parts_buf), "Invalid partitions string: %s\n", mbr_parts_buf);
@@ -441,10 +441,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]);
}
/*
@@ -455,10 +455,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]);
}
--
2.34.1
More information about the U-Boot
mailing list