blob: 9610adf1fe72f125445003fb0c5933b86d38550d [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001# SPDX-License-Identifier: GPL-2.0
Stephen Warrenf8826ef2016-01-15 11:15:25 -07002# Copyright (c) 2015 Stephen Warren
3# Copyright (c) 2015-2016, NVIDIA CORPORATION. All rights reserved.
Stephen Warrenf8826ef2016-01-15 11:15:25 -07004
5import pytest
6import signal
7
8@pytest.mark.boardspec('sandbox')
Heinrich Schuchardt5cf0f3b2020-10-27 20:29:23 +01009@pytest.mark.buildconfigspec('sysreset_cmd_poweroff')
Simon Glassddba5202025-02-09 09:07:14 -070010def test_poweroff(ubman):
Heinrich Schuchardt5cf0f3b2020-10-27 20:29:23 +010011 """Test that the "poweroff" command exits sandbox process."""
Stephen Warrenf8826ef2016-01-15 11:15:25 -070012
Simon Glassddba5202025-02-09 09:07:14 -070013 ubman.run_command('poweroff', wait_for_prompt=False)
14 assert(ubman.validate_exited())
Stephen Warrenf8826ef2016-01-15 11:15:25 -070015
16@pytest.mark.boardspec('sandbox')
Simon Glassddba5202025-02-09 09:07:14 -070017def test_ctrl_c(ubman):
Stephen Warren75e731e2016-01-26 13:41:30 -070018 """Test that sending SIGINT to sandbox causes it to exit."""
Stephen Warrenf8826ef2016-01-15 11:15:25 -070019
Simon Glassddba5202025-02-09 09:07:14 -070020 ubman.kill(signal.SIGINT)
21 assert(ubman.validate_exited())
Heinrich Schuchardt0e298732020-11-12 00:29:59 +010022
23@pytest.mark.boardspec('sandbox')
24@pytest.mark.buildconfigspec('cmd_exception')
25@pytest.mark.buildconfigspec('sandbox_crash_reset')
Simon Glassddba5202025-02-09 09:07:14 -070026def test_exception_reset(ubman):
Heinrich Schuchardt0e298732020-11-12 00:29:59 +010027 """Test that SIGILL causes a reset."""
28
Simon Glassddba5202025-02-09 09:07:14 -070029 ubman.run_command('exception undefined', wait_for_prompt=False)
30 m = ubman.p.expect(['resetting ...', 'U-Boot'])
Heinrich Schuchardt0e298732020-11-12 00:29:59 +010031 if m != 0:
32 raise Exception('SIGILL did not lead to reset')
Simon Glassddba5202025-02-09 09:07:14 -070033 m = ubman.p.expect(['U-Boot', '=>'])
Heinrich Schuchardt0e298732020-11-12 00:29:59 +010034 if m != 0:
35 raise Exception('SIGILL did not lead to reset')
Simon Glassddba5202025-02-09 09:07:14 -070036 ubman.restart_uboot()
Heinrich Schuchardt0e298732020-11-12 00:29:59 +010037
38@pytest.mark.boardspec('sandbox')
39@pytest.mark.buildconfigspec('cmd_exception')
40@pytest.mark.notbuildconfigspec('sandbox_crash_reset')
Simon Glassddba5202025-02-09 09:07:14 -070041def test_exception_exit(ubman):
Heinrich Schuchardt0e298732020-11-12 00:29:59 +010042 """Test that SIGILL causes a reset."""
43
Simon Glassddba5202025-02-09 09:07:14 -070044 ubman.run_command('exception undefined', wait_for_prompt=False)
45 assert(ubman.validate_exited())