blob: 3b3b791f0252aa9dd01410d8cacfe973c5af1ea1 [file] [log] [blame]
Heinrich Schuchardtaf5e6242020-10-17 14:31:59 +02001// 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 Schuchardtaf5e6242020-10-17 14:31:59 +02008#include <console.h>
Simon Glass3ba929a2020-10-30 21:38:53 -06009#include <asm/global_data.h>
Heinrich Schuchardtaf5e6242020-10-17 14:31:59 +020010#include <test/log.h>
11#include <test/test.h>
Heinrich Schuchardtaf5e6242020-10-17 14:31:59 +020012#include <test/ut.h>
13
14DECLARE_GLOBAL_DATA_PTR;
15
Heinrich Schuchardtaf5e6242020-10-17 14:31:59 +020016static int log_test_cont(struct unit_test_state *uts)
17{
18 int log_fmt;
19 int log_level;
20
21 log_fmt = gd->log_fmt;
22 log_level = gd->default_log_level;
23
24 /* Write two messages, the second continuing the first */
25 gd->log_fmt = (1 << LOGF_CAT) | (1 << LOGF_LEVEL) | (1 << LOGF_MSG);
26 gd->default_log_level = LOGL_INFO;
Simon Glass5fc47e32021-01-20 20:10:53 -070027 log(LOGC_ARCH, LOGL_ERR, "ea%d\n", 1);
Heinrich Schuchardtaf5e6242020-10-17 14:31:59 +020028 log(LOGC_CONT, LOGL_CONT, "cc%d\n", 2);
29 gd->default_log_level = log_level;
30 gd->log_fmt = log_fmt;
31 gd->flags &= ~GD_FLG_RECORD;
Simon Glass5fc47e32021-01-20 20:10:53 -070032 ut_assertok(ut_check_console_line(uts, "ERR.arch, ea1"));
33 ut_assertok(ut_check_console_line(uts, "ERR.arch, cc2"));
Simon Glassc579bd42024-08-22 07:58:03 -060034 ut_assert_console_end();
Heinrich Schuchardtaf5e6242020-10-17 14:31:59 +020035
36 /* Write a third message which is not a continuation */
37 gd->log_fmt = (1 << LOGF_CAT) | (1 << LOGF_LEVEL) | (1 << LOGF_MSG);
38 gd->default_log_level = LOGL_INFO;
39 console_record_reset_enable();
40 log(LOGC_EFI, LOGL_INFO, "ie%d\n", 3);
41 gd->default_log_level = log_level;
42 gd->log_fmt = log_fmt;
43 gd->flags &= ~GD_FLG_RECORD;
44 ut_assertok(ut_check_console_line(uts, "INFO.efi, ie3"));
Simon Glassc579bd42024-08-22 07:58:03 -060045 ut_assert_console_end();
Heinrich Schuchardtaf5e6242020-10-17 14:31:59 +020046
Simon Glass5fc47e32021-01-20 20:10:53 -070047 /* Write two messages without a newline between them */
48 gd->log_fmt = (1 << LOGF_CAT) | (1 << LOGF_LEVEL) | (1 << LOGF_MSG);
49 gd->default_log_level = LOGL_INFO;
50 console_record_reset_enable();
51 log(LOGC_ARCH, LOGL_ERR, "ea%d ", 1);
52 log(LOGC_CONT, LOGL_CONT, "cc%d\n", 2);
53 gd->default_log_level = log_level;
54 gd->log_fmt = log_fmt;
55 gd->flags &= ~GD_FLG_RECORD;
56 ut_assertok(ut_check_console_line(uts, "ERR.arch, ea1 cc2"));
Simon Glassc579bd42024-08-22 07:58:03 -060057 ut_assert_console_end();
Simon Glass5fc47e32021-01-20 20:10:53 -070058
Heinrich Schuchardtaf5e6242020-10-17 14:31:59 +020059 return 0;
60}
61LOG_TEST(log_test_cont);