From: Patrick Delaunay Date: Fri, 27 Nov 2020 10:20:51 +0000 (+0100) Subject: test: add LOGL_FORCE_DEBUG flags support in log tests X-Git-Url: http://git.dujemihanovic.xyz/html/%7B%7B%20.Permalink%20%7D%7D?a=commitdiff_plain;h=6278ec1919fff83a4f0adde1e5d987852b154ebf;p=u-boot.git test: add LOGL_FORCE_DEBUG flags support in log tests Add a check of the _log function with LOGL_FORCE_DEBUG flags, used to force the trace display. The trace should be displayed for all the level when flags have LOGL_FORCE_DEBUG bit is set, for any filter. Signed-off-by: Patrick Delaunay Reviewed-by: Sean Anderson Reviewed-by: Simon Glass --- diff --git a/test/log/log_test.c b/test/log/log_test.c index ea4fc6bc30..15874751f9 100644 --- a/test/log/log_test.c +++ b/test/log/log_test.c @@ -26,6 +26,11 @@ static int do_log_run(int cat, const char *file) _log(log_uc_cat(cat), i, file, 100 + i, "func", "_log %d\n", i); } + /* test with LOGL_COUNT flag */ + for (i = LOGL_FIRST; i < LOGL_COUNT; i++) { + _log(log_uc_cat(cat), i | LOGL_FORCE_DEBUG, file, 100 + i, + "func", "_log force %d\n", i); + } gd->log_fmt = log_get_default_format(); return 0; @@ -38,6 +43,7 @@ static int do_log_run(int cat, const char *file) #define EXPECT_LOG BIT(0) #define EXPECT_DIRECT BIT(1) #define EXPECT_EXTRA BIT(2) +#define EXPECT_FORCE BIT(3) static int do_check_log_entries(struct unit_test_state *uts, int flags, int min, int max) @@ -54,6 +60,11 @@ static int do_check_log_entries(struct unit_test_state *uts, int flags, int min, for (; i <= LOGL_MAX ; i++) ut_assert_nextline("func() _log %d", i); + for (i = LOGL_FIRST; i < LOGL_COUNT; i++) { + if (flags & EXPECT_FORCE) + ut_assert_nextline("func() _log force %d", i); + } + ut_assert_console_end(); return 0; } @@ -66,10 +77,10 @@ static int do_check_log_entries(struct unit_test_state *uts, int flags, int min, #define check_log_entries_flags(flags) \ check_log_entries_flags_levels(flags, LOGL_FIRST, _LOG_MAX_LEVEL) -#define check_log_entries() check_log_entries_flags(EXPECT_LOG | EXPECT_DIRECT) +#define check_log_entries() check_log_entries_flags(EXPECT_LOG | EXPECT_DIRECT | EXPECT_FORCE) #define check_log_entries_extra() \ - check_log_entries_flags(EXPECT_LOG | EXPECT_DIRECT | EXPECT_EXTRA) -#define check_log_entries_none() check_log_entries_flags(0) + check_log_entries_flags(EXPECT_LOG | EXPECT_DIRECT | EXPECT_EXTRA | EXPECT_FORCE) +#define check_log_entries_none() check_log_entries_flags(EXPECT_FORCE) /* Check a category filter using the first category */ int log_test_cat_allow(struct unit_test_state *uts) @@ -126,7 +137,7 @@ int log_test_file(struct unit_test_state *uts) ut_assertok(console_record_reset_enable()); log_run_file("file"); - check_log_entries_flags(EXPECT_DIRECT | EXPECT_EXTRA); + check_log_entries_flags(EXPECT_DIRECT | EXPECT_EXTRA | EXPECT_FORCE); ut_assertok(console_record_reset_enable()); log_run_file("file2"); @@ -147,7 +158,7 @@ int log_test_file_second(struct unit_test_state *uts) ut_assertok(console_record_reset_enable()); log_run_file("file2"); - check_log_entries_flags(EXPECT_DIRECT | EXPECT_EXTRA); + check_log_entries_flags(EXPECT_DIRECT | EXPECT_EXTRA | EXPECT_FORCE); ut_assertok(log_remove_filter("console", filt)); return 0; @@ -182,8 +193,8 @@ int log_test_level(struct unit_test_state *uts) ut_assertok(console_record_reset_enable()); log_run(); - check_log_entries_flags_levels(EXPECT_LOG | EXPECT_DIRECT, LOGL_FIRST, - LOGL_WARNING); + check_log_entries_flags_levels(EXPECT_LOG | EXPECT_DIRECT | EXPECT_FORCE, + LOGL_FIRST, LOGL_WARNING); ut_assertok(log_remove_filter("console", filt)); return 0; @@ -351,7 +362,7 @@ 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, + check_log_entries_flags_levels(EXPECT_LOG | EXPECT_DIRECT | EXPECT_FORCE, LOGL_WARNING + 1, _LOG_MAX_LEVEL); ut_assertok(log_remove_filter("console", filt1)); @@ -374,7 +385,7 @@ int log_test_min(struct unit_test_state *uts) ut_assertok(console_record_reset_enable()); log_run(); - check_log_entries_flags_levels(EXPECT_LOG | EXPECT_DIRECT, + check_log_entries_flags_levels(EXPECT_LOG | EXPECT_DIRECT | EXPECT_FORCE, LOGL_WARNING, LOGL_INFO - 1); ut_assertok(log_remove_filter("console", filt1));