Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | # SPDX-License-Identifier: GPL-2.0 |
Stephen Warren | f8826ef | 2016-01-15 11:15:25 -0700 | [diff] [blame] | 2 | # Copyright (c) 2015 Stephen Warren |
| 3 | # Copyright (c) 2015-2016, NVIDIA CORPORATION. All rights reserved. |
Stephen Warren | f8826ef | 2016-01-15 11:15:25 -0700 | [diff] [blame] | 4 | |
| 5 | import pytest |
| 6 | import signal |
| 7 | |
| 8 | @pytest.mark.boardspec('sandbox') |
Heinrich Schuchardt | 5cf0f3b | 2020-10-27 20:29:23 +0100 | [diff] [blame] | 9 | @pytest.mark.buildconfigspec('sysreset_cmd_poweroff') |
Simon Glass | ddba520 | 2025-02-09 09:07:14 -0700 | [diff] [blame] | 10 | def test_poweroff(ubman): |
Heinrich Schuchardt | 5cf0f3b | 2020-10-27 20:29:23 +0100 | [diff] [blame] | 11 | """Test that the "poweroff" command exits sandbox process.""" |
Stephen Warren | f8826ef | 2016-01-15 11:15:25 -0700 | [diff] [blame] | 12 | |
Simon Glass | ddba520 | 2025-02-09 09:07:14 -0700 | [diff] [blame] | 13 | ubman.run_command('poweroff', wait_for_prompt=False) |
| 14 | assert(ubman.validate_exited()) |
Stephen Warren | f8826ef | 2016-01-15 11:15:25 -0700 | [diff] [blame] | 15 | |
| 16 | @pytest.mark.boardspec('sandbox') |
Simon Glass | ddba520 | 2025-02-09 09:07:14 -0700 | [diff] [blame] | 17 | def test_ctrl_c(ubman): |
Stephen Warren | 75e731e | 2016-01-26 13:41:30 -0700 | [diff] [blame] | 18 | """Test that sending SIGINT to sandbox causes it to exit.""" |
Stephen Warren | f8826ef | 2016-01-15 11:15:25 -0700 | [diff] [blame] | 19 | |
Simon Glass | ddba520 | 2025-02-09 09:07:14 -0700 | [diff] [blame] | 20 | ubman.kill(signal.SIGINT) |
| 21 | assert(ubman.validate_exited()) |
Heinrich Schuchardt | 0e29873 | 2020-11-12 00:29:59 +0100 | [diff] [blame] | 22 | |
| 23 | @pytest.mark.boardspec('sandbox') |
| 24 | @pytest.mark.buildconfigspec('cmd_exception') |
| 25 | @pytest.mark.buildconfigspec('sandbox_crash_reset') |
Simon Glass | ddba520 | 2025-02-09 09:07:14 -0700 | [diff] [blame] | 26 | def test_exception_reset(ubman): |
Heinrich Schuchardt | 0e29873 | 2020-11-12 00:29:59 +0100 | [diff] [blame] | 27 | """Test that SIGILL causes a reset.""" |
| 28 | |
Simon Glass | ddba520 | 2025-02-09 09:07:14 -0700 | [diff] [blame] | 29 | ubman.run_command('exception undefined', wait_for_prompt=False) |
| 30 | m = ubman.p.expect(['resetting ...', 'U-Boot']) |
Heinrich Schuchardt | 0e29873 | 2020-11-12 00:29:59 +0100 | [diff] [blame] | 31 | if m != 0: |
| 32 | raise Exception('SIGILL did not lead to reset') |
Simon Glass | ddba520 | 2025-02-09 09:07:14 -0700 | [diff] [blame] | 33 | m = ubman.p.expect(['U-Boot', '=>']) |
Heinrich Schuchardt | 0e29873 | 2020-11-12 00:29:59 +0100 | [diff] [blame] | 34 | if m != 0: |
| 35 | raise Exception('SIGILL did not lead to reset') |
Simon Glass | ddba520 | 2025-02-09 09:07:14 -0700 | [diff] [blame] | 36 | ubman.restart_uboot() |
Heinrich Schuchardt | 0e29873 | 2020-11-12 00:29:59 +0100 | [diff] [blame] | 37 | |
| 38 | @pytest.mark.boardspec('sandbox') |
| 39 | @pytest.mark.buildconfigspec('cmd_exception') |
| 40 | @pytest.mark.notbuildconfigspec('sandbox_crash_reset') |
Simon Glass | ddba520 | 2025-02-09 09:07:14 -0700 | [diff] [blame] | 41 | def test_exception_exit(ubman): |
Heinrich Schuchardt | 0e29873 | 2020-11-12 00:29:59 +0100 | [diff] [blame] | 42 | """Test that SIGILL causes a reset.""" |
| 43 | |
Simon Glass | ddba520 | 2025-02-09 09:07:14 -0700 | [diff] [blame] | 44 | ubman.run_command('exception undefined', wait_for_prompt=False) |
| 45 | assert(ubman.validate_exited()) |