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