]> git.ipfire.org Git - thirdparty/u-boot.git/blame - test/log/nolog_test.c
usb: dwc3: add dis_u2_freeclk_exists_quirk
[thirdparty/u-boot.git] / test / log / nolog_test.c
CommitLineData
395041b2
HS
1// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright (c) 2020, Heinrich Schuchardt <xypron.glpk@gmx.de>
4 *
5 * Logging function tests for CONFIG_LOG=n.
6 */
7
8/* Needed for testing log_debug() */
9#define DEBUG 1
10
11#include <common.h>
12#include <console.h>
13#include <test/log.h>
14#include <test/test.h>
15#include <test/suites.h>
16#include <test/ut.h>
17
18DECLARE_GLOBAL_DATA_PTR;
19
20#define BUFFSIZE 32
21
be51c3ca 22static int log_test_nolog_err(struct unit_test_state *uts)
395041b2
HS
23{
24 char buf[BUFFSIZE];
25
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));
32 return 0;
33}
be51c3ca 34LOG_TEST(log_test_nolog_err);
395041b2 35
be51c3ca 36static int log_test_nolog_warning(struct unit_test_state *uts)
395041b2
HS
37{
38 char buf[BUFFSIZE];
39
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));
46 return 0;
47}
be51c3ca 48LOG_TEST(log_test_nolog_warning);
395041b2 49
be51c3ca 50static int log_test_nolog_notice(struct unit_test_state *uts)
395041b2
HS
51{
52 char buf[BUFFSIZE];
53
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));
60 return 0;
61}
be51c3ca 62LOG_TEST(log_test_nolog_notice);
395041b2 63
be51c3ca 64static int log_test_nolog_info(struct unit_test_state *uts)
395041b2
HS
65{
66 char buf[BUFFSIZE];
67
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));
74 return 0;
75}
be51c3ca 76LOG_TEST(log_test_nolog_info);
395041b2
HS
77
78#undef _DEBUG
79#define _DEBUG 0
80static int nolog_test_nodebug(struct unit_test_state *uts)
81{
82 char buf[BUFFSIZE];
83
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));
89 return 0;
90}
91LOG_TEST(nolog_test_nodebug);
92
be51c3ca 93static int log_test_nolog_nodebug(struct unit_test_state *uts)
395041b2
HS
94{
95 char buf[BUFFSIZE];
96
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));
103 return 0;
104}
be51c3ca 105LOG_TEST(log_test_nolog_nodebug);
395041b2
HS
106
107#undef _DEBUG
108#define _DEBUG 1
109static int nolog_test_debug(struct unit_test_state *uts)
110{
111 char buf[BUFFSIZE];
112
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));
119 return 0;
120}
121LOG_TEST(nolog_test_debug);
122
be51c3ca 123static int log_test_nolog_debug(struct unit_test_state *uts)
395041b2
HS
124{
125 char buf[BUFFSIZE];
126
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));
133 return 0;
134}
be51c3ca 135LOG_TEST(log_test_nolog_debug);