diff options
author | Simon Glass <sjg@chromium.org> | 2021-05-08 07:00:06 -0600 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2021-06-08 11:39:09 -0400 |
commit | 58b4b7133aba6fbb2409a975478157f9277c2e91 (patch) | |
tree | 134665e40bcbbfd82b1e42729c11f00de345390d /test | |
parent | 0cceb99ac59b1d383488ea3ce6511ffc01da5332 (diff) | |
download | u-boot-58b4b7133aba6fbb2409a975478157f9277c2e91.tar.gz |
log: Add support for logging a buffer
The print_buffer() function is very useful for debugging. Add a version
of this in the log system also.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'test')
-rw-r--r-- | test/log/log_test.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/log/log_test.c b/test/log/log_test.c index 4a814ff413..f1e67509c1 100644 --- a/test/log/log_test.c +++ b/test/log/log_test.c @@ -429,3 +429,30 @@ int log_test_dropped(struct unit_test_state *uts) return 0; } LOG_TEST_FLAGS(log_test_dropped, UT_TESTF_CONSOLE_REC); + +/* Check log_buffer() */ +int log_test_buffer(struct unit_test_state *uts) +{ + u8 *buf; + int i; + + buf = malloc(0x20); + ut_assertnonnull(buf); + memset(buf, '\0', 0x20); + for (i = 0; i < 0x11; i++) + buf[i] = i * 0x11; + + ut_assertok(console_record_reset_enable()); + log_buffer(LOGC_BOOT, LOGL_INFO, 0, buf, 1, 0x12, 0); + + /* This one should product no output due to the debug level */ + log_buffer(LOGC_BOOT, LOGL_DEBUG, 0, buf, 1, 0x12, 0); + + ut_assert_nextline("00000000: 00 11 22 33 44 55 66 77 88 99 aa bb cc dd ee ff ..\"3DUfw........"); + ut_assert_nextline("00000010: 10 00 .."); + ut_assert_console_end(); + free(buf); + + return 0; +} +LOG_TEST_FLAGS(log_test_buffer, UT_TESTF_CONSOLE_REC); |