Love Kumar | 66de8be | 2024-03-12 14:18:33 +0530 | [diff] [blame] | 1 | # SPDX-License-Identifier: GPL-2.0 |
| 2 | # (C) Copyright 2023, Advanced Micro Devices, Inc. |
| 3 | |
| 4 | """ |
| 5 | Note: This test doesn't rely on boardenv_* configuration value but they can |
| 6 | change test behavior. |
| 7 | |
| 8 | For example: |
| 9 | |
| 10 | # Setup env__reset_test_skip to True if reset test is not possible or desired |
| 11 | # and should be skipped. |
| 12 | env__reset_test_skip = True |
| 13 | |
| 14 | # Setup env__reset_test to set the bootmode if 'modeboot' u-boot environment |
| 15 | # variable is not set. Test will be skipped if bootmode is not set in both |
| 16 | # places i.e, boardenv and modeboot u-boot environment variable |
| 17 | env__reset_test = { |
| 18 | 'bootmode': 'qspiboot', |
| 19 | } |
| 20 | |
| 21 | # This test will be also skipped if the bootmode is detected to JTAG. |
| 22 | """ |
| 23 | |
| 24 | import pytest |
| 25 | import test_000_version |
| 26 | |
| 27 | def setup_reset_env(u_boot_console): |
| 28 | if u_boot_console.config.env.get('env__reset_test_skip', False): |
| 29 | pytest.skip('reset test is not enabled') |
| 30 | |
| 31 | output = u_boot_console.run_command('echo $modeboot') |
| 32 | if output: |
| 33 | bootmode = output |
| 34 | else: |
| 35 | f = u_boot_console.config.env.get('env__reset_test', None) |
| 36 | if not f: |
| 37 | pytest.skip('bootmode cannot be determined') |
| 38 | bootmode = f.get('bootmode', 'jtagboot') |
| 39 | |
| 40 | if 'jtag' in bootmode: |
| 41 | pytest.skip('skipping reset test due to jtag bootmode') |
| 42 | |
| 43 | @pytest.mark.buildconfigspec('hush_parser') |
| 44 | def test_reset(u_boot_console): |
| 45 | """Test the reset command in non-JTAG bootmode. |
| 46 | It does COLD reset, which resets CPU, DDR and peripherals |
| 47 | """ |
| 48 | setup_reset_env(u_boot_console) |
| 49 | u_boot_console.run_command('reset', wait_for_reboot=True) |
| 50 | |
| 51 | # Checks the u-boot command prompt's functionality after reset |
| 52 | test_000_version.test_version(u_boot_console) |
| 53 | |
| 54 | @pytest.mark.buildconfigspec('hush_parser') |
| 55 | def test_reset_w(u_boot_console): |
| 56 | """Test the reset -w command in non-JTAG bootmode. |
| 57 | It does WARM reset, which resets CPU but keep DDR/peripherals active. |
| 58 | """ |
| 59 | setup_reset_env(u_boot_console) |
| 60 | u_boot_console.run_command('reset -w', wait_for_reboot=True) |
| 61 | |
| 62 | # Checks the u-boot command prompt's functionality after reset |
| 63 | test_000_version.test_version(u_boot_console) |