[Lldb-commits] [lldb] r343033 - [lldb-mi] Fix bugs in target-select-so-path.test

Alexander Polyakov via lldb-commits lldb-commits at lists.llvm.org
Tue Sep 25 14:49:33 PDT 2018


Author: apolyakov
Date: Tue Sep 25 14:49:33 2018
New Revision: 343033

URL: http://llvm.org/viewvc/llvm-project?rev=343033&view=rev
Log:
[lldb-mi] Fix bugs in target-select-so-path.test

Summary:
* This patch fixes hanging of the test in case of using python3, changes callback
  function that will be called if the timer ends, changes python interpreter to
  `%python` that is set up by llvm-lit.
* Also, the test didn't work properly since it didn't contain a call of
  filecheck_proc.communicate(), that means that filecheck didn't run and its
  return code was equal to 0 in all cases.

Reviewers: teemperor, labath, tatyana-krasnukha, aprantl

Reviewed By: teemperor, labath

Subscribers: ki.stfu, lldb-commits

Differential Revision: https://reviews.llvm.org/D52498

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

Modified: lldb/trunk/lit/tools/lldb-mi/target/inputs/target-select-so-path.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/tools/lldb-mi/target/inputs/target-select-so-path.py?rev=343033&r1=343032&r2=343033&view=diff
==============================================================================
--- lldb/trunk/lit/tools/lldb-mi/target/inputs/target-select-so-path.py (original)
+++ lldb/trunk/lit/tools/lldb-mi/target/inputs/target-select-so-path.py Tue Sep 25 14:49:33 2018
@@ -1,5 +1,3 @@
-#!/usr/bin/env python2
-
 import os
 import sys
 import subprocess
@@ -9,6 +7,10 @@ from threading import Timer
 hostname = 'localhost'
 
 (r, w) = os.pipe()
+kwargs = {}
+if sys.version_info >= (3,2):
+    kwargs['pass_fds'] = [w]
+
 args = sys.argv
 # Get debugserver, lldb-mi and FileCheck executables' paths with arguments.
 debugserver = ' '.join([args[1], '--pipe', str(w), hostname + ':0'])
@@ -17,14 +19,14 @@ test_file = args[3]
 filecheck = 'FileCheck ' + test_file
 
 # Run debugserver, lldb-mi and FileCheck.
-debugserver_proc = subprocess.Popen(debugserver.split())
+debugserver_proc = subprocess.Popen(debugserver.split(), **kwargs)
 lldbmi_proc = subprocess.Popen(lldbmi, stdin=subprocess.PIPE,
                                stdout=subprocess.PIPE, shell=True)
 filecheck_proc = subprocess.Popen(filecheck, stdin=subprocess.PIPE,
                                   shell=True)
 
 timeout_sec = 30
-timer = Timer(timeout_sec, lldbmi_proc.kill)
+timer = Timer(timeout_sec, exit, [filecheck_proc.returncode])
 try:
     timer.start()
 
@@ -37,9 +39,10 @@ try:
     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.stdin.write(f.read().replace('$PORT', port).encode('utf-8'))
         out, err = lldbmi_proc.communicate()
         filecheck_proc.stdin.write(out)
+        filecheck_proc.communicate()
 finally:
     timer.cancel()
 

Modified: lldb/trunk/lit/tools/lldb-mi/target/target-select-so-path.test
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/tools/lldb-mi/target/target-select-so-path.test?rev=343033&r1=343032&r2=343033&view=diff
==============================================================================
--- lldb/trunk/lit/tools/lldb-mi/target/target-select-so-path.test (original)
+++ lldb/trunk/lit/tools/lldb-mi/target/target-select-so-path.test Tue Sep 25 14:49:33 2018
@@ -1,7 +1,7 @@
 # UNSUPPORTED: windows, darwin
 #
 # RUN: %cc -o %t %p/inputs/main.c -g
-# RUN: python %p/inputs/target-select-so-path.py "%debugserver" "%lldbmi %t" %s
+# RUN: %python %p/inputs/target-select-so-path.py "%debugserver" "%lldbmi %t" %s
 
 # Test that -target-select command can hook up a path
 # added by gdb-set solib-search-path.




More information about the lldb-commits mailing list