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.restart_uboot();
24 @pytest.mark.buildconfigspec('cmd_bootefi_selftest')
25 @pytest.mark.buildconfigspec('of_control')
26 @pytest.mark.notbuildconfigspec('generate_acpi_table')
27 def test_efi_selftest_device_tree(u_boot_console):
28 u_boot_console.run_command(cmd='setenv efi_selftest list')
29 output = u_boot_console.run_command('bootefi selftest')
30 assert '\'device tree\'' in output
31 u_boot_console.run_command(cmd='setenv efi_selftest device tree')
32 u_boot_console.run_command(cmd='setenv -f serial# Testing DT')
33 u_boot_console.run_command(cmd='bootefi selftest ${fdtcontroladdr}', wait_for_prompt=False)
34 m = u_boot_console.p.expect(['serial-number: Testing DT', 'U-Boot'])
36 raise Exception('serial-number missing in device tree')
37 u_boot_console.restart_uboot();
39 @pytest.mark.buildconfigspec('cmd_bootefi_selftest')
40 def test_efi_selftest_watchdog_reboot(u_boot_console):
41 u_boot_console.run_command(cmd='setenv efi_selftest list')
42 output = u_boot_console.run_command('bootefi selftest')
43 assert '\'watchdog reboot\'' in output
44 u_boot_console.run_command(cmd='setenv efi_selftest watchdog reboot')
45 u_boot_console.run_command(cmd='bootefi selftest', wait_for_prompt=False)
46 m = u_boot_console.p.expect(['resetting', 'U-Boot'])
48 raise Exception('Reset failed in \'watchdog reboot\' test')
49 u_boot_console.restart_uboot();
51 @pytest.mark.buildconfigspec('cmd_bootefi_selftest')
52 def test_efi_selftest_text_input(u_boot_console):
53 """Test the EFI_SIMPLE_TEXT_INPUT_PROTOCOL
55 :param u_boot_console: U-Boot console
57 This function calls the text input EFI selftest.
59 u_boot_console.run_command(cmd='setenv efi_selftest text input')
60 output = u_boot_console.run_command(cmd='bootefi selftest',
61 wait_for_prompt=False)
62 m = u_boot_console.p.expect([r'To terminate type \'x\''])
64 raise Exception('No prompt for \'text input\' test')
65 u_boot_console.drain_console()
66 u_boot_console.p.timeout = 500
68 u_boot_console.run_command(cmd=chr(4), wait_for_echo=False,
69 send_nl=False, wait_for_prompt=False)
70 m = u_boot_console.p.expect(
71 [r'Unicode char 4 \(unknown\), scan code 0 \(Null\)'])
73 raise Exception('EOT failed in \'text input\' test')
74 u_boot_console.drain_console()
76 u_boot_console.run_command(cmd=chr(8), wait_for_echo=False,
77 send_nl=False, wait_for_prompt=False)
78 m = u_boot_console.p.expect(
79 [r'Unicode char 8 \(BS\), scan code 0 \(Null\)'])
81 raise Exception('BS failed in \'text input\' test')
82 u_boot_console.drain_console()
84 u_boot_console.run_command(cmd=chr(9), wait_for_echo=False,
85 send_nl=False, wait_for_prompt=False)
86 m = u_boot_console.p.expect(
87 [r'Unicode char 9 \(TAB\), scan code 0 \(Null\)'])
89 raise Exception('BS failed in \'text input\' test')
90 u_boot_console.drain_console()
92 u_boot_console.run_command(cmd='a', wait_for_echo=False, send_nl=False,
93 wait_for_prompt=False)
94 m = u_boot_console.p.expect(
95 [r'Unicode char 97 \(\'a\'\), scan code 0 \(Null\)'])
97 raise Exception('\'a\' failed in \'text input\' test')
98 u_boot_console.drain_console()
100 u_boot_console.run_command(cmd=chr(27) + '[A', wait_for_echo=False,
101 send_nl=False, wait_for_prompt=False)
102 m = u_boot_console.p.expect(
103 [r'Unicode char 0 \(Null\), scan code 1 \(Up\)'])
105 raise Exception('UP failed in \'text input\' test')
106 u_boot_console.drain_console()
108 u_boot_console.run_command(cmd=b'\xe2\x82\xac'.decode(), wait_for_echo=False,
109 send_nl=False, wait_for_prompt=False)
110 m = u_boot_console.p.expect([r'Unicode char 8364 \(\''])
112 raise Exception('Euro sign failed in \'text input\' test')
113 u_boot_console.drain_console()
114 u_boot_console.run_command(cmd='x', wait_for_echo=False, send_nl=False,
115 wait_for_prompt=False)
116 m = u_boot_console.p.expect(['Summary: 0 failures', 'Press any key'])
118 raise Exception('Failures occurred during the EFI selftest')
119 u_boot_console.restart_uboot();
121 @pytest.mark.buildconfigspec('cmd_bootefi_selftest')
122 def test_efi_selftest_text_input_ex(u_boot_console):
123 """Test the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
125 :param u_boot_console: U-Boot console
127 This function calls the extended text input EFI selftest.
129 u_boot_console.run_command(cmd='setenv efi_selftest extended text input')
130 output = u_boot_console.run_command(cmd='bootefi selftest',
131 wait_for_prompt=False)
132 m = u_boot_console.p.expect([r'To terminate type \'CTRL\+x\''])
134 raise Exception('No prompt for \'text input\' test')
135 u_boot_console.drain_console()
136 u_boot_console.p.timeout = 500
138 u_boot_console.run_command(cmd=chr(4), wait_for_echo=False,
139 send_nl=False, wait_for_prompt=False)
140 m = u_boot_console.p.expect(
141 [r'Unicode char 100 \(\'d\'\), scan code 0 \(CTRL\+Null\)'])
143 raise Exception('EOT failed in \'text input\' test')
144 u_boot_console.drain_console()
146 u_boot_console.run_command(cmd=chr(8), wait_for_echo=False,
147 send_nl=False, wait_for_prompt=False)
148 m = u_boot_console.p.expect(
149 [r'Unicode char 8 \(BS\), scan code 0 \(\+Null\)'])
151 raise Exception('BS failed in \'text input\' test')
152 u_boot_console.drain_console()
154 u_boot_console.run_command(cmd=chr(9), wait_for_echo=False,
155 send_nl=False, wait_for_prompt=False)
156 m = u_boot_console.p.expect(
157 [r'Unicode char 9 \(TAB\), scan code 0 \(\+Null\)'])
159 raise Exception('TAB failed in \'text input\' test')
160 u_boot_console.drain_console()
162 u_boot_console.run_command(cmd='a', wait_for_echo=False, send_nl=False,
163 wait_for_prompt=False)
164 m = u_boot_console.p.expect(
165 [r'Unicode char 97 \(\'a\'\), scan code 0 \(Null\)'])
167 raise Exception('\'a\' failed in \'text input\' test')
168 u_boot_console.drain_console()
170 u_boot_console.run_command(cmd=chr(27) + '[A', wait_for_echo=False,
171 send_nl=False, wait_for_prompt=False)
172 m = u_boot_console.p.expect(
173 [r'Unicode char 0 \(Null\), scan code 1 \(\+Up\)'])
175 raise Exception('UP failed in \'text input\' test')
176 u_boot_console.drain_console()
178 u_boot_console.run_command(cmd=b'\xe2\x82\xac'.decode(), wait_for_echo=False,
179 send_nl=False, wait_for_prompt=False)
180 m = u_boot_console.p.expect([r'Unicode char 8364 \(\''])
182 raise Exception('Euro sign failed in \'text input\' test')
183 u_boot_console.drain_console()
185 u_boot_console.run_command(cmd=b'\x1b\x5b\x31\x35\x3b\x34\x7e'.decode(),
186 wait_for_echo=False, send_nl=False,
187 wait_for_prompt=False)
188 m = u_boot_console.p.expect(
189 [r'Unicode char 0 \(Null\), scan code 15 \(SHIFT\+ALT\+FN 5\)'])
191 raise Exception('SHIFT+ALT+FN 5 failed in \'text input\' test')
192 u_boot_console.drain_console()
193 u_boot_console.run_command(cmd=chr(24), wait_for_echo=False, send_nl=False,
194 wait_for_prompt=False)
195 m = u_boot_console.p.expect(['Summary: 0 failures', 'Press any key'])
197 raise Exception('Failures occurred during the EFI selftest')
198 u_boot_console.restart_uboot();