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 log_err("testing %s\n", "log_err");
29 gd->flags &= ~GD_FLG_RECORD;
30 ut_assertok(ut_check_console_line(uts, "testing log_err"));
31 ut_assertok(ut_check_console_end(uts));
34 LOG_TEST(log_test_nolog_err);
36 static int log_test_nolog_warning(struct unit_test_state *uts)
40 memset(buf, 0, BUFFSIZE);
41 log_warning("testing %s\n", "log_warning");
42 gd->flags &= ~GD_FLG_RECORD;
43 ut_assertok(ut_check_console_line(uts, "testing log_warning"));
44 ut_assertok(ut_check_console_end(uts));
47 LOG_TEST(log_test_nolog_warning);
49 static int log_test_nolog_notice(struct unit_test_state *uts)
53 memset(buf, 0, BUFFSIZE);
54 log_notice("testing %s\n", "log_notice");
55 gd->flags &= ~GD_FLG_RECORD;
56 ut_assertok(ut_check_console_line(uts, "testing log_notice"));
57 ut_assertok(ut_check_console_end(uts));
60 LOG_TEST(log_test_nolog_notice);
62 static int log_test_nolog_info(struct unit_test_state *uts)
66 memset(buf, 0, BUFFSIZE);
67 log_err("testing %s\n", "log_info");
68 gd->flags &= ~GD_FLG_RECORD;
69 ut_assertok(ut_check_console_line(uts, "testing log_info"));
70 ut_assertok(ut_check_console_end(uts));
73 LOG_TEST(log_test_nolog_info);
77 static int nolog_test_nodebug(struct unit_test_state *uts)
81 memset(buf, 0, BUFFSIZE);
82 debug("testing %s\n", "debug");
83 gd->flags &= ~GD_FLG_RECORD;
84 ut_assertok(ut_check_console_end(uts));
87 LOG_TEST(nolog_test_nodebug);
89 static int log_test_nolog_nodebug(struct unit_test_state *uts)
93 memset(buf, 0, BUFFSIZE);
94 log_debug("testing %s\n", "log_debug");
95 gd->flags &= ~GD_FLG_RECORD;
96 ut_assert(!strcmp(buf, ""));
97 ut_assertok(ut_check_console_end(uts));
100 LOG_TEST(log_test_nolog_nodebug);
104 static int nolog_test_debug(struct unit_test_state *uts)
108 memset(buf, 0, BUFFSIZE);
109 debug("testing %s\n", "debug");
110 gd->flags &= ~GD_FLG_RECORD;
111 ut_assertok(ut_check_console_line(uts, "testing debug"));
112 ut_assertok(ut_check_console_end(uts));
115 LOG_TEST(nolog_test_debug);
117 static int log_test_nolog_debug(struct unit_test_state *uts)
121 memset(buf, 0, BUFFSIZE);
122 log_debug("testing %s\n", "log_debug");
123 log(LOGC_NONE, LOGL_DEBUG, "more %s\n", "log_debug");
124 gd->flags &= ~GD_FLG_RECORD;
125 ut_assertok(ut_check_console_line(uts, "testing log_debug"));
126 ut_assertok(ut_check_console_line(uts, "more log_debug"));
127 ut_assertok(ut_check_console_end(uts));
130 LOG_TEST(log_test_nolog_debug);