[Lldb-commits] [PATCH] D52139: [lldb-mi] Fix hanging of target-select-so-path.test

Alexander Polyakov via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Mon Sep 24 12:14:07 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL342915: [lldb-mi] Fix hanging of target-select-so-path.test (authored by apolyakov, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D52139?vs=166714&id=166731#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D52139

Files:
  lldb/trunk/lit/tools/lldb-mi/target/inputs/target-select-so-path.py


Index: lldb/trunk/lit/tools/lldb-mi/target/inputs/target-select-so-path.py
===================================================================
--- lldb/trunk/lit/tools/lldb-mi/target/inputs/target-select-so-path.py
+++ lldb/trunk/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 @@
 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)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52139.166731.patch
Type: text/x-patch
Size: 1978 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20180924/8a63eacb/attachment.bin>


More information about the lldb-commits mailing list