[PATCH 2/4] test: fix log tests

Heinrich Schuchardt heinrich.schuchardt at canonical.com
Mon Jul 11 08:21:30 CEST 2022


Consider CONFIG_LOG_MAX_LEVEL and gd->default_log_level in

* do_log_test_helpers()
* log_test_dropped()
* log_test_level_deny()

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt at canonical.com>
---
 test/log/log_test.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/test/log/log_test.c b/test/log/log_test.c
index db7170f304..c5abff80d1 100644
--- a/test/log/log_test.c
+++ b/test/log/log_test.c
@@ -277,7 +277,7 @@ int do_log_test_helpers(struct unit_test_state *uts)
 	log_content("level %d\n", LOGL_DEBUG_CONTENT);
 	log_io("level %d\n", LOGL_DEBUG_IO);
 
-	for (i = LOGL_EMERG; i <= _LOG_MAX_LEVEL; i++)
+	for (i = LOGL_EMERG; i <= gd->default_log_level; i++)
 		ut_assert_nextline("%*s() level %d", CONFIG_LOGF_FUNC_PAD,
 				   __func__, i);
 	ut_assert_console_end();
@@ -381,7 +381,8 @@ int log_test_level_deny(struct unit_test_state *uts)
 	ut_assertok(console_record_reset_enable());
 	log_run();
 	check_log_entries_flags_levels(EXPECT_LOG | EXPECT_DIRECT | EXPECT_FORCE,
-				       LOGL_WARNING + 1, _LOG_MAX_LEVEL);
+				       LOGL_WARNING + 1,
+				       min(gd->default_log_level, LOGL_INFO));
 
 	ut_assertok(log_remove_filter("console", filt1));
 	ut_assertok(log_remove_filter("console", filt2));
@@ -420,9 +421,11 @@ int log_test_dropped(struct unit_test_state *uts)
 	gd->log_drop_count = 0;
 
 	ut_assertok(console_record_reset_enable());
-	log_run();
 
-	ut_asserteq(gd->log_drop_count, 3 * (LOGL_COUNT - LOGL_FIRST - 1));
+	log_run();
+	ut_asserteq(2 * (LOGL_COUNT - LOGL_FIRST) +
+		    _LOG_MAX_LEVEL - LOGL_FIRST + 1,
+		    gd->log_drop_count);
 	check_log_entries_flags_levels(EXPECT_DEBUG, LOGL_FIRST, CONFIG_LOG_DEFAULT_LEVEL);
 
 	gd->flags |= GD_FLG_LOG_READY;
-- 
2.36.1



More information about the U-Boot mailing list