Skip to content

Commit ecbe78c

Browse files
committed
[lldb] Fix Python test formatting (NFC)
All Python files in the LLVM repository were reformatted with Black [1]. Files inside the LLDB subproject were reformatted in 2238dcc. This patch updates a handful of tests that were added or modified since then and weren't formatted with Black. [1] https://discourse.llvm.org/t/rfc-document-and-standardize-python-code-style/68257
1 parent e0053bc commit ecbe78c

File tree

18 files changed

+123
-79
lines changed

18 files changed

+123
-79
lines changed

Diff for: lldb/test/API/commands/platform/process/launch/TestPlatformProcessLaunch.py

+27-6
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,17 @@ def test_process_launch_no_args(self):
2222
self.runCmd("continue")
2323

2424
with open(outfile) as f:
25-
self.assertEqual(dedent("""\
25+
self.assertEqual(
26+
dedent(
27+
"""\
2628
Got 1 argument(s).
2729
[0]: {}
28-
""".format(exe)), f.read())
30+
""".format(
31+
exe
32+
)
33+
),
34+
f.read(),
35+
)
2936

3037
def test_process_launch_command_args(self):
3138
exe, outfile = self.setup()
@@ -35,13 +42,20 @@ def test_process_launch_command_args(self):
3542
self.runCmd("continue")
3643

3744
with open(outfile) as f:
38-
self.assertEqual(dedent("""\
45+
self.assertEqual(
46+
dedent(
47+
"""\
3948
Got 4 argument(s).
4049
[0]: {}
4150
[1]: A
4251
[2]: B
4352
[3]: C
44-
""".format(exe)), f.read())
53+
""".format(
54+
exe
55+
)
56+
),
57+
f.read(),
58+
)
4559

4660
def test_process_launch_target_args(self):
4761
exe, outfile = self.setup()
@@ -51,9 +65,16 @@ def test_process_launch_target_args(self):
5165
self.runCmd("continue")
5266

5367
with open(outfile) as f:
54-
self.assertEqual(dedent("""\
68+
self.assertEqual(
69+
dedent(
70+
"""\
5571
Got 3 argument(s).
5672
[0]: {}
5773
[1]: D
5874
[2]: E
59-
""".format(exe)), f.read())
75+
""".format(
76+
exe
77+
)
78+
),
79+
f.read(),
80+
)

Diff for: lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_dynamic_resize/TestSVEThreadedDynamic.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@
1414
from lldbsuite.test.lldbtest import *
1515
from lldbsuite.test import lldbutil
1616

17+
1718
class Mode(Enum):
1819
SVE = 0
1920
SSVE = 1
2021

22+
2123
class RegisterCommandsTestCase(TestBase):
2224
def get_supported_vg(self):
2325
# Changing VL trashes the register state, so we need to run the program
@@ -147,7 +149,7 @@ def run_sve_test(self, mode):
147149
self.runCmd("process continue", RUN_SUCCEEDED)
148150

149151
# If we start the checks too quickly, thread 3 may not have started.
150-
while (process.GetNumThreads() < 3):
152+
while process.GetNumThreads() < 3:
151153
pass
152154

153155
for idx in range(1, process.GetNumThreads()):

Diff for: lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_static_config/TestSVERegisters.py

+16-6
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@
88
from lldbsuite.test.lldbtest import *
99
from lldbsuite.test import lldbutil
1010

11+
1112
class Mode(Enum):
1213
SVE = 0
1314
SSVE = 1
1415

16+
1517
class RegisterCommandsTestCase(TestBase):
1618
def check_sve_register_size(self, set, name, expected):
1719
reg_value = set.GetChildMemberWithName(name)
@@ -104,7 +106,9 @@ def sve_registers_configuration_impl(self, mode):
104106
currentFrame = thread.GetFrameAtIndex(0)
105107

106108
registerSets = process.GetThreadAtIndex(0).GetFrameAtIndex(0).GetRegisters()
107-
sve_registers = registerSets.GetFirstValueByName("Scalable Vector Extension Registers")
109+
sve_registers = registerSets.GetFirstValueByName(
110+
"Scalable Vector Extension Registers"
111+
)
108112
self.assertTrue(sve_registers)
109113

110114
vg_reg_value = sve_registers.GetChildMemberWithName("vg").GetValueAsUnsigned()
@@ -157,7 +161,9 @@ def sve_registers_read_write_impl(self, start_mode, eval_mode):
157161
process = target.GetProcess()
158162

159163
registerSets = process.GetThreadAtIndex(0).GetFrameAtIndex(0).GetRegisters()
160-
sve_registers = registerSets.GetFirstValueByName("Scalable Vector Extension Registers")
164+
sve_registers = registerSets.GetFirstValueByName(
165+
"Scalable Vector Extension Registers"
166+
)
161167
self.assertTrue(sve_registers)
162168

163169
vg_reg_value = sve_registers.GetChildMemberWithName("vg").GetValueAsUnsigned()
@@ -168,9 +174,13 @@ def sve_registers_read_write_impl(self, start_mode, eval_mode):
168174
self.expect("expression expr_eval_func", substrs=["= 0x"])
169175

170176
# Evaluate expression call function expr_eval_func.
171-
self.expect_expr("expr_eval_func({})".format(
172-
"true" if (eval_mode == Mode.SSVE) else "false"), result_type="int",
173-
result_value="1")
177+
self.expect_expr(
178+
"expr_eval_func({})".format(
179+
"true" if (eval_mode == Mode.SSVE) else "false"
180+
),
181+
result_type="int",
182+
result_value="1",
183+
)
174184

175185
# We called a jitted function above which must not have changed SVE
176186
# vector length or register values.
@@ -206,4 +216,4 @@ def test_registers_expr_read_write_sve_ssve(self):
206216
@skipIf(archs=no_match(["aarch64"]))
207217
@skipIf(oslist=no_match(["linux"]))
208218
def test_registers_expr_read_write_ssve_sve(self):
209-
self.sve_registers_read_write_impl(Mode.SSVE, Mode.SVE)
219+
self.sve_registers_read_write_impl(Mode.SSVE, Mode.SVE)

Diff for: lldb/test/API/commands/register/register/aarch64_sve_simd_registers/TestSVESIMDRegisters.py

+11-6
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@
1919
from lldbsuite.test.lldbtest import *
2020
from lldbsuite.test import lldbutil
2121

22+
2223
class Mode(Enum):
2324
SIMD = 0
2425
SVE = 1
2526
SSVE = 2
2627

28+
2729
class SVESIMDRegistersTestCase(TestBase):
2830
def get_build_flags(self, mode):
2931
cflags = "-march=armv8-a+sve"
@@ -69,19 +71,22 @@ def sve_simd_registers_impl(self, mode):
6971
# These are 128 bit registers, so getting them from the API as unsigned
7072
# values doesn't work. Check the command output instead.
7173
for i in range(32):
72-
self.expect("register read v{}".format(i),
73-
substrs=[self.make_simd_value(i)])
74+
self.expect(
75+
"register read v{}".format(i), substrs=[self.make_simd_value(i)]
76+
)
7477

7578
# Write a new set of values. The kernel will move the program back to
7679
# non-streaming mode here.
7780
for i in range(32):
78-
self.runCmd("register write v{} \"{}\"".format(
79-
i, self.make_simd_value(i+1)))
81+
self.runCmd(
82+
'register write v{} "{}"'.format(i, self.make_simd_value(i + 1))
83+
)
8084

8185
# Should be visible within lldb.
8286
for i in range(32):
83-
self.expect("register read v{}".format(i),
84-
substrs=[self.make_simd_value(i+1)])
87+
self.expect(
88+
"register read v{}".format(i), substrs=[self.make_simd_value(i + 1)]
89+
)
8590

8691
# The program should agree with lldb.
8792
self.expect("continue", substrs=["exited with status = 0"])

Diff for: lldb/test/API/commands/register/register/register_command/TestRegisters.py

+22-13
Original file line numberDiff line numberDiff line change
@@ -572,16 +572,22 @@ def test_info_unknown_register(self):
572572
self.build()
573573
self.common_setup()
574574

575-
self.expect("register info blub", error=True,
576-
substrs=["error: No register found with name 'blub'."])
575+
self.expect(
576+
"register info blub",
577+
error=True,
578+
substrs=["error: No register found with name 'blub'."],
579+
)
577580

578581
def test_info_many_registers(self):
579582
self.build()
580583
self.common_setup()
581584

582585
# Only 1 register allowed at this time.
583-
self.expect("register info abc def", error=True,
584-
substrs=["error: register info takes exactly 1 argument"])
586+
self.expect(
587+
"register info abc def",
588+
error=True,
589+
substrs=["error: register info takes exactly 1 argument"],
590+
)
585591

586592
@skipIf(archs=no_match(["aarch64"]))
587593
def test_info_register(self):
@@ -593,12 +599,17 @@ def test_info_register(self):
593599
self.common_setup()
594600

595601
# Standard register. Doesn't invalidate anything, doesn't have an alias.
596-
self.expect("register info x1", substrs=[
597-
"Name: x1",
598-
"Size: 8 bytes (64 bits)",
599-
"In sets: General Purpose Registers"])
600-
self.expect("register info x1", substrs=["Invalidates:", "Name: x1 ("],
601-
matching=False)
602+
self.expect(
603+
"register info x1",
604+
substrs=[
605+
"Name: x1",
606+
"Size: 8 bytes (64 bits)",
607+
"In sets: General Purpose Registers",
608+
],
609+
)
610+
self.expect(
611+
"register info x1", substrs=["Invalidates:", "Name: x1 ("], matching=False
612+
)
602613

603614
# These registers invalidate others as they are subsets of those registers.
604615
self.expect("register info w1", substrs=["Invalidates: x1"])
@@ -631,9 +642,7 @@ def test_fs_gs_base(self):
631642
self.assertTrue(reg_fs_base.IsValid(), "fs_base is not available")
632643
reg_gs_base = current_frame.FindRegister("gs_base")
633644
self.assertTrue(reg_gs_base.IsValid(), "gs_base is not available")
634-
self.assertEqual(
635-
reg_gs_base.GetValueAsSigned(-1), 0, f"gs_base should be zero"
636-
)
645+
self.assertEqual(reg_gs_base.GetValueAsSigned(-1), 0, f"gs_base should be zero")
637646

638647
# Evaluate pthread_self() and compare against fs_base register read.
639648
pthread_self_code = "(uint64_t)pthread_self()"

Diff for: lldb/test/API/commands/settings/TestSettings.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -971,11 +971,9 @@ def test_settings_api(self):
971971

972972
# Test OptionValueLanguage
973973
self.verify_setting_value_json("repl-lang", "c++")
974-
974+
975975
def test_global_option(self):
976976
# This command used to crash the settings because -g was signaled by a
977977
# NULL execution context (not one with an empty Target...) and in the
978978
# special handling for load-script-from-symbol-file this wasn't checked.
979979
self.runCmd("settings set -g target.load-script-from-symbol-file true")
980-
981-

Diff for: lldb/test/API/functionalities/archives/TestBSDArchives.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ def test_frame_var_errors_when_thin_archive_malformed(self):
167167
") of the .o file doesn't match",
168168
]
169169
self.check_frame_variable_errors(thread, error_strings)
170-
170+
171171
# Break at b() should succeed
172172
(target, process, thread, bkpt) = lldbutil.run_to_name_breakpoint(
173173
self, "b", bkpt_module=exe
@@ -181,7 +181,6 @@ def test_frame_var_errors_when_thin_archive_malformed(self):
181181
"frame variable", VARIABLES_DISPLAYED_CORRECTLY, substrs=["(int) arg = 2"]
182182
)
183183

184-
185184
@skipIfRemote
186185
@skipUnlessDarwin
187186
def test_frame_var_errors_when_mtime_mistmatch_for_object_in_archive(self):

Diff for: lldb/test/API/functionalities/completion/TestCompletion.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -883,7 +883,7 @@ def test_complete_breakpoint_with_names(self):
883883

884884
def test_ambiguous_command(self):
885885
"""Test completing an ambiguous commands"""
886-
self.complete_from_to("settings s", ['set', 'show'])
886+
self.complete_from_to("settings s", ["set", "show"])
887887

888888
def test_ambiguous_subcommand(self):
889889
"""Test completing a subcommand of an ambiguous command"""

Diff for: lldb/test/API/functionalities/gdb_remote_client/TestXMLRegisterFlags.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,8 @@ def test_flags_in_register_info(self):
620620
# The table should split according to terminal width.
621621
self.runCmd("settings set term-width 17")
622622

623-
self.expect("register info cpsr",
623+
self.expect(
624+
"register info cpsr",
624625
substrs=[
625626
" Name: cpsr\n"
626627
" Size: 4 bytes (32 bits)\n"
@@ -632,4 +633,6 @@ def test_flags_in_register_info(self):
632633
"\n"
633634
"| 15-8 | 7-0 |\n"
634635
"|------|-----|\n"
635-
"| C | D |"])
636+
"| C | D |"
637+
],
638+
)

Diff for: lldb/test/API/functionalities/postmortem/elf-core/thread_crash/TestLinuxCoreThreads.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def test_fs_gs_base(self):
4141

4242
# The fs_base/gs_base registers in linux-x86_64.core are parsed by
4343
# using "eu-readelf -n linux-x86_64.core" to verify.
44-
fs_base_values = [0x00007fc295017700, 0x00007fc294fff740, 0x00007fc29501f700]
44+
fs_base_values = [0x00007FC295017700, 0x00007FC294FFF740, 0x00007FC29501F700]
4545
gs_base_values = [0, 0, 0]
4646

4747
for i in range(process.GetNumThreads()):
@@ -57,15 +57,18 @@ def test_fs_gs_base(self):
5757
self.assertTrue(reg_gs_base.IsValid(), "gs_base is not available")
5858

5959
self.assertEqual(
60-
reg_fs_base.GetValueAsSigned(-1), fs_base_values[i], f"fs_base read is different from expected"
60+
reg_fs_base.GetValueAsSigned(-1),
61+
fs_base_values[i],
62+
f"fs_base read is different from expected",
6163
)
6264

6365
self.assertEqual(
64-
reg_gs_base.GetValueAsSigned(-1), gs_base_values[i], f"gs_base read is different from expected"
66+
reg_gs_base.GetValueAsSigned(-1),
67+
gs_base_values[i],
68+
f"gs_base read is different from expected",
6569
)
6670
self.dbg.DeleteTarget(target)
6771

68-
6972
def do_test(self, filename, pid, tid):
7073
target = self.dbg.CreateTarget("")
7174
process = target.LoadCore(filename + ".core")

Diff for: lldb/test/API/functionalities/unwind/aarch64_unwind_pac/TestAArch64UnwindPAC.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def test(self):
5252
self.assertTrue(thread.GetNumFrames() >= (len(backtrace) + len(libc_backtrace)))
5353

5454
# Strictly check frames that are in the test program's source.
55-
for frame_idx, frame in enumerate(thread.frames[:len(backtrace)]):
55+
for frame_idx, frame in enumerate(thread.frames[: len(backtrace)]):
5656
self.assertTrue(frame)
5757
self.assertEqual(frame.GetFunctionName(), backtrace[frame_idx])
5858
self.assertEqual(

Diff for: lldb/test/API/lang/cpp/namespace/TestNamespaceLookup.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,7 @@ def test_scope_lookup_with_run_command(self):
166166
self.runToBkpt("continue")
167167
# FIXME: In DWARF 5 with dsyms, the ordering of functions is slightly
168168
# different, which also hits the same issues mentioned previously.
169-
if (configuration.dwarf_version <= 4 or
170-
self.getDebugInfo() == 'dwarf'):
169+
if configuration.dwarf_version <= 4 or self.getDebugInfo() == "dwarf":
171170
self.expect_expr("func()", result_type="int", result_value="2")
172171

173172
# Continue to BP_ns_scope at ns scope

Diff for: lldb/test/API/lang/objc/objc-po-hint/TestObjcPoHint.py

+2-6
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ def test_show_po_hint(self):
2626
# Make sure it's not printed again.
2727
self.expect(
2828
"dwim-print -O -- foo",
29-
substrs=[
30-
"note: object description"
31-
],
29+
substrs=["note: object description"],
3230
matching=False,
3331
)
3432

@@ -42,8 +40,6 @@ def test_show_po_hint_disabled(self):
4240
# Make sure the hint is printed the first time
4341
self.expect(
4442
"dwim-print -O -- foo",
45-
substrs=[
46-
"note: object description"
47-
],
43+
substrs=["note: object description"],
4844
matching=False,
4945
)

0 commit comments

Comments
 (0)