1 // SPDX-License-Identifier: GPL-2.0+
5 * Logging function tests for CONFIG_LOG=n.
8 /* Needed for testing log_debug() */
14 #include <asm/global_data.h>
16 #include <test/test.h>
17 #include <test/suites.h>
20 DECLARE_GLOBAL_DATA_PTR;
24 static int log_test_nolog_err(struct unit_test_state *uts)
28 memset(buf, 0, BUFFSIZE);
29 console_record_reset_enable();
30 log_err("testing %s\n", "log_err");
31 gd->flags &= ~GD_FLG_RECORD;
32 ut_assertok(ut_check_console_line(uts, "testing log_err"));
33 ut_assertok(ut_check_console_end(uts));
36 LOG_TEST(log_test_nolog_err);
38 static int log_test_nolog_warning(struct unit_test_state *uts)
42 memset(buf, 0, BUFFSIZE);
43 console_record_reset_enable();
44 log_warning("testing %s\n", "log_warning");
45 gd->flags &= ~GD_FLG_RECORD;
46 ut_assertok(ut_check_console_line(uts, "testing log_warning"));
47 ut_assertok(ut_check_console_end(uts));
50 LOG_TEST(log_test_nolog_warning);
52 static int log_test_nolog_notice(struct unit_test_state *uts)
56 memset(buf, 0, BUFFSIZE);
57 console_record_reset_enable();
58 log_notice("testing %s\n", "log_notice");
59 gd->flags &= ~GD_FLG_RECORD;
60 ut_assertok(ut_check_console_line(uts, "testing log_notice"));
61 ut_assertok(ut_check_console_end(uts));
64 LOG_TEST(log_test_nolog_notice);
66 static int log_test_nolog_info(struct unit_test_state *uts)
70 memset(buf, 0, BUFFSIZE);
71 console_record_reset_enable();
72 log_err("testing %s\n", "log_info");
73 gd->flags &= ~GD_FLG_RECORD;
74 ut_assertok(ut_check_console_line(uts, "testing log_info"));
75 ut_assertok(ut_check_console_end(uts));
78 LOG_TEST(log_test_nolog_info);
82 static int nolog_test_nodebug(struct unit_test_state *uts)
86 memset(buf, 0, BUFFSIZE);
87 console_record_reset_enable();
88 debug("testing %s\n", "debug");
89 gd->flags &= ~GD_FLG_RECORD;
90 ut_assertok(ut_check_console_end(uts));
93 LOG_TEST(nolog_test_nodebug);
95 static int log_test_nolog_nodebug(struct unit_test_state *uts)
99 memset(buf, 0, BUFFSIZE);
100 console_record_reset_enable();
101 log_debug("testing %s\n", "log_debug");
102 gd->flags &= ~GD_FLG_RECORD;
103 ut_assert(!strcmp(buf, ""));
104 ut_assertok(ut_check_console_end(uts));
107 LOG_TEST(log_test_nolog_nodebug);
111 static int nolog_test_debug(struct unit_test_state *uts)
115 memset(buf, 0, BUFFSIZE);
116 console_record_reset_enable();
117 debug("testing %s\n", "debug");
118 gd->flags &= ~GD_FLG_RECORD;
119 ut_assertok(ut_check_console_line(uts, "testing debug"));
120 ut_assertok(ut_check_console_end(uts));
123 LOG_TEST(nolog_test_debug);
125 static int log_test_nolog_debug(struct unit_test_state *uts)
129 memset(buf, 0, BUFFSIZE);
130 console_record_reset_enable();
131 log_debug("testing %s\n", "log_debug");
132 log(LOGC_NONE, LOGL_DEBUG, "more %s\n", "log_debug");
133 gd->flags &= ~GD_FLG_RECORD;
134 ut_assertok(ut_check_console_line(uts, "testing log_debug"));
135 ut_assertok(ut_check_console_line(uts, "more log_debug"));
136 ut_assertok(ut_check_console_end(uts));
139 LOG_TEST(log_test_nolog_debug);