blob: b714a16d2e7e0c7b1f4fedb212d27a495ee153cc [file] [log] [blame]
Simon Glass8eaaedb2021-05-08 13:46:54 -06001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright 2021 Google LLC
4 *
5 * Logging function tests for CONFIG_LOG=n without #define DEBUG
6 */
7
Simon Glass8eaaedb2021-05-08 13:46:54 -06008#include <console.h>
9#include <log.h>
10#include <asm/global_data.h>
11#include <test/log.h>
12#include <test/ut.h>
13
14DECLARE_GLOBAL_DATA_PTR;
15
16#define BUFFSIZE 32
17
18static int log_test_log_disabled_ndebug(struct unit_test_state *uts)
19{
20 char buf[BUFFSIZE];
21 int i;
22
23 memset(buf, 0, BUFFSIZE);
24 console_record_reset_enable();
25
26 /* Output a log record at every level */
27 for (i = LOGL_EMERG; i < LOGL_COUNT; i++)
28 log(LOGC_NONE, i, "testing level %i\n", i);
29 gd->flags &= ~GD_FLG_RECORD;
30
31 /* Since DEBUG is not defined, we expect to not get debug output */
32 for (i = LOGL_EMERG; i < LOGL_DEBUG; i++)
33 ut_assertok(ut_check_console_line(uts, "testing level %d", i));
34 ut_assertok(ut_check_console_end(uts));
35
36 return 0;
37}
38LOG_TEST(log_test_log_disabled_ndebug);