[lldb] Replace assertRegexpMatches with assertRegex (NFC) (#82074)
assertRegexpMatches is a deprecated alias for assertRegex and has been removed in Python 3.12. This wasn't an issue previously because we used a vendored version of the unittest module. Now that we use the built-in version this gets updated together with the Python version used to run the test suite.
This commit is contained in:
parent
0bf4f82f66
commit
737bc9f76a
@ -249,13 +249,13 @@ class DAPTestCaseBase(TestBase):
|
|||||||
def continue_to_exit(self, exitCode=0):
|
def continue_to_exit(self, exitCode=0):
|
||||||
self.dap_server.request_continue()
|
self.dap_server.request_continue()
|
||||||
stopped_events = self.dap_server.wait_for_stopped()
|
stopped_events = self.dap_server.wait_for_stopped()
|
||||||
self.assertEquals(
|
self.assertEqual(
|
||||||
len(stopped_events), 1, "stopped_events = {}".format(stopped_events)
|
len(stopped_events), 1, "stopped_events = {}".format(stopped_events)
|
||||||
)
|
)
|
||||||
self.assertEquals(
|
self.assertEqual(
|
||||||
stopped_events[0]["event"], "exited", "make sure program ran to completion"
|
stopped_events[0]["event"], "exited", "make sure program ran to completion"
|
||||||
)
|
)
|
||||||
self.assertEquals(
|
self.assertEqual(
|
||||||
stopped_events[0]["body"]["exitCode"],
|
stopped_events[0]["body"]["exitCode"],
|
||||||
exitCode,
|
exitCode,
|
||||||
"exitCode == %i" % (exitCode),
|
"exitCode == %i" % (exitCode),
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
Test the 'memory region' command.
|
Test the 'memory region' command.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
import lldb
|
import lldb
|
||||||
from lldbsuite.test.decorators import *
|
from lldbsuite.test.decorators import *
|
||||||
from lldbsuite.test.lldbtest import *
|
from lldbsuite.test.lldbtest import *
|
||||||
@ -62,7 +61,7 @@ class MemoryCommandRegion(TestBase):
|
|||||||
# We allow --all or an address argument, not both
|
# We allow --all or an address argument, not both
|
||||||
interp.HandleCommand("memory region --all 0", result)
|
interp.HandleCommand("memory region --all 0", result)
|
||||||
self.assertFalse(result.Succeeded())
|
self.assertFalse(result.Succeeded())
|
||||||
self.assertRegexpMatches(
|
self.assertRegex(
|
||||||
result.GetError(),
|
result.GetError(),
|
||||||
'The "--all" option cannot be used when an address argument is given',
|
'The "--all" option cannot be used when an address argument is given',
|
||||||
)
|
)
|
||||||
@ -81,7 +80,7 @@ class MemoryCommandRegion(TestBase):
|
|||||||
# Now let's print the memory region starting at 0 which should always work.
|
# Now let's print the memory region starting at 0 which should always work.
|
||||||
interp.HandleCommand("memory region 0x0", result)
|
interp.HandleCommand("memory region 0x0", result)
|
||||||
self.assertTrue(result.Succeeded())
|
self.assertTrue(result.Succeeded())
|
||||||
self.assertRegexpMatches(result.GetOutput(), "\\[0x0+-")
|
self.assertRegex(result.GetOutput(), "\\[0x0+-")
|
||||||
all_regions += result.GetOutput()
|
all_regions += result.GetOutput()
|
||||||
|
|
||||||
# Keep printing memory regions until we printed all of them.
|
# Keep printing memory regions until we printed all of them.
|
||||||
@ -94,7 +93,7 @@ class MemoryCommandRegion(TestBase):
|
|||||||
# Now that we reached the end, 'memory region' should again print the usage.
|
# Now that we reached the end, 'memory region' should again print the usage.
|
||||||
interp.HandleCommand("memory region", result)
|
interp.HandleCommand("memory region", result)
|
||||||
self.assertFalse(result.Succeeded())
|
self.assertFalse(result.Succeeded())
|
||||||
self.assertRegexpMatches(
|
self.assertRegex(
|
||||||
result.GetError(),
|
result.GetError(),
|
||||||
"Usage: memory region <address\-expression> \(or \-\-all\)",
|
"Usage: memory region <address\-expression> \(or \-\-all\)",
|
||||||
)
|
)
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
Test how lldb reacts to wrong commands
|
Test how lldb reacts to wrong commands
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
import lldb
|
import lldb
|
||||||
from lldbsuite.test.decorators import *
|
from lldbsuite.test.decorators import *
|
||||||
from lldbsuite.test.lldbtest import *
|
from lldbsuite.test.lldbtest import *
|
||||||
@ -18,11 +17,9 @@ class UnknownCommandTestCase(TestBase):
|
|||||||
|
|
||||||
command_interpreter.HandleCommand("g", result)
|
command_interpreter.HandleCommand("g", result)
|
||||||
self.assertFalse(result.Succeeded())
|
self.assertFalse(result.Succeeded())
|
||||||
self.assertRegexpMatches(
|
self.assertRegex(result.GetError(), "Ambiguous command 'g'. Possible matches:")
|
||||||
result.GetError(), "Ambiguous command 'g'. Possible matches:"
|
self.assertRegex(result.GetError(), "gui")
|
||||||
)
|
self.assertRegex(result.GetError(), "gdb-remote")
|
||||||
self.assertRegexpMatches(result.GetError(), "gui")
|
|
||||||
self.assertRegexpMatches(result.GetError(), "gdb-remote")
|
|
||||||
self.assertEqual(1, result.GetError().count("gdb-remote"))
|
self.assertEqual(1, result.GetError().count("gdb-remote"))
|
||||||
|
|
||||||
@no_debug_info_test
|
@no_debug_info_test
|
||||||
|
@ -6,7 +6,6 @@ These tests use the top byte ignore feature of AArch64. Which Linux
|
|||||||
always enables.
|
always enables.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
import lldb
|
import lldb
|
||||||
from lldbsuite.test.decorators import *
|
from lldbsuite.test.decorators import *
|
||||||
from lldbsuite.test.lldbtest import *
|
from lldbsuite.test.lldbtest import *
|
||||||
@ -83,7 +82,7 @@ class AArch64LinuxTaggedMemoryReadTestCase(TestBase):
|
|||||||
out = self.res.GetOutput()
|
out = self.res.GetOutput()
|
||||||
# memory find does not fail when it doesn't find the data.
|
# memory find does not fail when it doesn't find the data.
|
||||||
# First check we actually got something.
|
# First check we actually got something.
|
||||||
self.assertRegexpMatches(out, "data found at location: 0x[0-9A-Fa-f]+")
|
self.assertRegex(out, "data found at location: 0x[0-9A-Fa-f]+")
|
||||||
# Then that the location found does not display the tag bits.
|
# Then that the location found does not display the tag bits.
|
||||||
self.assertNotRegexpMatches(
|
self.assertNotRegexpMatches(
|
||||||
out, "data found at location: 0x(34|56)[0-9A-Fa-f]+"
|
out, "data found at location: 0x(34|56)[0-9A-Fa-f]+"
|
||||||
|
@ -3,7 +3,6 @@ Test that "memory region" lookup uses the ABI plugin to remove
|
|||||||
non address bits from addresses before lookup.
|
non address bits from addresses before lookup.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
import lldb
|
import lldb
|
||||||
from lldbsuite.test.decorators import *
|
from lldbsuite.test.decorators import *
|
||||||
from lldbsuite.test.lldbtest import *
|
from lldbsuite.test.lldbtest import *
|
||||||
@ -57,7 +56,7 @@ class AArch64LinuxTaggedMemoryRegionTestCase(TestBase):
|
|||||||
if result.Succeeded():
|
if result.Succeeded():
|
||||||
repeats += 1
|
repeats += 1
|
||||||
else:
|
else:
|
||||||
self.assertRegexpMatches(result.GetError(), "Usage: memory region")
|
self.assertRegex(result.GetError(), "Usage: memory region")
|
||||||
break
|
break
|
||||||
|
|
||||||
# This time repeat until we get the last region. At that
|
# This time repeat until we get the last region. At that
|
||||||
|
@ -13,7 +13,7 @@ from lldbsuite.test.lldbtest import *
|
|||||||
|
|
||||||
class TestDAP_evaluate(lldbdap_testcase.DAPTestCaseBase):
|
class TestDAP_evaluate(lldbdap_testcase.DAPTestCaseBase):
|
||||||
def assertEvaluate(self, expression, regex):
|
def assertEvaluate(self, expression, regex):
|
||||||
self.assertRegexpMatches(
|
self.assertRegex(
|
||||||
self.dap_server.request_evaluate(expression, context=self.context)["body"][
|
self.dap_server.request_evaluate(expression, context=self.context)["body"][
|
||||||
"result"
|
"result"
|
||||||
],
|
],
|
||||||
@ -78,9 +78,11 @@ class TestDAP_evaluate(lldbdap_testcase.DAPTestCaseBase):
|
|||||||
else:
|
else:
|
||||||
self.assertEvaluate(
|
self.assertEvaluate(
|
||||||
"struct1",
|
"struct1",
|
||||||
re.escape("{foo:15}")
|
(
|
||||||
if enableAutoVariableSummaries
|
re.escape("{foo:15}")
|
||||||
else "my_struct @ 0x",
|
if enableAutoVariableSummaries
|
||||||
|
else "my_struct @ 0x"
|
||||||
|
),
|
||||||
)
|
)
|
||||||
self.assertEvaluate(
|
self.assertEvaluate(
|
||||||
"struct2", "0x.* {foo:16}" if enableAutoVariableSummaries else "0x.*"
|
"struct2", "0x.* {foo:16}" if enableAutoVariableSummaries else "0x.*"
|
||||||
@ -127,9 +129,11 @@ class TestDAP_evaluate(lldbdap_testcase.DAPTestCaseBase):
|
|||||||
else:
|
else:
|
||||||
self.assertEvaluate(
|
self.assertEvaluate(
|
||||||
"struct1",
|
"struct1",
|
||||||
re.escape("{foo:15}")
|
(
|
||||||
if enableAutoVariableSummaries
|
re.escape("{foo:15}")
|
||||||
else "my_struct @ 0x",
|
if enableAutoVariableSummaries
|
||||||
|
else "my_struct @ 0x"
|
||||||
|
),
|
||||||
)
|
)
|
||||||
self.assertEvaluate("struct1.foo", "15")
|
self.assertEvaluate("struct1.foo", "15")
|
||||||
self.assertEvaluate("struct2->foo", "16")
|
self.assertEvaluate("struct2->foo", "16")
|
||||||
|
@ -101,7 +101,7 @@ class GdbRemoteLaunchTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
|
|||||||
)
|
)
|
||||||
with open(exe_path, "ab") as exe_for_writing:
|
with open(exe_path, "ab") as exe_for_writing:
|
||||||
context = self.expect_gdbremote_sequence()
|
context = self.expect_gdbremote_sequence()
|
||||||
self.assertRegexpMatches(
|
self.assertRegex(
|
||||||
seven.unhexlify(context.get("msg")),
|
seven.unhexlify(context.get("msg")),
|
||||||
r"(execve failed: Text file busy|The process cannot access the file because it is being used by another process.)",
|
r"(execve failed: Text file busy|The process cannot access the file because it is being used by another process.)",
|
||||||
)
|
)
|
||||||
|
@ -41,8 +41,8 @@ class TestGdbRemoteModuleInfo(gdbremote_testcase.GdbRemoteTestCaseBase):
|
|||||||
|
|
||||||
context = self.expect_gdbremote_sequence()
|
context = self.expect_gdbremote_sequence()
|
||||||
spec = context.get("spec")
|
spec = context.get("spec")
|
||||||
self.assertRegexpMatches(spec, '"file_path":".*"')
|
self.assertRegex(spec, '"file_path":".*"')
|
||||||
self.assertRegexpMatches(spec, '"file_offset":\d+')
|
self.assertRegex(spec, '"file_offset":\d+')
|
||||||
self.assertRegexpMatches(spec, '"file_size":\d+')
|
self.assertRegex(spec, '"file_size":\d+')
|
||||||
self.assertRegexpMatches(spec, '"triple":"\w*-\w*-.*"')
|
self.assertRegex(spec, '"triple":"\w*-\w*-.*"')
|
||||||
self.assertRegexpMatches(spec, '"uuid":"[A-Fa-f0-9]+"')
|
self.assertRegex(spec, '"uuid":"[A-Fa-f0-9]+"')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user