Heinrich Schuchardt | af5e624 | 2020-10-17 14:31:59 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * Copyright (c) 2020, Heinrich Schuchardt <xypron.glpk@gmx.de> |
| 4 | * |
| 5 | * Test continuation of log messages. |
| 6 | */ |
| 7 | |
| 8 | #include <common.h> |
| 9 | #include <console.h> |
| 10 | #include <test/log.h> |
| 11 | #include <test/test.h> |
| 12 | #include <test/suites.h> |
| 13 | #include <test/ut.h> |
| 14 | |
| 15 | DECLARE_GLOBAL_DATA_PTR; |
| 16 | |
| 17 | #define BUFFSIZE 64 |
| 18 | |
| 19 | static int log_test_cont(struct unit_test_state *uts) |
| 20 | { |
| 21 | int log_fmt; |
| 22 | int log_level; |
| 23 | |
| 24 | log_fmt = gd->log_fmt; |
| 25 | log_level = gd->default_log_level; |
| 26 | |
| 27 | /* Write two messages, the second continuing the first */ |
| 28 | gd->log_fmt = (1 << LOGF_CAT) | (1 << LOGF_LEVEL) | (1 << LOGF_MSG); |
| 29 | gd->default_log_level = LOGL_INFO; |
| 30 | console_record_reset_enable(); |
| 31 | log(LOGC_ARCH, LOGL_ERR, "ea%d ", 1); |
| 32 | log(LOGC_CONT, LOGL_CONT, "cc%d\n", 2); |
| 33 | gd->default_log_level = log_level; |
| 34 | gd->log_fmt = log_fmt; |
| 35 | gd->flags &= ~GD_FLG_RECORD; |
| 36 | ut_assertok(ut_check_console_line(uts, "ERR.arch, ea1 ERR.arch, cc2")); |
| 37 | ut_assertok(ut_check_console_end(uts)); |
| 38 | |
| 39 | /* Write a third message which is not a continuation */ |
| 40 | gd->log_fmt = (1 << LOGF_CAT) | (1 << LOGF_LEVEL) | (1 << LOGF_MSG); |
| 41 | gd->default_log_level = LOGL_INFO; |
| 42 | console_record_reset_enable(); |
| 43 | log(LOGC_EFI, LOGL_INFO, "ie%d\n", 3); |
| 44 | gd->default_log_level = log_level; |
| 45 | gd->log_fmt = log_fmt; |
| 46 | gd->flags &= ~GD_FLG_RECORD; |
| 47 | ut_assertok(ut_check_console_line(uts, "INFO.efi, ie3")); |
| 48 | ut_assertok(ut_check_console_end(uts)); |
| 49 | |
| 50 | return 0; |
| 51 | } |
| 52 | LOG_TEST(log_test_cont); |