blob: 4dc0f2d3a33578cdce6fd12ac56ccdd5b7c8b445 [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));
Simon Glassc579bd42024-08-22 07:58:03 -060033 ut_assert_console_end();
Simon Glass8eaaedb2021-05-08 13:46:54 -060034
35 return 0;
36}
37LOG_TEST(log_test_log_disabled_ndebug);