Heinrich Schuchardt | d828a05 | 2017-09-15 10:06:12 +0200 | [diff] [blame] | 1 | # SPDX-License-Identifier: GPL-2.0 |
Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 2 | # Copyright (c) 2017, Heinrich Schuchardt <xypron.glpk@gmx.de> |
Heinrich Schuchardt | d828a05 | 2017-09-15 10:06:12 +0200 | [diff] [blame] | 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 | |
Heinrich Schuchardt | 1dc0a1b | 2017-10-18 18:13:17 +0200 | [diff] [blame] | 15 | u_boot_console.run_command(cmd='setenv efi_selftest') |
Heinrich Schuchardt | d828a05 | 2017-09-15 10:06:12 +0200 | [diff] [blame] | 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: |
Heinrich Schuchardt | 40e99c1 | 2018-09-06 20:29:50 +0200 | [diff] [blame] | 19 | raise Exception('Failures occurred during the EFI selftest') |
Heinrich Schuchardt | d828a05 | 2017-09-15 10:06:12 +0200 | [diff] [blame] | 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(); |
Heinrich Schuchardt | 1dc0a1b | 2017-10-18 18:13:17 +0200 | [diff] [blame] | 25 | |
| 26 | @pytest.mark.buildconfigspec('cmd_bootefi_selftest') |
Heinrich Schuchardt | 43d2799 | 2018-03-03 15:29:04 +0100 | [diff] [blame] | 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') |
Heinrich Schuchardt | 1dc0a1b | 2017-10-18 18:13:17 +0200 | [diff] [blame] | 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(); |
Heinrich Schuchardt | 5e450d4 | 2018-09-06 20:19:31 +0200 | [diff] [blame] | 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) |
Heinrich Schuchardt | d2cab7f | 2018-09-11 22:38:07 +0200 | [diff] [blame] | 71 | m = u_boot_console.p.expect( |
| 72 | ['Unicode char 4 \(unknown\), scan code 0 \(Null\)']) |
Heinrich Schuchardt | 5e450d4 | 2018-09-06 20:19:31 +0200 | [diff] [blame] | 73 | if m != 0: |
| 74 | raise Exception('EOT failed in \'text input\' test') |
| 75 | u_boot_console.drain_console() |
| 76 | # BS |
| 77 | u_boot_console.run_command(cmd=chr(8), wait_for_echo=False, |
| 78 | send_nl=False, wait_for_prompt=False) |
Heinrich Schuchardt | d2cab7f | 2018-09-11 22:38:07 +0200 | [diff] [blame] | 79 | m = u_boot_console.p.expect( |
| 80 | ['Unicode char 8 \(BS\), scan code 0 \(Null\)']) |
Heinrich Schuchardt | 5e450d4 | 2018-09-06 20:19:31 +0200 | [diff] [blame] | 81 | if m != 0: |
| 82 | raise Exception('BS failed in \'text input\' test') |
| 83 | u_boot_console.drain_console() |
| 84 | # TAB |
| 85 | u_boot_console.run_command(cmd=chr(9), wait_for_echo=False, |
| 86 | send_nl=False, wait_for_prompt=False) |
Heinrich Schuchardt | d2cab7f | 2018-09-11 22:38:07 +0200 | [diff] [blame] | 87 | m = u_boot_console.p.expect( |
| 88 | ['Unicode char 9 \(TAB\), scan code 0 \(Null\)']) |
Heinrich Schuchardt | 5e450d4 | 2018-09-06 20:19:31 +0200 | [diff] [blame] | 89 | if m != 0: |
| 90 | raise Exception('BS failed in \'text input\' test') |
| 91 | u_boot_console.drain_console() |
| 92 | # a |
| 93 | u_boot_console.run_command(cmd='a', wait_for_echo=False, send_nl=False, |
| 94 | wait_for_prompt=False) |
Heinrich Schuchardt | d2cab7f | 2018-09-11 22:38:07 +0200 | [diff] [blame] | 95 | m = u_boot_console.p.expect( |
| 96 | ['Unicode char 97 \(\'a\'\), scan code 0 \(Null\)']) |
Heinrich Schuchardt | 5e450d4 | 2018-09-06 20:19:31 +0200 | [diff] [blame] | 97 | if m != 0: |
| 98 | raise Exception('\'a\' failed in \'text input\' test') |
| 99 | u_boot_console.drain_console() |
| 100 | # UP escape sequence |
| 101 | u_boot_console.run_command(cmd=chr(27) + '[A', wait_for_echo=False, |
| 102 | send_nl=False, wait_for_prompt=False) |
Heinrich Schuchardt | d2cab7f | 2018-09-11 22:38:07 +0200 | [diff] [blame] | 103 | m = u_boot_console.p.expect( |
| 104 | ['Unicode char 0 \(Null\), scan code 1 \(Up\)']) |
Heinrich Schuchardt | 5e450d4 | 2018-09-06 20:19:31 +0200 | [diff] [blame] | 105 | if m != 0: |
| 106 | raise Exception('UP failed in \'text input\' test') |
| 107 | u_boot_console.drain_console() |
Heinrich Schuchardt | 8b2ba08 | 2018-09-11 22:38:03 +0200 | [diff] [blame] | 108 | # Euro sign |
| 109 | u_boot_console.run_command(cmd='\xe2\x82\xac', wait_for_echo=False, |
| 110 | send_nl=False, wait_for_prompt=False) |
Heinrich Schuchardt | d2cab7f | 2018-09-11 22:38:07 +0200 | [diff] [blame] | 111 | m = u_boot_console.p.expect(['Unicode char 8364 \(\'']) |
Heinrich Schuchardt | 8b2ba08 | 2018-09-11 22:38:03 +0200 | [diff] [blame] | 112 | if m != 0: |
| 113 | raise Exception('Euro sign failed in \'text input\' test') |
| 114 | u_boot_console.drain_console() |
Heinrich Schuchardt | 5e450d4 | 2018-09-06 20:19:31 +0200 | [diff] [blame] | 115 | u_boot_console.run_command(cmd='x', wait_for_echo=False, send_nl=False, |
| 116 | wait_for_prompt=False) |
| 117 | m = u_boot_console.p.expect(['Summary: 0 failures', 'Press any key']) |
| 118 | if m != 0: |
| 119 | raise Exception('Failures occurred during the EFI selftest') |
| 120 | u_boot_console.restart_uboot(); |
Heinrich Schuchardt | 7ecaf97 | 2018-09-11 22:38:11 +0200 | [diff] [blame] | 121 | |
| 122 | @pytest.mark.buildconfigspec('cmd_bootefi_selftest') |
| 123 | def test_efi_selftest_text_input_ex(u_boot_console): |
| 124 | """Test the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL |
| 125 | |
| 126 | :param u_boot_console: U-Boot console |
| 127 | |
| 128 | This function calls the extended text input EFI selftest. |
| 129 | """ |
| 130 | u_boot_console.run_command(cmd='setenv efi_selftest extended text input') |
| 131 | output = u_boot_console.run_command(cmd='bootefi selftest', |
| 132 | wait_for_prompt=False) |
Heinrich Schuchardt | a882c4c | 2018-09-11 22:38:13 +0200 | [diff] [blame^] | 133 | m = u_boot_console.p.expect(['To terminate type \'CTRL\+x\'']) |
Heinrich Schuchardt | 7ecaf97 | 2018-09-11 22:38:11 +0200 | [diff] [blame] | 134 | if m != 0: |
| 135 | raise Exception('No prompt for \'text input\' test') |
| 136 | u_boot_console.drain_console() |
| 137 | u_boot_console.p.timeout = 500 |
| 138 | # EOT |
| 139 | u_boot_console.run_command(cmd=chr(4), wait_for_echo=False, |
| 140 | send_nl=False, wait_for_prompt=False) |
| 141 | m = u_boot_console.p.expect( |
| 142 | ['Unicode char 4 \(unknown\), scan code 0 \(CTRL\+Null\)']) |
| 143 | if m != 0: |
| 144 | raise Exception('EOT failed in \'text input\' test') |
| 145 | u_boot_console.drain_console() |
| 146 | # BS |
| 147 | u_boot_console.run_command(cmd=chr(8), wait_for_echo=False, |
| 148 | send_nl=False, wait_for_prompt=False) |
| 149 | m = u_boot_console.p.expect( |
| 150 | ['Unicode char 8 \(BS\), scan code 0 \(\+Null\)']) |
| 151 | if m != 0: |
| 152 | raise Exception('BS failed in \'text input\' test') |
| 153 | u_boot_console.drain_console() |
| 154 | # TAB |
| 155 | u_boot_console.run_command(cmd=chr(9), wait_for_echo=False, |
| 156 | send_nl=False, wait_for_prompt=False) |
| 157 | m = u_boot_console.p.expect( |
| 158 | ['Unicode char 9 \(TAB\), scan code 0 \(\+Null\)']) |
| 159 | if m != 0: |
| 160 | raise Exception('TAB failed in \'text input\' test') |
| 161 | u_boot_console.drain_console() |
| 162 | # a |
| 163 | u_boot_console.run_command(cmd='a', wait_for_echo=False, send_nl=False, |
| 164 | wait_for_prompt=False) |
| 165 | m = u_boot_console.p.expect( |
| 166 | ['Unicode char 97 \(\'a\'\), scan code 0 \(Null\)']) |
| 167 | if m != 0: |
| 168 | raise Exception('\'a\' failed in \'text input\' test') |
| 169 | u_boot_console.drain_console() |
| 170 | # UP escape sequence |
| 171 | u_boot_console.run_command(cmd=chr(27) + '[A', wait_for_echo=False, |
| 172 | send_nl=False, wait_for_prompt=False) |
| 173 | m = u_boot_console.p.expect( |
| 174 | ['Unicode char 0 \(Null\), scan code 1 \(\+Up\)']) |
| 175 | if m != 0: |
| 176 | raise Exception('UP failed in \'text input\' test') |
| 177 | u_boot_console.drain_console() |
| 178 | # Euro sign |
| 179 | u_boot_console.run_command(cmd='\xe2\x82\xac', wait_for_echo=False, |
| 180 | send_nl=False, wait_for_prompt=False) |
| 181 | m = u_boot_console.p.expect(['Unicode char 8364 \(\'']) |
| 182 | if m != 0: |
| 183 | raise Exception('Euro sign failed in \'text input\' test') |
| 184 | u_boot_console.drain_console() |
| 185 | # SHIFT+ALT+FN 5 |
| 186 | u_boot_console.run_command(cmd='\x1b\x5b\x31\x35\x3b\x34\x7e', |
| 187 | wait_for_echo=False, send_nl=False, |
| 188 | wait_for_prompt=False) |
| 189 | m = u_boot_console.p.expect( |
| 190 | ['Unicode char 0 \(Null\), scan code 15 \(SHIFT\+ALT\+FN 5\)']) |
| 191 | if m != 0: |
| 192 | raise Exception('SHIFT+ALT+FN 5 failed in \'text input\' test') |
| 193 | u_boot_console.drain_console() |
Heinrich Schuchardt | a882c4c | 2018-09-11 22:38:13 +0200 | [diff] [blame^] | 194 | u_boot_console.run_command(cmd=chr(24), wait_for_echo=False, send_nl=False, |
Heinrich Schuchardt | 7ecaf97 | 2018-09-11 22:38:11 +0200 | [diff] [blame] | 195 | wait_for_prompt=False) |
| 196 | m = u_boot_console.p.expect(['Summary: 0 failures', 'Press any key']) |
| 197 | if m != 0: |
| 198 | raise Exception('Failures occurred during the EFI selftest') |
| 199 | u_boot_console.restart_uboot(); |