diff options
| author | Daniel Malea <daniel.malea@intel.com> | 2013-02-15 21:21:52 +0000 |
|---|---|---|
| committer | Daniel Malea <daniel.malea@intel.com> | 2013-02-15 21:21:52 +0000 |
| commit | 2dd69bb5f2a2c8eae285626bd12dfa1aafb63b2b (patch) | |
| tree | b7266a5fe202b777c44d8a110f15ecdb5d28ee35 /lldb/test/python_api | |
| parent | 69fb3d11ec19d099fda2b64a89abea9fa906c4d5 (diff) | |
| download | bcm5719-llvm-2dd69bb5f2a2c8eae285626bd12dfa1aafb63b2b.tar.gz bcm5719-llvm-2dd69bb5f2a2c8eae285626bd12dfa1aafb63b2b.zip | |
Fix misuse of python subprocess module (caused "leaking" processes and garbling the terminal)
- fixed cleanup of Popen objects by pushing spawn logic into test Base and out of test cases
- connect subprocess stdin to PIPE (rather than the parent's STDIN) to fix silent terminal issue
Tested on Linux and Mac OS X
llvm-svn: 175301
Diffstat (limited to 'lldb/test/python_api')
| -rw-r--r-- | lldb/test/python_api/hello_world/TestHelloWorld.py | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/lldb/test/python_api/hello_world/TestHelloWorld.py b/lldb/test/python_api/hello_world/TestHelloWorld.py index acb583b0061..2b895b9d1a5 100644 --- a/lldb/test/python_api/hello_world/TestHelloWorld.py +++ b/lldb/test/python_api/hello_world/TestHelloWorld.py @@ -135,11 +135,9 @@ class HelloWorldTestCase(TestBase): target = self.dbg.CreateTarget(self.exe) - # Spawn a new process and don't display the stdout if not in TraceOn() mode. - import subprocess - popen = subprocess.Popen([self.exe, "abc", "xyz"], - stdout = open(os.devnull, 'w') if not self.TraceOn() else None) - #print "pid of spawned process: %d" % popen.pid + # Spawn a new process + popen = self.spawnSubprocess(self.exe, ["abc", "xyz"]) + self.addTearDownHook(self.cleanupSubprocesses) listener = lldb.SBListener("my.attach.listener") error = lldb.SBError() @@ -159,11 +157,9 @@ class HelloWorldTestCase(TestBase): target = self.dbg.CreateTarget(self.exe) - # Spawn a new process and don't display the stdout if not in TraceOn() mode. - import subprocess - popen = subprocess.Popen([self.exe, "abc", "xyz"], - stdout = open(os.devnull, 'w') if not self.TraceOn() else None) - #print "pid of spawned process: %d" % popen.pid + # Spawn a new process + popen = self.spawnSubprocess(self.exe, ["abc", "xyz"]) + self.addTearDownHook(self.cleanupSubprocesses) listener = lldb.SBListener("my.attach.listener") error = lldb.SBError() |

