efi_selftest_textoutput.c 1.2 KB

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