summaryrefslogtreecommitdiff
path: root/lib/efi_selftest
diff options
context:
space:
mode:
authorHeinrich Schuchardt <xypron.glpk@gmx.de>2017-10-18 18:13:19 +0200
committerAlexander Graf <agraf@suse.de>2017-12-01 13:22:55 +0100
commit7406f824b8833447b15ef84b278b0c92bbe02922 (patch)
tree226a8023f6a41ddb6e2d4dfe3034cfd5b8b9e07f /lib/efi_selftest
parent83dee949cb0ad33f36001f39e8aed31ed30e151b (diff)
efi_selftest: provide test for EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
The following services are tested: OutputString, TestString, SetAttribute. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'lib/efi_selftest')
-rw-r--r--lib/efi_selftest/Makefile3
-rw-r--r--lib/efi_selftest/efi_selftest_textoutput.c53
2 files changed, 56 insertions, 0 deletions
diff --git a/lib/efi_selftest/Makefile b/lib/efi_selftest/Makefile
index 3e5c9a6d16..88b998bd4c 100644
--- a/lib/efi_selftest/Makefile
+++ b/lib/efi_selftest/Makefile
@@ -17,6 +17,8 @@ CFLAGS_efi_selftest_exitbootservices.o := $(CFLAGS_EFI)
CFLAGS_REMOVE_efi_selftest_exitbootservices.o := $(CFLAGS_NON_EFI)
CFLAGS_efi_selftest_snp.o := $(CFLAGS_EFI)
CFLAGS_REMOVE_efi_selftest_snp.o := $(CFLAGS_NON_EFI)
+CFLAGS_efi_selftest_textoutput.o := $(CFLAGS_EFI)
+CFLAGS_REVMOE_efi_selftest_textoutput.o := $(CFLAGS_NON_EFI)
CFLAGS_efi_selftest_tpl.o := $(CFLAGS_EFI)
CFLAGS_REMOVE_efi_selftest_tpl.o := $(CFLAGS_NON_EFI)
CFLAGS_efi_selftest_util.o := $(CFLAGS_EFI)
@@ -30,6 +32,7 @@ efi_selftest_console.o \
efi_selftest_events.o \
efi_selftest_exitbootservices.o \
efi_selftest_snp.o \
+efi_selftest_textoutput.o \
efi_selftest_tpl.o \
efi_selftest_util.o \
efi_selftest_watchdog.o
diff --git a/lib/efi_selftest/efi_selftest_textoutput.c b/lib/efi_selftest/efi_selftest_textoutput.c
new file mode 100644
index 0000000000..6e8c90cc8b
--- /dev/null
+++ b/lib/efi_selftest/efi_selftest_textoutput.c
@@ -0,0 +1,53 @@
+/*
+ * efi_selftest_textoutput
+ *
+ * Copyright (c) 2017 Heinrich Schuchardt <xypron.glpk@gmx.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ *
+ * Test the EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.
+ *
+ * The following services are tested:
+ * OutputString, TestString, SetAttribute.
+ */
+
+#include <efi_selftest.h>
+
+/*
+ * Execute unit test.
+ *
+ * @return: EFI_ST_SUCCESS for success
+ */
+static int execute(void)
+{
+ size_t foreground;
+ size_t background;
+ size_t attrib;
+ efi_status_t ret;
+
+ /* SetAttribute */
+ efi_st_printf("\nColor palette\n");
+ for (foreground = 0; foreground < 0x10; ++foreground) {
+ for (background = 0; background < 0x80; background += 0x10) {
+ attrib = foreground | background;
+ con_out->set_attribute(con_out, attrib);
+ efi_st_printf("%p", (void *)attrib);
+ }
+ con_out->set_attribute(con_out, 0);
+ efi_st_printf("\n");
+ }
+ /* TestString */
+ ret = con_out->test_string(con_out,
+ L" !\"#$%&'()*+,-./0-9:;<=>?@A-Z[\\]^_`a-z{|}~\n");
+ if (ret != EFI_ST_SUCCESS) {
+ efi_st_error("TestString failed for ANSI characters\n");
+ return EFI_ST_FAILURE;
+ }
+ return EFI_ST_SUCCESS;
+}
+
+EFI_UNIT_TEST(textoutput) = {
+ .name = "text output",
+ .phase = EFI_EXECUTE_BEFORE_BOOTTIME_EXIT,
+ .execute = execute,
+};