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 ${fdtcontroladdr}', 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 def test_efi_selftest_device_tree(u_boot_console):
31 u_boot_console.run_command(cmd='setenv efi_selftest list')
32 output = u_boot_console.run_command('bootefi selftest')
33 assert '\'device tree\'' in output
34 u_boot_console.run_command(cmd='setenv efi_selftest device tree')
35 u_boot_console.run_command(cmd='setenv -f serial# Testing DT')
36 u_boot_console.run_command(cmd='bootefi selftest ${fdtcontroladdr}', wait_for_prompt=False)
37 m = u_boot_console.p.expect(['serial-number: Testing DT', 'U-Boot'])
39 raise Exception('Reset failed in \'device tree\' test')
40 u_boot_console.restart_uboot();
42 @pytest.mark.buildconfigspec('cmd_bootefi_selftest')
43 def test_efi_selftest_watchdog_reboot(u_boot_console):
44 u_boot_console.run_command(cmd='setenv efi_selftest list')
45 output = u_boot_console.run_command('bootefi selftest')
46 assert '\'watchdog reboot\'' in output
47 u_boot_console.run_command(cmd='setenv efi_selftest watchdog reboot')
48 u_boot_console.run_command(cmd='bootefi selftest', wait_for_prompt=False)
49 m = u_boot_console.p.expect(['resetting', 'U-Boot'])
51 raise Exception('Reset failed in \'watchdog reboot\' test')
52 u_boot_console.restart_uboot();
54 @pytest.mark.buildconfigspec('cmd_bootefi_selftest')
55 def test_efi_selftest_text_input(u_boot_console):
56 """Test the EFI_SIMPLE_TEXT_INPUT_PROTOCOL
58 :param u_boot_console: U-Boot console
60 This function calls the text input EFI selftest.
62 u_boot_console.run_command(cmd='setenv efi_selftest text input')
63 output = u_boot_console.run_command(cmd='bootefi selftest',
64 wait_for_prompt=False)
65 m = u_boot_console.p.expect(['To terminate type \'x\''])
67 raise Exception('No prompt for \'text input\' test')
68 u_boot_console.drain_console()
69 u_boot_console.p.timeout = 500
71 u_boot_console.run_command(cmd=chr(4), wait_for_echo=False,
72 send_nl=False, wait_for_prompt=False)
73 m = u_boot_console.p.expect(
74 ['Unicode char 4 \(unknown\), scan code 0 \(Null\)'])
76 raise Exception('EOT failed in \'text input\' test')
77 u_boot_console.drain_console()
79 u_boot_console.run_command(cmd=chr(8), wait_for_echo=False,
80 send_nl=False, wait_for_prompt=False)
81 m = u_boot_console.p.expect(
82 ['Unicode char 8 \(BS\), scan code 0 \(Null\)'])
84 raise Exception('BS failed in \'text input\' test')
85 u_boot_console.drain_console()
87 u_boot_console.run_command(cmd=chr(9), wait_for_echo=False,
88 send_nl=False, wait_for_prompt=False)
89 m = u_boot_console.p.expect(
90 ['Unicode char 9 \(TAB\), scan code 0 \(Null\)'])
92 raise Exception('BS failed in \'text input\' test')
93 u_boot_console.drain_console()
95 u_boot_console.run_command(cmd='a', wait_for_echo=False, send_nl=False,
96 wait_for_prompt=False)
97 m = u_boot_console.p.expect(
98 ['Unicode char 97 \(\'a\'\), scan code 0 \(Null\)'])
100 raise Exception('\'a\' failed in \'text input\' test')
101 u_boot_console.drain_console()
103 u_boot_console.run_command(cmd=chr(27) + '[A', wait_for_echo=False,
104 send_nl=False, wait_for_prompt=False)
105 m = u_boot_console.p.expect(
106 ['Unicode char 0 \(Null\), scan code 1 \(Up\)'])
108 raise Exception('UP failed in \'text input\' test')
109 u_boot_console.drain_console()
111 u_boot_console.run_command(cmd='\xe2\x82\xac', wait_for_echo=False,
112 send_nl=False, wait_for_prompt=False)
113 m = u_boot_console.p.expect(['Unicode char 8364 \(\''])
115 raise Exception('Euro sign failed in \'text input\' test')
116 u_boot_console.drain_console()
117 u_boot_console.run_command(cmd='x', wait_for_echo=False, send_nl=False,
118 wait_for_prompt=False)
119 m = u_boot_console.p.expect(['Summary: 0 failures', 'Press any key'])
121 raise Exception('Failures occurred during the EFI selftest')
122 u_boot_console.restart_uboot();
124 @pytest.mark.buildconfigspec('cmd_bootefi_selftest')
125 def test_efi_selftest_text_input_ex(u_boot_console):
126 """Test the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
128 :param u_boot_console: U-Boot console
130 This function calls the extended text input EFI selftest.
132 u_boot_console.run_command(cmd='setenv efi_selftest extended text input')
133 output = u_boot_console.run_command(cmd='bootefi selftest',
134 wait_for_prompt=False)
135 m = u_boot_console.p.expect(['To terminate type \'CTRL\+x\''])
137 raise Exception('No prompt for \'text input\' test')
138 u_boot_console.drain_console()
139 u_boot_console.p.timeout = 500
141 u_boot_console.run_command(cmd=chr(4), wait_for_echo=False,
142 send_nl=False, wait_for_prompt=False)
143 m = u_boot_console.p.expect(
144 ['Unicode char 100 \\(\'d\'\\), scan code 0 \\(CTRL\\+Null\\)'])
146 raise Exception('EOT failed in \'text input\' test')
147 u_boot_console.drain_console()
149 u_boot_console.run_command(cmd=chr(8), wait_for_echo=False,
150 send_nl=False, wait_for_prompt=False)
151 m = u_boot_console.p.expect(
152 ['Unicode char 8 \(BS\), scan code 0 \(\+Null\)'])
154 raise Exception('BS failed in \'text input\' test')
155 u_boot_console.drain_console()
157 u_boot_console.run_command(cmd=chr(9), wait_for_echo=False,
158 send_nl=False, wait_for_prompt=False)
159 m = u_boot_console.p.expect(
160 ['Unicode char 9 \(TAB\), scan code 0 \(\+Null\)'])
162 raise Exception('TAB failed in \'text input\' test')
163 u_boot_console.drain_console()
165 u_boot_console.run_command(cmd='a', wait_for_echo=False, send_nl=False,
166 wait_for_prompt=False)
167 m = u_boot_console.p.expect(
168 ['Unicode char 97 \(\'a\'\), scan code 0 \(Null\)'])
170 raise Exception('\'a\' failed in \'text input\' test')
171 u_boot_console.drain_console()
173 u_boot_console.run_command(cmd=chr(27) + '[A', wait_for_echo=False,
174 send_nl=False, wait_for_prompt=False)
175 m = u_boot_console.p.expect(
176 ['Unicode char 0 \(Null\), scan code 1 \(\+Up\)'])
178 raise Exception('UP failed in \'text input\' test')
179 u_boot_console.drain_console()
181 u_boot_console.run_command(cmd='\xe2\x82\xac', wait_for_echo=False,
182 send_nl=False, wait_for_prompt=False)
183 m = u_boot_console.p.expect(['Unicode char 8364 \(\''])
185 raise Exception('Euro sign failed in \'text input\' test')
186 u_boot_console.drain_console()
188 u_boot_console.run_command(cmd='\x1b\x5b\x31\x35\x3b\x34\x7e',
189 wait_for_echo=False, send_nl=False,
190 wait_for_prompt=False)
191 m = u_boot_console.p.expect(
192 ['Unicode char 0 \(Null\), scan code 15 \(SHIFT\+ALT\+FN 5\)'])
194 raise Exception('SHIFT+ALT+FN 5 failed in \'text input\' test')
195 u_boot_console.drain_console()
196 u_boot_console.run_command(cmd=chr(24), wait_for_echo=False, send_nl=False,
197 wait_for_prompt=False)
198 m = u_boot_console.p.expect(['Summary: 0 failures', 'Press any key'])
200 raise Exception('Failures occurred during the EFI selftest')
201 u_boot_console.restart_uboot();