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: |
| 19 | raise Exception('Failures occured 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(); |
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(); |