test_sandbox_exit.py 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # SPDX-License-Identifier: GPL-2.0
  2. # Copyright (c) 2015 Stephen Warren
  3. # Copyright (c) 2015-2016, NVIDIA CORPORATION. All rights reserved.
  4. import pytest
  5. import signal
  6. @pytest.mark.boardspec('sandbox')
  7. @pytest.mark.buildconfigspec('sysreset_cmd_poweroff')
  8. def test_poweroff(u_boot_console):
  9. """Test that the "poweroff" command exits sandbox process."""
  10. u_boot_console.run_command('poweroff', wait_for_prompt=False)
  11. assert(u_boot_console.validate_exited())
  12. @pytest.mark.boardspec('sandbox')
  13. def test_ctrl_c(u_boot_console):
  14. """Test that sending SIGINT to sandbox causes it to exit."""
  15. u_boot_console.kill(signal.SIGINT)
  16. assert(u_boot_console.validate_exited())
  17. @pytest.mark.boardspec('sandbox')
  18. @pytest.mark.buildconfigspec('cmd_exception')
  19. @pytest.mark.buildconfigspec('sandbox_crash_reset')
  20. def test_exception_reset(u_boot_console):
  21. """Test that SIGILL causes a reset."""
  22. u_boot_console.run_command('exception undefined', wait_for_prompt=False)
  23. m = u_boot_console.p.expect(['resetting ...', 'U-Boot'])
  24. if m != 0:
  25. raise Exception('SIGILL did not lead to reset')
  26. m = u_boot_console.p.expect(['U-Boot', '=>'])
  27. if m != 0:
  28. raise Exception('SIGILL did not lead to reset')
  29. u_boot_console.restart_uboot()
  30. @pytest.mark.boardspec('sandbox')
  31. @pytest.mark.buildconfigspec('cmd_exception')
  32. @pytest.mark.notbuildconfigspec('sandbox_crash_reset')
  33. def test_exception_exit(u_boot_console):
  34. """Test that SIGILL causes a reset."""
  35. u_boot_console.run_command('exception undefined', wait_for_prompt=False)
  36. assert(u_boot_console.validate_exited())