1 /*
2  * efi_selftest_textoutput
3  *
4  * Copyright (c) 2017 Heinrich Schuchardt <xypron.glpk@gmx.de>
5  *
6  * SPDX-License-Identifier:     GPL-2.0+
7  *
8  * Test the EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.
9  *
10  * The following services are tested:
11  * OutputString, TestString, SetAttribute.
12  */
13 
14 #include <efi_selftest.h>
15 
16 /*
17  * Execute unit test.
18  *
19  * @return:	EFI_ST_SUCCESS for success
20  */
21 static int execute(void)
22 {
23 	size_t foreground;
24 	size_t background;
25 	size_t attrib;
26 	efi_status_t ret;
27 
28 	/* SetAttribute */
29 	efi_st_printf("\nColor palette\n");
30 	for (foreground = 0; foreground < 0x10; ++foreground) {
31 		for (background = 0; background < 0x80; background += 0x10) {
32 			attrib = foreground | background;
33 			con_out->set_attribute(con_out, attrib);
34 			efi_st_printf("%p", (void *)attrib);
35 		}
36 		con_out->set_attribute(con_out, 0);
37 		efi_st_printf("\n");
38 	}
39 	/* TestString */
40 	ret = con_out->test_string(con_out,
41 			L" !\"#$%&'()*+,-./0-9:;<=>?@A-Z[\\]^_`a-z{|}~\n");
42 	if (ret != EFI_ST_SUCCESS) {
43 		efi_st_error("TestString failed for ANSI characters\n");
44 		return EFI_ST_FAILURE;
45 	}
46 	return EFI_ST_SUCCESS;
47 }
48 
49 EFI_UNIT_TEST(textoutput) = {
50 	.name = "text output",
51 	.phase = EFI_EXECUTE_BEFORE_BOOTTIME_EXIT,
52 	.execute = execute,
53 };
54