-
Notifications
You must be signed in to change notification settings - Fork 343
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit introduces the suspend execution feature to the nrunner. The suspend execution was available on the legacy runner, but we didn't move it to the nrunner. With this feature, it is possible to pause execution of python based task on process spawner by sending SIGTSTP signal (ctrl+z). It is helpful for debugging test execution. Reference: #6059 Signed-off-by: Jan Richter <[email protected]>
- Loading branch information
Showing
9 changed files
with
180 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import os | ||
import re | ||
import signal | ||
import time | ||
|
||
from avocado.utils import process, script | ||
from selftests.utils import AVOCADO, TestCaseTmpDir | ||
|
||
SLEEP_TEST = """import time | ||
from avocado import Test | ||
class SleepTest(Test): | ||
timeout = 10 | ||
def test(self): | ||
self.log.debug("Sleeping starts: %s", time.time()) | ||
time.sleep(9) | ||
self.log.debug("Sleeping ends: %s", time.time()) | ||
""" | ||
|
||
|
||
class RunnerOperationTest(TestCaseTmpDir): | ||
def test_pause(self): | ||
with script.TemporaryScript( | ||
"sleep.py", | ||
SLEEP_TEST, | ||
) as tst: | ||
cmd_line = f"{AVOCADO} run --disable-sysinfo --job-results-dir {self.tmpdir.name} -- {tst}" | ||
proc = process.SubProcess(cmd_line) | ||
proc.start() | ||
init = True | ||
while init: | ||
output = proc.get_stdout() | ||
if b"STARTED" in output: | ||
init = False | ||
proc.send_signal(signal.SIGTSTP) | ||
time.sleep(10) | ||
proc.send_signal(signal.SIGTSTP) | ||
proc.wait() | ||
full_log_path = os.path.join(self.tmpdir.name, "latest", "full.log") | ||
with open(full_log_path, encoding="utf-8") as full_log_file: | ||
full_log = full_log_file.read() | ||
regex_start = re.search("Sleeping starts: ([0-9]*)", full_log) | ||
regex_end = re.search("Sleeping ends: ([0-9]*)", full_log) | ||
start_time = int(regex_start.group(1)) | ||
start_end = int(regex_end.group(1)) | ||
self.assertIn("SleepTest.test: PAUSED", full_log) | ||
self.assertIn("SleepTest.test: STARTED", full_log) | ||
self.assertGreaterEqual(start_end - start_time, 7) |