efi_selftest_textoutput.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. #include <efi_selftest.h>
  14. /*
  15. * Execute unit test.
  16. *
  17. * @return: EFI_ST_SUCCESS for success
  18. */
  19. static int execute(void)
  20. {
  21. size_t foreground;
  22. size_t background;
  23. size_t attrib;
  24. efi_status_t ret;
  25. /* SetAttribute */
  26. efi_st_printf("\nColor palette\n");
  27. for (foreground = 0; foreground < 0x10; ++foreground) {
  28. for (background = 0; background < 0x80; background += 0x10) {
  29. attrib = foreground | background;
  30. con_out->set_attribute(con_out, attrib);
  31. efi_st_printf("%p", (void *)attrib);
  32. }
  33. con_out->set_attribute(con_out, 0);
  34. efi_st_printf("\n");
  35. }
  36. /* TestString */
  37. ret = con_out->test_string(con_out,
  38. L" !\"#$%&'()*+,-./0-9:;<=>?@A-Z[\\]^_`a-z{|}~\n");
  39. if (ret != EFI_ST_SUCCESS) {
  40. efi_st_error("TestString failed for ANSI characters\n");
  41. return EFI_ST_FAILURE;
  42. }
  43. return EFI_ST_SUCCESS;
  44. }
  45. EFI_UNIT_TEST(textoutput) = {
  46. .name = "text output",
  47. .phase = EFI_EXECUTE_BEFORE_BOOTTIME_EXIT,
  48. .execute = execute,
  49. };