summaryrefslogtreecommitdiffstats
path: root/lldb/packages/Python/lldbsuite/test/test_runner
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/test_runner')
-rw-r--r--lldb/packages/Python/lldbsuite/test/test_runner/process_control.py10
-rwxr-xr-xlldb/packages/Python/lldbsuite/test/test_runner/test/test_process_control.py13
2 files changed, 17 insertions, 6 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/test_runner/process_control.py b/lldb/packages/Python/lldbsuite/test/test_runner/process_control.py
index a7e639e4b8b..e8bc69b7f62 100644
--- a/lldb/packages/Python/lldbsuite/test/test_runner/process_control.py
+++ b/lldb/packages/Python/lldbsuite/test/test_runner/process_control.py
@@ -23,6 +23,7 @@ import threading
class CommunicatorThread(threading.Thread):
"""Provides a thread class that communicates with a subprocess."""
+
def __init__(self, process, event, output_file):
super(CommunicatorThread, self).__init__()
# Don't let this thread prevent shutdown.
@@ -100,6 +101,7 @@ class ProcessHelper(object):
@see ProcessHelper.process_helper()
"""
+
def __init__(self):
super(ProcessHelper, self).__init__()
@@ -281,6 +283,7 @@ class UnixProcessHelper(ProcessHelper):
This implementation supports anything that looks Posix-y
(e.g. Darwin, Linux, *BSD, etc.)
"""
+
def __init__(self):
super(UnixProcessHelper, self).__init__()
@@ -302,7 +305,7 @@ class UnixProcessHelper(ProcessHelper):
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
- universal_newlines=True, # Elicits automatic byte -> string decoding in Py3
+ universal_newlines=True, # Elicits automatic byte -> string decoding in Py3
close_fds=True,
preexec_fn=preexec_func)
@@ -412,8 +415,10 @@ class UnixProcessHelper(ProcessHelper):
signal_name = signal_names_by_number.get(signo, "")
return (signo, signal_name)
+
class WindowsProcessHelper(ProcessHelper):
"""Provides a Windows implementation of the ProcessHelper class."""
+
def __init__(self):
super(WindowsProcessHelper, self).__init__()
@@ -429,7 +434,7 @@ class WindowsProcessHelper(ProcessHelper):
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
- universal_newlines=True, # Elicits automatic byte -> string decoding in Py3
+ universal_newlines=True, # Elicits automatic byte -> string decoding in Py3
creationflags=creation_flags)
def was_hard_terminate(self, returncode):
@@ -447,6 +452,7 @@ class ProcessDriver(object):
way. The on_process_exited method is informed if the exit was natural
or if it was due to a timeout.
"""
+
def __init__(self, soft_terminate_timeout=10.0):
super(ProcessDriver, self).__init__()
self.process_helper = ProcessHelper.process_helper()
diff --git a/lldb/packages/Python/lldbsuite/test/test_runner/test/test_process_control.py b/lldb/packages/Python/lldbsuite/test/test_runner/test/test_process_control.py
index 817c83c4fb5..88ad961be2b 100755
--- a/lldb/packages/Python/lldbsuite/test/test_runner/test/test_process_control.py
+++ b/lldb/packages/Python/lldbsuite/test/test_runner/test/test_process_control.py
@@ -27,6 +27,7 @@ from test_runner import process_control
class TestInferiorDriver(process_control.ProcessDriver):
+
def __init__(self, soft_terminate_timeout=None):
super(TestInferiorDriver, self).__init__(
soft_terminate_timeout=soft_terminate_timeout)
@@ -58,6 +59,7 @@ class TestInferiorDriver(process_control.ProcessDriver):
class ProcessControlTests(unittest.TestCase):
+
@classmethod
def _suppress_soft_terminate(cls, command):
# Do the right thing for your platform here.
@@ -79,7 +81,8 @@ class ProcessControlTests(unittest.TestCase):
# Base command.
script_name = "{}/inferior.py".format(os.path.dirname(__file__))
if not os.path.exists(script_name):
- raise Exception("test inferior python script not found: {}".format(script_name))
+ raise Exception(
+ "test inferior python script not found: {}".format(script_name))
command = ([sys.executable, script_name])
if ignore_soft_terminate:
@@ -97,6 +100,7 @@ class ProcessControlTests(unittest.TestCase):
class ProcessControlNoTimeoutTests(ProcessControlTests):
"""Tests the process_control module."""
+
def test_run_completes(self):
"""Test that running completes and gets expected stdout/stderr."""
driver = TestInferiorDriver()
@@ -115,6 +119,7 @@ class ProcessControlNoTimeoutTests(ProcessControlTests):
class ProcessControlTimeoutTests(ProcessControlTests):
+
def test_run_completes(self):
"""Test that running completes and gets expected return code."""
driver = TestInferiorDriver()
@@ -124,7 +129,7 @@ class ProcessControlTimeoutTests(ProcessControlTests):
"{}s".format(timeout_seconds),
False)
self.assertTrue(
- driver.completed_event.wait(2*timeout_seconds),
+ driver.completed_event.wait(2 * timeout_seconds),
"process failed to complete")
self.assertEqual(driver.returncode, 0)
@@ -141,13 +146,13 @@ class ProcessControlTimeoutTests(ProcessControlTests):
# Sleep twice as long as the timeout interval. This
# should force a timeout.
self.inferior_command(
- options="--sleep {}".format(timeout_seconds*2)),
+ options="--sleep {}".format(timeout_seconds * 2)),
"{}s".format(timeout_seconds),
with_core)
# We should complete, albeit with a timeout.
self.assertTrue(
- driver.completed_event.wait(2*timeout_seconds),
+ driver.completed_event.wait(2 * timeout_seconds),
"process failed to complete")
# Ensure we received a timeout.
OpenPOWER on IntegriCloud