blob: d33359d59b73f863ada72485a26c68d46f115722 [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);
Simon Glass8eaaedb2021-05-08 13:46:54 -060024
25 /* Output a log record at every level */
26 for (i = LOGL_EMERG; i < LOGL_COUNT; i++)
27 log(LOGC_NONE, i, "testing level %i\n", i);
28 gd->flags &= ~GD_FLG_RECORD;
29
30 /* Since DEBUG is not defined, we expect to not get debug output */
31 for (i = LOGL_EMERG; i < LOGL_DEBUG; i++)
32 ut_assertok(ut_check_console_line(uts, "testing level %d", i));
33 ut_assertok(ut_check_console_end(uts));
34
35 return 0;
36}
37LOG_TEST(log_test_log_disabled_ndebug);