From 1fb5c7a2f17f10e768160fe23d4a04537c7224c1 Mon Sep 17 00:00:00 2001 From: Dave Lee Date: Fri, 11 Nov 2022 16:19:03 -0800 Subject: [PATCH] [lldb] Rewrite to assertEqual/assertNotEqual (NFC) Using the more specific assert* methods results in more useful error message. --- lldb/test/API/api/listeners/TestListener.py | 8 +-- .../call-restarts/TestCallThatRestarts.py | 9 ++- .../expression/formatters/TestFormatters.py | 66 +++++++------------ lldb/test/API/commands/trace/TestTraceExport.py | 6 +- .../breakpoint_command/TestBreakpointCommand.py | 2 +- .../serialize/TestBreakpointSerialization.py | 2 +- lldb/test/API/functionalities/dwo/TestZeroDwoId.py | 2 +- .../fat_archives/TestFatArchives.py | 4 +- .../recursion/TestValueObjectRecursion.py | 8 +-- .../step-avoids-no-debug/TestStepNoDebug.py | 4 +- lldb/test/API/lang/c/fpeval/TestFPEval.py | 2 +- .../API/lang/c/stepping/TestStepAndBreakpoints.py | 11 ++-- .../API/lang/cpp/dynamic-value/TestCppValueCast.py | 8 +-- .../objc/objc-dyn-sbtype/TestObjCDynamicSBType.py | 10 +-- .../lang/objc/objc-property/TestObjCProperty.py | 4 +- .../lang/objc/objc-stepping/TestObjCStepping.py | 4 +- .../TestCorefileExceptionReason.py | 2 +- .../TestBundleWithDotInFilename.py | 2 +- .../macosx/find-dsym/deep-bundle/TestDeepBundle.py | 2 +- lldb/test/API/macosx/queues/TestQueues.py | 10 +-- .../absolute_symbol/TestAbsoluteSymbol.py | 2 +- .../findvalue_duplist/TestSBFrameFindValue.py | 24 ++----- .../python_api/function_symbol/TestSymbolAPI.py | 12 ++-- .../module_section/TestModuleAndSection.py | 5 +- .../process/read-mem-cstring/TestReadMemCString.py | 6 +- lldb/test/API/python_api/sbdata/TestSBData.py | 77 +++++----------------- lldb/test/API/python_api/value/TestValueAPI.py | 18 +++-- .../value_var_update/TestValueVarUpdate.py | 4 +- .../tools/lldb-vscode/launch/TestVSCode_launch.py | 4 +- 29 files changed, 121 insertions(+), 197 deletions(-) diff --git a/lldb/test/API/api/listeners/TestListener.py b/lldb/test/API/api/listeners/TestListener.py index de0491b..c6f15bf 100644 --- a/lldb/test/API/api/listeners/TestListener.py +++ b/lldb/test/API/api/listeners/TestListener.py @@ -63,8 +63,8 @@ class ListenToModuleLoadedEvents (TestBase): self.assertTrue( lldb.SBBreakpoint.EventIsBreakpointEvent(event), "It is a breakpoint event.") - self.assertTrue(lldb.SBBreakpoint.GetBreakpointEventTypeFromEvent( - event) == lldb.eBreakpointEventTypeAdded, "It is a breakpoint added event.") + self.assertEqual(lldb.SBBreakpoint.GetBreakpointEventTypeFromEvent(event), + lldb.eBreakpointEventTypeAdded, "It is a breakpoint added event.") self.assertEqual( bkpt, lldb.SBBreakpoint.GetBreakpointFromEvent(event), "It is our breakpoint.") @@ -106,8 +106,8 @@ class ListenToModuleLoadedEvents (TestBase): self.assertTrue( lldb.SBBreakpoint.EventIsBreakpointEvent(event), "It is a breakpoint event.") - self.assertTrue(lldb.SBBreakpoint.GetBreakpointEventTypeFromEvent( - event) == lldb.eBreakpointEventTypeAdded, "It is a breakpoint added event.") + self.assertEqual(lldb.SBBreakpoint.GetBreakpointEventTypeFromEvent(event), + lldb.eBreakpointEventTypeAdded, "It is a breakpoint added event.") self.assertEqual( bkpt, lldb.SBBreakpoint.GetBreakpointFromEvent(event), "It is our breakpoint.") diff --git a/lldb/test/API/commands/expression/call-restarts/TestCallThatRestarts.py b/lldb/test/API/commands/expression/call-restarts/TestCallThatRestarts.py index 487c55f..995a595 100644 --- a/lldb/test/API/commands/expression/call-restarts/TestCallThatRestarts.py +++ b/lldb/test/API/commands/expression/call-restarts/TestCallThatRestarts.py @@ -31,9 +31,8 @@ class ExprCommandThatRestartsTestCase(TestBase): def check_after_call(self, num_sigchld): after_call = self.sigchld_no.GetValueAsSigned(-1) - self.assertTrue( - after_call - - self.start_sigchld_no == num_sigchld, + self.assertEqual( + after_call - self.start_sigchld_no, num_sigchld, "Really got %d SIGCHLD signals through the call." % (num_sigchld)) self.start_sigchld_no = after_call @@ -58,8 +57,8 @@ class ExprCommandThatRestartsTestCase(TestBase): "Got a value for sigchld_no") self.start_sigchld_no = self.sigchld_no.GetValueAsSigned(-1) - self.assertTrue( - self.start_sigchld_no != -1, + self.assertNotEqual( + self.start_sigchld_no, -1, "Got an actual value for sigchld_no") options = lldb.SBExpressionOptions() diff --git a/lldb/test/API/commands/expression/formatters/TestFormatters.py b/lldb/test/API/commands/expression/formatters/TestFormatters.py index f6eeeb2..4073ac3 100644 --- a/lldb/test/API/commands/expression/formatters/TestFormatters.py +++ b/lldb/test/API/commands/expression/formatters/TestFormatters.py @@ -216,10 +216,8 @@ class ExprFormattersTestCase(TestBase): a_data = frozen.GetPointeeData() error = lldb.SBError() - self.assertTrue( - a_data.GetUnsignedInt32( - error, - 0) == 122, + self.assertEqual( + a_data.GetUnsignedInt32(error, 0), 122, '*a_ptr = 122') ret = line_number("main.cpp", "Done initializing") @@ -235,58 +233,38 @@ class ExprFormattersTestCase(TestBase): a_data = frozen.GetPointeeData(0, 1) - self.assertTrue( - a_data.GetUnsignedInt32( - error, - 0) == 1, + self.assertEqual( + a_data.GetUnsignedInt32(error, 0), 1, 'numbers[0] == 1') - self.assertTrue( - a_data.GetUnsignedInt32( - error, - 4) == 2, + self.assertEqual( + a_data.GetUnsignedInt32(error, 4), 2, 'numbers[1] == 2') - self.assertTrue( - a_data.GetUnsignedInt32( - error, - 8) == 3, + self.assertEqual( + a_data.GetUnsignedInt32(error, 8), 3, 'numbers[2] == 3') - self.assertTrue( - a_data.GetUnsignedInt32( - error, - 12) == 4, + self.assertEqual( + a_data.GetUnsignedInt32(error, 12), 4, 'numbers[3] == 4') - self.assertTrue( - a_data.GetUnsignedInt32( - error, - 16) == 5, + self.assertEqual( + a_data.GetUnsignedInt32(error, 16), 5, 'numbers[4] == 5') frozen = frame.EvaluateExpression("numbers") a_data = frozen.GetData() - self.assertTrue( - a_data.GetUnsignedInt32( - error, - 0) == 1, + self.assertEqual( + a_data.GetUnsignedInt32(error, 0), 1, 'numbers[0] == 1') - self.assertTrue( - a_data.GetUnsignedInt32( - error, - 4) == 2, + self.assertEqual( + a_data.GetUnsignedInt32(error, 4), 2, 'numbers[1] == 2') - self.assertTrue( - a_data.GetUnsignedInt32( - error, - 8) == 3, + self.assertEqual( + a_data.GetUnsignedInt32(error, 8), 3, 'numbers[2] == 3') - self.assertTrue( - a_data.GetUnsignedInt32( - error, - 12) == 4, + self.assertEqual( + a_data.GetUnsignedInt32(error, 12), 4, 'numbers[3] == 4') - self.assertTrue( - a_data.GetUnsignedInt32( - error, - 16) == 5, + self.assertEqual( + a_data.GetUnsignedInt32(error, 16), 5, 'numbers[4] == 5') diff --git a/lldb/test/API/commands/trace/TestTraceExport.py b/lldb/test/API/commands/trace/TestTraceExport.py index 981df96..2a5f186 100644 --- a/lldb/test/API/commands/trace/TestTraceExport.py +++ b/lldb/test/API/commands/trace/TestTraceExport.py @@ -111,10 +111,10 @@ class TestTraceExport(TraceIntelPTTestCaseBase): ] # Check that the length of the expected JSON array is equal to the actual - self.assertTrue(len(data) == len(expected)) + self.assertEqual(len(data), len(expected)) for i in range(len(data)): # Check each individual JSON object in "ctf-test.json" against the expected value above - self.assertTrue(data[i] == expected[i]) + self.assertEqual(data[i], expected[i]) def _testHtrBasicSuperBlockPassSequenceCheck(self): ''' @@ -169,4 +169,4 @@ class TestTraceExport(TraceIntelPTTestCaseBase): data_index = index_of_first_layer_1_block for i in range(len(expected_block_names)): - self.assertTrue(data[data_index + i]['name'] == expected_block_names[i]) + self.assertEqual(data[data_index + i]['name'], expected_block_names[i]) diff --git a/lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py b/lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py index 6c0afee..36860ecb 100644 --- a/lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py +++ b/lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py @@ -102,7 +102,7 @@ class BreakpointCommandTestCase(TestBase): self.runCmd("settings clear target.source-map") for path in invalid_paths: bkpt = target.BreakpointCreateByLocation(path, 2) - self.assertTrue(bkpt.GetNumLocations() == 0, + self.assertEqual(bkpt.GetNumLocations(), 0, 'Incorrectly resolved a breakpoint using full path "%s" with ' 'debug info that has relative path with matching suffix' % (path)) diff --git a/lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py b/lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py index 8b09cbc..a8eeb6f 100644 --- a/lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py +++ b/lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py @@ -147,7 +147,7 @@ class BreakpointSerialization(TestBase): # These two should be identical. self.trace("Source text for %d is %s."%(i, source_text)) - self.assertTrue (source_text == copy_text, "Source and dest breakpoints are not identical: \nsource: %s\ndest: %s"%(source_text, copy_text)) + self.assertEqual(source_text, copy_text, "Source and dest breakpoints are not identical: \nsource: %s\ndest: %s"%(source_text, copy_text)) def do_check_resolvers(self): """Use Python APIs to check serialization of breakpoint resolvers""" diff --git a/lldb/test/API/functionalities/dwo/TestZeroDwoId.py b/lldb/test/API/functionalities/dwo/TestZeroDwoId.py index 40d8583..7fc00c6 100644 --- a/lldb/test/API/functionalities/dwo/TestZeroDwoId.py +++ b/lldb/test/API/functionalities/dwo/TestZeroDwoId.py @@ -39,7 +39,7 @@ class ExecTestCase(TestBase): # Set a breakpoint by file and line, this doesn't require anything from # the .dwo file. bp = target.BreakpointCreateByLocation('main.cpp', 6) - self.assertTrue(bp.GetNumLocations() == 1) + self.assertEqual(bp.GetNumLocations(), 1) bp_loc = bp.GetLocationAtIndex(0) self.assertTrue(bp_loc.IsValid()) diff --git a/lldb/test/API/functionalities/fat_archives/TestFatArchives.py b/lldb/test/API/functionalities/fat_archives/TestFatArchives.py index 11b3edd..21614f9 100644 --- a/lldb/test/API/functionalities/fat_archives/TestFatArchives.py +++ b/lldb/test/API/functionalities/fat_archives/TestFatArchives.py @@ -50,6 +50,6 @@ class FatArchiveTestCase(TestBase): self.assertTrue( line_entry.GetFileSpec(), "Verify breakpoint in fat BSD archive has source file information") - self.assertTrue( - line_entry.GetLine() != 0, + self.assertNotEqual( + line_entry.GetLine(), 0, "Verify breakpoint in fat BSD archive has source line information") diff --git a/lldb/test/API/functionalities/recursion/TestValueObjectRecursion.py b/lldb/test/API/functionalities/recursion/TestValueObjectRecursion.py index 4d83bf3..7e8c7cb 100644 --- a/lldb/test/API/functionalities/recursion/TestValueObjectRecursion.py +++ b/lldb/test/API/functionalities/recursion/TestValueObjectRecursion.py @@ -56,9 +56,9 @@ class ValueObjectRecursionTestCase(TestBase): self.assertTrue( child.GetChildAtIndex(0).IsValid(), "the deep ValueObject has no value") - self.assertTrue( - child.GetChildAtIndex(0).GetValueAsUnsigned() != 0, + self.assertNotEqual( + child.GetChildAtIndex(0).GetValueAsUnsigned(), 0, "the deep ValueObject has a zero value") - self.assertTrue( - child.GetChildAtIndex(1).GetValueAsUnsigned() != 0, + self.assertNotEqual( + child.GetChildAtIndex(1).GetValueAsUnsigned(), 0, "the deep ValueObject has no next") diff --git a/lldb/test/API/functionalities/step-avoids-no-debug/TestStepNoDebug.py b/lldb/test/API/functionalities/step-avoids-no-debug/TestStepNoDebug.py index 98b8005..17ac2e0 100644 --- a/lldb/test/API/functionalities/step-avoids-no-debug/TestStepNoDebug.py +++ b/lldb/test/API/functionalities/step-avoids-no-debug/TestStepNoDebug.py @@ -71,8 +71,8 @@ class StepAvoidsNoDebugTestCase(TestBase): def hit_correct_line(self, pattern): target_line = line_number(self.main_source, pattern) - self.assertTrue( - target_line != 0, + self.assertNotEqual( + target_line, 0, "Could not find source pattern " + pattern) cur_line = self.thread.frames[0].GetLineEntry().GetLine() diff --git a/lldb/test/API/lang/c/fpeval/TestFPEval.py b/lldb/test/API/lang/c/fpeval/TestFPEval.py index 42ea02c..f2b6bf7 100644 --- a/lldb/test/API/lang/c/fpeval/TestFPEval.py +++ b/lldb/test/API/lang/c/fpeval/TestFPEval.py @@ -95,5 +95,5 @@ class FPEvalTestCase(TestBase): v1 = frame.EvaluateExpression("{0}; eval(x, y, 2)".format(vardef), self.jit_opts) v2 = frame.EvaluateExpression("{0}; x / y".format(vardef), self.no_jit_opts) self.assertTrue(v1.IsValid() and v2.IsValid()) - self.assertTrue(str(v1.GetData()) == str(v2.GetData())) + self.assertEqual(str(v1.GetData()), str(v2.GetData())) diff --git a/lldb/test/API/lang/c/stepping/TestStepAndBreakpoints.py b/lldb/test/API/lang/c/stepping/TestStepAndBreakpoints.py index 1834771..b7ba733 100644 --- a/lldb/test/API/lang/c/stepping/TestStepAndBreakpoints.py +++ b/lldb/test/API/lang/c/stepping/TestStepAndBreakpoints.py @@ -209,10 +209,10 @@ class TestCStepping(TestBase): # should end up back in "a" as if nothing had happened: process.Continue() - self.assertTrue(thread.GetFrameAtIndex( - 0).GetLineEntry().GetLine() == current_line) - self.assertTrue(thread.GetFrameAtIndex( - 0).GetLineEntry().GetFileSpec() == current_file) + self.assertEqual( + thread.GetFrameAtIndex(0).GetLineEntry().GetLine(), current_line) + self.assertEqual( + thread.GetFrameAtIndex(0).GetLineEntry().GetFileSpec(), current_file) # Now we are going to test step in targeting a function: @@ -252,8 +252,7 @@ class TestCStepping(TestBase): break_before_complex_2.SetEnabled(False) thread.StepInto("complex") - self.assertTrue(thread.GetFrameAtIndex( - 0).GetFunctionName() == "complex") + self.assertEqual(thread.GetFrameAtIndex(0).GetFunctionName(), "complex") # Now continue out and stop at the next call to complex. This time # enable breakpoints in a and c and then step targeting b: diff --git a/lldb/test/API/lang/cpp/dynamic-value/TestCppValueCast.py b/lldb/test/API/lang/cpp/dynamic-value/TestCppValueCast.py index 5b298b4..f1d4e12 100644 --- a/lldb/test/API/lang/cpp/dynamic-value/TestCppValueCast.py +++ b/lldb/test/API/lang/cpp/dynamic-value/TestCppValueCast.py @@ -78,8 +78,8 @@ class CppValueCastTestCase(TestBase): tellerA = frame0.FindVariable('teller', lldb.eNoDynamicValues) self.DebugSBValue(tellerA) - self.assertTrue(tellerA.GetChildMemberWithName( - 'm_base_val').GetValueAsUnsigned(error, 0) == 20) + self.assertEqual( + tellerA.GetChildMemberWithName('m_base_val').GetValueAsUnsigned(error, 0), 20) if self.TraceOn(): for child in tellerA: @@ -107,8 +107,8 @@ class CppValueCastTestCase(TestBase): tellerB = frame0.FindVariable('teller', lldb.eNoDynamicValues) self.DebugSBValue(tellerB) - self.assertTrue(tellerB.GetChildMemberWithName( - 'm_base_val').GetValueAsUnsigned(error, 0) == 12) + self.assertEqual( + tellerB.GetChildMemberWithName('m_base_val').GetValueAsUnsigned(error, 0), 12) if self.TraceOn(): for child in tellerB: diff --git a/lldb/test/API/lang/objc/objc-dyn-sbtype/TestObjCDynamicSBType.py b/lldb/test/API/lang/objc/objc-dyn-sbtype/TestObjCDynamicSBType.py index 363b231..0343ee2 100644 --- a/lldb/test/API/lang/objc/objc-dyn-sbtype/TestObjCDynamicSBType.py +++ b/lldb/test/API/lang/objc/objc-dyn-sbtype/TestObjCDynamicSBType.py @@ -74,10 +74,12 @@ class ObjCDynamicSBTypeTestCase(TestBase): base_pointee_type.GetDirectBaseClassAtIndex(0).GetName(), "MyBaseClass", "The dynamic type for Base can go back to its base class") - self.assertTrue(object_pointee_type.GetDirectBaseClassAtIndex(0).GetType().GetDirectBaseClassAtIndex( - 0).GetName() == "NSObject", "The dynamic type for NSObject can go up the hierarchy") - self.assertTrue(base_pointee_type.GetDirectBaseClassAtIndex(0).GetType().GetDirectBaseClassAtIndex( - 0).GetName() == "NSObject", "The dynamic type for Base can go up the hierarchy") + self.assertEqual( + object_pointee_type.GetDirectBaseClassAtIndex(0).GetType().GetDirectBaseClassAtIndex(0).GetName(), + "NSObject", "The dynamic type for NSObject can go up the hierarchy") + self.assertEqual( + base_pointee_type.GetDirectBaseClassAtIndex(0).GetType().GetDirectBaseClassAtIndex(0).GetName(), + "NSObject", "The dynamic type for Base can go up the hierarchy") self.assertEqual( object_pointee_type.GetNumberOfFields(), 2, diff --git a/lldb/test/API/lang/objc/objc-property/TestObjCProperty.py b/lldb/test/API/lang/objc/objc-property/TestObjCProperty.py index 1582d3f..2316d91 100644 --- a/lldb/test/API/lang/objc/objc-property/TestObjCProperty.py +++ b/lldb/test/API/lang/objc/objc-property/TestObjCProperty.py @@ -104,8 +104,8 @@ class ObjCPropertyTestCase(TestBase): self.assertSuccess(backed_error) backing_value = mine.GetChildMemberWithName("_backedInt") self.assertTrue(backing_value.IsValid()) - self.assertTrue(backed_value.GetValueAsUnsigned(12345) - == backing_value.GetValueAsUnsigned(23456)) + self.assertEqual(backed_value.GetValueAsUnsigned(12345), + backing_value.GetValueAsUnsigned(23456)) value_from_typedef = frame.EvaluateExpression("typedefd.backedInt", False) self.assertSuccess(value_from_typedef.GetError()) diff --git a/lldb/test/API/lang/objc/objc-stepping/TestObjCStepping.py b/lldb/test/API/lang/objc/objc-stepping/TestObjCStepping.py index 5b4fffd..1bbabdf 100644 --- a/lldb/test/API/lang/objc/objc-stepping/TestObjCStepping.py +++ b/lldb/test/API/lang/objc/objc-stepping/TestObjCStepping.py @@ -154,8 +154,8 @@ class TestObjCStepping(TestBase): print("className is %s, newClassName is %s" % (className, newClassName)) print(mySource_isa) - self.assertTrue( - newClassName != className, + self.assertNotEqual( + newClassName, className, "The isa did indeed change, swizzled!") # Now step in, that should leave us in the Source randomMethod: diff --git a/lldb/test/API/macosx/corefile-exception-reason/TestCorefileExceptionReason.py b/lldb/test/API/macosx/corefile-exception-reason/TestCorefileExceptionReason.py index cd87816..dc43338 100644 --- a/lldb/test/API/macosx/corefile-exception-reason/TestCorefileExceptionReason.py +++ b/lldb/test/API/macosx/corefile-exception-reason/TestCorefileExceptionReason.py @@ -39,4 +39,4 @@ class TestCorefileExceptionReason(TestBase): self.runCmd("bt") self.runCmd("fr v") - self.assertTrue(thread.GetStopDescription(256) == "ESR_EC_DABORT_EL0 (fault address: 0x0)") + self.assertEqual(thread.GetStopDescription(256), "ESR_EC_DABORT_EL0 (fault address: 0x0)") diff --git a/lldb/test/API/macosx/find-dsym/bundle-with-dot-in-filename/TestBundleWithDotInFilename.py b/lldb/test/API/macosx/find-dsym/bundle-with-dot-in-filename/TestBundleWithDotInFilename.py index 1be8da9..71c67fe 100644 --- a/lldb/test/API/macosx/find-dsym/bundle-with-dot-in-filename/TestBundleWithDotInFilename.py +++ b/lldb/test/API/macosx/find-dsym/bundle-with-dot-in-filename/TestBundleWithDotInFilename.py @@ -67,6 +67,6 @@ class BundleWithDotInFilenameTestCase(TestBase): mod = target.GetModuleAtIndex(i) if mod.GetFileSpec().GetFilename() == 'com.apple.sbd': dsym_name = mod.GetSymbolFileSpec().GetFilename() - self.assertTrue (dsym_name == 'com.apple.sbd', "Check that we found the dSYM for the bundle that was loaded") + self.assertEqual(dsym_name, 'com.apple.sbd', "Check that we found the dSYM for the bundle that was loaded") i=i+1 os.chdir(self.getSourceDir()); diff --git a/lldb/test/API/macosx/find-dsym/deep-bundle/TestDeepBundle.py b/lldb/test/API/macosx/find-dsym/deep-bundle/TestDeepBundle.py index 6867ae0..7659862 100644 --- a/lldb/test/API/macosx/find-dsym/deep-bundle/TestDeepBundle.py +++ b/lldb/test/API/macosx/find-dsym/deep-bundle/TestDeepBundle.py @@ -66,7 +66,7 @@ class DeepBundleTestCase(TestBase): if mod.GetFileSpec().GetFilename() == 'MyFramework': found_module = True dsym_name = mod.GetSymbolFileSpec().GetFilename() - self.assertTrue (dsym_name == 'MyFramework', "Check that we found the dSYM for the bundle that was loaded") + self.assertEqual(dsym_name, 'MyFramework', "Check that we found the dSYM for the bundle that was loaded") i=i+1 self.assertTrue(found_module, "Check that we found the framework loaded in lldb's image list") diff --git a/lldb/test/API/macosx/queues/TestQueues.py b/lldb/test/API/macosx/queues/TestQueues.py index f906f5b3..21efac2 100644 --- a/lldb/test/API/macosx/queues/TestQueues.py +++ b/lldb/test/API/macosx/queues/TestQueues.py @@ -377,15 +377,17 @@ class TestQueues(TestBase): self.assertTrue(queue_performer_2.GetPendingItemAtIndex( 0).IsValid(), "queue 2's pending item #0 is valid") - self.assertTrue(queue_performer_2.GetPendingItemAtIndex(0).GetAddress().GetSymbol( - ).GetName() == "doing_the_work_2", "queue 2's pending item #0 should be doing_the_work_2") + self.assertEqual( + queue_performer_2.GetPendingItemAtIndex(0).GetAddress().GetSymbol().GetName(), + "doing_the_work_2", "queue 2's pending item #0 should be doing_the_work_2") self.assertEqual( queue_performer_2.GetNumPendingItems(), 9999, "verify that queue 2 still has 9999 pending items") self.assertTrue(queue_performer_2.GetPendingItemAtIndex( 9998).IsValid(), "queue 2's pending item #9998 is valid") - self.assertTrue(queue_performer_2.GetPendingItemAtIndex(9998).GetAddress().GetSymbol( - ).GetName() == "doing_the_work_2", "queue 2's pending item #0 should be doing_the_work_2") + self.assertEqual( + queue_performer_2.GetPendingItemAtIndex(9998).GetAddress().GetSymbol().GetName(), + "doing_the_work_2", "queue 2's pending item #0 should be doing_the_work_2") self.assertTrue(queue_performer_2.GetPendingItemAtIndex( 9999).IsValid() == False, "queue 2's pending item #9999 is invalid") diff --git a/lldb/test/API/python_api/absolute_symbol/TestAbsoluteSymbol.py b/lldb/test/API/python_api/absolute_symbol/TestAbsoluteSymbol.py index f51bd2d..6e419f6 100644 --- a/lldb/test/API/python_api/absolute_symbol/TestAbsoluteSymbol.py +++ b/lldb/test/API/python_api/absolute_symbol/TestAbsoluteSymbol.py @@ -77,4 +77,4 @@ class TestAbsoluteSymbol(TestBase): # prefix of ".absolute." followed by the symbol name as they interfere # with address lookups if they are treated like real sections. for section in module.sections: - self.assertTrue(section.GetName() != ".absolute.absolute") + self.assertNotEqual(section.GetName(), ".absolute.absolute") diff --git a/lldb/test/API/python_api/findvalue_duplist/TestSBFrameFindValue.py b/lldb/test/API/python_api/findvalue_duplist/TestSBFrameFindValue.py index 7dc0781..42961f8 100644 --- a/lldb/test/API/python_api/findvalue_duplist/TestSBFrameFindValue.py +++ b/lldb/test/API/python_api/findvalue_duplist/TestSBFrameFindValue.py @@ -42,12 +42,8 @@ class SBFrameFindValueTestCase(TestBase): self.frame = self.thread.frames[0] self.assertTrue(self.frame, "Frame 0 is valid.") - self.assertTrue( - self.frame.GetVariables( - True, - True, - False, - True).GetSize() == 2, + self.assertEqual( + self.frame.GetVariables(True, True, False, True).GetSize(), 2, "variable count is off") self.assertFalse( self.frame.FindValue( @@ -55,12 +51,8 @@ class SBFrameFindValueTestCase(TestBase): lldb.eValueTypeVariableArgument, lldb.eDynamicCanRunTarget).IsValid(), "found something that should not be here") - self.assertTrue( - self.frame.GetVariables( - True, - True, - False, - True).GetSize() == 2, + self.assertEqual( + self.frame.GetVariables(True, True, False, True).GetSize(), 2, "variable count is off after failed FindValue()") self.assertTrue( self.frame.FindValue( @@ -68,10 +60,6 @@ class SBFrameFindValueTestCase(TestBase): lldb.eValueTypeVariableArgument, lldb.eDynamicCanRunTarget).IsValid(), "FindValue() didn't find an argument") - self.assertTrue( - self.frame.GetVariables( - True, - True, - False, - True).GetSize() == 2, + self.assertEqual( + self.frame.GetVariables(True, True, False, True).GetSize(), 2, "variable count is off after successful FindValue()") diff --git a/lldb/test/API/python_api/function_symbol/TestSymbolAPI.py b/lldb/test/API/python_api/function_symbol/TestSymbolAPI.py index 5e6a02a..14cc3eb 100644 --- a/lldb/test/API/python_api/function_symbol/TestSymbolAPI.py +++ b/lldb/test/API/python_api/function_symbol/TestSymbolAPI.py @@ -59,8 +59,8 @@ class SymbolAPITestCase(TestBase): self.assertEqual(symbol_line1.GetType(), lldb.eSymbolTypeCode) addr_line1 = symbol_line1.GetStartAddress() # And a section type of code, too. - self.assertTrue(addr_line1.GetSection().GetSectionType() - == lldb.eSectionTypeCode) + self.assertEqual(addr_line1.GetSection().GetSectionType(), + lldb.eSectionTypeCode) # Continue the inferior, the breakpoint 2 should be hit. process.Continue() @@ -76,11 +76,11 @@ class SymbolAPITestCase(TestBase): self.assertEqual(symbol_line2.GetType(), lldb.eSymbolTypeCode) addr_line2 = symbol_line2.GetStartAddress() # And a section type of code, too. - self.assertTrue(addr_line2.GetSection().GetSectionType() - == lldb.eSectionTypeCode) + self.assertEqual(addr_line2.GetSection().GetSectionType(), + lldb.eSectionTypeCode) # Now verify that both addresses point to the same module. if self.TraceOn(): print("UUID:", addr_line1.GetModule().GetUUIDString()) - self.assertTrue(addr_line1.GetModule().GetUUIDString() - == addr_line2.GetModule().GetUUIDString()) + self.assertEqual(addr_line1.GetModule().GetUUIDString(), + addr_line2.GetModule().GetUUIDString()) diff --git a/lldb/test/API/python_api/module_section/TestModuleAndSection.py b/lldb/test/API/python_api/module_section/TestModuleAndSection.py index 493d372..377640f 100644 --- a/lldb/test/API/python_api/module_section/TestModuleAndSection.py +++ b/lldb/test/API/python_api/module_section/TestModuleAndSection.py @@ -153,6 +153,5 @@ class ModuleAndSectionAPIsTestCase(TestBase): for source_name in source_name_list: list = module.FindCompileUnits(lldb.SBFileSpec(source_name, False)) for sc in list: - self.assertTrue( - sc.GetCompileUnit().GetFileSpec().GetFilename() == - source_name) + self.assertEqual( + sc.GetCompileUnit().GetFileSpec().GetFilename(), source_name) diff --git a/lldb/test/API/python_api/process/read-mem-cstring/TestReadMemCString.py b/lldb/test/API/python_api/process/read-mem-cstring/TestReadMemCString.py index beda712..e84a808 100644 --- a/lldb/test/API/python_api/process/read-mem-cstring/TestReadMemCString.py +++ b/lldb/test/API/python_api/process/read-mem-cstring/TestReadMemCString.py @@ -31,15 +31,15 @@ class TestReadMemCString(TestBase): empty_str_addr = frame.FindVariable("empty_string").GetValueAsUnsigned(err) self.assertSuccess(err) - self.assertTrue(empty_str_addr != lldb.LLDB_INVALID_ADDRESS) + self.assertNotEqual(empty_str_addr, lldb.LLDB_INVALID_ADDRESS) one_letter_str_addr = frame.FindVariable("one_letter_string").GetValueAsUnsigned(err) self.assertSuccess(err) - self.assertTrue(one_letter_str_addr != lldb.LLDB_INVALID_ADDRESS) + self.assertNotEqual(one_letter_str_addr, lldb.LLDB_INVALID_ADDRESS) invalid_memory_str_addr = frame.FindVariable("invalid_memory_string").GetValueAsUnsigned(err) self.assertSuccess(err) - self.assertTrue(invalid_memory_str_addr != lldb.LLDB_INVALID_ADDRESS) + self.assertNotEqual(invalid_memory_str_addr, lldb.LLDB_INVALID_ADDRESS) # Important: An empty (0-length) c-string must come back as a Python string, not a # None object. diff --git a/lldb/test/API/python_api/sbdata/TestSBData.py b/lldb/test/API/python_api/sbdata/TestSBData.py index ae87312..932781b 100644 --- a/lldb/test/API/python_api/sbdata/TestSBData.py +++ b/lldb/test/API/python_api/sbdata/TestSBData.py @@ -118,10 +118,8 @@ class SBDataAPICase(TestBase): offset += 4 self.assert_data(data.GetSignedInt32, offset, 7) offset += 8 - self.assertTrue( - data.GetUnsignedInt32( - error, - offset) == 0, + self.assertEqual( + data.GetUnsignedInt32(error, offset), 0, 'do not read beyond end') self.assertTrue(not error.Success()) error.Clear() # clear the error for the next test @@ -287,22 +285,15 @@ class SBDataAPICase(TestBase): self.assert_data(data2.GetUnsignedInt64, 24, 4) self.assert_data(data2.GetUnsignedInt64, 32, 5) - self.assertTrue( - data2.uint64s == [ - 1, - 2, - 3, - 4, - 5], + self.assertEqual( + data2.uint64s, [1, 2, 3, 4, 5], 'read_data_helper failure: data2 == [1,2,3,4,5]') for l in int_lists: data2 = lldb.SBData.CreateDataFromSInt32Array( process.GetByteOrder(), process.GetAddressByteSize(), l) - self.assertTrue( - data2.sint32[ - 0:2] == [ - 2, -2], 'signed32 data2 = [2,-2]') + self.assertEqual( + data2.sint32[0:2], [2, -2], 'signed32 data2 = [2,-2]') data2.Append( lldb.SBData.CreateDataFromSInt64Array( @@ -311,20 +302,16 @@ class SBDataAPICase(TestBase): int_lists[0])) self.assert_data(data2.GetSignedInt32, 0, 2) self.assert_data(data2.GetSignedInt32, 4, -2) - self.assertTrue( - data2.sint64[ - 1:3] == [ - 2, -2], 'signed64 data2 = [2,-2]') + self.assertEqual( + data2.sint64[1:3], [2, -2], 'signed64 data2 = [2,-2]') for l in int_lists: data2 = lldb.SBData.CreateDataFromSInt64Array( process.GetByteOrder(), process.GetAddressByteSize(), l) self.assert_data(data2.GetSignedInt64, 0, 2) self.assert_data(data2.GetSignedInt64, 8, -2) - self.assertTrue( - data2.sint64[ - 0:2] == [ - 2, -2], 'signed64 data2 = [2,-2]') + self.assertEqual( + data2.sint64[0:2], [2, -2], 'signed64 data2 = [2,-2]') for l in uint_lists: data2 = lldb.SBData.CreateDataFromUInt32Array( @@ -339,54 +326,26 @@ class SBDataAPICase(TestBase): data2 = lldb.SBData.CreateDataFromSInt32Array( process.GetByteOrder(), process.GetAddressByteSize(), bool_list) - self.assertTrue( - data2.sint32[ - 0:6] == [ - 1, - 1, - 0, - 0, - 1, - 0], + self.assertEqual( + data2.sint32[0:6], [1, 1, 0, 0, 1, 0], 'signed32 data2 = [1, 1, 0, 0, 1, 0]') data2 = lldb.SBData.CreateDataFromUInt32Array( process.GetByteOrder(), process.GetAddressByteSize(), bool_list) - self.assertTrue( - data2.uint32[ - 0:6] == [ - 1, - 1, - 0, - 0, - 1, - 0], + self.assertEqual( + data2.uint32[0:6], [1, 1, 0, 0, 1, 0], 'unsigned32 data2 = [1, 1, 0, 0, 1, 0]') data2 = lldb.SBData.CreateDataFromSInt64Array( process.GetByteOrder(), process.GetAddressByteSize(), bool_list) - self.assertTrue( - data2.sint64[ - 0:6] == [ - 1, - 1, - 0, - 0, - 1, - 0], + self.assertEqual( + data2.sint64[0:6], [1, 1, 0, 0, 1, 0], 'signed64 data2 = [1, 1, 0, 0, 1, 0]') data2 = lldb.SBData.CreateDataFromUInt64Array( process.GetByteOrder(), process.GetAddressByteSize(), bool_list) - self.assertTrue( - data2.uint64[ - 0:6] == [ - 1, - 1, - 0, - 0, - 1, - 0], + self.assertEqual( + data2.uint64[0:6], [1, 1, 0, 0, 1, 0], 'signed64 data2 = [1, 1, 0, 0, 1, 0]') data2 = lldb.SBData.CreateDataFromDoubleArray( diff --git a/lldb/test/API/python_api/value/TestValueAPI.py b/lldb/test/API/python_api/value/TestValueAPI.py index 98546e8..85d8b49 100644 --- a/lldb/test/API/python_api/value/TestValueAPI.py +++ b/lldb/test/API/python_api/value/TestValueAPI.py @@ -158,10 +158,10 @@ class ValueAPITestCase(TestBase): self.assertFalse(lldb.value(frame0.FindVariable('bogus'))) self.assertTrue(lldb.value(frame0.FindVariable('uinthex'))) - self.assertTrue(int(lldb.value(frame0.FindVariable('uinthex'))) - == 3768803088, 'uinthex == 3768803088') - self.assertTrue(int(lldb.value(frame0.FindVariable('sinthex'))) - == -526164208, 'sinthex == -526164208') + self.assertEqual(int(lldb.value(frame0.FindVariable('uinthex'))), + 3768803088, 'uinthex == 3768803088') + self.assertEqual(int(lldb.value(frame0.FindVariable('sinthex'))), + -526164208, 'sinthex == -526164208') # Check value_iter works correctly. for v in [ @@ -177,11 +177,9 @@ class ValueAPITestCase(TestBase): frame0.FindVariable('sinthex').GetValueAsUnsigned(), 3768803088, 'unsigned sinthex == 3768803088') - self.assertTrue( - frame0.FindVariable('uinthex').GetValueAsSigned() == - - 526164208, + self.assertEqual( + frame0.FindVariable('uinthex').GetValueAsSigned(), -526164208, 'signed uinthex == -526164208') - self.assertTrue( - frame0.FindVariable('sinthex').GetValueAsSigned() == - - 526164208, + self.assertEqual( + frame0.FindVariable('sinthex').GetValueAsSigned(), -526164208, 'signed sinthex == -526164208') diff --git a/lldb/test/API/python_api/value_var_update/TestValueVarUpdate.py b/lldb/test/API/python_api/value_var_update/TestValueVarUpdate.py index cbc9135..88ddce9 100644 --- a/lldb/test/API/python_api/value_var_update/TestValueVarUpdate.py +++ b/lldb/test/API/python_api/value_var_update/TestValueVarUpdate.py @@ -47,8 +47,8 @@ class ValueVarUpdateTestCase(TestBase): if self.TraceOn(): self.runCmd("frame variable") - self.assertTrue( - i_val != i.GetValueAsUnsigned(0), + self.assertNotEqual( + i_val, i.GetValueAsUnsigned(0), "GetValue() is saying a lie") self.assertTrue( i.GetValueDidChange(), diff --git a/lldb/test/API/tools/lldb-vscode/launch/TestVSCode_launch.py b/lldb/test/API/tools/lldb-vscode/launch/TestVSCode_launch.py index e364f7f..6e916d7 100644 --- a/lldb/test/API/tools/lldb-vscode/launch/TestVSCode_launch.py +++ b/lldb/test/API/tools/lldb-vscode/launch/TestVSCode_launch.py @@ -74,8 +74,8 @@ class TestVSCode_launch(lldbvscode_testcase.VSCodeTestCaseBase): body = stopped_event['body'] if 'reason' in body: reason = body['reason'] - self.assertTrue( - reason != 'breakpoint', + self.assertNotEqual( + reason, 'breakpoint', 'verify stop isn\'t "main" breakpoint') @skipIfWindows -- 2.7.4