diff --git a/selftests/all/functional/avocado/basic_tests.py b/selftests/all/functional/avocado/basic_tests.py index ca34cba1789f51a57fd8a4014cc761c92d33f162..257924e7ef1b89b0702e8b4306383cd6c626488b 100644 --- a/selftests/all/functional/avocado/basic_tests.py +++ b/selftests/all/functional/avocado/basic_tests.py @@ -17,6 +17,7 @@ import json import unittest import os +import signal import shutil import sys import tempfile @@ -113,6 +114,25 @@ class RunnerOperationTest(unittest.TestCase): self.assertEqual(result.exit_status, expected_rc, "Avocado did not return rc %d:\n%s" % (expected_rc, result)) + def test_runner_ctrl_c(self): + os.chdir(basedir) + cmd_line = './scripts/avocado run sleeptenmin' + sp = process.SubProcess(cmd_line) + # Let it run for 3 seconds, then send a SIGINT + # (translates to KeyboardInterrupt) + sp.wait(timeout=3, sig=signal.SIGINT) + result = sp.result + output = result.stdout + result.stderr + expected_rc = 2 + unexpected_rc = 3 + self.assertNotEqual(result.exit_status, unexpected_rc, + "Avocado crashed (rc %d):\n%s" % (unexpected_rc, result)) + self.assertEqual(result.exit_status, expected_rc, + "Avocado did not return rc %d:\n%s" % (expected_rc, result)) + self.assertIn("Interrupted by user request", output, + "Avocado did not display interruption message. " + "Output:\n%s" % output) + class RunnerDropinTest(unittest.TestCase):