Simon Glass | 8eaaedb | 2021-05-08 13:46:54 -0600 | [diff] [blame] | 1 | // 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 Glass | 8eaaedb | 2021-05-08 13:46:54 -0600 | [diff] [blame] | 8 | #include <console.h> |
| 9 | #include <log.h> |
| 10 | #include <asm/global_data.h> |
| 11 | #include <test/log.h> |
| 12 | #include <test/ut.h> |
| 13 | |
| 14 | DECLARE_GLOBAL_DATA_PTR; |
| 15 | |
| 16 | #define BUFFSIZE 32 |
| 17 | |
| 18 | static 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 Glass | 8eaaedb | 2021-05-08 13:46:54 -0600 | [diff] [blame] | 24 | |
| 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 | } |
| 37 | LOG_TEST(log_test_log_disabled_ndebug); |