test/py: typo occured
[platform/kernel/u-boot.git] / test / py / tests / test_efi_selftest.py
1 # SPDX-License-Identifier: GPL-2.0
2 # Copyright (c) 2017, Heinrich Schuchardt <xypron.glpk@gmx.de>
3
4 # Test efi API implementation
5
6 import pytest
7 import u_boot_utils
8
9 @pytest.mark.buildconfigspec('cmd_bootefi_selftest')
10 def test_efi_selftest(u_boot_console):
11         """
12         Run bootefi selftest
13         """
14
15         u_boot_console.run_command(cmd='setenv efi_selftest')
16         u_boot_console.run_command(cmd='bootefi selftest', wait_for_prompt=False)
17         m = u_boot_console.p.expect(['Summary: 0 failures', 'Press any key'])
18         if m != 0:
19                 raise Exception('Failures occurred during the EFI selftest')
20         u_boot_console.run_command(cmd='', wait_for_echo=False, wait_for_prompt=False);
21         m = u_boot_console.p.expect(['resetting', 'U-Boot'])
22         if m != 0:
23                 raise Exception('Reset failed during the EFI selftest')
24         u_boot_console.restart_uboot();
25
26 @pytest.mark.buildconfigspec('cmd_bootefi_selftest')
27 @pytest.mark.buildconfigspec('of_control')
28 def test_efi_selftest_device_tree(u_boot_console):
29         u_boot_console.run_command(cmd='setenv efi_selftest list')
30         output = u_boot_console.run_command('bootefi selftest')
31         assert '\'device tree\'' in output
32         u_boot_console.run_command(cmd='setenv efi_selftest device tree')
33         u_boot_console.run_command(cmd='setenv -f serial# Testing DT')
34         u_boot_console.run_command(cmd='bootefi selftest ${fdtcontroladdr}', wait_for_prompt=False)
35         m = u_boot_console.p.expect(['serial-number: Testing DT', 'U-Boot'])
36         if m != 0:
37                 raise Exception('Reset failed in \'device tree\' test')
38         u_boot_console.restart_uboot();
39
40 @pytest.mark.buildconfigspec('cmd_bootefi_selftest')
41 def test_efi_selftest_watchdog_reboot(u_boot_console):
42         u_boot_console.run_command(cmd='setenv efi_selftest list')
43         output = u_boot_console.run_command('bootefi selftest')
44         assert '\'watchdog reboot\'' in output
45         u_boot_console.run_command(cmd='setenv efi_selftest watchdog reboot')
46         u_boot_console.run_command(cmd='bootefi selftest', wait_for_prompt=False)
47         m = u_boot_console.p.expect(['resetting', 'U-Boot'])
48         if m != 0:
49                 raise Exception('Reset failed in \'watchdog reboot\' test')
50         u_boot_console.restart_uboot();
51
52 @pytest.mark.buildconfigspec('cmd_bootefi_selftest')
53 def test_efi_selftest_text_input(u_boot_console):
54         """Test the EFI_SIMPLE_TEXT_INPUT_PROTOCOL
55
56         :param u_boot_console: U-Boot console
57
58         This function calls the text input EFI selftest.
59         """
60         u_boot_console.run_command(cmd='setenv efi_selftest text input')
61         output = u_boot_console.run_command(cmd='bootefi selftest',
62                                             wait_for_prompt=False)
63         m = u_boot_console.p.expect(['To terminate type \'x\''])
64         if m != 0:
65                 raise Exception('No prompt for \'text input\' test')
66         u_boot_console.drain_console()
67         u_boot_console.p.timeout = 500
68         # EOT
69         u_boot_console.run_command(cmd=chr(4), wait_for_echo=False,
70                                    send_nl=False, wait_for_prompt=False)
71         m = u_boot_console.p.expect(['Unicode char 4'])
72         if m != 0:
73                 raise Exception('EOT failed in \'text input\' test')
74         u_boot_console.drain_console()
75         # BS
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(['(BS)'])
79         if m != 0:
80                 raise Exception('BS failed in \'text input\' test')
81         u_boot_console.drain_console()
82         # TAB
83         u_boot_console.run_command(cmd=chr(9), wait_for_echo=False,
84                                    send_nl=False, wait_for_prompt=False)
85         m = u_boot_console.p.expect(['(TAB)'])
86         if m != 0:
87                 raise Exception('BS failed in \'text input\' test')
88         u_boot_console.drain_console()
89         # a
90         u_boot_console.run_command(cmd='a', wait_for_echo=False, send_nl=False,
91                                    wait_for_prompt=False)
92         m = u_boot_console.p.expect(['(\'a\')'])
93         if m != 0:
94                 raise Exception('\'a\' failed in \'text input\' test')
95         u_boot_console.drain_console()
96         # UP escape sequence
97         u_boot_console.run_command(cmd=chr(27) + '[A', wait_for_echo=False,
98                                    send_nl=False, wait_for_prompt=False)
99         m = u_boot_console.p.expect(['(Up)'])
100         if m != 0:
101                 raise Exception('UP failed in \'text input\' test')
102         u_boot_console.drain_console()
103         u_boot_console.run_command(cmd='x', wait_for_echo=False, send_nl=False,
104                                    wait_for_prompt=False)
105         m = u_boot_console.p.expect(['Summary: 0 failures', 'Press any key'])
106         if m != 0:
107                 raise Exception('Failures occurred during the EFI selftest')
108         u_boot_console.restart_uboot();