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 | |
Heinrich Schuchardt | af5e624 | 2020-10-17 14:31:59 +0200 | [diff] [blame] | 8 | #include <console.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 9 | #include <asm/global_data.h> |
Heinrich Schuchardt | af5e624 | 2020-10-17 14:31:59 +0200 | [diff] [blame] | 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 | |
Heinrich Schuchardt | af5e624 | 2020-10-17 14:31:59 +0200 | [diff] [blame] | 17 | static int log_test_cont(struct unit_test_state *uts) |
| 18 | { |
| 19 | int log_fmt; |
| 20 | int log_level; |
| 21 | |
| 22 | log_fmt = gd->log_fmt; |
| 23 | log_level = gd->default_log_level; |
| 24 | |
| 25 | /* Write two messages, the second continuing the first */ |
| 26 | gd->log_fmt = (1 << LOGF_CAT) | (1 << LOGF_LEVEL) | (1 << LOGF_MSG); |
| 27 | gd->default_log_level = LOGL_INFO; |
Simon Glass | 5fc47e3 | 2021-01-20 20:10:53 -0700 | [diff] [blame] | 28 | log(LOGC_ARCH, LOGL_ERR, "ea%d\n", 1); |
Heinrich Schuchardt | af5e624 | 2020-10-17 14:31:59 +0200 | [diff] [blame] | 29 | log(LOGC_CONT, LOGL_CONT, "cc%d\n", 2); |
| 30 | gd->default_log_level = log_level; |
| 31 | gd->log_fmt = log_fmt; |
| 32 | gd->flags &= ~GD_FLG_RECORD; |
Simon Glass | 5fc47e3 | 2021-01-20 20:10:53 -0700 | [diff] [blame] | 33 | ut_assertok(ut_check_console_line(uts, "ERR.arch, ea1")); |
| 34 | ut_assertok(ut_check_console_line(uts, "ERR.arch, cc2")); |
Simon Glass | c579bd4 | 2024-08-22 07:58:03 -0600 | [diff] [blame] | 35 | ut_assert_console_end(); |
Heinrich Schuchardt | af5e624 | 2020-10-17 14:31:59 +0200 | [diff] [blame] | 36 | |
| 37 | /* Write a third message which is not a continuation */ |
| 38 | gd->log_fmt = (1 << LOGF_CAT) | (1 << LOGF_LEVEL) | (1 << LOGF_MSG); |
| 39 | gd->default_log_level = LOGL_INFO; |
| 40 | console_record_reset_enable(); |
| 41 | log(LOGC_EFI, LOGL_INFO, "ie%d\n", 3); |
| 42 | gd->default_log_level = log_level; |
| 43 | gd->log_fmt = log_fmt; |
| 44 | gd->flags &= ~GD_FLG_RECORD; |
| 45 | ut_assertok(ut_check_console_line(uts, "INFO.efi, ie3")); |
Simon Glass | c579bd4 | 2024-08-22 07:58:03 -0600 | [diff] [blame] | 46 | ut_assert_console_end(); |
Heinrich Schuchardt | af5e624 | 2020-10-17 14:31:59 +0200 | [diff] [blame] | 47 | |
Simon Glass | 5fc47e3 | 2021-01-20 20:10:53 -0700 | [diff] [blame] | 48 | /* Write two messages without a newline between them */ |
| 49 | gd->log_fmt = (1 << LOGF_CAT) | (1 << LOGF_LEVEL) | (1 << LOGF_MSG); |
| 50 | gd->default_log_level = LOGL_INFO; |
| 51 | console_record_reset_enable(); |
| 52 | log(LOGC_ARCH, LOGL_ERR, "ea%d ", 1); |
| 53 | log(LOGC_CONT, LOGL_CONT, "cc%d\n", 2); |
| 54 | gd->default_log_level = log_level; |
| 55 | gd->log_fmt = log_fmt; |
| 56 | gd->flags &= ~GD_FLG_RECORD; |
| 57 | ut_assertok(ut_check_console_line(uts, "ERR.arch, ea1 cc2")); |
Simon Glass | c579bd4 | 2024-08-22 07:58:03 -0600 | [diff] [blame] | 58 | ut_assert_console_end(); |
Simon Glass | 5fc47e3 | 2021-01-20 20:10:53 -0700 | [diff] [blame] | 59 | |
Heinrich Schuchardt | af5e624 | 2020-10-17 14:31:59 +0200 | [diff] [blame] | 60 | return 0; |
| 61 | } |
| 62 | LOG_TEST(log_test_cont); |