diff options
| author | Simon Glass <[email protected]> | 2021-05-08 07:00:05 -0600 |
|---|---|---|
| committer | Tom Rini <[email protected]> | 2021-06-08 11:39:09 -0400 |
| commit | 0cceb99ac59b1d383488ea3ce6511ffc01da5332 (patch) | |
| tree | 67dc9eb75f3aa6a469eb4c57bfd432139a7958aa /test | |
| parent | 735dd6ef89ebd3e05c1dfaef06aca61046503c63 (diff) | |
display_options: Split print_buffer() into two functions
At present print_buffer() outputs a hex dump but it is not possible to
place this dump in a string. Refactor it into a top-level function which
does the printing and a utility function that dumps a line into a string.
This makes the code more generally useful.
Signed-off-by: Simon Glass <[email protected]>
Diffstat (limited to 'test')
| -rw-r--r-- | test/print_ut.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/print_ut.c b/test/print_ut.c index 86b1a5477e8..e2bcfbef007 100644 --- a/test/print_ut.c +++ b/test/print_ut.c @@ -227,6 +227,32 @@ static int print_display_buffer(struct unit_test_state *uts) } PRINT_TEST(print_display_buffer, UT_TESTF_CONSOLE_REC); +static int print_hexdump_line(struct unit_test_state *uts) +{ + char *linebuf; + u8 *buf; + int i; + + buf = map_sysmem(0, BUF_SIZE); + memset(buf, '\0', BUF_SIZE); + for (i = 0; i < 0x11; i++) + buf[i] = i * 0x11; + + /* Check buffer size calculations */ + linebuf = map_sysmem(0x400, BUF_SIZE); + memset(linebuf, '\xff', BUF_SIZE); + ut_asserteq(-ENOSPC, hexdump_line(0, buf, 1, 0x10, 0, linebuf, 75)); + ut_asserteq(-1, linebuf[0]); + ut_asserteq(0x10, hexdump_line(0, buf, 1, 0x10, 0, linebuf, 76)); + ut_asserteq(0, linebuf[75]); + ut_asserteq(-1, linebuf[76]); + + unmap_sysmem(buf); + + return 0; +} +PRINT_TEST(print_hexdump_line, UT_TESTF_CONSOLE_REC); + static int print_do_hex_dump(struct unit_test_state *uts) { u8 *buf; |
