1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include "../console/init.c"
5 #include <console/console.h>
9 #include <tests/test.h>
11 struct log_combinations_t
{
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
},
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
},
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
)
55 static int teardown_console_log_level(void **state
)
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
);