mb/google/brya: Enable Fast VMode for brya0, skolas and skolas4es
[coreboot.git] / tests / console / routing-test.c
blob3cba51f7c45ac662c692913bdc97f1393a00789e
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include "../console/init.c"
5 #include <console/console.h>
6 #include <stdlib.h>
7 #include <string.h>
8 #include <stdint.h>
9 #include <tests/test.h>
11 struct log_combinations_t {
12 int log_lvl;
13 int msg_lvl;
14 int behavior;
15 } combinations[] = {
16 {.log_lvl = -1, .msg_lvl = BIOS_ERR, .behavior = CONSOLE_LOG_NONE},
17 {.log_lvl = -1, .msg_lvl = BIOS_SPEW, .behavior = CONSOLE_LOG_NONE},
19 {.log_lvl = BIOS_DEBUG, .msg_lvl = BIOS_ERR, .behavior = CONSOLE_LOG_ALL},
20 {.log_lvl = BIOS_DEBUG, .msg_lvl = BIOS_DEBUG, .behavior = CONSOLE_LOG_ALL},
21 {.log_lvl = BIOS_DEBUG, .msg_lvl = BIOS_SPEW, .behavior = CONSOLE_LOG_NONE},
23 {.log_lvl = BIOS_SPEW, .msg_lvl = BIOS_ERR, .behavior = CONSOLE_LOG_ALL},
24 {.log_lvl = BIOS_SPEW, .msg_lvl = BIOS_DEBUG, .behavior = CONSOLE_LOG_ALL},
25 {.log_lvl = BIOS_SPEW, .msg_lvl = BIOS_SPEW, .behavior = CONSOLE_LOG_ALL},
27 #if CONFIG(CONSOLE_CBMEM)
28 {.log_lvl = BIOS_WARNING, .msg_lvl = BIOS_ERR, .behavior = CONSOLE_LOG_ALL},
29 {.log_lvl = BIOS_WARNING, .msg_lvl = BIOS_DEBUG, .behavior = CONSOLE_LOG_FAST},
30 {.log_lvl = BIOS_WARNING, .msg_lvl = BIOS_SPEW, .behavior = CONSOLE_LOG_NONE},
32 #else
33 {.log_lvl = BIOS_WARNING, .msg_lvl = BIOS_ERR, .behavior = CONSOLE_LOG_ALL},
34 {.log_lvl = BIOS_WARNING, .msg_lvl = BIOS_DEBUG, .behavior = CONSOLE_LOG_NONE},
35 {.log_lvl = BIOS_WARNING, .msg_lvl = BIOS_SPEW, .behavior = CONSOLE_LOG_NONE},
36 #endif
40 static void test_console_log_level(void **state)
42 for (int i = 0; i < ARRAY_SIZE(combinations); i++) {
43 console_loglevel = combinations[i].log_lvl;
44 assert_int_equal(combinations[i].behavior,
45 console_log_level(combinations[i].msg_lvl));
49 static int setup_console_log_level(void **state)
51 console_inited = 1;
52 return 0;
55 static int teardown_console_log_level(void **state)
57 console_inited = 0;
58 return 0;
61 int main(void)
63 const struct CMUnitTest tests[] = {
64 cmocka_unit_test_setup_teardown(test_console_log_level, setup_console_log_level,
65 teardown_console_log_level),
68 return cb_run_group_tests(tests, NULL, NULL);