Skip to content

Commit 619e2e0

Browse files
committed
[lldb] Convert assertTrue(a == b) to assertEqual(a, b)
Convert `assertTrue(a == b)` to `assertEqual(a, b)` to produce better failure messages. These were mostly done via regex search & replace, with some manual fixes. Differential Revision: https://reviews.llvm.org/D95813
1 parent ff1147c commit 619e2e0

File tree

55 files changed

+206
-205
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+206
-205
lines changed

lldb/test/API/commands/register/register/register_command/TestRegisters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ def fp_special_purpose_register_read(self):
222222
self.assertTrue(matched, STOPPED_DUE_TO_SIGNAL)
223223

224224
process = target.GetProcess()
225-
self.assertTrue(process.GetState() == lldb.eStateStopped,
225+
self.assertEqual(process.GetState(), lldb.eStateStopped,
226226
PROCESS_STOPPED)
227227

228228
thread = process.GetThreadAtIndex(0)

lldb/test/API/commands/watchpoints/watchpoint_events/TestWatchpointEvents.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def test_with_python_api(self):
8484
local_watch.SetCondition(condition)
8585
self.GetWatchpointEvent(lldb.eWatchpointEventTypeConditionChanged)
8686

87-
self.assertTrue(local_watch.GetCondition() == condition,
87+
self.assertEqual(local_watch.GetCondition(), condition,
8888
'make sure watchpoint condition is "' + condition + '"')
8989

9090
def GetWatchpointEvent(self, event_type):

lldb/test/API/functionalities/breakpoint/breakpoint_conditions/TestBreakpointConditions.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def breakpoint_conditions_python(self):
133133

134134
# We didn't associate a thread index with the breakpoint, so it should
135135
# be invalid.
136-
self.assertTrue(breakpoint.GetThreadIndex() == lldb.UINT32_MAX,
136+
self.assertEqual(breakpoint.GetThreadIndex(), lldb.UINT32_MAX,
137137
"The thread index should be invalid")
138138
# The thread name should be invalid, too.
139139
self.assertTrue(breakpoint.GetThreadName() is None,
@@ -143,7 +143,7 @@ def breakpoint_conditions_python(self):
143143
# indeed, being set correctly.
144144
# There's only one thread for the process.
145145
breakpoint.SetThreadIndex(1)
146-
self.assertTrue(breakpoint.GetThreadIndex() == 1,
146+
self.assertEqual(breakpoint.GetThreadIndex(), 1,
147147
"The thread index has been set correctly")
148148

149149
# Get the breakpoint location from breakpoint after we verified that,
@@ -175,7 +175,7 @@ def breakpoint_conditions_python(self):
175175
var.GetValue() == '3')
176176

177177
# The hit count for the breakpoint should be 1.
178-
self.assertTrue(breakpoint.GetHitCount() == 1)
178+
self.assertEqual(breakpoint.GetHitCount(), 1)
179179

180180
# Test that the condition expression didn't create a result variable:
181181
options = lldb.SBExpressionOptions()
@@ -217,7 +217,7 @@ def breakpoint_invalid_conditions_python(self):
217217
"There should be a thread stopped due to breakpoint condition")
218218
frame0 = thread.GetFrameAtIndex(0)
219219
var = frame0.FindValue('val', lldb.eValueTypeVariableArgument)
220-
self.assertTrue(frame0.GetLineEntry().GetLine() == self.line1)
220+
self.assertEqual(frame0.GetLineEntry().GetLine(), self.line1)
221221

222222
# The hit count for the breakpoint should be 1.
223-
self.assertTrue(breakpoint.GetHitCount() == 1)
223+
self.assertEqual(breakpoint.GetHitCount(), 1)

lldb/test/API/functionalities/breakpoint/breakpoint_ignore_count/TestBreakpointIgnoreCount.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def breakpoint_ignore_count_python(self):
120120

121121
# Set the ignore count on the breakpoint location.
122122
location.SetIgnoreCount(2)
123-
self.assertTrue(location.GetIgnoreCount() == 2,
123+
self.assertEqual(location.GetIgnoreCount(), 2,
124124
"SetIgnoreCount() works correctly")
125125

126126
# Now launch the process, and do not stop at entry point.
@@ -145,6 +145,6 @@ def breakpoint_ignore_count_python(self):
145145
STOPPED_DUE_TO_BREAKPOINT_IGNORE_COUNT)
146146

147147
# The hit count for the breakpoint should be 3.
148-
self.assertTrue(breakpoint.GetHitCount() == 3)
148+
self.assertEqual(breakpoint.GetHitCount(), 3)
149149

150150
process.Continue()

lldb/test/API/functionalities/breakpoint/breakpoint_in_delayslot/TestAvoidBreakpointInDelaySlot.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ def test(self):
3838
self.assertTrue(process, PROCESS_IS_VALID)
3939

4040
list = target.FindFunctions('foo', lldb.eFunctionNameTypeAuto)
41-
self.assertTrue(list.GetSize() == 1)
41+
self.assertEqual(list.GetSize(), 1)
4242
sc = list.GetContextAtIndex(0)
43-
self.assertTrue(sc.GetSymbol().GetName() == "foo")
43+
self.assertEqual(sc.GetSymbol().GetName(), "foo")
4444
function = sc.GetFunction()
4545
self.assertTrue(function)
4646
self.function(function, target)
@@ -75,7 +75,7 @@ def function(self, function, target):
7575

7676
# Breakpoint address should be adjusted to the address of
7777
# branch instruction.
78-
self.assertTrue(branchinstaddress == bpaddr)
78+
self.assertEqual(branchinstaddress, bpaddr)
7979
i += 1
8080
else:
8181
i += 1

lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def check_equivalence(self, source_bps, do_write = True):
133133

134134
num_source_bps = source_bps.GetSize()
135135
num_copy_bps = copy_bps.GetSize()
136-
self.assertTrue(num_source_bps == num_copy_bps, "Didn't get same number of input and output breakpoints - orig: %d copy: %d"%(num_source_bps, num_copy_bps))
136+
self.assertEqual(num_source_bps, num_copy_bps, "Didn't get same number of input and output breakpoints - orig: %d copy: %d"%(num_source_bps, num_copy_bps))
137137

138138
for i in range(0, num_source_bps):
139139
source_bp = source_bps.GetBreakpointAtIndex(i)
@@ -327,12 +327,12 @@ def do_check_names(self):
327327

328328
error = self.copy_target.BreakpointsCreateFromFile(self.bkpts_file_spec, names_list, copy_bps)
329329
self.assertTrue(error.Success(), "Failed reading breakpoints from file: %s"%(error.GetCString()))
330-
self.assertTrue(copy_bps.GetSize() == 0, "Found breakpoints with a nonexistent name.")
330+
self.assertEqual(copy_bps.GetSize(), 0, "Found breakpoints with a nonexistent name.")
331331

332332
names_list.AppendString(good_bkpt_name)
333333
error = self.copy_target.BreakpointsCreateFromFile(self.bkpts_file_spec, names_list, copy_bps)
334334
self.assertTrue(error.Success(), "Failed reading breakpoints from file: %s"%(error.GetCString()))
335-
self.assertTrue(copy_bps.GetSize() == 1, "Found the matching breakpoint.")
335+
self.assertEqual(copy_bps.GetSize(), 1, "Found the matching breakpoint.")
336336

337337
def do_check_extra_args(self):
338338

lldb/test/API/functionalities/conditional_break/TestConditionalBreak.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def do_conditional_break(self):
4949
self.assertTrue(process, PROCESS_IS_VALID)
5050

5151
# The stop reason of the thread should be breakpoint.
52-
self.assertTrue(process.GetState() == lldb.eStateStopped,
52+
self.assertEqual(process.GetState(), lldb.eStateStopped,
5353
STOPPED_DUE_TO_BREAKPOINT)
5454

5555
# Find the line number where a's parent frame function is c.
@@ -77,12 +77,12 @@ def do_conditional_break(self):
7777
frame1 = thread.GetFrameAtIndex(1)
7878
name1 = frame1.GetFunction().GetName()
7979
# lldbutil.print_stacktrace(thread)
80-
self.assertTrue(name0 == "c", "Break on function c()")
80+
self.assertEqual(name0, "c", "Break on function c()")
8181
if (name1 == "a"):
8282
# By design, we know that a() calls c() only from main.c:27.
8383
# In reality, similar logic can be used to find out the call
8484
# site.
85-
self.assertTrue(frame1.GetLineEntry().GetLine() == line,
85+
self.assertEqual(frame1.GetLineEntry().GetLine(), line,
8686
"Immediate caller a() at main.c:%d" % line)
8787

8888
# And the local variable 'val' should have a value of (int)

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/TestLibCxxAtomic.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ def test(self):
5656
self.assertEqual(i_atomic.GetNumChildren(), 1)
5757
i = i_atomic.GetChildAtIndex(0)
5858

59-
self.assertTrue(i.GetValueAsUnsigned(0) == 5, "i == 5")
60-
self.assertTrue(s.GetNumChildren() == 2, "s has two children")
59+
self.assertEqual(i.GetValueAsUnsigned(0), 5, "i == 5")
60+
self.assertEqual(s.GetNumChildren(), 2, "s has two children")
6161
self.assertTrue(
6262
s.GetChildAtIndex(0).GetValueAsUnsigned(0) == 1,
6363
"s.x == 1")

lldb/test/API/functionalities/data-formatter/data-formatter-synthval/TestDataFormatterSynthVal.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ def cleanup():
6666
"x_val = %s; y_val = %s; z_val = %s; q_val = %s" %
6767
(x_val(), y_val(), z_val(), q_val()))
6868

69-
self.assertFalse(x_val() == 3, "x == 3 before synthetics")
70-
self.assertFalse(y_val() == 4, "y == 4 before synthetics")
71-
self.assertFalse(z_val() == 7, "z == 7 before synthetics")
72-
self.assertFalse(q_val() == 8, "q == 8 before synthetics")
69+
self.assertNotEqual(x_val(), 3, "x == 3 before synthetics")
70+
self.assertNotEqual(y_val(), 4, "y == 4 before synthetics")
71+
self.assertNotEqual(z_val(), 7, "z == 7 before synthetics")
72+
self.assertNotEqual(q_val(), 8, "q == 8 before synthetics")
7373

7474
# now set up the synth
7575
self.runCmd("script from myIntSynthProvider import *")
@@ -82,10 +82,10 @@ def cleanup():
8282
"x_val = %s; y_val = %s; z_val = %s; q_val = %s" %
8383
(x_val(), y_val(), z_val(), q_val()))
8484

85-
self.assertTrue(x_val() == 3, "x != 3 after synthetics")
86-
self.assertTrue(y_val() == 4, "y != 4 after synthetics")
87-
self.assertTrue(z_val() == 7, "z != 7 after synthetics")
88-
self.assertTrue(q_val() == 8, "q != 8 after synthetics")
85+
self.assertEqual(x_val(), 3, "x != 3 after synthetics")
86+
self.assertEqual(y_val(), 4, "y != 4 after synthetics")
87+
self.assertEqual(z_val(), 7, "z != 7 after synthetics")
88+
self.assertEqual(q_val(), 8, "q != 8 after synthetics")
8989

9090
self.expect("frame variable x", substrs=['3'])
9191
self.expect(

lldb/test/API/functionalities/data-formatter/vector-types/TestVectorTypesFormatting.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,17 @@ def cleanup():
5555
if self.TraceOn():
5656
print(v)
5757

58-
self.assertTrue(
59-
v.GetNumChildren() == 4,
58+
self.assertEqual(
59+
v.GetNumChildren(), 4,
6060
"v as float32[] has 4 children")
61-
self.assertTrue(v.GetChildAtIndex(0).GetData().float[
62-
0] == 1.25, "child 0 == 1.25")
63-
self.assertTrue(v.GetChildAtIndex(1).GetData().float[
64-
0] == 1.25, "child 1 == 1.25")
65-
self.assertTrue(v.GetChildAtIndex(2).GetData().float[
66-
0] == 2.50, "child 2 == 2.50")
67-
self.assertTrue(v.GetChildAtIndex(3).GetData().float[
68-
0] == 2.50, "child 3 == 2.50")
61+
self.assertEqual(v.GetChildAtIndex(0).GetData().float[0], 1.25,
62+
"child 0 == 1.25")
63+
self.assertEqual(v.GetChildAtIndex(1).GetData().float[0], 1.25,
64+
"child 1 == 1.25")
65+
self.assertEqual(v.GetChildAtIndex(2).GetData().float[0], 2.50,
66+
"child 2 == 2.50")
67+
self.assertEqual(v.GetChildAtIndex(3).GetData().float[0], 2.50,
68+
"child 3 == 2.50")
6969

7070
self.expect("expr -f int16_t[] -- v",
7171
substrs=['(0, 16288, 0, 16288, 0, 16416, 0, 16416)'])
@@ -78,11 +78,11 @@ def cleanup():
7878
oldValue = v.GetChildAtIndex(0).GetValue()
7979
v.SetFormat(lldb.eFormatHex)
8080
newValue = v.GetChildAtIndex(0).GetValue()
81-
self.assertFalse(oldValue == newValue,
82-
"values did not change along with format")
81+
self.assertNotEqual(oldValue, newValue,
82+
"values did not change along with format")
8383

8484
v.SetFormat(lldb.eFormatVectorOfFloat32)
8585
oldValueAgain = v.GetChildAtIndex(0).GetValue()
86-
self.assertTrue(
87-
oldValue == oldValueAgain,
86+
self.assertEqual(
87+
oldValue, oldValueAgain,
8888
"same format but different values")

0 commit comments

Comments
 (0)