diff options
author | Simon Glass <sjg@chromium.org> | 2021-08-19 06:40:33 +0300 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2021-09-16 21:39:40 +0300 |
commit | 2e09008c3c938dac28440d948a27b1c4190f36d2 (patch) | |
tree | 13618b7abd3389e066642046463e61db576eb0c9 /test/ut.c | |
parent | b9274095c2cd1ae42f232c823e9e9557696be91a (diff) | |
download | u-boot-2e09008c3c938dac28440d948a27b1c4190f36d2.tar.xz |
test: Add a way to skip console checking until a string matches
Some tests produce a lot of output that does not need to be individually
checked by an assertion. Add a macro to handle this.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'test/ut.c')
-rw-r--r-- | test/ut.c | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -121,6 +121,32 @@ int ut_check_skipline(struct unit_test_state *uts) return 0; } +int ut_check_skip_to_line(struct unit_test_state *uts, const char *fmt, ...) +{ + va_list args; + int len; + int ret; + + va_start(args, fmt); + len = vsnprintf(uts->expect_str, sizeof(uts->expect_str), fmt, args); + va_end(args); + if (len >= sizeof(uts->expect_str)) { + ut_fail(uts, __FILE__, __LINE__, __func__, + "unit_test_state->expect_str too small"); + return -EOVERFLOW; + } + while (1) { + if (!console_record_avail()) + return -ENOENT; + ret = readline_check(uts); + if (ret < 0) + return ret; + + if (!strcmp(uts->expect_str, uts->actual_str)) + return 0; + } +} + int ut_check_console_end(struct unit_test_state *uts) { int ret; |