1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (c) 2020, Heinrich Schuchardt <xypron.glpk@gmx.de>
5 * Logging function tests for CONFIG_LOG=n.
8 /* Needed for testing log_debug() */
14 #include <test/test.h>
15 #include <test/suites.h>
18 DECLARE_GLOBAL_DATA_PTR;
22 static int log_test_nolog_err(struct unit_test_state *uts)
26 memset(buf, 0, BUFFSIZE);
27 console_record_reset_enable();
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 console_record_reset_enable();
42 log_warning("testing %s\n", "log_warning");
43 gd->flags &= ~GD_FLG_RECORD;
44 ut_assertok(ut_check_console_line(uts, "testing log_warning"));
45 ut_assertok(ut_check_console_end(uts));
48 LOG_TEST(log_test_nolog_warning);
50 static int log_test_nolog_notice(struct unit_test_state *uts)
54 memset(buf, 0, BUFFSIZE);
55 console_record_reset_enable();
56 log_notice("testing %s\n", "log_notice");
57 gd->flags &= ~GD_FLG_RECORD;
58 ut_assertok(ut_check_console_line(uts, "testing log_notice"));
59 ut_assertok(ut_check_console_end(uts));
62 LOG_TEST(log_test_nolog_notice);
64 static int log_test_nolog_info(struct unit_test_state *uts)
68 memset(buf, 0, BUFFSIZE);
69 console_record_reset_enable();
70 log_err("testing %s\n", "log_info");
71 gd->flags &= ~GD_FLG_RECORD;
72 ut_assertok(ut_check_console_line(uts, "testing log_info"));
73 ut_assertok(ut_check_console_end(uts));
76 LOG_TEST(log_test_nolog_info);
80 static int nolog_test_nodebug(struct unit_test_state *uts)
84 memset(buf, 0, BUFFSIZE);
85 console_record_reset_enable();
86 debug("testing %s\n", "debug");
87 gd->flags &= ~GD_FLG_RECORD;
88 ut_assertok(ut_check_console_end(uts));
91 LOG_TEST(nolog_test_nodebug);
93 static int log_test_nolog_nodebug(struct unit_test_state *uts)
97 memset(buf, 0, BUFFSIZE);
98 console_record_reset_enable();
99 log_debug("testing %s\n", "log_debug");
100 gd->flags &= ~GD_FLG_RECORD;
101 ut_assert(!strcmp(buf, ""));
102 ut_assertok(ut_check_console_end(uts));
105 LOG_TEST(log_test_nolog_nodebug);
109 static int nolog_test_debug(struct unit_test_state *uts)
113 memset(buf, 0, BUFFSIZE);
114 console_record_reset_enable();
115 debug("testing %s\n", "debug");
116 gd->flags &= ~GD_FLG_RECORD;
117 ut_assertok(ut_check_console_line(uts, "testing debug"));
118 ut_assertok(ut_check_console_end(uts));
121 LOG_TEST(nolog_test_debug);
123 static int log_test_nolog_debug(struct unit_test_state *uts)
127 memset(buf, 0, BUFFSIZE);
128 console_record_reset_enable();
129 log_debug("testing %s\n", "log_debug");
130 gd->flags &= ~GD_FLG_RECORD;
131 ut_assertok(ut_check_console_line(uts, "testing log_debug"));
132 ut_assertok(ut_check_console_end(uts));
135 LOG_TEST(log_test_nolog_debug);