blob: db7170f304229e7876f7bfe1de279801f4c4c356 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Simon Glassef11ed82017-12-04 13:48:27 -07002/*
3 * Logging support test program
4 *
5 * Copyright (c) 2017 Google, Inc
6 * Written by Simon Glass <sjg@chromium.org>
Simon Glassef11ed82017-12-04 13:48:27 -07007 */
8
9#include <common.h>
Simon Glass09140112020-05-10 11:40:03 -060010#include <command.h>
Simon Glassf7ae49f2020-05-10 11:40:05 -060011#include <log.h>
Simon Glass401d1c42020-10-30 21:38:53 -060012#include <asm/global_data.h>
Sean Anderson62ef8182020-10-27 19:55:27 -040013#include <test/log.h>
14#include <test/ut.h>
15
16DECLARE_GLOBAL_DATA_PTR;
Simon Glassef11ed82017-12-04 13:48:27 -070017
18/* emit some sample log records in different ways, for testing */
Patrick Delaunayce9af2a2020-11-27 11:20:53 +010019static int do_log_run(struct unit_test_state *uts, int cat, const char *file)
Simon Glassef11ed82017-12-04 13:48:27 -070020{
21 int i;
Patrick Delaunayce9af2a2020-11-27 11:20:53 +010022 int ret, expected_ret;
23
24 if (gd->flags & GD_FLG_LOG_READY)
25 expected_ret = 0;
26 else
27 expected_ret = -ENOSYS;
Simon Glassef11ed82017-12-04 13:48:27 -070028
Sean Anderson62ef8182020-10-27 19:55:27 -040029 gd->log_fmt = LOGF_TEST;
Simon Glassef11ed82017-12-04 13:48:27 -070030 debug("debug\n");
31 for (i = LOGL_FIRST; i < LOGL_COUNT; i++) {
32 log(cat, i, "log %d\n", i);
Patrick Delaunayce9af2a2020-11-27 11:20:53 +010033 ret = _log(log_uc_cat(cat), i, file, 100 + i,
34 "func", "_log %d\n", i);
35 ut_asserteq(ret, expected_ret);
Simon Glassef11ed82017-12-04 13:48:27 -070036 }
Patrick Delaunay6278ec12020-11-27 11:20:51 +010037 /* test with LOGL_COUNT flag */
38 for (i = LOGL_FIRST; i < LOGL_COUNT; i++) {
Patrick Delaunayce9af2a2020-11-27 11:20:53 +010039 ret = _log(log_uc_cat(cat), i | LOGL_FORCE_DEBUG, file, 100 + i,
40 "func", "_log force %d\n", i);
41 ut_asserteq(ret, expected_ret);
Patrick Delaunay6278ec12020-11-27 11:20:51 +010042 }
Simon Glassef11ed82017-12-04 13:48:27 -070043
Sean Anderson62ef8182020-10-27 19:55:27 -040044 gd->log_fmt = log_get_default_format();
Simon Glassef11ed82017-12-04 13:48:27 -070045 return 0;
46}
47
Patrick Delaunayce9af2a2020-11-27 11:20:53 +010048#define log_run_cat(cat) do_log_run(uts, cat, "file")
49#define log_run_file(file) do_log_run(uts, UCLASS_SPI, file)
50#define log_run() do_log_run(uts, UCLASS_SPI, "file")
Sean Anderson62ef8182020-10-27 19:55:27 -040051
52#define EXPECT_LOG BIT(0)
53#define EXPECT_DIRECT BIT(1)
54#define EXPECT_EXTRA BIT(2)
Patrick Delaunay6278ec12020-11-27 11:20:51 +010055#define EXPECT_FORCE BIT(3)
Patrick Delaunay742346f2020-11-27 11:20:58 +010056#define EXPECT_DEBUG BIT(4)
Sean Anderson62ef8182020-10-27 19:55:27 -040057
58static int do_check_log_entries(struct unit_test_state *uts, int flags, int min,
59 int max)
Simon Glassef11ed82017-12-04 13:48:27 -070060{
Sean Anderson62ef8182020-10-27 19:55:27 -040061 int i;
Simon Glassef11ed82017-12-04 13:48:27 -070062
Sean Anderson62ef8182020-10-27 19:55:27 -040063 for (i = min; i <= max; i++) {
64 if (flags & EXPECT_LOG)
Simon Glass72fa1ad2021-07-05 16:33:00 -060065 ut_assert_nextline(" do_log_run() log %d", i);
Sean Anderson62ef8182020-10-27 19:55:27 -040066 if (flags & EXPECT_DIRECT)
Simon Glass72fa1ad2021-07-05 16:33:00 -060067 ut_assert_nextline(" func() _log %d", i);
Patrick Delaunay742346f2020-11-27 11:20:58 +010068 if (flags & EXPECT_DEBUG) {
69 ut_assert_nextline("log %d", i);
70 ut_assert_nextline("_log %d", i);
71 }
Sean Anderson62ef8182020-10-27 19:55:27 -040072 }
73 if (flags & EXPECT_EXTRA)
74 for (; i <= LOGL_MAX ; i++)
Simon Glass72fa1ad2021-07-05 16:33:00 -060075 ut_assert_nextline(" func() _log %d", i);
Simon Glassef11ed82017-12-04 13:48:27 -070076
Patrick Delaunay6278ec12020-11-27 11:20:51 +010077 for (i = LOGL_FIRST; i < LOGL_COUNT; i++) {
78 if (flags & EXPECT_FORCE)
Simon Glass72fa1ad2021-07-05 16:33:00 -060079 ut_assert_nextline(" func() _log force %d",
80 i);
Patrick Delaunay742346f2020-11-27 11:20:58 +010081 if (flags & EXPECT_DEBUG)
82 ut_assert_nextline("_log force %d", i);
Patrick Delaunay6278ec12020-11-27 11:20:51 +010083 }
84
Sean Anderson62ef8182020-10-27 19:55:27 -040085 ut_assert_console_end();
Simon Glassef11ed82017-12-04 13:48:27 -070086 return 0;
87}
88
Sean Anderson62ef8182020-10-27 19:55:27 -040089#define check_log_entries_flags_levels(flags, min, max) do {\
90 int ret = do_check_log_entries(uts, flags, min, max); \
91 if (ret) \
92 return ret; \
93} while (0)
94
95#define check_log_entries_flags(flags) \
96 check_log_entries_flags_levels(flags, LOGL_FIRST, _LOG_MAX_LEVEL)
Patrick Delaunay6278ec12020-11-27 11:20:51 +010097#define check_log_entries() check_log_entries_flags(EXPECT_LOG | EXPECT_DIRECT | EXPECT_FORCE)
Sean Anderson62ef8182020-10-27 19:55:27 -040098#define check_log_entries_extra() \
Patrick Delaunay6278ec12020-11-27 11:20:51 +010099 check_log_entries_flags(EXPECT_LOG | EXPECT_DIRECT | EXPECT_EXTRA | EXPECT_FORCE)
100#define check_log_entries_none() check_log_entries_flags(EXPECT_FORCE)
Sean Anderson62ef8182020-10-27 19:55:27 -0400101
102/* Check a category filter using the first category */
Sean Anderson046b8c02020-10-27 19:55:28 -0400103int log_test_cat_allow(struct unit_test_state *uts)
Simon Glassef11ed82017-12-04 13:48:27 -0700104{
Sean Anderson62ef8182020-10-27 19:55:27 -0400105 enum log_category_t cat_list[] = {
106 log_uc_cat(UCLASS_MMC), log_uc_cat(UCLASS_SPI),
107 LOGC_NONE, LOGC_END
108 };
109 int filt;
110
111 filt = log_add_filter("console", cat_list, LOGL_MAX, NULL);
112 ut_assert(filt >= 0);
113
114 ut_assertok(console_record_reset_enable());
115 log_run_cat(UCLASS_MMC);
116 check_log_entries_extra();
117
118 ut_assertok(console_record_reset_enable());
119 log_run_cat(UCLASS_SPI);
120 check_log_entries_extra();
121
122 ut_assertok(log_remove_filter("console", filt));
123 return 0;
124}
Sean Anderson046b8c02020-10-27 19:55:28 -0400125LOG_TEST_FLAGS(log_test_cat_allow, UT_TESTF_CONSOLE_REC);
Sean Anderson62ef8182020-10-27 19:55:27 -0400126
127/* Check a category filter that should block log entries */
Sean Anderson046b8c02020-10-27 19:55:28 -0400128int log_test_cat_deny_implicit(struct unit_test_state *uts)
Sean Anderson62ef8182020-10-27 19:55:27 -0400129{
130 enum log_category_t cat_list[] = {
131 log_uc_cat(UCLASS_MMC), LOGC_NONE, LOGC_END
132 };
133 int filt;
134
135 filt = log_add_filter("console", cat_list, LOGL_MAX, NULL);
136 ut_assert(filt >= 0);
137
138 ut_assertok(console_record_reset_enable());
139 log_run_cat(UCLASS_SPI);
140 check_log_entries_none();
141
142 ut_assertok(log_remove_filter("console", filt));
143 return 0;
144}
Sean Anderson046b8c02020-10-27 19:55:28 -0400145LOG_TEST_FLAGS(log_test_cat_deny_implicit, UT_TESTF_CONSOLE_REC);
Sean Anderson62ef8182020-10-27 19:55:27 -0400146
147/* Check passing and failing file filters */
Sean Anderson046b8c02020-10-27 19:55:28 -0400148int log_test_file(struct unit_test_state *uts)
Sean Anderson62ef8182020-10-27 19:55:27 -0400149{
150 int filt;
151
152 filt = log_add_filter("console", NULL, LOGL_MAX, "file");
153 ut_assert(filt >= 0);
154
155 ut_assertok(console_record_reset_enable());
156 log_run_file("file");
Patrick Delaunay6278ec12020-11-27 11:20:51 +0100157 check_log_entries_flags(EXPECT_DIRECT | EXPECT_EXTRA | EXPECT_FORCE);
Sean Anderson62ef8182020-10-27 19:55:27 -0400158
159 ut_assertok(console_record_reset_enable());
160 log_run_file("file2");
161 check_log_entries_none();
162
163 ut_assertok(log_remove_filter("console", filt));
164 return 0;
165}
Sean Anderson046b8c02020-10-27 19:55:28 -0400166LOG_TEST_FLAGS(log_test_file, UT_TESTF_CONSOLE_REC);
Sean Anderson62ef8182020-10-27 19:55:27 -0400167
168/* Check a passing file filter (second in list) */
Sean Anderson046b8c02020-10-27 19:55:28 -0400169int log_test_file_second(struct unit_test_state *uts)
Sean Anderson62ef8182020-10-27 19:55:27 -0400170{
171 int filt;
172
173 filt = log_add_filter("console", NULL, LOGL_MAX, "file,file2");
174 ut_assert(filt >= 0);
175
176 ut_assertok(console_record_reset_enable());
177 log_run_file("file2");
Patrick Delaunay6278ec12020-11-27 11:20:51 +0100178 check_log_entries_flags(EXPECT_DIRECT | EXPECT_EXTRA | EXPECT_FORCE);
Sean Anderson62ef8182020-10-27 19:55:27 -0400179
180 ut_assertok(log_remove_filter("console", filt));
181 return 0;
182}
Sean Anderson046b8c02020-10-27 19:55:28 -0400183LOG_TEST_FLAGS(log_test_file_second, UT_TESTF_CONSOLE_REC);
Sean Anderson62ef8182020-10-27 19:55:27 -0400184
185/* Check a passing file filter (middle of list) */
Sean Anderson046b8c02020-10-27 19:55:28 -0400186int log_test_file_mid(struct unit_test_state *uts)
Sean Anderson62ef8182020-10-27 19:55:27 -0400187{
188 int filt;
189
190 filt = log_add_filter("console", NULL, LOGL_MAX,
191 "file,file2,log/log_test.c");
192 ut_assert(filt >= 0);
193
194 ut_assertok(console_record_reset_enable());
195 log_run_file("file2");
196 check_log_entries_extra();
197
198 ut_assertok(log_remove_filter("console", filt));
199 return 0;
200}
Sean Anderson046b8c02020-10-27 19:55:28 -0400201LOG_TEST_FLAGS(log_test_file_mid, UT_TESTF_CONSOLE_REC);
Sean Anderson62ef8182020-10-27 19:55:27 -0400202
203/* Check a log level filter */
Sean Anderson046b8c02020-10-27 19:55:28 -0400204int log_test_level(struct unit_test_state *uts)
Sean Anderson62ef8182020-10-27 19:55:27 -0400205{
206 int filt;
207
208 filt = log_add_filter("console", NULL, LOGL_WARNING, NULL);
209 ut_assert(filt >= 0);
210
211 ut_assertok(console_record_reset_enable());
212 log_run();
Patrick Delaunay6278ec12020-11-27 11:20:51 +0100213 check_log_entries_flags_levels(EXPECT_LOG | EXPECT_DIRECT | EXPECT_FORCE,
214 LOGL_FIRST, LOGL_WARNING);
Sean Anderson62ef8182020-10-27 19:55:27 -0400215
216 ut_assertok(log_remove_filter("console", filt));
217 return 0;
218}
Sean Anderson046b8c02020-10-27 19:55:28 -0400219LOG_TEST_FLAGS(log_test_level, UT_TESTF_CONSOLE_REC);
Sean Anderson62ef8182020-10-27 19:55:27 -0400220
221/* Check two filters, one of which passes everything */
Sean Anderson046b8c02020-10-27 19:55:28 -0400222int log_test_double(struct unit_test_state *uts)
Sean Anderson62ef8182020-10-27 19:55:27 -0400223{
224 int filt1, filt2;
225
226 filt1 = log_add_filter("console", NULL, LOGL_WARNING, NULL);
227 ut_assert(filt1 >= 0);
228 filt2 = log_add_filter("console", NULL, LOGL_MAX, NULL);
229 ut_assert(filt2 >= 0);
230
231 ut_assertok(console_record_reset_enable());
232 log_run();
233 check_log_entries_extra();
234
235 ut_assertok(log_remove_filter("console", filt1));
236 ut_assertok(log_remove_filter("console", filt2));
237 return 0;
238}
Sean Anderson046b8c02020-10-27 19:55:28 -0400239LOG_TEST_FLAGS(log_test_double, UT_TESTF_CONSOLE_REC);
Sean Anderson62ef8182020-10-27 19:55:27 -0400240
241/* Check three filters, which together pass everything */
Sean Anderson046b8c02020-10-27 19:55:28 -0400242int log_test_triple(struct unit_test_state *uts)
Sean Anderson62ef8182020-10-27 19:55:27 -0400243{
244 int filt1, filt2, filt3;
245
246 filt1 = log_add_filter("console", NULL, LOGL_MAX, "file)");
247 ut_assert(filt1 >= 0);
248 filt2 = log_add_filter("console", NULL, LOGL_MAX, "file2");
249 ut_assert(filt2 >= 0);
250 filt3 = log_add_filter("console", NULL, LOGL_MAX, "log/log_test.c");
251 ut_assert(filt3 >= 0);
252
253 ut_assertok(console_record_reset_enable());
254 log_run_file("file2");
255 check_log_entries_extra();
256
257 ut_assertok(log_remove_filter("console", filt1));
258 ut_assertok(log_remove_filter("console", filt2));
259 ut_assertok(log_remove_filter("console", filt3));
260 return 0;
261}
Sean Anderson046b8c02020-10-27 19:55:28 -0400262LOG_TEST_FLAGS(log_test_triple, UT_TESTF_CONSOLE_REC);
Sean Anderson62ef8182020-10-27 19:55:27 -0400263
Sean Anderson046b8c02020-10-27 19:55:28 -0400264int do_log_test_helpers(struct unit_test_state *uts)
Sean Anderson62ef8182020-10-27 19:55:27 -0400265{
266 int i;
267
268 ut_assertok(console_record_reset_enable());
269 log_err("level %d\n", LOGL_EMERG);
270 log_err("level %d\n", LOGL_ALERT);
271 log_err("level %d\n", LOGL_CRIT);
272 log_err("level %d\n", LOGL_ERR);
273 log_warning("level %d\n", LOGL_WARNING);
274 log_notice("level %d\n", LOGL_NOTICE);
275 log_info("level %d\n", LOGL_INFO);
276 log_debug("level %d\n", LOGL_DEBUG);
277 log_content("level %d\n", LOGL_DEBUG_CONTENT);
278 log_io("level %d\n", LOGL_DEBUG_IO);
279
280 for (i = LOGL_EMERG; i <= _LOG_MAX_LEVEL; i++)
Simon Glass72fa1ad2021-07-05 16:33:00 -0600281 ut_assert_nextline("%*s() level %d", CONFIG_LOGF_FUNC_PAD,
282 __func__, i);
Sean Anderson62ef8182020-10-27 19:55:27 -0400283 ut_assert_console_end();
284 return 0;
285}
286
Sean Anderson046b8c02020-10-27 19:55:28 -0400287int log_test_helpers(struct unit_test_state *uts)
Sean Anderson62ef8182020-10-27 19:55:27 -0400288{
Simon Glassef11ed82017-12-04 13:48:27 -0700289 int ret;
290
Sean Anderson62ef8182020-10-27 19:55:27 -0400291 gd->log_fmt = LOGF_TEST;
Sean Anderson046b8c02020-10-27 19:55:28 -0400292 ret = do_log_test_helpers(uts);
Sean Anderson62ef8182020-10-27 19:55:27 -0400293 gd->log_fmt = log_get_default_format();
294 return ret;
Simon Glassef11ed82017-12-04 13:48:27 -0700295}
Sean Anderson046b8c02020-10-27 19:55:28 -0400296LOG_TEST_FLAGS(log_test_helpers, UT_TESTF_CONSOLE_REC);
Sean Anderson62ef8182020-10-27 19:55:27 -0400297
Sean Anderson046b8c02020-10-27 19:55:28 -0400298int do_log_test_disable(struct unit_test_state *uts)
Sean Anderson62ef8182020-10-27 19:55:27 -0400299{
300 ut_assertok(console_record_reset_enable());
301 log_err("default\n");
Simon Glass72fa1ad2021-07-05 16:33:00 -0600302 ut_assert_nextline("%*s() default", CONFIG_LOGF_FUNC_PAD, __func__);
Sean Anderson62ef8182020-10-27 19:55:27 -0400303
304 ut_assertok(log_device_set_enable(LOG_GET_DRIVER(console), false));
305 log_err("disabled\n");
306
307 ut_assertok(log_device_set_enable(LOG_GET_DRIVER(console), true));
308 log_err("enabled\n");
Simon Glass72fa1ad2021-07-05 16:33:00 -0600309 ut_assert_nextline("%*s() enabled", CONFIG_LOGF_FUNC_PAD, __func__);
Sean Anderson62ef8182020-10-27 19:55:27 -0400310 ut_assert_console_end();
311 return 0;
312}
313
Sean Anderson046b8c02020-10-27 19:55:28 -0400314int log_test_disable(struct unit_test_state *uts)
Sean Anderson62ef8182020-10-27 19:55:27 -0400315{
316 int ret;
317
318 gd->log_fmt = LOGF_TEST;
Sean Anderson046b8c02020-10-27 19:55:28 -0400319 ret = do_log_test_disable(uts);
Sean Anderson62ef8182020-10-27 19:55:27 -0400320 gd->log_fmt = log_get_default_format();
321 return ret;
322}
Sean Anderson046b8c02020-10-27 19:55:28 -0400323LOG_TEST_FLAGS(log_test_disable, UT_TESTF_CONSOLE_REC);
Sean Andersonf51e5ec2020-10-27 19:55:29 -0400324
325/* Check denying based on category */
326int log_test_cat_deny(struct unit_test_state *uts)
327{
328 int filt1, filt2;
329 enum log_category_t cat_list[] = {
330 log_uc_cat(UCLASS_SPI), LOGC_END
331 };
332
333 filt1 = log_add_filter("console", cat_list, LOGL_MAX, NULL);
334 ut_assert(filt1 >= 0);
335 filt2 = log_add_filter_flags("console", cat_list, LOGL_MAX, NULL,
336 LOGFF_DENY);
337 ut_assert(filt2 >= 0);
338
339 ut_assertok(console_record_reset_enable());
340 log_run_cat(UCLASS_SPI);
341 check_log_entries_none();
342
343 ut_assertok(log_remove_filter("console", filt1));
344 ut_assertok(log_remove_filter("console", filt2));
345 return 0;
346}
347LOG_TEST_FLAGS(log_test_cat_deny, UT_TESTF_CONSOLE_REC);
348
349/* Check denying based on file */
350int log_test_file_deny(struct unit_test_state *uts)
351{
352 int filt1, filt2;
353
354 filt1 = log_add_filter("console", NULL, LOGL_MAX, "file");
355 ut_assert(filt1 >= 0);
356 filt2 = log_add_filter_flags("console", NULL, LOGL_MAX, "file",
357 LOGFF_DENY);
358 ut_assert(filt2 >= 0);
359
360 ut_assertok(console_record_reset_enable());
361 log_run_file("file");
362 check_log_entries_none();
363
364 ut_assertok(log_remove_filter("console", filt1));
365 ut_assertok(log_remove_filter("console", filt2));
366 return 0;
367}
368LOG_TEST_FLAGS(log_test_file_deny, UT_TESTF_CONSOLE_REC);
369
370/* Check denying based on level */
371int log_test_level_deny(struct unit_test_state *uts)
372{
373 int filt1, filt2;
374
375 filt1 = log_add_filter("console", NULL, LOGL_INFO, NULL);
376 ut_assert(filt1 >= 0);
377 filt2 = log_add_filter_flags("console", NULL, LOGL_WARNING, NULL,
378 LOGFF_DENY);
379 ut_assert(filt2 >= 0);
380
381 ut_assertok(console_record_reset_enable());
382 log_run();
Patrick Delaunay6278ec12020-11-27 11:20:51 +0100383 check_log_entries_flags_levels(EXPECT_LOG | EXPECT_DIRECT | EXPECT_FORCE,
Sean Andersonf51e5ec2020-10-27 19:55:29 -0400384 LOGL_WARNING + 1, _LOG_MAX_LEVEL);
385
386 ut_assertok(log_remove_filter("console", filt1));
387 ut_assertok(log_remove_filter("console", filt2));
388 return 0;
389}
390LOG_TEST_FLAGS(log_test_level_deny, UT_TESTF_CONSOLE_REC);
Sean Anderson12273042020-10-27 19:55:31 -0400391
392/* Check matching based on minimum level */
393int log_test_min(struct unit_test_state *uts)
394{
395 int filt1, filt2;
396
397 filt1 = log_add_filter_flags("console", NULL, LOGL_WARNING, NULL,
398 LOGFF_LEVEL_MIN);
399 ut_assert(filt1 >= 0);
400 filt2 = log_add_filter_flags("console", NULL, LOGL_INFO, NULL,
401 LOGFF_DENY | LOGFF_LEVEL_MIN);
402 ut_assert(filt2 >= 0);
403
404 ut_assertok(console_record_reset_enable());
405 log_run();
Patrick Delaunay6278ec12020-11-27 11:20:51 +0100406 check_log_entries_flags_levels(EXPECT_LOG | EXPECT_DIRECT | EXPECT_FORCE,
Sean Anderson12273042020-10-27 19:55:31 -0400407 LOGL_WARNING, LOGL_INFO - 1);
408
409 ut_assertok(log_remove_filter("console", filt1));
410 ut_assertok(log_remove_filter("console", filt2));
411 return 0;
412}
413LOG_TEST_FLAGS(log_test_min, UT_TESTF_CONSOLE_REC);
Patrick Delaunayce9af2a2020-11-27 11:20:53 +0100414
415/* Check dropped traces */
416int log_test_dropped(struct unit_test_state *uts)
417{
418 /* force LOG not ready */
419 gd->flags &= ~(GD_FLG_LOG_READY);
420 gd->log_drop_count = 0;
421
422 ut_assertok(console_record_reset_enable());
423 log_run();
424
425 ut_asserteq(gd->log_drop_count, 3 * (LOGL_COUNT - LOGL_FIRST - 1));
Patrick Delaunay742346f2020-11-27 11:20:58 +0100426 check_log_entries_flags_levels(EXPECT_DEBUG, LOGL_FIRST, CONFIG_LOG_DEFAULT_LEVEL);
Patrick Delaunayce9af2a2020-11-27 11:20:53 +0100427
428 gd->flags |= GD_FLG_LOG_READY;
429 gd->log_drop_count = 0;
430
431 return 0;
432}
433LOG_TEST_FLAGS(log_test_dropped, UT_TESTF_CONSOLE_REC);
Simon Glass58b4b712021-05-08 07:00:06 -0600434
435/* Check log_buffer() */
436int log_test_buffer(struct unit_test_state *uts)
437{
438 u8 *buf;
439 int i;
440
441 buf = malloc(0x20);
442 ut_assertnonnull(buf);
443 memset(buf, '\0', 0x20);
444 for (i = 0; i < 0x11; i++)
445 buf[i] = i * 0x11;
446
447 ut_assertok(console_record_reset_enable());
448 log_buffer(LOGC_BOOT, LOGL_INFO, 0, buf, 1, 0x12, 0);
449
450 /* This one should product no output due to the debug level */
451 log_buffer(LOGC_BOOT, LOGL_DEBUG, 0, buf, 1, 0x12, 0);
452
453 ut_assert_nextline("00000000: 00 11 22 33 44 55 66 77 88 99 aa bb cc dd ee ff ..\"3DUfw........");
454 ut_assert_nextline("00000010: 10 00 ..");
455 ut_assert_console_end();
456 free(buf);
457
458 return 0;
459}
460LOG_TEST_FLAGS(log_test_buffer, UT_TESTF_CONSOLE_REC);