diff options
author | Alexander Polyakov <polyakov@synopsys.com> | 2018-09-25 21:49:33 +0000 |
---|---|---|
committer | Alexander Polyakov <polyakov@synopsys.com> | 2018-09-25 21:49:33 +0000 |
commit | 9afe0f5d82b175a7560943798ed9ebc398c1748d (patch) | |
tree | 1fefc02a810e79b4d9b6d86b526c62bddadd2344 /lldb | |
parent | a7892e30e003f549e23b2a601f5adebbe0ee1747 (diff) |
[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
Diffstat (limited to 'lldb')
-rw-r--r-- | lldb/lit/tools/lldb-mi/target/inputs/target-select-so-path.py | 13 | ||||
-rw-r--r-- | lldb/lit/tools/lldb-mi/target/target-select-so-path.test | 2 |
2 files changed, 9 insertions, 6 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 834a1ed4071..5eb07d84237 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 @@ -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() diff --git a/lldb/lit/tools/lldb-mi/target/target-select-so-path.test b/lldb/lit/tools/lldb-mi/target/target-select-so-path.test index 33ba1fd4635..80b51446e28 100644 --- a/lldb/lit/tools/lldb-mi/target/target-select-so-path.test +++ b/lldb/lit/tools/lldb-mi/target/target-select-so-path.test @@ -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. |