From: Simon Glass <sjg@chromium.org>
To: U-Boot Mailing List <u-boot@lists.denx.de>
Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org>,
Tom Rini <trini@konsulko.com>,
Heinrich Schuchardt <xypron.glpk@gmx.de>,
Simon Glass <sjg@chromium.org>,
Caleb Connolly <caleb.connolly@linaro.org>,
Dmitry Rokosov <ddrokosov@salutedevices.com>,
Jonathan Humphreys <j-humphreys@ti.com>,
Mattijs Korpershoek <mkorpershoek@baylibre.com>,
Neil Armstrong <neil.armstrong@linaro.org>,
Oliver Gaskell <Oliver.Gaskell@analog.com>,
Robert Marko <robert.marko@sartura.hr>,
Sam Protsenko <semen.protsenko@linaro.org>,
Sean Anderson <seanga2@gmail.com>,
Sumit Garg <sumit.garg@linaro.org>
Subject: [PATCH 13/15] test: efi_loader: Add a simple test for the EFI log
Date: Mon, 28 Oct 2024 13:48:04 +0100 [thread overview]
Message-ID: <20241028124815.47262-14-sjg@chromium.org> (raw)
In-Reply-To: <20241028124815.47262-1-sjg@chromium.org>
Create a test which does some sample calls and checks the output.
Expand the size of the sandbox bloblist to accommodate the log.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
MAINTAINERS | 1 +
configs/sandbox_defconfig | 3 +++
lib/efi_loader/efi_log.c | 7 +++---
test/lib/Makefile | 1 +
test/lib/efi_log.c | 49 +++++++++++++++++++++++++++++++++++++++
5 files changed, 57 insertions(+), 4 deletions(-)
create mode 100644 test/lib/efi_log.c
diff --git a/MAINTAINERS b/MAINTAINERS
index 9ade0ca4bc3..3e571174ad5 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1072,6 +1072,7 @@ M: Simon Glass <sjg@chromium.org>
S: Maintained
F: include/efi_log.h
F: lib/efi_loader/efi_log.c
+F: test/lib/efi_log.c
EFI PAYLOAD
M: Heinrich Schuchardt <xypron.glpk@gmx.de>
diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
index d111858082d..afba6c78e28 100644
--- a/configs/sandbox_defconfig
+++ b/configs/sandbox_defconfig
@@ -17,6 +17,7 @@ CONFIG_EFI_CAPSULE_ON_DISK=y
CONFIG_EFI_CAPSULE_FIRMWARE_RAW=y
CONFIG_EFI_CAPSULE_AUTHENTICATE=y
CONFIG_EFI_CAPSULE_CRT_FILE="board/sandbox/capsule_pub_key_good.crt"
+CONFIG_EFI_LOG=y
CONFIG_BUTTON_CMD=y
CONFIG_FIT=y
CONFIG_FIT_RSASSA_PSS=y
@@ -50,6 +51,7 @@ CONFIG_LOG_DEFAULT_LEVEL=6
CONFIG_LOGF_FUNC=y
CONFIG_DISPLAY_BOARDINFO_LATE=y
CONFIG_STACKPROTECTOR=y
+CONFIG_BLOBLIST_SIZE_RELOC=0x5000
CONFIG_CMD_CPU=y
CONFIG_CMD_LICENSE=y
CONFIG_CMD_SMBIOS=y
@@ -72,6 +74,7 @@ CONFIG_CMD_NVEDIT_SELECT=y
CONFIG_LOOPW=y
CONFIG_CMD_MD5SUM=y
CONFIG_CMD_MEMINFO=y
+CONFIG_CMD_MEMINFO=y
CONFIG_CMD_MEM_SEARCH=y
CONFIG_CMD_MX_CYCLIC=y
CONFIG_CMD_MEMTEST=y
diff --git a/lib/efi_loader/efi_log.c b/lib/efi_loader/efi_log.c
index 01e495d3995..780860d8b2f 100644
--- a/lib/efi_loader/efi_log.c
+++ b/lib/efi_loader/efi_log.c
@@ -129,6 +129,7 @@ int efi_logs_testing(enum efil_test_t enum_val, efi_uintn_t int_val,
if (ret < 0)
return ret;
+ rec->enum_val = enum_val;
rec->int_val = int_val;
rec->buffer = buffer;
rec->memory = memory;
@@ -194,10 +195,8 @@ void show_rec(int seq, struct efil_rec_hdr *rec_hdr)
show_addr("buf", map_to_sysmem(rec->buffer));
show_addr("mem", map_to_sysmem(rec->memory));
if (rec_hdr->ended) {
- show_addr("*buf",
- (ulong)map_to_sysmem((void *)rec->e_buffer));
- show_addr("*mem",
- (ulong)rec->e_memory);
+ show_addr("*buf", (ulong)map_to_sysmem(rec->e_buffer));
+ show_addr("*mem", (ulong)rec->e_memory);
show_ret(rec_hdr->e_ret);
}
}
diff --git a/test/lib/Makefile b/test/lib/Makefile
index 217c3baf881..050eaef4bb9 100644
--- a/test/lib/Makefile
+++ b/test/lib/Makefile
@@ -11,6 +11,7 @@ obj-y += abuf.o
obj-y += alist.o
obj-$(CONFIG_EFI_LOADER) += efi_device_path.o
obj-$(CONFIG_EFI_SECURE_BOOT) += efi_image_region.o
+obj-$(CONFIG_EFI_LOG) += efi_log.o
obj-y += hexdump.o
obj-$(CONFIG_SANDBOX) += kconfig.o
obj-y += lmb.o
diff --git a/test/lib/efi_log.c b/test/lib/efi_log.c
new file mode 100644
index 00000000000..414b7081bd9
--- /dev/null
+++ b/test/lib/efi_log.c
@@ -0,0 +1,49 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2024 Google LLC
+ * Written by Simon Glass <sjg@chromium.org>
+ */
+
+#include <efi_log.h>
+#include <mapmem.h>
+#include <test/lib.h>
+#include <test/test.h>
+#include <test/ut.h>
+
+/* basic test of logging */
+static int lib_test_efi_log_base(struct unit_test_state *uts)
+{
+ void **buf = map_sysmem(0x1000, 0);
+ u64 *addr = map_sysmem(0x1010, 0);
+ int ofs1, ofs2;
+
+ ut_assertok(efi_log_reset());
+
+ ofs1 = efi_logs_testing(EFI_LOG_TEST0, 123, &buf[0], &addr[0]);
+
+ ofs2 = efi_logs_testing(EFI_LOG_TEST1, 456, &buf[1], &addr[1]);
+
+ /* simulate an EFI call setting the return values */
+ addr[0] = 0x100;
+ buf[0] = map_sysmem(0x1100, 0);
+ addr[1] = 0x200;
+ buf[1] = map_sysmem(0x1200, 0);
+
+ ut_assertok(efi_loge_testing(ofs2, EFI_LOAD_ERROR));
+ ut_assertok(efi_loge_testing(ofs1, EFI_SUCCESS));
+
+ ut_assertok(efi_log_show());
+ ut_assert_nextline("EFI log (size 98)");
+ ut_assert_nextline(
+ " 0 testing test0 int 7b/123 buf 1000 mem 1010 *buf 1100 *mem 100 ret OK");
+ ut_assert_nextline(
+ " 1 testing test1 int 1c8/456 buf 1008 mem 1018 *buf 1200 *mem 200 ret load");
+ ut_assert_nextline("2 records");
+ ut_assert_console_end();
+
+ unmap_sysmem(buf);
+ unmap_sysmem(addr);
+
+ return 0;
+}
+LIB_TEST(lib_test_efi_log_base, UTF_CONSOLE);
--
2.43.0
next prev parent reply other threads:[~2024-10-28 12:50 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-28 12:47 [PATCH 00/15] efi_loader: Add support for logging to a buffer Simon Glass
2024-10-28 12:47 ` [PATCH 01/15] log: Add a new category for tests Simon Glass
2024-10-28 12:47 ` [PATCH 02/15] test: Allow saving and restoring the bloblist Simon Glass
2024-10-28 12:47 ` [PATCH 03/15] bloblist: test: Mark tests with UTF_BLOBLIST Simon Glass
2024-10-28 12:47 ` [PATCH 04/15] sandbox: Convert sb command to use new macro Simon Glass
2024-10-28 12:47 ` [PATCH 05/15] doc: sandbox: Add docs for the sb command Simon Glass
2024-11-03 23:24 ` Heinrich Schuchardt
2024-10-28 12:47 ` [PATCH 06/15] sandbox: Add a way to show the sandbox memory-mapping Simon Glass
2024-10-29 9:59 ` Ilias Apalodimas
2024-10-29 15:46 ` Simon Glass
2024-10-28 12:47 ` [PATCH 07/15] sandbox: Fix comment for nomap_sysmem() function Simon Glass
2024-10-28 12:47 ` [PATCH 08/15] lmb: Drop extra 16KB of stack space Simon Glass
2024-10-28 12:48 ` [PATCH 09/15] efi_loader: Fix free in ..._media_device_boot_option() Simon Glass
2024-10-29 10:01 ` Ilias Apalodimas
2024-10-29 15:45 ` Simon Glass
2024-10-29 22:13 ` Heinrich Schuchardt
2024-10-31 17:51 ` Simon Glass
2024-10-28 12:48 ` [PATCH 10/15] efi_loader: Add support for logging EFI calls Simon Glass
2024-10-29 11:44 ` Heinrich Schuchardt
2024-10-29 22:19 ` Heinrich Schuchardt
2024-10-31 18:01 ` Simon Glass
2024-10-31 22:30 ` Heinrich Schuchardt
2024-10-31 22:37 ` Tom Rini
2024-11-20 15:37 ` Simon Glass
2024-10-28 12:48 ` [PATCH 11/15] efi_loader: Create the log on startup Simon Glass
2024-10-28 12:48 ` [PATCH 12/15] efi_loader: Add a command to show the EFI log Simon Glass
2024-10-28 12:48 ` Simon Glass [this message]
2024-10-28 12:48 ` [PATCH 14/15] efi_loader: Use the log with memory-related functions Simon Glass
2024-10-28 12:48 ` [PATCH 15/15] efi_loader: Add documentation for the EFI log Simon Glass
2024-10-29 9:58 ` [PATCH 00/15] efi_loader: Add support for logging to a buffer Ilias Apalodimas
2024-10-29 15:45 ` Simon Glass
2024-10-29 18:31 ` Ilias Apalodimas
2024-10-31 18:01 ` Simon Glass
2024-11-01 11:31 ` Ilias Apalodimas
2024-11-20 15:37 ` Simon Glass
2024-11-20 15:55 ` Ilias Apalodimas
2024-11-20 18:06 ` Tom Rini
2024-11-20 20:05 ` Heinrich Schuchardt
2024-11-21 2:19 ` Simon Glass
2024-12-02 0:12 ` Simon Glass
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241028124815.47262-14-sjg@chromium.org \
--to=sjg@chromium.org \
--cc=Oliver.Gaskell@analog.com \
--cc=caleb.connolly@linaro.org \
--cc=ddrokosov@salutedevices.com \
--cc=ilias.apalodimas@linaro.org \
--cc=j-humphreys@ti.com \
--cc=mkorpershoek@baylibre.com \
--cc=neil.armstrong@linaro.org \
--cc=robert.marko@sartura.hr \
--cc=seanga2@gmail.com \
--cc=semen.protsenko@linaro.org \
--cc=sumit.garg@linaro.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
--cc=xypron.glpk@gmx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.