test_efi_selftest.py 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. # SPDX-License-Identifier: GPL-2.0
  2. # Copyright (c) 2017, Heinrich Schuchardt <xypron.glpk@gmx.de>
  3. # Test efi API implementation
  4. import pytest
  5. import u_boot_utils
  6. @pytest.mark.buildconfigspec('cmd_bootefi_selftest')
  7. def test_efi_selftest(u_boot_console):
  8. """
  9. Run bootefi selftest
  10. """
  11. u_boot_console.run_command(cmd='setenv efi_selftest')
  12. u_boot_console.run_command(cmd='bootefi selftest', wait_for_prompt=False)
  13. m = u_boot_console.p.expect(['Summary: 0 failures', 'Press any key'])
  14. if m != 0:
  15. raise Exception('Failures occured during the EFI selftest')
  16. u_boot_console.run_command(cmd='', wait_for_echo=False, wait_for_prompt=False);
  17. m = u_boot_console.p.expect(['resetting', 'U-Boot'])
  18. if m != 0:
  19. raise Exception('Reset failed during the EFI selftest')
  20. u_boot_console.restart_uboot();
  21. @pytest.mark.buildconfigspec('cmd_bootefi_selftest')
  22. @pytest.mark.buildconfigspec('of_control')
  23. def test_efi_selftest_device_tree(u_boot_console):
  24. u_boot_console.run_command(cmd='setenv efi_selftest list')
  25. output = u_boot_console.run_command('bootefi selftest')
  26. assert '\'device tree\'' in output
  27. u_boot_console.run_command(cmd='setenv efi_selftest device tree')
  28. u_boot_console.run_command(cmd='setenv -f serial# Testing DT')
  29. u_boot_console.run_command(cmd='bootefi selftest ${fdtcontroladdr}', wait_for_prompt=False)
  30. m = u_boot_console.p.expect(['serial-number: Testing DT', 'U-Boot'])
  31. if m != 0:
  32. raise Exception('Reset failed in \'device tree\' test')
  33. u_boot_console.restart_uboot();
  34. @pytest.mark.buildconfigspec('cmd_bootefi_selftest')
  35. def test_efi_selftest_watchdog_reboot(u_boot_console):
  36. u_boot_console.run_command(cmd='setenv efi_selftest list')
  37. output = u_boot_console.run_command('bootefi selftest')
  38. assert '\'watchdog reboot\'' in output
  39. u_boot_console.run_command(cmd='setenv efi_selftest watchdog reboot')
  40. u_boot_console.run_command(cmd='bootefi selftest', wait_for_prompt=False)
  41. m = u_boot_console.p.expect(['resetting', 'U-Boot'])
  42. if m != 0:
  43. raise Exception('Reset failed in \'watchdog reboot\' test')
  44. u_boot_console.restart_uboot();
  45. @pytest.mark.buildconfigspec('cmd_bootefi_selftest')
  46. def test_efi_selftest_text_input(u_boot_console):
  47. """Test the EFI_SIMPLE_TEXT_INPUT_PROTOCOL
  48. :param u_boot_console: U-Boot console
  49. This function calls the text input EFI selftest.
  50. """
  51. u_boot_console.run_command(cmd='setenv efi_selftest text input')
  52. output = u_boot_console.run_command(cmd='bootefi selftest',
  53. wait_for_prompt=False)
  54. m = u_boot_console.p.expect(['To terminate type \'x\''])
  55. if m != 0:
  56. raise Exception('No prompt for \'text input\' test')
  57. u_boot_console.drain_console()
  58. u_boot_console.p.timeout = 500
  59. # EOT
  60. u_boot_console.run_command(cmd=chr(4), wait_for_echo=False,
  61. send_nl=False, wait_for_prompt=False)
  62. m = u_boot_console.p.expect(['Unicode char 4'])
  63. if m != 0:
  64. raise Exception('EOT failed in \'text input\' test')
  65. u_boot_console.drain_console()
  66. # BS
  67. u_boot_console.run_command(cmd=chr(8), wait_for_echo=False,
  68. send_nl=False, wait_for_prompt=False)
  69. m = u_boot_console.p.expect(['(BS)'])
  70. if m != 0:
  71. raise Exception('BS failed in \'text input\' test')
  72. u_boot_console.drain_console()
  73. # TAB
  74. u_boot_console.run_command(cmd=chr(9), wait_for_echo=False,
  75. send_nl=False, wait_for_prompt=False)
  76. m = u_boot_console.p.expect(['(TAB)'])
  77. if m != 0:
  78. raise Exception('BS failed in \'text input\' test')
  79. u_boot_console.drain_console()
  80. # a
  81. u_boot_console.run_command(cmd='a', wait_for_echo=False, send_nl=False,
  82. wait_for_prompt=False)
  83. m = u_boot_console.p.expect(['(\'a\')'])
  84. if m != 0:
  85. raise Exception('\'a\' failed in \'text input\' test')
  86. u_boot_console.drain_console()
  87. # UP escape sequence
  88. u_boot_console.run_command(cmd=chr(27) + '[A', wait_for_echo=False,
  89. send_nl=False, wait_for_prompt=False)
  90. m = u_boot_console.p.expect(['(Up)'])
  91. if m != 0:
  92. raise Exception('UP failed in \'text input\' test')
  93. u_boot_console.drain_console()
  94. u_boot_console.run_command(cmd='x', wait_for_echo=False, send_nl=False,
  95. wait_for_prompt=False)
  96. m = u_boot_console.p.expect(['Summary: 0 failures', 'Press any key'])
  97. if m != 0:
  98. raise Exception('Failures occurred during the EFI selftest')
  99. u_boot_console.restart_uboot();