]> Git Repo - J-u-boot.git/blob - test/log/cont_test.c
Merge patch series "FWU: Add support for FWU metadata version 2"
[J-u-boot.git] / test / log / cont_test.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Copyright (c) 2020, Heinrich Schuchardt <[email protected]>
4  *
5  * Test continuation of log messages.
6  */
7
8 #include <console.h>
9 #include <asm/global_data.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 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;
28         console_record_reset_enable();
29         log(LOGC_ARCH, LOGL_ERR, "ea%d\n", 1);
30         log(LOGC_CONT, LOGL_CONT, "cc%d\n", 2);
31         gd->default_log_level = log_level;
32         gd->log_fmt = log_fmt;
33         gd->flags &= ~GD_FLG_RECORD;
34         ut_assertok(ut_check_console_line(uts, "ERR.arch, ea1"));
35         ut_assertok(ut_check_console_line(uts, "ERR.arch, cc2"));
36         ut_assertok(ut_check_console_end(uts));
37
38         /* Write a third message which is not a continuation */
39         gd->log_fmt = (1 << LOGF_CAT) | (1 << LOGF_LEVEL) | (1 << LOGF_MSG);
40         gd->default_log_level = LOGL_INFO;
41         console_record_reset_enable();
42         log(LOGC_EFI, LOGL_INFO, "ie%d\n", 3);
43         gd->default_log_level = log_level;
44         gd->log_fmt = log_fmt;
45         gd->flags &= ~GD_FLG_RECORD;
46         ut_assertok(ut_check_console_line(uts, "INFO.efi, ie3"));
47         ut_assertok(ut_check_console_end(uts));
48
49         /* Write two messages without a newline between them */
50         gd->log_fmt = (1 << LOGF_CAT) | (1 << LOGF_LEVEL) | (1 << LOGF_MSG);
51         gd->default_log_level = LOGL_INFO;
52         console_record_reset_enable();
53         log(LOGC_ARCH, LOGL_ERR, "ea%d ", 1);
54         log(LOGC_CONT, LOGL_CONT, "cc%d\n", 2);
55         gd->default_log_level = log_level;
56         gd->log_fmt = log_fmt;
57         gd->flags &= ~GD_FLG_RECORD;
58         ut_assertok(ut_check_console_line(uts, "ERR.arch, ea1 cc2"));
59         ut_assertok(ut_check_console_end(uts));
60
61         return 0;
62 }
63 LOG_TEST(log_test_cont);
This page took 0.028022 seconds and 4 git commands to generate.