JDevlieghere updated this revision to Diff 425113.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D124430/new/
https://reviews.llvm.org/D124430
Files:
lldb/test/API/functionalities/step_scripted/TestStepScripted.py
lldb/test/API/lldbtest.py
lldb/test/API/macosx/nslog/TestDarwinNSLogOutput.py
lldb/test/API/python_api/disassemble-raw-data/TestDisassemble_VST1_64.py
lldb/test/API/python_api/file_handle/TestFileHandle.py
lldb/test/API/terminal/TestSTTYBeforeAndAfter.py
Index: lldb/test/API/terminal/TestSTTYBeforeAndAfter.py
===================================================================
--- lldb/test/API/terminal/TestSTTYBeforeAndAfter.py
+++ lldb/test/API/terminal/TestSTTYBeforeAndAfter.py
@@ -7,6 +7,7 @@
import lldb
import six
+import sys
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
@@ -41,11 +42,7 @@
lldb_prompt = "(lldb) "
# So that the child gets torn down after the test.
- import sys
- if sys.version_info.major == 3:
- self.child = pexpect.spawnu('expect')
- else:
- self.child = pexpect.spawn('expect')
+ self.child = pexpect.spawnu('expect')
child = self.child
child.expect(expect_prompt)
Index: lldb/test/API/python_api/file_handle/TestFileHandle.py
===================================================================
--- lldb/test/API/python_api/file_handle/TestFileHandle.py
+++ lldb/test/API/python_api/file_handle/TestFileHandle.py
@@ -276,7 +276,6 @@
self.assertTrue(re.search(r'QUUX', output))
- @skipIf(py_version=['<', (3,)])
def test_immediate_string(self):
f = io.StringIO()
ret = lldb.SBCommandReturnObject()
@@ -291,7 +290,6 @@
self.assertTrue(re.search(r'QUUX', output))
- @skipIf(py_version=['<', (3,)])
def test_immediate_sbfile_string(self):
f = io.StringIO()
ret = lldb.SBCommandReturnObject()
@@ -361,7 +359,6 @@
self.assertIn('Show a list of all debugger commands', output)
- @skipIf(py_version=['<', (3,)])
def test_string_inout(self):
inf = io.StringIO("help help\np/x ~0\n")
outf = io.StringIO()
@@ -377,7 +374,6 @@
self.assertIn('0xfff', output)
- @skipIf(py_version=['<', (3,)])
def test_bytes_inout(self):
inf = io.BytesIO(b"help help\nhelp b\n")
outf = io.BytesIO()
@@ -447,7 +443,6 @@
- @skipIf(py_version=['<', (3,)])
def test_sbfile_write_forced(self):
with open(self.out_filename, 'w') as f:
written = MutableBool(False)
@@ -467,7 +462,6 @@
self.assertEqual(f.read().strip(), 'FOO')
- @skipIf(py_version=['<', (3,)])
def test_sbfile_write_forced_borrowed(self):
with open(self.out_filename, 'w') as f:
written = MutableBool(False)
@@ -487,7 +481,6 @@
self.assertEqual(f.read().strip(), 'FOO')
- @skipIf(py_version=['<', (3,)])
def test_sbfile_write_string(self):
f = io.StringIO()
sbf = lldb.SBFile(f)
@@ -499,7 +492,6 @@
self.assertTrue(f.closed)
- @skipIf(py_version=['<', (3,)])
def test_string_out(self):
f = io.StringIO()
status = self.dbg.SetOutputFile(f)
@@ -508,7 +500,6 @@
self.assertEqual(f.getvalue().strip(), "'foobar'")
- @skipIf(py_version=['<', (3,)])
def test_string_error(self):
f = io.StringIO()
status = self.dbg.SetErrorFile(f)
@@ -518,7 +509,6 @@
self.assertTrue(re.search(r'error:.*lolwut', errors))
- @skipIf(py_version=['<', (3,)])
def test_sbfile_write_bytes(self):
f = io.BytesIO()
sbf = lldb.SBFile(f)
@@ -529,7 +519,6 @@
sbf.Close()
self.assertTrue(f.closed)
- @skipIf(py_version=['<', (3,)])
def test_sbfile_read_string(self):
f = io.StringIO('zork')
sbf = lldb.SBFile(f)
@@ -539,7 +528,6 @@
self.assertEqual(buf[:n], b'zork')
- @skipIf(py_version=['<', (3,)])
def test_sbfile_read_string_one_byte(self):
f = io.StringIO('z')
sbf = lldb.SBFile(f)
@@ -550,7 +538,6 @@
self.assertEqual(e.GetCString(), "can't read less than 6 bytes from a utf8 text stream")
- @skipIf(py_version=['<', (3,)])
def test_sbfile_read_bytes(self):
f = io.BytesIO(b'zork')
sbf = lldb.SBFile(f)
@@ -560,7 +547,6 @@
self.assertEqual(buf[:n], b'zork')
- @skipIf(py_version=['<', (3,)])
def test_sbfile_out(self):
with open(self.out_filename, 'w') as f:
sbf = lldb.SBFile(f)
@@ -571,7 +557,6 @@
self.assertEqual(f.read().strip(), '4')
- @skipIf(py_version=['<', (3,)])
def test_file_out(self):
with open(self.out_filename, 'w') as f:
status = self.dbg.SetOutputFile(f)
@@ -605,21 +590,17 @@
def test_exceptions(self):
self.assertRaises(Exception, lldb.SBFile, None)
self.assertRaises(Exception, lldb.SBFile, "ham sandwich")
- if sys.version_info[0] < 3:
- self.assertRaises(Exception, lldb.SBFile, ReallyBadIO())
- else:
- self.assertRaises(OhNoe, lldb.SBFile, ReallyBadIO())
- error, n = lldb.SBFile(BadIO()).Write(b"FOO")
- self.assertEqual(n, 0)
- self.assertTrue(error.Fail())
- self.assertIn('OH NOE', error.GetCString())
- error, n = lldb.SBFile(BadIO()).Read(bytearray(100))
- self.assertEqual(n, 0)
- self.assertTrue(error.Fail())
- self.assertIn('OH NOE', error.GetCString())
-
-
- @skipIf(py_version=['<', (3,)])
+ self.assertRaises(OhNoe, lldb.SBFile, ReallyBadIO())
+ error, n = lldb.SBFile(BadIO()).Write(b"FOO")
+ self.assertEqual(n, 0)
+ self.assertTrue(error.Fail())
+ self.assertIn('OH NOE', error.GetCString())
+ error, n = lldb.SBFile(BadIO()).Read(bytearray(100))
+ self.assertEqual(n, 0)
+ self.assertTrue(error.Fail())
+ self.assertIn('OH NOE', error.GetCString())
+
+
def test_exceptions_logged(self):
messages = list()
self.dbg.SetLoggingCallback(messages.append)
@@ -629,7 +610,6 @@
self.assertTrue(any('OH NOE' in msg for msg in messages))
- @skipIf(py_version=['<', (3,)])
def test_flush(self):
flushed = MutableBool(False)
closed = MutableBool(False)
@@ -695,7 +675,6 @@
self.assertTrue(re.search(r'ZAP', output))
- @skipIf(py_version=['<', (3,)])
def test_stdout(self):
f = io.StringIO()
status = self.dbg.SetOutputFile(f)
@@ -718,9 +697,7 @@
self.assertEqual(lines, ["foobar"])
- @skipIf(py_version=['<', (3,)])
def test_identity(self):
-
f = io.StringIO()
sbf = lldb.SBFile(f)
self.assertTrue(f is sbf.GetFile())
@@ -810,22 +787,15 @@
self.dbg.SetOutputFileHandle(None, False)
self.dbg.SetErrorFileHandle(None, False)
sbf = self.dbg.GetOutputFile()
- if sys.version_info.major >= 3:
- # python 2 lacks PyFile_FromFd, so GetFile() will
- # have to duplicate the file descriptor and make a FILE*
- # in order to convert a NativeFile it back to a python
- # file.
- self.assertEqual(sbf.GetFile().fileno(), 1)
+ self.assertEqual(sbf.GetFile().fileno(), 1)
sbf = self.dbg.GetErrorFile()
- if sys.version_info.major >= 3:
- self.assertEqual(sbf.GetFile().fileno(), 2)
+ self.assertEqual(sbf.GetFile().fileno(), 2)
with open(self.out_filename, 'r') as f:
status = self.dbg.SetInputFile(f)
self.assertSuccess(status)
self.dbg.SetInputFileHandle(None, False)
sbf = self.dbg.GetInputFile()
- if sys.version_info.major >= 3:
- self.assertEqual(sbf.GetFile().fileno(), 0)
+ self.assertEqual(sbf.GetFile().fileno(), 0)
def test_sbstream(self):
Index: lldb/test/API/python_api/disassemble-raw-data/TestDisassemble_VST1_64.py
===================================================================
--- lldb/test/API/python_api/disassemble-raw-data/TestDisassemble_VST1_64.py
+++ lldb/test/API/python_api/disassemble-raw-data/TestDisassemble_VST1_64.py
@@ -49,19 +49,17 @@
for i in insts:
print("Disassembled %s" % str(i))
- if sys.version_info.major >= 3:
- sio = StringIO()
- insts.Print(sio)
- self.assertEqual(split(assembly), split(sio.getvalue()))
+ sio = StringIO()
+ insts.Print(sio)
+ self.assertEqual(split(assembly), split(sio.getvalue()))
self.assertEqual(insts.GetSize(), len(split(assembly)))
- if sys.version_info.major >= 3:
- for i,asm in enumerate(split(assembly)):
- inst = insts.GetInstructionAtIndex(i)
- sio = StringIO()
- inst.Print(sio)
- self.assertEqual(asm, sio.getvalue().strip())
+ for i,asm in enumerate(split(assembly)):
+ inst = insts.GetInstructionAtIndex(i)
+ sio = StringIO()
+ inst.Print(sio)
+ self.assertEqual(asm, sio.getvalue().strip())
raw_bytes = bytearray([0x04, 0xf9, 0xed, 0x82])
Index: lldb/test/API/macosx/nslog/TestDarwinNSLogOutput.py
===================================================================
--- lldb/test/API/macosx/nslog/TestDarwinNSLogOutput.py
+++ lldb/test/API/macosx/nslog/TestDarwinNSLogOutput.py
@@ -10,6 +10,7 @@
import lldb
import platform
import re
+import sys
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
@@ -57,13 +58,8 @@
# So that the child gets torn down after the test.
import pexpect
- import sys
- if sys.version_info.major == 3:
- self.child = pexpect.spawnu('%s %s %s' % (lldbtest_config.lldbExec,
- self.lldbOption, exe))
- else:
- self.child = pexpect.spawn('%s %s %s' % (lldbtest_config.lldbExec,
- self.lldbOption, exe))
+ self.child = pexpect.spawnu('%s %s %s' % (lldbtest_config.lldbExec,
+ self.lldbOption, exe))
child = self.child
# Turn on logging for what the child sends back.
Index: lldb/test/API/lldbtest.py
===================================================================
--- lldb/test/API/lldbtest.py
+++ lldb/test/API/lldbtest.py
@@ -74,16 +74,6 @@
timeoutInfo = 'Reached timeout of {} seconds'.format(
litConfig.maxIndividualTestTime)
- if sys.version_info.major == 2:
- # In Python 2, string objects can contain Unicode characters. Use
- # the non-strict 'replace' decoding mode. We cannot use the strict
- # mode right now because lldb's StringPrinter facility and the
- # Python utf8 decoder have different interpretations of which
- # characters are "printable". This leads to Python utf8 decoding
- # exceptions even though lldb is behaving as expected.
- out = out.decode('utf-8', 'replace')
- err = err.decode('utf-8', 'replace')
-
output = """Script:\n--\n%s\n--\nExit Code: %d\n""" % (
' '.join(cmd), exitCode)
if timeoutInfo is not None:
Index: lldb/test/API/functionalities/step_scripted/TestStepScripted.py
===================================================================
--- lldb/test/API/functionalities/step_scripted/TestStepScripted.py
+++ lldb/test/API/functionalities/step_scripted/TestStepScripted.py
@@ -19,13 +19,13 @@
self.runCmd("command script import Steps.py")
def test_standard_step_out(self):
- """Tests stepping with the scripted thread plan laying over a standard
+ """Tests stepping with the scripted thread plan laying over a standard
thread plan for stepping out."""
self.build()
self.step_out_with_scripted_plan("Steps.StepOut")
def test_scripted_step_out(self):
- """Tests stepping with the scripted thread plan laying over an another
+ """Tests stepping with the scripted thread plan laying over an another
scripted thread plan for stepping out."""
self.build()
self.step_out_with_scripted_plan("Steps.StepScripted")
@@ -54,23 +54,23 @@
stop_id = process.GetStopID()
# Pass a non-existent class for the plan class:
err = thread.StepUsingScriptedThreadPlan("NoSuchModule.NoSuchPlan")
-
+
# Make sure we got a good error:
self.assertTrue(err.Fail(), "We got a failure state")
msg = err.GetCString()
self.assertIn("NoSuchModule.NoSuchPlan", msg, "Mentioned missing class")
-
+
# Make sure we didn't let the process run:
self.assertEqual(stop_id, process.GetStopID(), "Process didn't run")
-
+
def test_checking_variable(self):
"""Test that we can call SBValue API's from a scripted thread plan - using SBAPI's to step"""
self.do_test_checking_variable(False)
-
+
def test_checking_variable_cli(self):
"""Test that we can call SBValue API's from a scripted thread plan - using cli to step"""
self.do_test_checking_variable(True)
-
+
def do_test_checking_variable(self, use_cli):
self.build()
(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self,
@@ -101,7 +101,7 @@
# We should not have exited:
self.assertEqual(process.GetState(), lldb.eStateStopped, "We are stopped")
-
+
# We should still be in foo:
self.assertEqual("foo", frame.GetFunctionName())
@@ -127,18 +127,14 @@
print(Steps.StepReportsStopOthers.stop_mode_dict)
value = Steps.StepReportsStopOthers.stop_mode_dict[token]
self.assertEqual(value, stop_others_value, "Stop others has the correct value.")
-
+
def do_test_stop_others(self):
self.build()
(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self,
"Set a breakpoint here",
self.main_source_file)
# First run with stop others false and see that we got that.
- thread_id = ""
- if sys.version_info.major == 2:
- thread_id = str(threading._get_ident())
- else:
- thread_id = str(threading.get_ident())
+ thread_id = str(threading.get_ident())
# all-threads should set stop others to False.
self.run_step(False, "all-threads", thread_id)
@@ -152,13 +148,8 @@
# The target.process.run-all-threads should override this:
interp = self.dbg.GetCommandInterpreter()
result = lldb.SBCommandReturnObject()
-
+
interp.HandleCommand("settings set target.process.run-all-threads true", result)
self.assertTrue(result.Succeeded, "setting run-all-threads works.")
self.run_step(False, None, thread_id)
-
-
-
-
-
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits