]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
test: add LOGL_FORCE_DEBUG flags support in log tests
authorPatrick Delaunay <patrick.delaunay@st.com>
Fri, 27 Nov 2020 10:20:51 +0000 (11:20 +0100)
committerTom Rini <trini@konsulko.com>
Fri, 15 Jan 2021 19:36:10 +0000 (14:36 -0500)
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 <patrick.delaunay@st.com>
Reviewed-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
test/log/log_test.c

index ea4fc6bc30b11fdf932353089361022043f0e7d6..15874751f991edc41143606d2bf0c25305b8c6dc 100644 (file)
@@ -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));