diff options
author | Zachary Turner <zturner@google.com> | 2015-11-18 18:40:16 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2015-11-18 18:40:16 +0000 |
commit | 48ef8d4c375777f6232214a44aa23d6fc2c44396 (patch) | |
tree | 140c7b5c21deb8dd57e5515a7a7e671b15c3d4b0 /lldb/packages/Python/lldbsuite/test/functionalities/process_launch | |
parent | f08e1848157fae1f6a5466dc2192694ad04d7ba5 (diff) | |
download | bcm5719-llvm-48ef8d4c375777f6232214a44aa23d6fc2c44396.tar.gz bcm5719-llvm-48ef8d4c375777f6232214a44aa23d6fc2c44396.zip |
Fix some issues with swig & string conversion.
This patch fixes two issues:
1) Popen needs to be used with universal_newlines=True by default.
This elicits automatic decoding from bytes -> string in Py3,
and has no negative effects in other Py versions.
2) The swig typemaps for converting between string and (char*, int)
did not work correctly when the length of the string was 0,
indicating an error. In this case we would try to construct a
string from uninitialized data.
3) Ironically, the bug mentioned in #2 led to a test passing on
Windows that was actually broken, because the test was written
such that the assertion was never even getting checked, so it
passed by default. So we additionally fix this test to also
fail if the method errors. By fixing this test it's now broken
on Windows, so we also xfail it.
llvm-svn: 253487
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/functionalities/process_launch')
-rw-r--r-- | lldb/packages/Python/lldbsuite/test/functionalities/process_launch/TestProcessLaunch.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/process_launch/TestProcessLaunch.py b/lldb/packages/Python/lldbsuite/test/functionalities/process_launch/TestProcessLaunch.py index 9346bb0ba85..3131000be42 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/process_launch/TestProcessLaunch.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/process_launch/TestProcessLaunch.py @@ -192,10 +192,16 @@ class ProcessLaunchTestCase(TestBase): process = target.LaunchSimple(None, ['EVIL=' + evil_var], self.get_process_working_directory()) self.assertEqual(process.GetState(), lldb.eStateExited, PROCESS_EXITED) - out = process.GetSTDOUT(len(evil_var))[:len(evil_var)] + out = process.GetSTDOUT(len(evil_var)) + self.assertIsNotNone(out, "Encountered an error reading the process's output") + + out = out[:len(evil_var)] if out != evil_var: self.fail('The environment variable was mis-coded: %s\n' % repr(out)) - newline = process.GetSTDOUT(1)[0] + newline = process.GetSTDOUT(1) + self.assertIsNotNone(newline, "Encountered an error reading the process's output") + + newline = newline[0] if newline != '\r' and newline != '\n': self.fail('Garbage at end of environment variable') |