summaryrefslogtreecommitdiffstats
path: root/lldb/packages/Python/lldbsuite/test
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test')
-rw-r--r--lldb/packages/Python/lldbsuite/test/dosep.py21
-rw-r--r--lldb/packages/Python/lldbsuite/test/test_runner/process_control.py34
2 files changed, 39 insertions, 16 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/dosep.py b/lldb/packages/Python/lldbsuite/test/dosep.py
index 0e6b277e47c..4cdffa653f1 100644
--- a/lldb/packages/Python/lldbsuite/test/dosep.py
+++ b/lldb/packages/Python/lldbsuite/test/dosep.py
@@ -243,7 +243,7 @@ class DoTestProcessDriver(process_control.ProcessDriver):
except ImportError:
# We don't have one for this platform. Skip.
sys.stderr.write("\nwarning: no timeout handler module: " +
- module_name)
+ module_name + "\n")
return
# Try to run the pre-kill-hook method.
@@ -254,13 +254,26 @@ class DoTestProcessDriver(process_control.ProcessDriver):
# Write the output to a filename associated with the test file and
# pid.
+ MAX_UNCOMPRESSED_BYTE_COUNT = 10 * 1024
+
+ content = output_io.getvalue()
+ compress_output = len(content) > MAX_UNCOMPRESSED_BYTE_COUNT
basename = "{}-{}.sample".format(self.file_name, self.pid)
sample_path = os.path.join(g_session_dir, basename)
- with open(sample_path, "w") as output_file:
- output_file.write(output_io.getvalue())
+
+ if compress_output:
+ # Write compressed output into a .zip file.
+ from zipfile import ZipFile, ZIP_DEFLATED
+ zipfile = sample_path + ".zip"
+ with ZipFile(zipfile, "w", ZIP_DEFLATED) as sample_zip:
+ sample_zip.writestr(basename, content)
+ else:
+ # Write raw output into a text file.
+ with open(sample_path, "w") as output_file:
+ output_file.write(content)
except Exception as e:
sys.stderr.write("caught exception while running "
- "pre-kill action: {}".format(e))
+ "pre-kill action: {}\n".format(e))
return
def is_exceptional_exit(self):
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 005500ab6bf..720f5112a4c 100644
--- a/lldb/packages/Python/lldbsuite/test/test_runner/process_control.py
+++ b/lldb/packages/Python/lldbsuite/test/test_runner/process_control.py
@@ -360,18 +360,28 @@ class UnixProcessHelper(ProcessHelper):
# Choose kill mechanism based on whether we're targeting
# a process group or just a process.
- if popen_process.using_process_groups:
- # if log_file:
- # log_file.write(
- # "sending signum {} to process group {} now\n".format(
- # signum, popen_process.pid))
- os.killpg(popen_process.pid, signum)
- else:
- # if log_file:
- # log_file.write(
- # "sending signum {} to process {} now\n".format(
- # signum, popen_process.pid))
- os.kill(popen_process.pid, signum)
+ try:
+ if popen_process.using_process_groups:
+ # if log_file:
+ # log_file.write(
+ # "sending signum {} to process group {} now\n".format(
+ # signum, popen_process.pid))
+ os.killpg(popen_process.pid, signum)
+ else:
+ # if log_file:
+ # log_file.write(
+ # "sending signum {} to process {} now\n".format(
+ # signum, popen_process.pid))
+ os.kill(popen_process.pid, signum)
+ except OSError as error:
+ import errno
+ if error.errno == errno.ESRCH:
+ # This is okay - failed to find the process. It may be that
+ # that the timeout pre-kill hook eliminated the process. We'll
+ # ignore.
+ pass
+ else:
+ raise
def soft_terminate(self, popen_process, log_file=None, want_core=True):
# Choose signal based on desire for core file.
OpenPOWER on IntegriCloud