Skip to content

Commit

Permalink
[lldb][Tests] Reformat API tests with black
Browse files Browse the repository at this point in the history
These are all recent additions I think, including a few of mine
for AArch64.

Going forward the CI checks should help us fix these earlier.
  • Loading branch information
DavidSpickett committed Sep 11, 2023
1 parent 62bec3d commit 6bf923d
Show file tree
Hide file tree
Showing 11 changed files with 215 additions and 114 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import sys


class TestGuiSpawnThreadsTest(PExpectTest):
# PExpect uses many timeouts internally and doesn't play well
# under ASAN on a loaded machine..
Expand All @@ -18,12 +19,14 @@ class TestGuiSpawnThreadsTest(PExpectTest):
def test_gui(self):
self.build()

self.launch(executable=self.getBuildArtifact('a.out'), dimensions=(100, 500))
self.launch(executable=self.getBuildArtifact("a.out"), dimensions=(100, 500))
self.expect(
'breakpoint set -f main.cpp -p "break here"', substrs=['Breakpoint 1', 'address =']
'breakpoint set -f main.cpp -p "break here"',
substrs=["Breakpoint 1", "address ="],
)
self.expect(
'breakpoint set -f main.cpp -p "before join"', substrs=['Breakpoint 2', 'address =']
'breakpoint set -f main.cpp -p "before join"',
substrs=["Breakpoint 2", "address ="],
)
self.expect("run", substrs=["stop reason ="])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ def test_mte_ctrl_register(self):
# This would return to synchronous faults if we did not restore the
# previous value.
self.expect("expression setup_mte()", substrs=["= 0"])
self.expect("register read mte_ctrl", substrs=["0x0000000000000005"])
self.expect("register read mte_ctrl", substrs=["0x0000000000000005"])
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ def check_simd_values(self, value_offset):
# These are 128 bit registers, so getting them from the API as unsigned
# values doesn't work. Check the command output instead.
for i in range(32):
self.expect("register read v{}".format(i),
substrs=[self.make_simd_value(i+value_offset)])
self.expect(
"register read v{}".format(i),
substrs=[self.make_simd_value(i + value_offset)],
)

def sve_simd_registers_impl(self, mode):
self.skip_if_needed(mode)
Expand Down
2 changes: 0 additions & 2 deletions lldb/test/API/functionalities/archives/TestBSDArchives.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ def test(self):
)
self.expect_var_path("__b_global", type="int", value="2")


def check_frame_variable_errors(self, thread, error_strings):
command_result = lldb.SBCommandReturnObject()
interp = self.dbg.GetCommandInterpreter()
Expand Down Expand Up @@ -173,7 +172,6 @@ def test_archive_specifications(self):
self.assertEqual(spec.GetObjectName(), "b.o")
self.assertEqual(spec.GetObjectSize(), size_b, libfoothin_path)


@skipIfRemote
@skipUnlessDarwin
def test_frame_var_errors_when_thin_archive_malformed(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@ def test(self):
# in the main executable. Setting breakpoints by file and line ensures
# that the main executable was loaded correctly by the dynamic loader
(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
self, "// Break here", lldb.SBFileSpec("main.cpp"),
extra_images=["testlib"]
self, "// Break here", lldb.SBFileSpec("main.cpp"), extra_images=["testlib"]
)
# Set breakpoints both on shared library function to ensure that
# we hit a source breakpoint in the shared library which only will
# happen if we load the shared library correctly in the dynamic
# loader.
lldbutil.continue_to_source_breakpoint(
self, process, "// Library break here",
lldb.SBFileSpec("library_file.cpp", False)
self,
process,
"// Library break here",
lldb.SBFileSpec("library_file.cpp", False),
)
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def setUp(self):
# These tests are flakey and sometimes timeout. They work most of the time
# so the basic event flow is right, but somehow the handling is off.
@skipUnlessDarwin
@skipIfDarwin
@skipIfDarwin
def test_passthrough_launch(self):
"""Test a simple pass-through process launch"""
self.passthrough_launch()
Expand Down
14 changes: 10 additions & 4 deletions lldb/test/API/lang/rust/enum-structs/RustEnumValue.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
DISCRIMINANT_MEMBER_NAME = "$discr$"
VALUE_MEMBER_NAME = "value"

class RustEnumValue:

class RustEnumValue:
def __init__(self, value: lldb.SBValue):
self.value = value

Expand All @@ -19,7 +19,11 @@ def _inner(self) -> lldb.SBValue:
return self.value.GetChildAtIndex(0)

def getVariantByIndex(self, index):
return self._inner().GetChildAtIndex(index).GetChildMemberWithName(VALUE_MEMBER_NAME)
return (
self._inner()
.GetChildAtIndex(index)
.GetChildMemberWithName(VALUE_MEMBER_NAME)
)

@staticmethod
def _getDiscriminantValueAsUnsigned(discr_sbvalue: lldb.SBValue):
Expand All @@ -42,10 +46,12 @@ def _getDiscriminantValueAsUnsigned(discr_sbvalue: lldb.SBValue):
def getCurrentVariantIndex(self):
default_index = 0
for i in range(self._inner().GetNumChildren()):
variant: lldb.SBValue = self._inner().GetChildAtIndex(i);
variant: lldb.SBValue = self._inner().GetChildAtIndex(i)
discr = variant.GetChildMemberWithName(DISCRIMINANT_MEMBER_NAME)
if discr.IsValid():
discr_unsigned_value = RustEnumValue._getDiscriminantValueAsUnsigned(discr)
discr_unsigned_value = RustEnumValue._getDiscriminantValueAsUnsigned(
discr
)
if variant.GetName() == f"$variant${discr_unsigned_value}":
return discr_unsigned_value
else:
Expand Down
Loading

0 comments on commit 6bf923d

Please sign in to comment.