aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/Makefile2
-rw-r--r--test/bloblist.c13
-rw-r--r--test/cmd/mem.c2
-rw-r--r--test/lib/Makefile2
-rw-r--r--test/log/Makefile1
-rw-r--r--test/log/pr_cont_test.c45
-rw-r--r--test/str_ut.c4
-rw-r--r--test/ut.c18
8 files changed, 73 insertions, 14 deletions
diff --git a/test/Makefile b/test/Makefile
index d4323f9963..3c7bc8b549 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -2,7 +2,7 @@
#
# (C) Copyright 2012 The Chromium Authors
-ifneq ($(CONFIG_SANDBOX),)
+ifneq ($(CONFIG_$(SPL_)BLOBLIST),)
obj-$(CONFIG_$(SPL_)CMDLINE) += bloblist.o
endif
obj-$(CONFIG_$(SPL_)CMDLINE) += bootm.o
diff --git a/test/bloblist.c b/test/bloblist.c
index 0bb9e2d81e..900299dd68 100644
--- a/test/bloblist.c
+++ b/test/bloblist.c
@@ -7,7 +7,6 @@
#include <bloblist.h>
#include <log.h>
#include <mapmem.h>
-#include <asm/state.h>
#include <test/suites.h>
#include <test/test.h>
#include <test/ut.h>
@@ -240,7 +239,6 @@ BLOBLIST_TEST(bloblist_test_checksum, 0);
/* Test the 'bloblist info' command */
static int bloblist_test_cmd_info(struct unit_test_state *uts)
{
- struct sandbox_state *state = state_get_current();
struct bloblist_hdr *hdr;
char *data, *data2;
@@ -250,8 +248,7 @@ static int bloblist_test_cmd_info(struct unit_test_state *uts)
data2 = bloblist_ensure(TEST_TAG2, TEST_SIZE2);
console_record_reset_enable();
- if (!state->show_test_output)
- gd->flags |= GD_FLG_SILENT;
+ ut_silence_console(uts);
console_record_reset();
run_command("bloblist info", 0);
ut_assert_nextline("base: %lx", (ulong)map_to_sysmem(hdr));
@@ -259,7 +256,7 @@ static int bloblist_test_cmd_info(struct unit_test_state *uts)
ut_assert_nextline("alloced: 70 112 Bytes");
ut_assert_nextline("free: 390 912 Bytes");
ut_assert_console_end();
- gd->flags &= ~(GD_FLG_SILENT | GD_FLG_RECORD);
+ ut_unsilence_console(uts);
return 0;
}
@@ -268,7 +265,6 @@ BLOBLIST_TEST(bloblist_test_cmd_info, 0);
/* Test the 'bloblist list' command */
static int bloblist_test_cmd_list(struct unit_test_state *uts)
{
- struct sandbox_state *state = state_get_current();
struct bloblist_hdr *hdr;
char *data, *data2;
@@ -278,8 +274,7 @@ static int bloblist_test_cmd_list(struct unit_test_state *uts)
data2 = bloblist_ensure(TEST_TAG2, TEST_SIZE2);
console_record_reset_enable();
- if (!state->show_test_output)
- gd->flags |= GD_FLG_SILENT;
+ ut_silence_console(uts);
console_record_reset();
run_command("bloblist list", 0);
ut_assert_nextline("Address Size Tag Name");
@@ -288,7 +283,7 @@ static int bloblist_test_cmd_list(struct unit_test_state *uts)
ut_assert_nextline("%08lx %8x 2 SPL hand-off",
(ulong)map_to_sysmem(data2), TEST_SIZE2);
ut_assert_console_end();
- gd->flags &= ~(GD_FLG_SILENT | GD_FLG_RECORD);
+ ut_unsilence_console(uts);
return 0;
}
diff --git a/test/cmd/mem.c b/test/cmd/mem.c
index fa6770e8c0..fbaa8a4b3c 100644
--- a/test/cmd/mem.c
+++ b/test/cmd/mem.c
@@ -15,6 +15,6 @@ int do_ut_mem(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
struct unit_test *tests = ll_entry_start(struct unit_test, mem_test);
const int n_ents = ll_entry_count(struct unit_test, mem_test);
- return cmd_ut_category("cmd_mem", "cmd_mem_", tests, n_ents, argc,
+ return cmd_ut_category("cmd_mem", "mem_test_", tests, n_ents, argc,
argv);
}
diff --git a/test/lib/Makefile b/test/lib/Makefile
index 98a9abf40e..97c11e35a8 100644
--- a/test/lib/Makefile
+++ b/test/lib/Makefile
@@ -7,7 +7,7 @@ obj-$(CONFIG_EFI_LOADER) += efi_device_path.o
obj-$(CONFIG_EFI_SECURE_BOOT) += efi_image_region.o
obj-y += hexdump.o
obj-y += lmb.o
-obj-y += test_print.o
+obj-$(CONFIG_CONSOLE_RECORD) += test_print.o
obj-$(CONFIG_SSCANF) += sscanf.o
obj-y += string.o
obj-$(CONFIG_ERRNO_STR) += test_errno_str.o
diff --git a/test/log/Makefile b/test/log/Makefile
index 88bc573e9f..afdafa502a 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 0000000000..236eff4b33
--- /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);
diff --git a/test/str_ut.c b/test/str_ut.c
index ef1205dbbd..cd5045516d 100644
--- a/test/str_ut.c
+++ b/test/str_ut.c
@@ -19,7 +19,7 @@ static const char str3[] = "0xbI'm sorry you're alive.";
/* Declare a new str test */
#define STR_TEST(_name, _flags) UNIT_TEST(_name, _flags, str_test)
-static int str_test_upper(struct unit_test_state *uts)
+static int str_upper(struct unit_test_state *uts)
{
char out[TEST_STR_SIZE];
@@ -55,7 +55,7 @@ static int str_test_upper(struct unit_test_state *uts)
return 0;
}
-STR_TEST(str_test_upper, 0);
+STR_TEST(str_upper, 0);
static int run_strtoul(struct unit_test_state *uts, const char *str, int base,
ulong expect_val, int expect_endp_offset, bool upper)
diff --git a/test/ut.c b/test/ut.c
index 95bdd66de6..44ed1ba2d3 100644
--- a/test/ut.c
+++ b/test/ut.c
@@ -8,6 +8,9 @@
#include <common.h>
#include <console.h>
#include <malloc.h>
+#ifdef CONFIG_SANDBOX
+#include <asm/state.h>
+#endif
#include <test/test.h>
#include <test/ut.h>
@@ -114,3 +117,18 @@ int ut_check_console_dump(struct unit_test_state *uts, int total_bytes)
return upto == total_bytes ? 0 : 1;
}
+
+void ut_silence_console(struct unit_test_state *uts)
+{
+#ifdef CONFIG_SANDBOX
+ struct sandbox_state *state = state_get_current();
+
+ if (!state->show_test_output)
+ gd->flags |= GD_FLG_SILENT;
+#endif
+}
+
+void ut_unsilence_console(struct unit_test_state *uts)
+{
+ gd->flags &= ~(GD_FLG_SILENT | GD_FLG_RECORD);
+}