1 // SPDX-License-Identifier: GPL-2.0+
5 * Logging function tests for CONFIG_LOG=n.
8 /* Needed for testing log_debug() */
13 #include <asm/global_data.h>
15 #include <test/test.h>
16 #include <test/suites.h>
19 DECLARE_GLOBAL_DATA_PTR;
23 static int log_test_nolog_err(struct unit_test_state *uts)
27 memset(buf, 0, BUFFSIZE);
28 console_record_reset_enable();
29 log_err("testing %s\n", "log_err");
30 gd->flags &= ~GD_FLG_RECORD;
31 ut_assertok(ut_check_console_line(uts, "testing log_err"));
32 ut_assertok(ut_check_console_end(uts));
35 LOG_TEST(log_test_nolog_err);
37 static int log_test_nolog_warning(struct unit_test_state *uts)
41 memset(buf, 0, BUFFSIZE);
42 console_record_reset_enable();
43 log_warning("testing %s\n", "log_warning");
44 gd->flags &= ~GD_FLG_RECORD;
45 ut_assertok(ut_check_console_line(uts, "testing log_warning"));
46 ut_assertok(ut_check_console_end(uts));
49 LOG_TEST(log_test_nolog_warning);
51 static int log_test_nolog_notice(struct unit_test_state *uts)
55 memset(buf, 0, BUFFSIZE);
56 console_record_reset_enable();
57 log_notice("testing %s\n", "log_notice");
58 gd->flags &= ~GD_FLG_RECORD;
59 ut_assertok(ut_check_console_line(uts, "testing log_notice"));
60 ut_assertok(ut_check_console_end(uts));
63 LOG_TEST(log_test_nolog_notice);
65 static int log_test_nolog_info(struct unit_test_state *uts)
69 memset(buf, 0, BUFFSIZE);
70 console_record_reset_enable();
71 log_err("testing %s\n", "log_info");
72 gd->flags &= ~GD_FLG_RECORD;
73 ut_assertok(ut_check_console_line(uts, "testing log_info"));
74 ut_assertok(ut_check_console_end(uts));
77 LOG_TEST(log_test_nolog_info);
81 static int nolog_test_nodebug(struct unit_test_state *uts)
85 memset(buf, 0, BUFFSIZE);
86 console_record_reset_enable();
87 debug("testing %s\n", "debug");
88 gd->flags &= ~GD_FLG_RECORD;
89 ut_assertok(ut_check_console_end(uts));
92 LOG_TEST(nolog_test_nodebug);
94 static int log_test_nolog_nodebug(struct unit_test_state *uts)
98 memset(buf, 0, BUFFSIZE);
99 console_record_reset_enable();
100 log_debug("testing %s\n", "log_debug");
101 gd->flags &= ~GD_FLG_RECORD;
102 ut_assert(!strcmp(buf, ""));
103 ut_assertok(ut_check_console_end(uts));
106 LOG_TEST(log_test_nolog_nodebug);
110 static int nolog_test_debug(struct unit_test_state *uts)
114 memset(buf, 0, BUFFSIZE);
115 console_record_reset_enable();
116 debug("testing %s\n", "debug");
117 gd->flags &= ~GD_FLG_RECORD;
118 ut_assertok(ut_check_console_line(uts, "testing debug"));
119 ut_assertok(ut_check_console_end(uts));
122 LOG_TEST(nolog_test_debug);
124 static int log_test_nolog_debug(struct unit_test_state *uts)
128 memset(buf, 0, BUFFSIZE);
129 console_record_reset_enable();
130 log_debug("testing %s\n", "log_debug");
131 log(LOGC_NONE, LOGL_DEBUG, "more %s\n", "log_debug");
132 gd->flags &= ~GD_FLG_RECORD;
133 ut_assertok(ut_check_console_line(uts, "testing log_debug"));
134 ut_assertok(ut_check_console_line(uts, "more log_debug"));
135 ut_assertok(ut_check_console_end(uts));
138 LOG_TEST(log_test_nolog_debug);