1 # SPDX-License-Identifier: GPL-2.0
2 # Copyright (c) 2017, Heinrich Schuchardt <xypron.glpk@gmx.de>
5 Test UEFI API implementation
10 @pytest.mark.buildconfigspec('cmd_bootefi_selftest')
11 def test_efi_selftest(u_boot_console):
12 """Run UEFI unit tests
14 :param u_boot_console: U-Boot console
16 This function executes all selftests that are not marked as on request.
18 u_boot_console.run_command(cmd='setenv efi_selftest')
19 u_boot_console.run_command(cmd='bootefi selftest', wait_for_prompt=False)
20 m = u_boot_console.p.expect(['Summary: 0 failures', 'Press any key'])
22 raise Exception('Failures occurred during the EFI selftest')
23 u_boot_console.restart_uboot()
25 @pytest.mark.buildconfigspec('cmd_bootefi_selftest')
26 @pytest.mark.buildconfigspec('of_control')
27 @pytest.mark.notbuildconfigspec('generate_acpi_table')
28 def test_efi_selftest_device_tree(u_boot_console):
29 """Test the device tree support in the UEFI sub-system
31 :param u_boot_console: U-Boot console
33 This test executes the UEFI unit test by calling 'bootefi selftest'.
35 u_boot_console.run_command(cmd='setenv efi_selftest list')
36 output = u_boot_console.run_command('bootefi selftest')
37 assert '\'device tree\'' in output
38 u_boot_console.run_command(cmd='setenv efi_selftest device tree')
39 u_boot_console.run_command(cmd='setenv -f serial# Testing DT')
40 u_boot_console.run_command(cmd='bootefi selftest ${fdtcontroladdr}', wait_for_prompt=False)
41 m = u_boot_console.p.expect(['serial-number: Testing DT', 'U-Boot'])
43 raise Exception('serial-number missing in device tree')
44 u_boot_console.restart_uboot()
46 @pytest.mark.buildconfigspec('cmd_bootefi_selftest')
47 def test_efi_selftest_watchdog_reboot(u_boot_console):
48 """Test the watchdog timer
50 :param u_boot_console: U-Boot console
52 This function executes the 'watchdog reboot' unit test.
54 u_boot_console.run_command(cmd='setenv efi_selftest list')
55 output = u_boot_console.run_command('bootefi selftest')
56 assert '\'watchdog reboot\'' in output
57 u_boot_console.run_command(cmd='setenv efi_selftest watchdog reboot')
58 u_boot_console.run_command(cmd='bootefi selftest', wait_for_prompt=False)
59 m = u_boot_console.p.expect(['resetting', 'U-Boot'])
61 raise Exception('Reset failed in \'watchdog reboot\' test')
62 u_boot_console.restart_uboot()
64 @pytest.mark.buildconfigspec('cmd_bootefi_selftest')
65 def test_efi_selftest_text_input(u_boot_console):
66 """Test the EFI_SIMPLE_TEXT_INPUT_PROTOCOL
68 :param u_boot_console: U-Boot console
70 This function calls the text input EFI selftest.
72 u_boot_console.run_command(cmd='setenv efi_selftest text input')
73 output = u_boot_console.run_command(cmd='bootefi selftest',
74 wait_for_prompt=False)
75 m = u_boot_console.p.expect([r'To terminate type \'x\''])
77 raise Exception('No prompt for \'text input\' test')
78 u_boot_console.drain_console()
79 u_boot_console.p.timeout = 500
81 u_boot_console.run_command(cmd=chr(4), wait_for_echo=False,
82 send_nl=False, wait_for_prompt=False)
83 m = u_boot_console.p.expect(
84 [r'Unicode char 4 \(unknown\), scan code 0 \(Null\)'])
86 raise Exception('EOT failed in \'text input\' test')
87 u_boot_console.drain_console()
89 u_boot_console.run_command(cmd=chr(8), wait_for_echo=False,
90 send_nl=False, wait_for_prompt=False)
91 m = u_boot_console.p.expect(
92 [r'Unicode char 8 \(BS\), scan code 0 \(Null\)'])
94 raise Exception('BS failed in \'text input\' test')
95 u_boot_console.drain_console()
97 u_boot_console.run_command(cmd=chr(9), wait_for_echo=False,
98 send_nl=False, wait_for_prompt=False)
99 m = u_boot_console.p.expect(
100 [r'Unicode char 9 \(TAB\), scan code 0 \(Null\)'])
102 raise Exception('BS failed in \'text input\' test')
103 u_boot_console.drain_console()
105 u_boot_console.run_command(cmd='a', wait_for_echo=False, send_nl=False,
106 wait_for_prompt=False)
107 m = u_boot_console.p.expect(
108 [r'Unicode char 97 \(\'a\'\), scan code 0 \(Null\)'])
110 raise Exception('\'a\' failed in \'text input\' test')
111 u_boot_console.drain_console()
113 u_boot_console.run_command(cmd=chr(27) + '[A', wait_for_echo=False,
114 send_nl=False, wait_for_prompt=False)
115 m = u_boot_console.p.expect(
116 [r'Unicode char 0 \(Null\), scan code 1 \(Up\)'])
118 raise Exception('UP failed in \'text input\' test')
119 u_boot_console.drain_console()
121 u_boot_console.run_command(cmd=b'\xe2\x82\xac'.decode(), wait_for_echo=False,
122 send_nl=False, wait_for_prompt=False)
123 m = u_boot_console.p.expect([r'Unicode char 8364 \(\''])
125 raise Exception('Euro sign failed in \'text input\' test')
126 u_boot_console.drain_console()
127 u_boot_console.run_command(cmd='x', wait_for_echo=False, send_nl=False,
128 wait_for_prompt=False)
129 m = u_boot_console.p.expect(['Summary: 0 failures', 'Press any key'])
131 raise Exception('Failures occurred during the EFI selftest')
132 u_boot_console.restart_uboot()
134 @pytest.mark.buildconfigspec('cmd_bootefi_selftest')
135 def test_efi_selftest_text_input_ex(u_boot_console):
136 """Test the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
138 :param u_boot_console: U-Boot console
140 This function calls the extended text input EFI selftest.
142 u_boot_console.run_command(cmd='setenv efi_selftest extended text input')
143 output = u_boot_console.run_command(cmd='bootefi selftest',
144 wait_for_prompt=False)
145 m = u_boot_console.p.expect([r'To terminate type \'CTRL\+x\''])
147 raise Exception('No prompt for \'text input\' test')
148 u_boot_console.drain_console()
149 u_boot_console.p.timeout = 500
151 u_boot_console.run_command(cmd=chr(4), wait_for_echo=False,
152 send_nl=False, wait_for_prompt=False)
153 m = u_boot_console.p.expect(
154 [r'Unicode char 100 \(\'d\'\), scan code 0 \(CTRL\+Null\)'])
156 raise Exception('EOT failed in \'text input\' test')
157 u_boot_console.drain_console()
159 u_boot_console.run_command(cmd=chr(8), wait_for_echo=False,
160 send_nl=False, wait_for_prompt=False)
161 m = u_boot_console.p.expect(
162 [r'Unicode char 8 \(BS\), scan code 0 \(\+Null\)'])
164 raise Exception('BS failed in \'text input\' test')
165 u_boot_console.drain_console()
167 u_boot_console.run_command(cmd=chr(9), wait_for_echo=False,
168 send_nl=False, wait_for_prompt=False)
169 m = u_boot_console.p.expect(
170 [r'Unicode char 9 \(TAB\), scan code 0 \(\+Null\)'])
172 raise Exception('TAB failed in \'text input\' test')
173 u_boot_console.drain_console()
175 u_boot_console.run_command(cmd='a', wait_for_echo=False, send_nl=False,
176 wait_for_prompt=False)
177 m = u_boot_console.p.expect(
178 [r'Unicode char 97 \(\'a\'\), scan code 0 \(Null\)'])
180 raise Exception('\'a\' failed in \'text input\' test')
181 u_boot_console.drain_console()
183 u_boot_console.run_command(cmd=chr(27) + '[A', wait_for_echo=False,
184 send_nl=False, wait_for_prompt=False)
185 m = u_boot_console.p.expect(
186 [r'Unicode char 0 \(Null\), scan code 1 \(\+Up\)'])
188 raise Exception('UP failed in \'text input\' test')
189 u_boot_console.drain_console()
191 u_boot_console.run_command(cmd=b'\xe2\x82\xac'.decode(), wait_for_echo=False,
192 send_nl=False, wait_for_prompt=False)
193 m = u_boot_console.p.expect([r'Unicode char 8364 \(\''])
195 raise Exception('Euro sign failed in \'text input\' test')
196 u_boot_console.drain_console()
198 u_boot_console.run_command(cmd=b'\x1b\x5b\x31\x35\x3b\x34\x7e'.decode(),
199 wait_for_echo=False, send_nl=False,
200 wait_for_prompt=False)
201 m = u_boot_console.p.expect(
202 [r'Unicode char 0 \(Null\), scan code 15 \(SHIFT\+ALT\+FN 5\)'])
204 raise Exception('SHIFT+ALT+FN 5 failed in \'text input\' test')
205 u_boot_console.drain_console()
206 u_boot_console.run_command(cmd=chr(24), wait_for_echo=False, send_nl=False,
207 wait_for_prompt=False)
208 m = u_boot_console.p.expect(['Summary: 0 failures', 'Press any key'])
210 raise Exception('Failures occurred during the EFI selftest')
211 u_boot_console.restart_uboot()