summaryrefslogtreecommitdiff
path: root/lldb
diff options
context:
space:
mode:
authorAlexander Polyakov <polyakov@synopsys.com>2018-09-24 19:10:48 +0000
committerAlexander Polyakov <polyakov@synopsys.com>2018-09-24 19:10:48 +0000
commitc9e708f83b3e2bc423f32d03772bd3b465daec6f (patch)
tree1d670f5909944bac159525e84ced88e72f057723 /lldb
parentbd70a0a3a5311992d625f3790fcd345f7b43248c (diff)
[lldb-mi] Fix hanging of target-select-so-path.test
Summary: The target-select-so-path test might hang on some platforms. The reason of that behavior was in incorrect usage of Filecheck and lldb-mi processes. Instead of redirecting lldb-mi's output to Filecheck, we should run lldb-mi session, finish the session, collect its output and then pass it to Filecheck. Also, this patch adds a timer to the test to prevent it from hanging in the future. Reviewers: tatyana-krasnukha, aprantl, teemperor Reviewed By: tatyana-krasnukha, teemperor Subscribers: apolyakov, aprantl, teemperor, ki.stfu, abidh, lldb-commits Differential Revision: https://reviews.llvm.org/D52139
Diffstat (limited to 'lldb')
-rw-r--r--lldb/lit/tools/lldb-mi/target/inputs/target-select-so-path.py34
1 files changed, 21 insertions, 13 deletions
diff --git a/lldb/lit/tools/lldb-mi/target/inputs/target-select-so-path.py b/lldb/lit/tools/lldb-mi/target/inputs/target-select-so-path.py
index dd271e3a664..834a1ed4071 100644
--- a/lldb/lit/tools/lldb-mi/target/inputs/target-select-so-path.py
+++ b/lldb/lit/tools/lldb-mi/target/inputs/target-select-so-path.py
@@ -3,6 +3,7 @@
import os
import sys
import subprocess
+from threading import Timer
hostname = 'localhost'
@@ -19,21 +20,28 @@ filecheck = 'FileCheck ' + test_file
debugserver_proc = subprocess.Popen(debugserver.split())
lldbmi_proc = subprocess.Popen(lldbmi, stdin=subprocess.PIPE,
stdout=subprocess.PIPE, shell=True)
-filecheck_proc = subprocess.Popen(filecheck, stdin=lldbmi_proc.stdout,
+filecheck_proc = subprocess.Popen(filecheck, stdin=subprocess.PIPE,
shell=True)
-# Get a tcp port chosen by debugserver.
-# The number quite big to get lldb-server's output and to not hang.
-bytes_to_read = 10
-port_bytes = os.read(r, bytes_to_read)
-port = str(port_bytes.decode('utf-8').strip('\x00'))
-
-with open(test_file, 'r') as f:
- # Replace '$PORT' with a free port number and pass
- # test's content to lldb-mi.
- lldbmi_proc.stdin.write(f.read().replace('$PORT', port))
- lldbmi_proc.wait()
- filecheck_proc.wait()
+timeout_sec = 30
+timer = Timer(timeout_sec, lldbmi_proc.kill)
+try:
+ timer.start()
+
+ # Get a tcp port chosen by debugserver.
+ # The number quite big to get lldb-server's output and to not hang.
+ bytes_to_read = 10
+ port_bytes = os.read(r, bytes_to_read)
+ port = str(port_bytes.decode('utf-8').strip('\x00'))
+
+ with open(test_file, 'r') as f:
+ # Replace '$PORT' with a free port number and pass
+ # test's content to lldb-mi.
+ lldbmi_proc.stdin.write(f.read().replace('$PORT', port))
+ out, err = lldbmi_proc.communicate()
+ filecheck_proc.stdin.write(out)
+finally:
+ timer.cancel()
debugserver_proc.kill()
exit(filecheck_proc.returncode)