diff options
| author | Tom Rini <[email protected]> | 2021-09-22 14:54:21 -0400 |
|---|---|---|
| committer | Tom Rini <[email protected]> | 2021-09-22 14:54:21 -0400 |
| commit | 63823da4b9e25d2f6a81f1e9adb06391837055cb (patch) | |
| tree | 3ee694f9c5342307b1bbb4123276a5eeff77d57f /include/test | |
| parent | 44131caa4025455a659e958281f0e337bdf83f89 (diff) | |
| parent | 121a165c51cd281e61c9d45c3919608af42ca9cd (diff) | |
Merge branch '2021-09-22-general-updates' into next
- Some sandbox improvements
- Make cleanups related to the overusage of the exact build time
variable.
Diffstat (limited to 'include/test')
| -rw-r--r-- | include/test/ut.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/include/test/ut.h b/include/test/ut.h index 656e25fe574..fb2e5fcff2c 100644 --- a/include/test/ut.h +++ b/include/test/ut.h @@ -83,6 +83,21 @@ int ut_check_console_linen(struct unit_test_state *uts, const char *fmt, ...) int ut_check_skipline(struct unit_test_state *uts); /** + * ut_check_skip_to_line() - skip output until a line is found + * + * This creates a string and then checks it against the following lines of + * console output obtained with console_record_readline() until it is found. + * + * After the function returns, uts->expect_str holds the expected string and + * uts->actual_str holds the actual string read from the console. + * + * @uts: Test state + * @fmt: printf() format string to look for, followed by args + * @return 0 if OK, -ENOENT if not found, other value on error + */ +int ut_check_skip_to_line(struct unit_test_state *uts, const char *fmt, ...); + +/** * ut_check_console_end() - Check there is no more console output * * After the function returns, uts->actual_str holds the actual string read @@ -286,6 +301,15 @@ int ut_check_console_dump(struct unit_test_state *uts, int total_bytes); return CMD_RET_FAILURE; \ } \ +/* Assert that a following console output line matches */ +#define ut_assert_skip_to_line(fmt, args...) \ + if (ut_check_skip_to_line(uts, fmt, ##args)) { \ + ut_failf(uts, __FILE__, __LINE__, __func__, \ + "console", "\nExpected '%s',\n got to '%s'", \ + uts->expect_str, uts->actual_str); \ + return CMD_RET_FAILURE; \ + } \ + /* Assert that there is no more console output */ #define ut_assert_console_end() \ if (ut_check_console_end(uts)) { \ |
