Skip to content

[lldb] Convert assertTrue(a == b) to assertEqual(a, b) #2420

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def fp_special_purpose_register_read(self):
self.assertTrue(matched, STOPPED_DUE_TO_SIGNAL)

process = target.GetProcess()
self.assertTrue(process.GetState() == lldb.eStateStopped,
self.assertEqual(process.GetState(), lldb.eStateStopped,
PROCESS_STOPPED)

thread = process.GetThreadAtIndex(0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def test_with_python_api(self):
local_watch.SetCondition(condition)
self.GetWatchpointEvent(lldb.eWatchpointEventTypeConditionChanged)

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

def GetWatchpointEvent(self, event_type):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def breakpoint_conditions_python(self):

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

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

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

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

# The hit count for the breakpoint should be 1.
self.assertTrue(breakpoint.GetHitCount() == 1)
self.assertEqual(breakpoint.GetHitCount(), 1)
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def breakpoint_ignore_count_python(self):

# Set the ignore count on the breakpoint location.
location.SetIgnoreCount(2)
self.assertTrue(location.GetIgnoreCount() == 2,
self.assertEqual(location.GetIgnoreCount(), 2,
"SetIgnoreCount() works correctly")

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

# The hit count for the breakpoint should be 3.
self.assertTrue(breakpoint.GetHitCount() == 3)
self.assertEqual(breakpoint.GetHitCount(), 3)

process.Continue()
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ def test(self):
self.assertTrue(process, PROCESS_IS_VALID)

list = target.FindFunctions('foo', lldb.eFunctionNameTypeAuto)
self.assertTrue(list.GetSize() == 1)
self.assertEqual(list.GetSize(), 1)
sc = list.GetContextAtIndex(0)
self.assertTrue(sc.GetSymbol().GetName() == "foo")
self.assertEqual(sc.GetSymbol().GetName(), "foo")
function = sc.GetFunction()
self.assertTrue(function)
self.function(function, target)
Expand Down Expand Up @@ -75,7 +75,7 @@ def function(self, function, target):

# Breakpoint address should be adjusted to the address of
# branch instruction.
self.assertTrue(branchinstaddress == bpaddr)
self.assertEqual(branchinstaddress, bpaddr)
i += 1
else:
i += 1
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def check_equivalence(self, source_bps, do_write = True):

num_source_bps = source_bps.GetSize()
num_copy_bps = copy_bps.GetSize()
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))
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))

for i in range(0, num_source_bps):
source_bp = source_bps.GetBreakpointAtIndex(i)
Expand Down Expand Up @@ -327,12 +327,12 @@ def do_check_names(self):

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

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

def do_check_extra_args(self):

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def do_conditional_break(self):
self.assertTrue(process, PROCESS_IS_VALID)

# The stop reason of the thread should be breakpoint.
self.assertTrue(process.GetState() == lldb.eStateStopped,
self.assertEqual(process.GetState(), lldb.eStateStopped,
STOPPED_DUE_TO_BREAKPOINT)

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

# And the local variable 'val' should have a value of (int)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ def test(self):
self.assertEqual(i_atomic.GetNumChildren(), 1)
i = i_atomic.GetChildAtIndex(0)

self.assertTrue(i.GetValueAsUnsigned(0) == 5, "i == 5")
self.assertTrue(s.GetNumChildren() == 2, "s has two children")
self.assertEqual(i.GetValueAsUnsigned(0), 5, "i == 5")
self.assertEqual(s.GetNumChildren(), 2, "s has two children")
self.assertTrue(
s.GetChildAtIndex(0).GetValueAsUnsigned(0) == 1,
"s.x == 1")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ def cleanup():
"x_val = %s; y_val = %s; z_val = %s; q_val = %s" %
(x_val(), y_val(), z_val(), q_val()))

self.assertFalse(x_val() == 3, "x == 3 before synthetics")
self.assertFalse(y_val() == 4, "y == 4 before synthetics")
self.assertFalse(z_val() == 7, "z == 7 before synthetics")
self.assertFalse(q_val() == 8, "q == 8 before synthetics")
self.assertNotEqual(x_val(), 3, "x == 3 before synthetics")
self.assertNotEqual(y_val(), 4, "y == 4 before synthetics")
self.assertNotEqual(z_val(), 7, "z == 7 before synthetics")
self.assertNotEqual(q_val(), 8, "q == 8 before synthetics")

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

self.assertTrue(x_val() == 3, "x != 3 after synthetics")
self.assertTrue(y_val() == 4, "y != 4 after synthetics")
self.assertTrue(z_val() == 7, "z != 7 after synthetics")
self.assertTrue(q_val() == 8, "q != 8 after synthetics")
self.assertEqual(x_val(), 3, "x != 3 after synthetics")
self.assertEqual(y_val(), 4, "y != 4 after synthetics")
self.assertEqual(z_val(), 7, "z != 7 after synthetics")
self.assertEqual(q_val(), 8, "q != 8 after synthetics")

self.expect("frame variable x", substrs=['3'])
self.expect(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,17 @@ def cleanup():
if self.TraceOn():
print(v)

self.assertTrue(
v.GetNumChildren() == 4,
self.assertEqual(
v.GetNumChildren(), 4,
"v as float32[] has 4 children")
self.assertTrue(v.GetChildAtIndex(0).GetData().float[
0] == 1.25, "child 0 == 1.25")
self.assertTrue(v.GetChildAtIndex(1).GetData().float[
0] == 1.25, "child 1 == 1.25")
self.assertTrue(v.GetChildAtIndex(2).GetData().float[
0] == 2.50, "child 2 == 2.50")
self.assertTrue(v.GetChildAtIndex(3).GetData().float[
0] == 2.50, "child 3 == 2.50")
self.assertEqual(v.GetChildAtIndex(0).GetData().float[0], 1.25,
"child 0 == 1.25")
self.assertEqual(v.GetChildAtIndex(1).GetData().float[0], 1.25,
"child 1 == 1.25")
self.assertEqual(v.GetChildAtIndex(2).GetData().float[0], 2.50,
"child 2 == 2.50")
self.assertEqual(v.GetChildAtIndex(3).GetData().float[0], 2.50,
"child 3 == 2.50")

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

v.SetFormat(lldb.eFormatVectorOfFloat32)
oldValueAgain = v.GetChildAtIndex(0).GetValue()
self.assertTrue(
oldValue == oldValueAgain,
self.assertEqual(
oldValue, oldValueAgain,
"same format but different values")
16 changes: 8 additions & 8 deletions lldb/test/API/functionalities/exec/TestExec.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ def cleanup():
self.addTearDownHook(cleanup)

# The stop reason of the thread should be breakpoint.
self.assertTrue(process.GetState() == lldb.eStateStopped,
self.assertEqual(process.GetState(), lldb.eStateStopped,
STOPPED_DUE_TO_BREAKPOINT)

threads = lldbutil.get_threads_stopped_at_breakpoint(
process, breakpoint1)
self.assertTrue(len(threads) == 1)
self.assertEqual(len(threads), 1)

# We had a deadlock tearing down the TypeSystemMap on exec, but only if some
# expression had been evaluated. So make sure we do that here so the teardown
Expand All @@ -86,16 +86,16 @@ def cleanup():
value.IsValid(),
"Expression evaluated successfully")
int_value = value.GetValueAsSigned()
self.assertTrue(int_value == 3, "Expression got the right result.")
self.assertEqual(int_value, 3, "Expression got the right result.")

# Run and we should stop due to exec
process.Continue()

if not skip_exec:
self.assertFalse(process.GetState() == lldb.eStateExited,
"Process should not have exited!")
self.assertTrue(process.GetState() == lldb.eStateStopped,
"Process should be stopped at __dyld_start")
self.assertNotEqual(process.GetState(), lldb.eStateExited,
"Process should not have exited!")
self.assertEqual(process.GetState(), lldb.eStateStopped,
"Process should be stopped at __dyld_start")

threads = lldbutil.get_stopped_threads(
process, lldb.eStopReasonExec)
Expand All @@ -113,5 +113,5 @@ def cleanup():
print(t)
if t.GetStopReason() != lldb.eStopReasonBreakpoint:
self.runCmd("bt")
self.assertTrue(len(threads) == 1,
self.assertEqual(len(threads), 1,
"Stopped at breakpoint in exec'ed process.")
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def test_with_python(self):
#self.assertTrue(return_value.IsValid())
#return_float = float(return_value.GetValue())

#self.assertTrue(in_float == return_float)
#self.assertEqual(in_float, return_float)

if not self.affected_by_radar_34562999() and not self.affected_by_pr44132():
self.return_and_test_struct_value("return_one_int")
Expand Down
2 changes: 1 addition & 1 deletion lldb/test/API/functionalities/tty/TestTerminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ def test_launch_in_terminal(self):
"Make sure launch happened successfully in a terminal window")
# Running in synchronous mode our process should have run and already
# exited by the time target.Launch() returns
self.assertTrue(process.GetState() == lldb.eStateExited)
self.assertEqual(process.GetState(), lldb.eStateExited)
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ def test(self):

comp_unit = self.find_comp_unit(exe_module, 'compile_unit1.c')
cu_type = self.find_type(comp_unit.GetTypes(), 'compile_unit1_type')
self.assertTrue(exe_module == cu_type.GetModule())
self.assertEqual(exe_module, cu_type.GetModule())

comp_unit = self.find_comp_unit(exe_module, 'compile_unit2.c')
cu_type = self.find_type(comp_unit.GetTypes(), 'compile_unit2_type')
self.assertTrue(exe_module == cu_type.GetModule())
self.assertEqual(exe_module, cu_type.GetModule())
2 changes: 1 addition & 1 deletion lldb/test/API/lang/c/bitfields/TestBitfields.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def test_and_python_api(self):
bits.GetNumChildren() == 10,
"bits.GetNumChildren() == 10")
test_compiler = self.getCompiler()
self.assertTrue(bits.GetByteSize() == 32, "bits.GetByteSize() == 32")
self.assertEqual(bits.GetByteSize(), 32, "bits.GetByteSize() == 32")

# Notice the pattern of int(b1.GetValue(), 0). We pass a base of 0
# so that the proper radix is determined based on the contents of the
Expand Down
24 changes: 12 additions & 12 deletions lldb/test/API/lang/c/stepping/TestStepAndBreakpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,14 @@ def test_and_python_api(self):

process.Continue()

self.assertTrue(thread.GetFrameAtIndex(0).GetFunctionName() == "a")
self.assertTrue(thread.GetStopReason() == lldb.eStopReasonPlanComplete)
self.assertEqual(thread.GetFrameAtIndex(0).GetFunctionName(), "a")
self.assertEqual(thread.GetStopReason(), lldb.eStopReasonPlanComplete)

# And one more time should get us back to main:
process.Continue()

self.assertTrue(thread.GetFrameAtIndex(0).GetFunctionName() == "main")
self.assertTrue(thread.GetStopReason() == lldb.eStopReasonPlanComplete)
self.assertEqual(thread.GetFrameAtIndex(0).GetFunctionName(), "main")
self.assertEqual(thread.GetStopReason(), lldb.eStopReasonPlanComplete)

# Now make sure we can call a function, break in the called function,
# then have "continue" get us back out again:
Expand Down Expand Up @@ -238,18 +238,18 @@ def test_and_python_api(self):

threads = lldbutil.continue_to_breakpoint(
process, break_before_complex_1)
self.assertTrue(len(threads) == 1)
self.assertEqual(len(threads), 1)
thread = threads[0]
break_before_complex_1.SetEnabled(False)

thread.StepInto("b")
self.assertTrue(thread.GetFrameAtIndex(0).GetFunctionName() == "b")
self.assertEqual(thread.GetFrameAtIndex(0).GetFunctionName(), "b")

# Now continue out and stop at the next call to complex. This time
# step all the way into complex:
threads = lldbutil.continue_to_breakpoint(
process, break_before_complex_2)
self.assertTrue(len(threads) == 1)
self.assertEqual(len(threads), 1)
thread = threads[0]
break_before_complex_2.SetEnabled(False)

Expand All @@ -261,7 +261,7 @@ def test_and_python_api(self):
# enable breakpoints in a and c and then step targeting b:
threads = lldbutil.continue_to_breakpoint(
process, break_before_complex_3)
self.assertTrue(len(threads) == 1)
self.assertEqual(len(threads), 1)
thread = threads[0]
break_before_complex_3.SetEnabled(False)

Expand All @@ -272,7 +272,7 @@ def test_and_python_api(self):
threads = lldbutil.get_stopped_threads(
process, lldb.eStopReasonBreakpoint)

self.assertTrue(len(threads) == 1)
self.assertEqual(len(threads), 1)
thread = threads[0]
stop_break_id = thread.GetStopReasonDataAtIndex(0)
self.assertTrue(stop_break_id == break_at_start_of_a.GetID()
Expand All @@ -282,15 +282,15 @@ def test_and_python_api(self):
break_at_start_of_c.SetEnabled(False)

process.Continue()
self.assertTrue(thread.GetFrameAtIndex(0).GetFunctionName() == "b")
self.assertEqual(thread.GetFrameAtIndex(0).GetFunctionName(), "b")

# Now continue out and stop at the next call to complex. This time
# enable breakpoints in a and c and then step targeting b:
threads = lldbutil.continue_to_breakpoint(
process, break_before_complex_4)
self.assertTrue(len(threads) == 1)
self.assertEqual(len(threads), 1)
thread = threads[0]
break_before_complex_4.SetEnabled(False)

thread.StepInto("NoSuchFunction")
self.assertTrue(thread.GetFrameAtIndex(0).GetFunctionName() == "main")
self.assertEqual(thread.GetFrameAtIndex(0).GetFunctionName(), "main")
Loading