aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2023-10-01 19:15:13 -0600
committerTom Rini <trini@konsulko.com>2023-12-13 18:39:05 -0500
commit30a75e77946b8b2f4ed26e207bba3e4828629fee (patch)
tree0f3c7fea1a9473c591b54c4a5d1179ce726d9be8 /test
parent4001e5ab9b9bd4735798477531c68cdf26951d7c (diff)
downloadu-boot-30a75e77946b8b2f4ed26e207bba3e4828629fee.zip
u-boot-30a75e77946b8b2f4ed26e207bba3e4828629fee.tar.gz
u-boot-30a75e77946b8b2f4ed26e207bba3e4828629fee.tar.bz2
test: Add helper to skip to partial console line
Sometimes we need to skip to a line but it includes addresses or other information which can vary depending on the runtime conditions. Add a new ut_assert_skip_to_linen() which is similar to the existing ut_assert_skip_to_line() function but only checks that the console line matches up to the length of the provided string. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'test')
-rw-r--r--test/ut.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/ut.c b/test/ut.c
index 28da417..628e9dc 100644
--- a/test/ut.c
+++ b/test/ut.c
@@ -121,6 +121,33 @@ int ut_check_skipline(struct unit_test_state *uts)
return 0;
}
+int ut_check_skip_to_linen(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 (!strncmp(uts->expect_str, uts->actual_str,
+ strlen(uts->expect_str)))
+ return 0;
+ }
+}
+
int ut_check_skip_to_line(struct unit_test_state *uts, const char *fmt, ...)
{
va_list args;