aboutsummaryrefslogtreecommitdiff
path: root/test/ut.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2020-07-28 19:41:10 -0600
committerTom Rini <trini@konsulko.com>2020-08-07 22:31:32 -0400
commit33d7edfd5f69b9847bd7affc5481338ec8d7ee39 (patch)
tree94d443118bfa3e3d190165429527a31565d9d78b /test/ut.c
parent7d914bc76b18b644e27d0cf367e745fc2c4fe1c7 (diff)
downloadu-boot-33d7edfd5f69b9847bd7affc5481338ec8d7ee39.zip
u-boot-33d7edfd5f69b9847bd7affc5481338ec8d7ee39.tar.gz
u-boot-33d7edfd5f69b9847bd7affc5481338ec8d7ee39.tar.bz2
test: Add a way to check part of a console line or skip it
Some lines of the output are not worth testing, or not worth testing in their entirety. For example, when checking a hex dump we know that the hex-dump routine can display ASCII so we only need to check the hex bytes, not the ASCII dump. Add a new test macros which can check only part of a console line. Sometimes it is useful to skip a line altogether, so add a macro for that also. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'test/ut.c')
-rw-r--r--test/ut.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/ut.c b/test/ut.c
index c64f0b5..95bdd66 100644
--- a/test/ut.c
+++ b/test/ut.c
@@ -59,6 +59,28 @@ int ut_check_console_line(struct unit_test_state *uts, const char *fmt, ...)
return strcmp(uts->expect_str, uts->actual_str);
}
+int ut_check_console_linen(struct unit_test_state *uts, const char *fmt, ...)
+{
+ va_list args;
+
+ va_start(args, fmt);
+ vsnprintf(uts->expect_str, sizeof(uts->expect_str), fmt, args);
+ va_end(args);
+ console_record_readline(uts->actual_str, sizeof(uts->actual_str));
+
+ return strncmp(uts->expect_str, uts->actual_str,
+ strlen(uts->expect_str));
+}
+
+int ut_check_skipline(struct unit_test_state *uts)
+{
+ if (!console_record_avail())
+ return -ENFILE;
+ console_record_readline(uts->actual_str, sizeof(uts->actual_str));
+
+ return 0;
+}
+
int ut_check_console_end(struct unit_test_state *uts)
{
if (!console_record_avail())