1 # SPDX-License-Identifier: GPL-2.0
2 # Copyright (c) 2017, Heinrich Schuchardt <xypron.glpk@gmx.de>
4 # Test efi API implementation
9 @pytest.mark.buildconfigspec('cmd_bootefi_selftest')
10 def test_efi_selftest(u_boot_console):
11 """Test the UEFI implementation
13 :param u_boot_console: U-Boot console
15 This function executes all selftests that are not marked as on request.
17 u_boot_console.run_command(cmd='setenv efi_selftest')
18 u_boot_console.run_command(cmd='bootefi selftest', wait_for_prompt=False)
19 m = u_boot_console.p.expect(['Summary: 0 failures', 'Press any key'])
21 raise Exception('Failures occurred during the EFI selftest')
22 u_boot_console.run_command(cmd='', wait_for_echo=False, wait_for_prompt=False);
23 m = u_boot_console.p.expect(['resetting', 'U-Boot'])
25 raise Exception('Reset failed during the EFI selftest')
26 u_boot_console.restart_uboot();
28 @pytest.mark.buildconfigspec('cmd_bootefi_selftest')
29 @pytest.mark.buildconfigspec('of_control')
30 @pytest.mark.notbuildconfigspec('generate_acpi_table')
31 def test_efi_selftest_device_tree(u_boot_console):
32 u_boot_console.run_command(cmd='setenv efi_selftest list')
33 output = u_boot_console.run_command('bootefi selftest')
34 assert '\'device tree\'' in output
35 u_boot_console.run_command(cmd='setenv efi_selftest device tree')
36 u_boot_console.run_command(cmd='setenv -f serial# Testing DT')
37 u_boot_console.run_command(cmd='bootefi selftest ${fdtcontroladdr}', wait_for_prompt=False)
38 m = u_boot_console.p.expect(['serial-number: Testing DT', 'U-Boot'])
40 raise Exception('Reset failed in \'device tree\' test')
41 u_boot_console.restart_uboot();
43 @pytest.mark.buildconfigspec('cmd_bootefi_selftest')
44 def test_efi_selftest_watchdog_reboot(u_boot_console):
45 u_boot_console.run_command(cmd='setenv efi_selftest list')
46 output = u_boot_console.run_command('bootefi selftest')
47 assert '\'watchdog reboot\'' in output
48 u_boot_console.run_command(cmd='setenv efi_selftest watchdog reboot')
49 u_boot_console.run_command(cmd='bootefi selftest', wait_for_prompt=False)
50 m = u_boot_console.p.expect(['resetting', 'U-Boot'])
52 raise Exception('Reset failed in \'watchdog reboot\' test')
53 u_boot_console.restart_uboot();
55 @pytest.mark.buildconfigspec('cmd_bootefi_selftest')
56 def test_efi_selftest_text_input(u_boot_console):
57 """Test the EFI_SIMPLE_TEXT_INPUT_PROTOCOL
59 :param u_boot_console: U-Boot console
61 This function calls the text input EFI selftest.
63 u_boot_console.run_command(cmd='setenv efi_selftest text input')
64 output = u_boot_console.run_command(cmd='bootefi selftest',
65 wait_for_prompt=False)
66 m = u_boot_console.p.expect(['To terminate type \'x\''])
68 raise Exception('No prompt for \'text input\' test')
69 u_boot_console.drain_console()
70 u_boot_console.p.timeout = 500
72 u_boot_console.run_command(cmd=chr(4), wait_for_echo=False,
73 send_nl=False, wait_for_prompt=False)
74 m = u_boot_console.p.expect(
75 ['Unicode char 4 \(unknown\), scan code 0 \(Null\)'])
77 raise Exception('EOT failed in \'text input\' test')
78 u_boot_console.drain_console()
80 u_boot_console.run_command(cmd=chr(8), wait_for_echo=False,
81 send_nl=False, wait_for_prompt=False)
82 m = u_boot_console.p.expect(
83 ['Unicode char 8 \(BS\), scan code 0 \(Null\)'])
85 raise Exception('BS failed in \'text input\' test')
86 u_boot_console.drain_console()
88 u_boot_console.run_command(cmd=chr(9), wait_for_echo=False,
89 send_nl=False, wait_for_prompt=False)
90 m = u_boot_console.p.expect(
91 ['Unicode char 9 \(TAB\), scan code 0 \(Null\)'])
93 raise Exception('BS failed in \'text input\' test')
94 u_boot_console.drain_console()
96 u_boot_console.run_command(cmd='a', wait_for_echo=False, send_nl=False,
97 wait_for_prompt=False)
98 m = u_boot_console.p.expect(
99 ['Unicode char 97 \(\'a\'\), scan code 0 \(Null\)'])
101 raise Exception('\'a\' failed in \'text input\' test')
102 u_boot_console.drain_console()
104 u_boot_console.run_command(cmd=chr(27) + '[A', wait_for_echo=False,
105 send_nl=False, wait_for_prompt=False)
106 m = u_boot_console.p.expect(
107 ['Unicode char 0 \(Null\), scan code 1 \(Up\)'])
109 raise Exception('UP failed in \'text input\' test')
110 u_boot_console.drain_console()
112 u_boot_console.run_command(cmd='\xe2\x82\xac', wait_for_echo=False,
113 send_nl=False, wait_for_prompt=False)
114 m = u_boot_console.p.expect(['Unicode char 8364 \(\''])
116 raise Exception('Euro sign failed in \'text input\' test')
117 u_boot_console.drain_console()
118 u_boot_console.run_command(cmd='x', wait_for_echo=False, send_nl=False,
119 wait_for_prompt=False)
120 m = u_boot_console.p.expect(['Summary: 0 failures', 'Press any key'])
122 raise Exception('Failures occurred during the EFI selftest')
123 u_boot_console.restart_uboot();
125 @pytest.mark.buildconfigspec('cmd_bootefi_selftest')
126 def test_efi_selftest_text_input_ex(u_boot_console):
127 """Test the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
129 :param u_boot_console: U-Boot console
131 This function calls the extended text input EFI selftest.
133 u_boot_console.run_command(cmd='setenv efi_selftest extended text input')
134 output = u_boot_console.run_command(cmd='bootefi selftest',
135 wait_for_prompt=False)
136 m = u_boot_console.p.expect(['To terminate type \'CTRL\+x\''])
138 raise Exception('No prompt for \'text input\' test')
139 u_boot_console.drain_console()
140 u_boot_console.p.timeout = 500
142 u_boot_console.run_command(cmd=chr(4), wait_for_echo=False,
143 send_nl=False, wait_for_prompt=False)
144 m = u_boot_console.p.expect(
145 ['Unicode char 100 \\(\'d\'\\), scan code 0 \\(CTRL\\+Null\\)'])
147 raise Exception('EOT failed in \'text input\' test')
148 u_boot_console.drain_console()
150 u_boot_console.run_command(cmd=chr(8), wait_for_echo=False,
151 send_nl=False, wait_for_prompt=False)
152 m = u_boot_console.p.expect(
153 ['Unicode char 8 \(BS\), scan code 0 \(\+Null\)'])
155 raise Exception('BS failed in \'text input\' test')
156 u_boot_console.drain_console()
158 u_boot_console.run_command(cmd=chr(9), wait_for_echo=False,
159 send_nl=False, wait_for_prompt=False)
160 m = u_boot_console.p.expect(
161 ['Unicode char 9 \(TAB\), scan code 0 \(\+Null\)'])
163 raise Exception('TAB failed in \'text input\' test')
164 u_boot_console.drain_console()
166 u_boot_console.run_command(cmd='a', wait_for_echo=False, send_nl=False,
167 wait_for_prompt=False)
168 m = u_boot_console.p.expect(
169 ['Unicode char 97 \(\'a\'\), scan code 0 \(Null\)'])
171 raise Exception('\'a\' failed in \'text input\' test')
172 u_boot_console.drain_console()
174 u_boot_console.run_command(cmd=chr(27) + '[A', wait_for_echo=False,
175 send_nl=False, wait_for_prompt=False)
176 m = u_boot_console.p.expect(
177 ['Unicode char 0 \(Null\), scan code 1 \(\+Up\)'])
179 raise Exception('UP failed in \'text input\' test')
180 u_boot_console.drain_console()
182 u_boot_console.run_command(cmd='\xe2\x82\xac', wait_for_echo=False,
183 send_nl=False, wait_for_prompt=False)
184 m = u_boot_console.p.expect(['Unicode char 8364 \(\''])
186 raise Exception('Euro sign failed in \'text input\' test')
187 u_boot_console.drain_console()
189 u_boot_console.run_command(cmd='\x1b\x5b\x31\x35\x3b\x34\x7e',
190 wait_for_echo=False, send_nl=False,
191 wait_for_prompt=False)
192 m = u_boot_console.p.expect(
193 ['Unicode char 0 \(Null\), scan code 15 \(SHIFT\+ALT\+FN 5\)'])
195 raise Exception('SHIFT+ALT+FN 5 failed in \'text input\' test')
196 u_boot_console.drain_console()
197 u_boot_console.run_command(cmd=chr(24), wait_for_echo=False, send_nl=False,
198 wait_for_prompt=False)
199 m = u_boot_console.p.expect(['Summary: 0 failures', 'Press any key'])
201 raise Exception('Failures occurred during the EFI selftest')
202 u_boot_console.restart_uboot();