blob: 36b35ee536b1607dfe97a3c432ee763e6d2d8cea [file] [log] [blame]
Heinrich Schuchardtd828a052017-09-15 10:06:12 +02001# SPDX-License-Identifier: GPL-2.0
Tom Rini10e47792018-05-06 17:58:06 -04002# Copyright (c) 2017, Heinrich Schuchardt <xypron.glpk@gmx.de>
Heinrich Schuchardtd828a052017-09-15 10:06:12 +02003
4# Test efi API implementation
5
6import pytest
7import u_boot_utils
8
9@pytest.mark.buildconfigspec('cmd_bootefi_selftest')
10def test_efi_selftest(u_boot_console):
Heinrich Schuchardt48161e12018-11-18 17:58:54 +010011 """Test the UEFI implementation
Heinrich Schuchardtd828a052017-09-15 10:06:12 +020012
Heinrich Schuchardt48161e12018-11-18 17:58:54 +010013 :param u_boot_console: U-Boot console
14
15 This function executes all selftests that are not marked as on request.
16 """
Heinrich Schuchardt1dc0a1b2017-10-18 18:13:17 +020017 u_boot_console.run_command(cmd='setenv efi_selftest')
Heinrich Schuchardt48161e12018-11-18 17:58:54 +010018 u_boot_console.run_command(cmd='bootefi selftest ${fdtcontroladdr}', wait_for_prompt=False)
Heinrich Schuchardtd828a052017-09-15 10:06:12 +020019 m = u_boot_console.p.expect(['Summary: 0 failures', 'Press any key'])
20 if m != 0:
Heinrich Schuchardt40e99c12018-09-06 20:29:50 +020021 raise Exception('Failures occurred during the EFI selftest')
Heinrich Schuchardtd828a052017-09-15 10:06:12 +020022 u_boot_console.run_command(cmd='', wait_for_echo=False, wait_for_prompt=False);
23 m = u_boot_console.p.expect(['resetting', 'U-Boot'])
24 if m != 0:
25 raise Exception('Reset failed during the EFI selftest')
26 u_boot_console.restart_uboot();
Heinrich Schuchardt1dc0a1b2017-10-18 18:13:17 +020027
28@pytest.mark.buildconfigspec('cmd_bootefi_selftest')
Heinrich Schuchardt43d27992018-03-03 15:29:04 +010029@pytest.mark.buildconfigspec('of_control')
30def 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'])
38 if m != 0:
39 raise Exception('Reset failed in \'device tree\' test')
40 u_boot_console.restart_uboot();
41
42@pytest.mark.buildconfigspec('cmd_bootefi_selftest')
Heinrich Schuchardt1dc0a1b2017-10-18 18:13:17 +020043def 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'])
50 if m != 0:
51 raise Exception('Reset failed in \'watchdog reboot\' test')
52 u_boot_console.restart_uboot();
Heinrich Schuchardt5e450d42018-09-06 20:19:31 +020053
54@pytest.mark.buildconfigspec('cmd_bootefi_selftest')
55def test_efi_selftest_text_input(u_boot_console):
56 """Test the EFI_SIMPLE_TEXT_INPUT_PROTOCOL
57
58 :param u_boot_console: U-Boot console
59
60 This function calls the text input EFI selftest.
61 """
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\''])
66 if m != 0:
67 raise Exception('No prompt for \'text input\' test')
68 u_boot_console.drain_console()
69 u_boot_console.p.timeout = 500
70 # EOT
71 u_boot_console.run_command(cmd=chr(4), wait_for_echo=False,
72 send_nl=False, wait_for_prompt=False)
Heinrich Schuchardtd2cab7f2018-09-11 22:38:07 +020073 m = u_boot_console.p.expect(
74 ['Unicode char 4 \(unknown\), scan code 0 \(Null\)'])
Heinrich Schuchardt5e450d42018-09-06 20:19:31 +020075 if m != 0:
76 raise Exception('EOT failed in \'text input\' test')
77 u_boot_console.drain_console()
78 # BS
79 u_boot_console.run_command(cmd=chr(8), wait_for_echo=False,
80 send_nl=False, wait_for_prompt=False)
Heinrich Schuchardtd2cab7f2018-09-11 22:38:07 +020081 m = u_boot_console.p.expect(
82 ['Unicode char 8 \(BS\), scan code 0 \(Null\)'])
Heinrich Schuchardt5e450d42018-09-06 20:19:31 +020083 if m != 0:
84 raise Exception('BS failed in \'text input\' test')
85 u_boot_console.drain_console()
86 # TAB
87 u_boot_console.run_command(cmd=chr(9), wait_for_echo=False,
88 send_nl=False, wait_for_prompt=False)
Heinrich Schuchardtd2cab7f2018-09-11 22:38:07 +020089 m = u_boot_console.p.expect(
90 ['Unicode char 9 \(TAB\), scan code 0 \(Null\)'])
Heinrich Schuchardt5e450d42018-09-06 20:19:31 +020091 if m != 0:
92 raise Exception('BS failed in \'text input\' test')
93 u_boot_console.drain_console()
94 # a
95 u_boot_console.run_command(cmd='a', wait_for_echo=False, send_nl=False,
96 wait_for_prompt=False)
Heinrich Schuchardtd2cab7f2018-09-11 22:38:07 +020097 m = u_boot_console.p.expect(
98 ['Unicode char 97 \(\'a\'\), scan code 0 \(Null\)'])
Heinrich Schuchardt5e450d42018-09-06 20:19:31 +020099 if m != 0:
100 raise Exception('\'a\' failed in \'text input\' test')
101 u_boot_console.drain_console()
102 # UP escape sequence
103 u_boot_console.run_command(cmd=chr(27) + '[A', wait_for_echo=False,
104 send_nl=False, wait_for_prompt=False)
Heinrich Schuchardtd2cab7f2018-09-11 22:38:07 +0200105 m = u_boot_console.p.expect(
106 ['Unicode char 0 \(Null\), scan code 1 \(Up\)'])
Heinrich Schuchardt5e450d42018-09-06 20:19:31 +0200107 if m != 0:
108 raise Exception('UP failed in \'text input\' test')
109 u_boot_console.drain_console()
Heinrich Schuchardt8b2ba082018-09-11 22:38:03 +0200110 # Euro sign
111 u_boot_console.run_command(cmd='\xe2\x82\xac', wait_for_echo=False,
112 send_nl=False, wait_for_prompt=False)
Heinrich Schuchardtd2cab7f2018-09-11 22:38:07 +0200113 m = u_boot_console.p.expect(['Unicode char 8364 \(\''])
Heinrich Schuchardt8b2ba082018-09-11 22:38:03 +0200114 if m != 0:
115 raise Exception('Euro sign failed in \'text input\' test')
116 u_boot_console.drain_console()
Heinrich Schuchardt5e450d42018-09-06 20:19:31 +0200117 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'])
120 if m != 0:
121 raise Exception('Failures occurred during the EFI selftest')
122 u_boot_console.restart_uboot();
Heinrich Schuchardt7ecaf972018-09-11 22:38:11 +0200123
124@pytest.mark.buildconfigspec('cmd_bootefi_selftest')
125def test_efi_selftest_text_input_ex(u_boot_console):
126 """Test the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
127
128 :param u_boot_console: U-Boot console
129
130 This function calls the extended text input EFI selftest.
131 """
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)
Heinrich Schuchardta882c4c2018-09-11 22:38:13 +0200135 m = u_boot_console.p.expect(['To terminate type \'CTRL\+x\''])
Heinrich Schuchardt7ecaf972018-09-11 22:38:11 +0200136 if m != 0:
137 raise Exception('No prompt for \'text input\' test')
138 u_boot_console.drain_console()
139 u_boot_console.p.timeout = 500
140 # EOT
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 4 \(unknown\), scan code 0 \(CTRL\+Null\)'])
145 if m != 0:
146 raise Exception('EOT failed in \'text input\' test')
147 u_boot_console.drain_console()
148 # BS
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\)'])
153 if m != 0:
154 raise Exception('BS failed in \'text input\' test')
155 u_boot_console.drain_console()
156 # TAB
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\)'])
161 if m != 0:
162 raise Exception('TAB failed in \'text input\' test')
163 u_boot_console.drain_console()
164 # a
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\)'])
169 if m != 0:
170 raise Exception('\'a\' failed in \'text input\' test')
171 u_boot_console.drain_console()
172 # UP escape sequence
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\)'])
177 if m != 0:
178 raise Exception('UP failed in \'text input\' test')
179 u_boot_console.drain_console()
180 # Euro sign
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 \(\''])
184 if m != 0:
185 raise Exception('Euro sign failed in \'text input\' test')
186 u_boot_console.drain_console()
187 # SHIFT+ALT+FN 5
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\)'])
193 if m != 0:
194 raise Exception('SHIFT+ALT+FN 5 failed in \'text input\' test')
195 u_boot_console.drain_console()
Heinrich Schuchardta882c4c2018-09-11 22:38:13 +0200196 u_boot_console.run_command(cmd=chr(24), wait_for_echo=False, send_nl=False,
Heinrich Schuchardt7ecaf972018-09-11 22:38:11 +0200197 wait_for_prompt=False)
198 m = u_boot_console.p.expect(['Summary: 0 failures', 'Press any key'])
199 if m != 0:
200 raise Exception('Failures occurred during the EFI selftest')
201 u_boot_console.restart_uboot();