diff options
author | Heinrich Schuchardt <xypron.glpk@gmx.de> | 2021-01-04 08:02:56 +0100 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2021-01-16 12:11:43 -0500 |
commit | e578d5b1d94c535e9d71f0e76ade864a06a198fc (patch) | |
tree | 6806b4729bb212c2c07733dd8ad4a8d639bb77d0 | |
parent | d806199bb6670bc0ac7dd43c9eb6288522d07c2f (diff) | |
download | u-boot-e578d5b1d94c535e9d71f0e76ade864a06a198fc.zip u-boot-e578d5b1d94c535e9d71f0e76ade864a06a198fc.tar.gz u-boot-e578d5b1d94c535e9d71f0e76ade864a06a198fc.tar.bz2 |
test: unit test for pr_err(), pr_cont()
Provide a unit test for printing via pr_err() and pr_cont().
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
-rw-r--r-- | test/log/Makefile | 1 | ||||
-rw-r--r-- | test/log/pr_cont_test.c | 45 |
2 files changed, 46 insertions, 0 deletions
diff --git a/test/log/Makefile b/test/log/Makefile index 88bc573..afdafa5 100644 --- a/test/log/Makefile +++ b/test/log/Makefile @@ -8,6 +8,7 @@ obj-$(CONFIG_CMD_LOG) += log_filter.o ifdef CONFIG_UT_LOG obj-y += test-main.o +obj-y += pr_cont_test.o ifdef CONFIG_SANDBOX obj-$(CONFIG_LOG_SYSLOG) += syslog_test.o diff --git a/test/log/pr_cont_test.c b/test/log/pr_cont_test.c new file mode 100644 index 0000000..236eff4 --- /dev/null +++ b/test/log/pr_cont_test.c @@ -0,0 +1,45 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (c) 2021, Heinrich Schuchardt <xypron.glpk@gmx.de> + * + * Test continuation of log messages using pr_cont(). + */ + +#include <common.h> +#include <console.h> +#include <test/log.h> +#include <test/test.h> +#include <test/suites.h> +#include <test/ut.h> +#include <linux/printk.h> + +#define BUFFSIZE 64 + +#undef CONFIG_LOGLEVEL +#define CONFIG_LOGLEVEL 4 + +DECLARE_GLOBAL_DATA_PTR; + +static int log_test_pr_cont(struct unit_test_state *uts) +{ + int log_fmt; + int log_level; + + log_fmt = gd->log_fmt; + log_level = gd->default_log_level; + + /* Write two messages, the second continuing the first */ + gd->log_fmt = BIT(LOGF_MSG); + gd->default_log_level = LOGL_INFO; + console_record_reset_enable(); + pr_err("ea%d ", 1); + pr_cont("cc%d\n", 2); + gd->default_log_level = log_level; + gd->log_fmt = log_fmt; + gd->flags &= ~GD_FLG_RECORD; + ut_assertok(ut_check_console_line(uts, "ea1 cc2")); + ut_assertok(ut_check_console_end(uts)); + + return 0; +} +LOG_TEST(log_test_pr_cont); |