Heinrich Schuchardt | b5a828e | 2021-01-04 08:02:56 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * Copyright (c) 2021, Heinrich Schuchardt <xypron.glpk@gmx.de> |
| 4 | * |
| 5 | * Test continuation of log messages using pr_cont(). |
| 6 | */ |
| 7 | |
Heinrich Schuchardt | b5a828e | 2021-01-04 08:02:56 +0100 | [diff] [blame] | 8 | #include <console.h> |
| 9 | #include <test/log.h> |
| 10 | #include <test/test.h> |
| 11 | #include <test/suites.h> |
| 12 | #include <test/ut.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 13 | #include <asm/global_data.h> |
Heinrich Schuchardt | b5a828e | 2021-01-04 08:02:56 +0100 | [diff] [blame] | 14 | #include <linux/printk.h> |
| 15 | |
| 16 | #define BUFFSIZE 64 |
| 17 | |
Heinrich Schuchardt | b5a828e | 2021-01-04 08:02:56 +0100 | [diff] [blame] | 18 | DECLARE_GLOBAL_DATA_PTR; |
| 19 | |
| 20 | static int log_test_pr_cont(struct unit_test_state *uts) |
| 21 | { |
| 22 | int log_fmt; |
| 23 | int log_level; |
| 24 | |
| 25 | log_fmt = gd->log_fmt; |
| 26 | log_level = gd->default_log_level; |
| 27 | |
| 28 | /* Write two messages, the second continuing the first */ |
| 29 | gd->log_fmt = BIT(LOGF_MSG); |
| 30 | gd->default_log_level = LOGL_INFO; |
Heinrich Schuchardt | b5a828e | 2021-01-04 08:02:56 +0100 | [diff] [blame] | 31 | pr_err("ea%d ", 1); |
| 32 | pr_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, "ea1 cc2")); |
| 37 | ut_assertok(ut_check_console_end(uts)); |
| 38 | |
| 39 | return 0; |
| 40 | } |
| 41 | LOG_TEST(log_test_pr_cont); |