Heinrich Schuchardt | c548a38 | 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 | |
Tom Rini | d678a59 | 2024-05-18 20:20:43 -0600 | [diff] [blame] | 8 | #include <common.h> |
Heinrich Schuchardt | c548a38 | 2021-01-04 08:02:56 +0100 | [diff] [blame] | 9 | #include <console.h> |
| 10 | #include <test/log.h> |
| 11 | #include <test/test.h> |
| 12 | #include <test/suites.h> |
| 13 | #include <test/ut.h> |
Simon Glass | 401d1c4 | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 14 | #include <asm/global_data.h> |
Heinrich Schuchardt | c548a38 | 2021-01-04 08:02:56 +0100 | [diff] [blame] | 15 | #include <linux/printk.h> |
| 16 | |
| 17 | #define BUFFSIZE 64 |
| 18 | |
Heinrich Schuchardt | c548a38 | 2021-01-04 08:02:56 +0100 | [diff] [blame] | 19 | DECLARE_GLOBAL_DATA_PTR; |
| 20 | |
| 21 | static int log_test_pr_cont(struct unit_test_state *uts) |
| 22 | { |
| 23 | int log_fmt; |
| 24 | int log_level; |
| 25 | |
| 26 | log_fmt = gd->log_fmt; |
| 27 | log_level = gd->default_log_level; |
| 28 | |
| 29 | /* Write two messages, the second continuing the first */ |
| 30 | gd->log_fmt = BIT(LOGF_MSG); |
| 31 | gd->default_log_level = LOGL_INFO; |
| 32 | console_record_reset_enable(); |
| 33 | pr_err("ea%d ", 1); |
| 34 | pr_cont("cc%d\n", 2); |
| 35 | gd->default_log_level = log_level; |
| 36 | gd->log_fmt = log_fmt; |
| 37 | gd->flags &= ~GD_FLG_RECORD; |
| 38 | ut_assertok(ut_check_console_line(uts, "ea1 cc2")); |
| 39 | ut_assertok(ut_check_console_end(uts)); |
| 40 | |
| 41 | return 0; |
| 42 | } |
| 43 | LOG_TEST(log_test_pr_cont); |