diff options
| author | Dave Lee <davelee.com@gmail.com> | 2021-02-01 12:01:32 -0800 |
|---|---|---|
| committer | Dave Lee <davelee.com@gmail.com> | 2021-02-02 12:39:03 -0800 |
| commit | 619e2e095fb1cd1e60b745cf1a10af9f67a4cd41 (patch) | |
| tree | 438cb3e839024613694d1fd5f6cd1e2a50654dc7 /lldb/test/API/python_api | |
| parent | ff1147c3635685ba6aefbdc9394300adb5404595 (diff) | |
| download | llvm-619e2e095fb1cd1e60b745cf1a10af9f67a4cd41.zip llvm-619e2e095fb1cd1e60b745cf1a10af9f67a4cd41.tar.gz llvm-619e2e095fb1cd1e60b745cf1a10af9f67a4cd41.tar.bz2 | |
[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
Diffstat (limited to 'lldb/test/API/python_api')
23 files changed, 93 insertions, 92 deletions
diff --git a/lldb/test/API/python_api/disassemble-raw-data/TestDisassembleRawData.py b/lldb/test/API/python_api/disassemble-raw-data/TestDisassembleRawData.py index 49992f4..80b39d2 100644 --- a/lldb/test/API/python_api/disassemble-raw-data/TestDisassembleRawData.py +++ b/lldb/test/API/python_api/disassemble-raw-data/TestDisassembleRawData.py @@ -47,13 +47,13 @@ class DisassembleRawDataTestCase(TestBase): print("Raw bytes: ", [hex(x) for x in raw_bytes]) print("Disassembled%s" % str(inst)) if re.match("mips", arch): - self.assertTrue(inst.GetMnemonic(target) == "move") - self.assertTrue(inst.GetOperands(target) == + self.assertEqual(inst.GetMnemonic(target), "move") + self.assertEqual(inst.GetOperands(target), '$' + "fp, " + '$' + "sp") elif re.match("powerpc64le", arch): - self.assertTrue(inst.GetMnemonic(target) == "li") - self.assertTrue(inst.GetOperands(target) == "4, 0") + self.assertEqual(inst.GetMnemonic(target), "li") + self.assertEqual(inst.GetOperands(target), "4, 0") else: - self.assertTrue(inst.GetMnemonic(target) == "movq") - self.assertTrue(inst.GetOperands(target) == + self.assertEqual(inst.GetMnemonic(target), "movq") + self.assertEqual(inst.GetOperands(target), '%' + "rsp, " + '%' + "rbp") diff --git a/lldb/test/API/python_api/disassemble-raw-data/TestDisassemble_VST1_64.py b/lldb/test/API/python_api/disassemble-raw-data/TestDisassemble_VST1_64.py index fd5c9ec..86c51a2 100644 --- a/lldb/test/API/python_api/disassemble-raw-data/TestDisassemble_VST1_64.py +++ b/lldb/test/API/python_api/disassemble-raw-data/TestDisassemble_VST1_64.py @@ -76,4 +76,4 @@ class Disassemble_VST1_64(TestBase): print("Raw bytes: ", [hex(x) for x in raw_bytes]) print("Disassembled%s" % str(inst)) - self.assertTrue(inst.GetMnemonic(target) == "vst1.64") + self.assertEqual(inst.GetMnemonic(target), "vst1.64") diff --git a/lldb/test/API/python_api/event/TestEvents.py b/lldb/test/API/python_api/event/TestEvents.py index 238e9eb..5816fc3 100644 --- a/lldb/test/API/python_api/event/TestEvents.py +++ b/lldb/test/API/python_api/event/TestEvents.py @@ -315,5 +315,5 @@ class EventAPITestCase(TestBase): my_thread.join() # The final judgement. :-) - self.assertTrue(self.state == 'stopped', + self.assertEqual(self.state, 'stopped', "Both expected state changed events received") diff --git a/lldb/test/API/python_api/frame/TestFrames.py b/lldb/test/API/python_api/frame/TestFrames.py index 1ec66a3d..23de180 100644 --- a/lldb/test/API/python_api/frame/TestFrames.py +++ b/lldb/test/API/python_api/frame/TestFrames.py @@ -38,7 +38,7 @@ class FrameAPITestCase(TestBase): None, None, self.get_process_working_directory()) process = target.GetProcess() - self.assertTrue(process.GetState() == lldb.eStateStopped, + self.assertEqual(process.GetState(), lldb.eStateStopped, PROCESS_STOPPED) # Keeps track of the number of times 'a' is called where it is within a @@ -94,8 +94,9 @@ class FrameAPITestCase(TestBase): sp_value = gpr_reg_set.GetChildMemberWithName("sp") self.assertTrue( sp_value, "We should have a valid Stack Pointer.") - self.assertTrue(int(sp_value.GetValue(), 0) == frame.GetSP( - ), "SP gotten as a value should equal frame's GetSP") + self.assertEqual( + int(sp_value.GetValue(), 0), frame.GetSP(), + "SP gotten as a value should equal frame's GetSP") print("---", file=session) process.Continue() @@ -106,7 +107,7 @@ class FrameAPITestCase(TestBase): PROCESS_EXITED) # Expect to find 'a' on the call stacks two times. - self.assertTrue(callsOfA == 2, + self.assertEqual(callsOfA, 2, "Expect to find 'a' on the call stacks two times") # By design, the 'a' call frame has the following arg vals: # o a((int)val=1, (char)ch='A') @@ -141,7 +142,7 @@ class FrameAPITestCase(TestBase): None, None, self.get_process_working_directory()) process = target.GetProcess() - self.assertTrue(process.GetState() == lldb.eStateStopped, + self.assertEqual(process.GetState(), lldb.eStateStopped, PROCESS_STOPPED) thread = lldbutil.get_stopped_thread( @@ -183,7 +184,7 @@ class FrameAPITestCase(TestBase): None, None, self.get_process_working_directory()) process = target.GetProcess() - self.assertTrue(process.GetState() == lldb.eStateStopped, + self.assertEqual(process.GetState(), lldb.eStateStopped, PROCESS_STOPPED) thread = lldbutil.get_stopped_thread( diff --git a/lldb/test/API/python_api/frame/inlines/TestInlinedFrame.py b/lldb/test/API/python_api/frame/inlines/TestInlinedFrame.py index eb40b4c..46b9b9f 100644 --- a/lldb/test/API/python_api/frame/inlines/TestInlinedFrame.py +++ b/lldb/test/API/python_api/frame/inlines/TestInlinedFrame.py @@ -47,7 +47,7 @@ class InlinedFrameAPITestCase(TestBase): None, None, self.get_process_working_directory()) process = target.GetProcess() - self.assertTrue(process.GetState() == lldb.eStateStopped, + self.assertEqual(process.GetState(), lldb.eStateStopped, PROCESS_STOPPED) import lldbsuite.test.lldbutil as lldbutil @@ -70,7 +70,7 @@ class InlinedFrameAPITestCase(TestBase): frame0 = thread.GetFrameAtIndex(0) if frame0.IsInlined(): filename = frame0.GetLineEntry().GetFileSpec().GetFilename() - self.assertTrue(filename == self.source) + self.assertEqual(filename, self.source) self.expect( stack_traces1, "First stop at %s:%d" % (self.source, self.first_stop), exe=False, substrs=[ @@ -79,7 +79,7 @@ class InlinedFrameAPITestCase(TestBase): # Expect to break again for the second time. process.Continue() - self.assertTrue(process.GetState() == lldb.eStateStopped, + self.assertEqual(process.GetState(), lldb.eStateStopped, PROCESS_STOPPED) stack_traces2 = lldbutil.print_stacktraces( process, string_buffer=True) diff --git a/lldb/test/API/python_api/function_symbol/TestDisasmAPI.py b/lldb/test/API/python_api/function_symbol/TestDisasmAPI.py index 01d26da0..d67798eb 100644 --- a/lldb/test/API/python_api/function_symbol/TestDisasmAPI.py +++ b/lldb/test/API/python_api/function_symbol/TestDisasmAPI.py @@ -53,7 +53,7 @@ class DisasmAPITestCase(TestBase): self.assertTrue(process, PROCESS_IS_VALID) # Frame #0 should be on self.line1. - self.assertTrue(process.GetState() == lldb.eStateStopped) + self.assertEqual(process.GetState(), lldb.eStateStopped) thread = lldbutil.get_stopped_thread( process, lldb.eStopReasonBreakpoint) self.assertTrue( @@ -61,7 +61,7 @@ class DisasmAPITestCase(TestBase): "There should be a thread stopped due to breakpoint condition") frame0 = thread.GetFrameAtIndex(0) lineEntry = frame0.GetLineEntry() - self.assertTrue(lineEntry.GetLine() == self.line1) + self.assertEqual(lineEntry.GetLine(), self.line1) address1 = lineEntry.GetStartAddress() self.trace("address1:", address1) @@ -76,7 +76,7 @@ class DisasmAPITestCase(TestBase): # Continue the inferior, the breakpoint 2 should be hit. process.Continue() - self.assertTrue(process.GetState() == lldb.eStateStopped) + self.assertEqual(process.GetState(), lldb.eStateStopped) thread = lldbutil.get_stopped_thread( process, lldb.eStopReasonBreakpoint) self.assertTrue( @@ -84,7 +84,7 @@ class DisasmAPITestCase(TestBase): "There should be a thread stopped due to breakpoint condition") frame0 = thread.GetFrameAtIndex(0) lineEntry = frame0.GetLineEntry() - self.assertTrue(lineEntry.GetLine() == self.line2) + self.assertEqual(lineEntry.GetLine(), self.line2) # Verify that the symbol and the function has the same address range # per function 'a'. diff --git a/lldb/test/API/python_api/function_symbol/TestSymbolAPI.py b/lldb/test/API/python_api/function_symbol/TestSymbolAPI.py index c5bcb15..09e7db7 100644 --- a/lldb/test/API/python_api/function_symbol/TestSymbolAPI.py +++ b/lldb/test/API/python_api/function_symbol/TestSymbolAPI.py @@ -53,7 +53,7 @@ class SymbolAPITestCase(TestBase): self.assertTrue(process, PROCESS_IS_VALID) # Frame #0 should be on self.line1. - self.assertTrue(process.GetState() == lldb.eStateStopped) + self.assertEqual(process.GetState(), lldb.eStateStopped) thread = lldbutil.get_stopped_thread( process, lldb.eStopReasonBreakpoint) self.assertTrue( @@ -62,7 +62,7 @@ class SymbolAPITestCase(TestBase): frame0 = thread.GetFrameAtIndex(0) symbol_line1 = frame0.GetSymbol() # We should have a symbol type of code. - self.assertTrue(symbol_line1.GetType() == lldb.eSymbolTypeCode) + 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() @@ -70,7 +70,7 @@ class SymbolAPITestCase(TestBase): # Continue the inferior, the breakpoint 2 should be hit. process.Continue() - self.assertTrue(process.GetState() == lldb.eStateStopped) + self.assertEqual(process.GetState(), lldb.eStateStopped) thread = lldbutil.get_stopped_thread( process, lldb.eStopReasonBreakpoint) self.assertTrue( @@ -79,7 +79,7 @@ class SymbolAPITestCase(TestBase): frame0 = thread.GetFrameAtIndex(0) symbol_line2 = frame0.GetSymbol() # We should have a symbol type of code. - self.assertTrue(symbol_line2.GetType() == lldb.eSymbolTypeCode) + 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() diff --git a/lldb/test/API/python_api/lldbutil/frame/TestFrameUtils.py b/lldb/test/API/python_api/lldbutil/frame/TestFrameUtils.py index ec8d1f8..09a179c 100644 --- a/lldb/test/API/python_api/lldbutil/frame/TestFrameUtils.py +++ b/lldb/test/API/python_api/lldbutil/frame/TestFrameUtils.py @@ -40,7 +40,7 @@ class FrameUtilsTestCase(TestBase): if not process: self.fail("SBTarget.LaunchProcess() failed") - self.assertTrue(process.GetState() == lldb.eStateStopped, + self.assertEqual(process.GetState(), lldb.eStateStopped, PROCESS_STOPPED) import lldbsuite.test.lldbutil as lldbutil diff --git a/lldb/test/API/python_api/lldbutil/iter/TestLLDBIterator.py b/lldb/test/API/python_api/lldbutil/iter/TestLLDBIterator.py index 050ec87..0397b0f 100644 --- a/lldb/test/API/python_api/lldbutil/iter/TestLLDBIterator.py +++ b/lldb/test/API/python_api/lldbutil/iter/TestLLDBIterator.py @@ -50,7 +50,7 @@ class LLDBIteratorTestCase(TestBase): for m in target.module_iter(): mine.append(m) - self.assertTrue(len(yours) == len(mine)) + self.assertEqual(len(yours), len(mine)) for i in range(len(yours)): if self.TraceOn(): print("yours[%d]='%s'" % (i, get_description(yours[i]))) @@ -73,7 +73,7 @@ class LLDBIteratorTestCase(TestBase): breakpoint = target.BreakpointCreateByLocation("main.cpp", self.line2) self.assertTrue(breakpoint, VALID_BREAKPOINT) - self.assertTrue(target.GetNumBreakpoints() == 2) + self.assertEqual(target.GetNumBreakpoints(), 2) from lldbsuite.test.lldbutil import get_description yours = [] @@ -83,12 +83,12 @@ class LLDBIteratorTestCase(TestBase): for b in target.breakpoint_iter(): mine.append(b) - self.assertTrue(len(yours) == len(mine)) + self.assertEqual(len(yours), len(mine)) for i in range(len(yours)): if self.TraceOn(): print("yours[%d]='%s'" % (i, get_description(yours[i]))) print("mine[%d]='%s'" % (i, get_description(mine[i]))) - self.assertTrue(yours[i] == mine[i], + self.assertEqual(yours[i], mine[i], "ID of yours[{0}] and mine[{0}] matches".format(i)) @add_test_categories(['pyapi']) @@ -119,7 +119,7 @@ class LLDBIteratorTestCase(TestBase): if thread.GetStopReason() == lldb.eStopReasonBreakpoint: stopped_due_to_breakpoint = True for frame in thread: - self.assertTrue(frame.GetThread().GetThreadID() == ID) + self.assertEqual(frame.GetThread().GetThreadID(), ID) if self.TraceOn(): print(frame) diff --git a/lldb/test/API/python_api/process/io/TestProcessIO.py b/lldb/test/API/python_api/process/io/TestProcessIO.py index 4646c9d..3f210bc 100644 --- a/lldb/test/API/python_api/process/io/TestProcessIO.py +++ b/lldb/test/API/python_api/process/io/TestProcessIO.py @@ -201,7 +201,7 @@ class ProcessIOTestCase(TestBase): threads = lldbutil.get_threads_stopped_at_breakpoint( self.process, self.breakpoint) - self.assertTrue(len(threads) == 1) + self.assertEqual(len(threads), 1) self.thread = threads[0] self.frame = self.thread.frames[0] self.assertTrue(self.frame, "Frame 0 is valid.") @@ -217,7 +217,7 @@ class ProcessIOTestCase(TestBase): # Let process continue so it will exit self.process.Continue() state = self.process.GetState() - self.assertTrue(state == lldb.eStateExited, PROCESS_IS_VALID) + self.assertEqual(state, lldb.eStateExited, PROCESS_IS_VALID) def check_process_output(self, output, error): # Since we launched the process without specifying stdin/out/err, 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 f18b8e3..0e5aa0b 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 @@ -48,11 +48,11 @@ class TestReadMemCString(TestBase): # None object. empty_str = process.ReadCStringFromMemory(empty_str_addr, 2048, err) self.assertTrue(err.Success()) - self.assertTrue(empty_str == "") + self.assertEqual(empty_str, "") one_letter_string = process.ReadCStringFromMemory(one_letter_str_addr, 2048, err) self.assertTrue(err.Success()) - self.assertTrue(one_letter_string == "1") + self.assertEqual(one_letter_string, "1") invalid_memory_string = process.ReadCStringFromMemory(invalid_memory_str_addr, 2048, err) self.assertTrue(err.Fail()) diff --git a/lldb/test/API/python_api/sbdata/TestSBData.py b/lldb/test/API/python_api/sbdata/TestSBData.py index ee04968..16381b8 100644 --- a/lldb/test/API/python_api/sbdata/TestSBData.py +++ b/lldb/test/API/python_api/sbdata/TestSBData.py @@ -30,16 +30,16 @@ class SBDataAPICase(TestBase): data = lldb.SBData() data.SetData(error, addr_data, lldb.eByteOrderBig, 4) addr = data.GetAddress(error, 0) - self.assertTrue(addr == 0x11223344); + self.assertEqual(addr, 0x11223344); data.SetData(error, addr_data, lldb.eByteOrderBig, 8) addr = data.GetAddress(error, 0) - self.assertTrue(addr == 0x1122334455667788); + self.assertEqual(addr, 0x1122334455667788); data.SetData(error, addr_data, lldb.eByteOrderLittle, 4) addr = data.GetAddress(error, 0) - self.assertTrue(addr == 0x44332211); + self.assertEqual(addr, 0x44332211); data.SetData(error, addr_data, lldb.eByteOrderLittle, 8) addr = data.GetAddress(error, 0) - self.assertTrue(addr == 0x8877665544332211); + self.assertEqual(addr, 0x8877665544332211); @add_test_categories(['pyapi']) @skipIfReproducer # SBData::SetData is not instrumented. @@ -146,8 +146,8 @@ class SBDataAPICase(TestBase): self.assertTrue(new_foobar.IsValid()) data = new_foobar.GetData() - self.assertTrue(data.uint32[0] == 8, 'then foo[1].a == 8') - self.assertTrue(data.uint32[1] == 7, 'then foo[1].b == 7') + self.assertEqual(data.uint32[0], 8, 'then foo[1].a == 8') + self.assertEqual(data.uint32[1], 7, 'then foo[1].b == 7') # exploiting that sizeof(uint32) == sizeof(float) self.assertTrue(fabs(data.float[2] - 3.14) < 1, 'foo[1].c == 3.14') @@ -218,7 +218,7 @@ class SBDataAPICase(TestBase): new_object = barfoo.CreateValueFromData( "new_object", data, barfoo.GetType().GetBasicType( lldb.eBasicTypeInt)) - self.assertTrue(new_object.GetValue() == "1", 'new_object == 1') + self.assertEqual(new_object.GetValue(), "1", 'new_object == 1') if data.GetByteOrder() == lldb.eByteOrderBig: data.SetData( @@ -262,12 +262,12 @@ class SBDataAPICase(TestBase): hello_str = "hello!" data2 = lldb.SBData.CreateDataFromCString( process.GetByteOrder(), process.GetAddressByteSize(), hello_str) - self.assertTrue(len(data2.uint8) == len(hello_str)) - self.assertTrue(data2.uint8[0] == 104, 'h == 104') - self.assertTrue(data2.uint8[1] == 101, 'e == 101') - self.assertTrue(data2.uint8[2] == 108, 'l == 108') + self.assertEqual(len(data2.uint8), len(hello_str)) + self.assertEqual(data2.uint8[0], 104, 'h == 104') + self.assertEqual(data2.uint8[1], 101, 'e == 101') + self.assertEqual(data2.uint8[2], 108, 'l == 108') self.assert_data(data2.GetUnsignedInt8, 3, 108) # l - self.assertTrue(data2.uint8[4] == 111, 'o == 111') + self.assertEqual(data2.uint8[4], 111, 'o == 111') self.assert_data(data2.GetUnsignedInt8, 5, 33) # ! uint_lists = [[1, 2, 3, 4, 5], [int(i) for i in [1, 2, 3, 4, 5]]] @@ -415,7 +415,7 @@ class SBDataAPICase(TestBase): data2 = lldb.SBData() data2.SetDataFromCString(hello_str) - self.assertTrue(len(data2.uint8) == len(hello_str)) + self.assertEqual(len(data2.uint8), len(hello_str)) self.assert_data(data2.GetUnsignedInt8, 0, 104) self.assert_data(data2.GetUnsignedInt8, 1, 101) self.assert_data(data2.GetUnsignedInt8, 2, 108) diff --git a/lldb/test/API/python_api/symbol-context/TestSymbolContext.py b/lldb/test/API/python_api/symbol-context/TestSymbolContext.py index cbe4eff..742ecec 100644 --- a/lldb/test/API/python_api/symbol-context/TestSymbolContext.py +++ b/lldb/test/API/python_api/symbol-context/TestSymbolContext.py @@ -49,7 +49,7 @@ class SymbolContextAPITestCase(TestBase): self.assertTrue(thread.IsValid(), "There should be a thread stopped due to breakpoint") frame0 = thread.GetFrameAtIndex(0) - self.assertTrue(frame0.GetLineEntry().GetLine() == self.line) + self.assertEqual(frame0.GetLineEntry().GetLine(), self.line) # Now get the SBSymbolContext from this frame. We want everything. :-) context = frame0.GetSymbolContext(lldb.eSymbolContextEverything) @@ -81,7 +81,7 @@ class SymbolContextAPITestCase(TestBase): "The line entry should have the correct filename", exe=False, substrs=['main.c']) - self.assertTrue(lineEntry.GetLine() == self.line, + self.assertEqual(lineEntry.GetLine(), self.line, "The line entry's line number should match ") symbol = context.GetSymbol() diff --git a/lldb/test/API/python_api/target/TestTargetAPI.py b/lldb/test/API/python_api/target/TestTargetAPI.py index ae9ff12..a8a10e4 100644 --- a/lldb/test/API/python_api/target/TestTargetAPI.py +++ b/lldb/test/API/python_api/target/TestTargetAPI.py @@ -244,11 +244,11 @@ class TargetAPITestCase(TestBase): # Make sure we hit our breakpoint: thread_list = lldbutil.get_threads_stopped_at_breakpoint( process, breakpoint) - self.assertTrue(len(thread_list) == 1) + self.assertEqual(len(thread_list), 1) value_list = target.FindGlobalVariables( 'my_global_var_of_char_type', 3) - self.assertTrue(value_list.GetSize() == 1) + self.assertEqual(value_list.GetSize(), 1) my_global_var = value_list.GetValueAtIndex(0) self.DebugSBValue(my_global_var) self.assertTrue(my_global_var) @@ -267,7 +267,7 @@ class TargetAPITestCase(TestBase): if os.path.normpath(m.GetFileSpec().GetDirectory()) == self.getBuildDir() and m.GetFileSpec().GetFilename() == exe_name: value_list = m.FindGlobalVariables( target, 'my_global_var_of_char_type', 3) - self.assertTrue(value_list.GetSize() == 1) + self.assertEqual(value_list.GetSize(), 1) self.assertTrue( value_list.GetValueAtIndex(0).GetValue() == "'X'") break @@ -296,15 +296,15 @@ class TargetAPITestCase(TestBase): # Try it with a null name: list = target.FindFunctions(None, lldb.eFunctionNameTypeAuto) - self.assertTrue(list.GetSize() == 0) + self.assertEqual(list.GetSize(), 0) list = target.FindFunctions('c', lldb.eFunctionNameTypeAuto) - self.assertTrue(list.GetSize() == 1) + self.assertEqual(list.GetSize(), 1) for sc in list: self.assertTrue( sc.GetModule().GetFileSpec().GetFilename() == exe_name) - self.assertTrue(sc.GetSymbol().GetName() == 'c') + self.assertEqual(sc.GetSymbol().GetName(), 'c') def get_description(self): """Exercise SBTaget.GetDescription() API.""" @@ -422,7 +422,7 @@ class TargetAPITestCase(TestBase): self.assertTrue(process, PROCESS_IS_VALID) # Frame #0 should be on self.line1. - self.assertTrue(process.GetState() == lldb.eStateStopped) + self.assertEqual(process.GetState(), lldb.eStateStopped) thread = lldbutil.get_stopped_thread( process, lldb.eStopReasonBreakpoint) self.assertTrue( @@ -431,13 +431,13 @@ class TargetAPITestCase(TestBase): #self.runCmd("process status") frame0 = thread.GetFrameAtIndex(0) lineEntry = frame0.GetLineEntry() - self.assertTrue(lineEntry.GetLine() == self.line1) + self.assertEqual(lineEntry.GetLine(), self.line1) address1 = lineEntry.GetStartAddress() # Continue the inferior, the breakpoint 2 should be hit. process.Continue() - self.assertTrue(process.GetState() == lldb.eStateStopped) + self.assertEqual(process.GetState(), lldb.eStateStopped) thread = lldbutil.get_stopped_thread( process, lldb.eStopReasonBreakpoint) self.assertTrue( @@ -446,7 +446,7 @@ class TargetAPITestCase(TestBase): #self.runCmd("process status") frame0 = thread.GetFrameAtIndex(0) lineEntry = frame0.GetLineEntry() - self.assertTrue(lineEntry.GetLine() == self.line2) + self.assertEqual(lineEntry.GetLine(), self.line2) address2 = lineEntry.GetStartAddress() diff --git a/lldb/test/API/python_api/thread/TestThreadAPI.py b/lldb/test/API/python_api/thread/TestThreadAPI.py index c97be6c..420510a 100644 --- a/lldb/test/API/python_api/thread/TestThreadAPI.py +++ b/lldb/test/API/python_api/thread/TestThreadAPI.py @@ -203,7 +203,7 @@ class ThreadAPITestCase(TestBase): self.assertTrue(process, PROCESS_IS_VALID) # Frame #0 should be on self.step_out_of_malloc. - self.assertTrue(process.GetState() == lldb.eStateStopped) + self.assertEqual(process.GetState(), lldb.eStateStopped) thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint) self.assertTrue( thread.IsValid(), @@ -211,7 +211,7 @@ class ThreadAPITestCase(TestBase): self.runCmd("thread backtrace") frame0 = thread.GetFrameAtIndex(0) lineEntry = frame0.GetLineEntry() - self.assertTrue(lineEntry.GetLine() == self.step_out_of_malloc) + self.assertEqual(lineEntry.GetLine(), self.step_out_of_malloc) thread.StepOver() thread.StepOver() @@ -222,13 +222,13 @@ class ThreadAPITestCase(TestBase): # main2.cpp. frame0 = thread.GetFrameAtIndex(0) lineEntry = frame0.GetLineEntry() - self.assertTrue(thread.GetStopReason() == lldb.eStopReasonPlanComplete) + self.assertEqual(thread.GetStopReason(), lldb.eStopReasonPlanComplete) # Expected failure with clang as the compiler. # rdar://problem/9223880 # # Which has been fixed on the lldb by compensating for inaccurate line # table information with r140416. - self.assertTrue(lineEntry.GetLine() == self.after_3_step_overs) + self.assertEqual(lineEntry.GetLine(), self.after_3_step_overs) def run_to_address(self, exe_name): """Test Python SBThread.RunToAddress() API.""" @@ -249,7 +249,7 @@ class ThreadAPITestCase(TestBase): self.assertTrue(process, PROCESS_IS_VALID) # Frame #0 should be on self.step_out_of_malloc. - self.assertTrue(process.GetState() == lldb.eStateStopped) + self.assertEqual(process.GetState(), lldb.eStateStopped) thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint) self.assertTrue( thread.IsValid(), @@ -257,7 +257,7 @@ class ThreadAPITestCase(TestBase): self.runCmd("thread backtrace") frame0 = thread.GetFrameAtIndex(0) lineEntry = frame0.GetLineEntry() - self.assertTrue(lineEntry.GetLine() == self.step_out_of_malloc) + self.assertEqual(lineEntry.GetLine(), self.step_out_of_malloc) # Get the start/end addresses for this line entry. start_addr = lineEntry.GetStartAddress().GetLoadAddress(target) diff --git a/lldb/test/API/python_api/type/TestTypeList.py b/lldb/test/API/python_api/type/TestTypeList.py index 359dfe8c..9d4f164 100644 --- a/lldb/test/API/python_api/type/TestTypeList.py +++ b/lldb/test/API/python_api/type/TestTypeList.py @@ -47,7 +47,7 @@ class TypeAndTypeListTestCase(TestBase): self.assertTrue(process, PROCESS_IS_VALID) # Get Frame #0. - self.assertTrue(process.GetState() == lldb.eStateStopped) + self.assertEqual(process.GetState(), lldb.eStateStopped) thread = lldbutil.get_stopped_thread( process, lldb.eStopReasonBreakpoint) self.assertTrue( @@ -113,13 +113,13 @@ class TypeAndTypeListTestCase(TestBase): self.DebugSBType(task_head_type) self.assertTrue(task_head_type.IsPointerType()) - self.assertTrue(task_head_type == task_pointer_type) + self.assertEqual(task_head_type, task_pointer_type) # Get the pointee type of 'task_head'. task_head_pointee_type = task_head_type.GetPointeeType() self.DebugSBType(task_head_pointee_type) - self.assertTrue(task_type == task_head_pointee_type) + self.assertEqual(task_type, task_head_pointee_type) # We'll now get the child member 'id' from 'task_head'. id = task_head.GetChildMemberWithName('id') @@ -130,7 +130,7 @@ class TypeAndTypeListTestCase(TestBase): # SBType.GetBasicType() takes an enum 'BasicType' # (lldb-enumerations.h). int_type = id_type.GetBasicType(lldb.eBasicTypeInt) - self.assertTrue(id_type == int_type) + self.assertEqual(id_type, int_type) # Find 'myint_arr' and check the array element type. myint_arr = frame0.FindVariable('myint_arr') @@ -143,7 +143,7 @@ class TypeAndTypeListTestCase(TestBase): self.DebugSBType(myint_arr_element_type) myint_type = target.FindFirstType('myint') self.DebugSBType(myint_type) - self.assertTrue(myint_arr_element_type == myint_type) + self.assertEqual(myint_arr_element_type, myint_type) # Test enum methods. Requires DW_AT_enum_class which was added in Dwarf 4. if configuration.dwarf_version >= 4: diff --git a/lldb/test/API/python_api/value/TestValueAPI.py b/lldb/test/API/python_api/value/TestValueAPI.py index bf8cbe3..d6fff9b 100644 --- a/lldb/test/API/python_api/value/TestValueAPI.py +++ b/lldb/test/API/python_api/value/TestValueAPI.py @@ -46,7 +46,7 @@ class ValueAPITestCase(TestBase): self.assertTrue(process, PROCESS_IS_VALID) # Get Frame #0. - self.assertTrue(process.GetState() == lldb.eStateStopped) + self.assertEqual(process.GetState(), lldb.eStateStopped) thread = lldbutil.get_stopped_thread( process, lldb.eStopReasonBreakpoint) self.assertTrue( @@ -79,14 +79,14 @@ class ValueAPITestCase(TestBase): list = target.FindGlobalVariables('weekdays', 1) weekdays = list.GetValueAtIndex(0) self.assertTrue(weekdays, VALID_VARIABLE) - self.assertTrue(weekdays.GetNumChildren() == 5, VALID_VARIABLE) + self.assertEqual(weekdays.GetNumChildren(), 5, VALID_VARIABLE) self.DebugSBValue(weekdays) # Get global variable 'g_table'. list = target.FindGlobalVariables('g_table', 1) g_table = list.GetValueAtIndex(0) self.assertTrue(g_table, VALID_VARIABLE) - self.assertTrue(g_table.GetNumChildren() == 2, VALID_VARIABLE) + self.assertEqual(g_table.GetNumChildren(), 2, VALID_VARIABLE) self.DebugSBValue(g_table) fmt = lldbutil.BasicFormatter() @@ -126,9 +126,9 @@ class ValueAPITestCase(TestBase): # Verify the SBValue::GetByteSize() API is working correctly. arch = self.getArchitecture() if arch == 'i386': - self.assertTrue(value.GetByteSize() == 4) + self.assertEqual(value.GetByteSize(), 4) elif arch == 'x86_64': - self.assertTrue(value.GetByteSize() == 8) + self.assertEqual(value.GetByteSize(), 8) # Get child at index 5 => 'Friday'. child = value.GetChildAtIndex(5, lldb.eNoDynamicValues, True) diff --git a/lldb/test/API/python_api/value/linked_list/TestValueAPILinkedList.py b/lldb/test/API/python_api/value/linked_list/TestValueAPILinkedList.py index b45186a..f01ce03 100644 --- a/lldb/test/API/python_api/value/linked_list/TestValueAPILinkedList.py +++ b/lldb/test/API/python_api/value/linked_list/TestValueAPILinkedList.py @@ -50,7 +50,7 @@ class ValueAsLinkedListTestCase(TestBase): self.assertTrue(process, PROCESS_IS_VALID) # Get Frame #0. - self.assertTrue(process.GetState() == lldb.eStateStopped) + self.assertEqual(process.GetState(), lldb.eStateStopped) thread = lldbutil.get_stopped_thread( process, lldb.eStopReasonBreakpoint) self.assertTrue( @@ -80,7 +80,7 @@ class ValueAsLinkedListTestCase(TestBase): # Sanity checks that the we visited all the items (no more, no less). if self.TraceOn(): print("visited IDs:", list) - self.assertTrue(visitedIDs == list) + self.assertEqual(visitedIDs, list) # Let's exercise the linked_list_iter() API again, this time supplying # our end of list test function. @@ -111,7 +111,7 @@ class ValueAsLinkedListTestCase(TestBase): # Sanity checks that the we visited all the items (no more, no less). if self.TraceOn(): print("visited IDs:", list) - self.assertTrue(visitedIDs == list) + self.assertEqual(visitedIDs, list) # Get variable 'empty_task_head'. empty_task_head = frame0.FindVariable('empty_task_head') @@ -125,7 +125,7 @@ class ValueAsLinkedListTestCase(TestBase): print(cvf.format(t)) list.append(int(t.GetChildMemberWithName("id").GetValue())) - self.assertTrue(len(list) == 0) + self.assertEqual(len(list), 0) # Get variable 'task_evil'. task_evil = frame0.FindVariable('task_evil') @@ -139,4 +139,4 @@ class ValueAsLinkedListTestCase(TestBase): print(cvf.format(t)) list.append(int(t.GetChildMemberWithName("id").GetValue())) - self.assertTrue(len(list) == 3) + self.assertEqual(len(list), 3) diff --git a/lldb/test/API/python_api/watchpoint/TestSetWatchpoint.py b/lldb/test/API/python_api/watchpoint/TestSetWatchpoint.py index 49ecf7a..9ac5d83 100644 --- a/lldb/test/API/python_api/watchpoint/TestSetWatchpoint.py +++ b/lldb/test/API/python_api/watchpoint/TestSetWatchpoint.py @@ -49,7 +49,7 @@ class SetWatchpointAPITestCase(TestBase): # We should be stopped due to the breakpoint. Get frame #0. process = target.GetProcess() - self.assertTrue(process.GetState() == lldb.eStateStopped, + self.assertEqual(process.GetState(), lldb.eStateStopped, PROCESS_STOPPED) thread = lldbutil.get_stopped_thread( process, lldb.eStopReasonBreakpoint) diff --git a/lldb/test/API/python_api/watchpoint/TestWatchpointIter.py b/lldb/test/API/python_api/watchpoint/TestWatchpointIter.py index 44df96b..1a001f99 100644 --- a/lldb/test/API/python_api/watchpoint/TestWatchpointIter.py +++ b/lldb/test/API/python_api/watchpoint/TestWatchpointIter.py @@ -52,7 +52,7 @@ class WatchpointIteratorTestCase(TestBase): # We should be stopped due to the breakpoint. Get frame #0. process = target.GetProcess() - self.assertTrue(process.GetState() == lldb.eStateStopped, + self.assertEqual(process.GetState(), lldb.eStateStopped, PROCESS_STOPPED) thread = lldbutil.get_stopped_thread( process, lldb.eStopReasonBreakpoint) @@ -71,7 +71,7 @@ class WatchpointIteratorTestCase(TestBase): self.HideStdout() # There should be only 1 watchpoint location under the target. - self.assertTrue(target.GetNumWatchpoints() == 1) + self.assertEqual(target.GetNumWatchpoints(), 1) self.assertTrue(watchpoint.IsEnabled()) watch_id = watchpoint.GetID() self.assertTrue(watch_id != 0) @@ -105,7 +105,7 @@ class WatchpointIteratorTestCase(TestBase): # Now disable the 'rw' watchpoint. The program won't stop when it reads # 'global' next. watchpoint.SetEnabled(False) - self.assertTrue(watchpoint.GetHardwareIndex() == -1) + self.assertEqual(watchpoint.GetHardwareIndex(), -1) self.assertFalse(watchpoint.IsEnabled()) # Continue. The program does not stop again when the variable is being @@ -120,6 +120,6 @@ class WatchpointIteratorTestCase(TestBase): # Verify some vital statistics and exercise the iterator API. for watchpoint in target.watchpoint_iter(): self.assertTrue(watchpoint) - self.assertTrue(watchpoint.GetWatchSize() == 4) - self.assertTrue(watchpoint.GetHitCount() == 1) + self.assertEqual(watchpoint.GetWatchSize(), 4) + self.assertEqual(watchpoint.GetHitCount(), 1) print(watchpoint) diff --git a/lldb/test/API/python_api/watchpoint/condition/TestWatchpointConditionAPI.py b/lldb/test/API/python_api/watchpoint/condition/TestWatchpointConditionAPI.py index 7334734..847f678 100644 --- a/lldb/test/API/python_api/watchpoint/condition/TestWatchpointConditionAPI.py +++ b/lldb/test/API/python_api/watchpoint/condition/TestWatchpointConditionAPI.py @@ -54,7 +54,7 @@ class WatchpointConditionAPITestCase(TestBase): # We should be stopped due to the breakpoint. Get frame #0. process = target.GetProcess() - self.assertTrue(process.GetState() == lldb.eStateStopped, + self.assertEqual(process.GetState(), lldb.eStateStopped, PROCESS_STOPPED) thread = lldbutil.get_stopped_thread( process, lldb.eStopReasonBreakpoint) @@ -92,4 +92,4 @@ class WatchpointConditionAPITestCase(TestBase): self.DebugSBValue(value) # Verify that the condition is met. - self.assertTrue(value.GetValueAsUnsigned() == 5) + self.assertEqual(value.GetValueAsUnsigned(), 5) diff --git a/lldb/test/API/python_api/watchpoint/watchlocation/TestSetWatchlocation.py b/lldb/test/API/python_api/watchpoint/watchlocation/TestSetWatchlocation.py index 9cbc396..0b59e8d 100644 --- a/lldb/test/API/python_api/watchpoint/watchlocation/TestSetWatchlocation.py +++ b/lldb/test/API/python_api/watchpoint/watchlocation/TestSetWatchlocation.py @@ -50,7 +50,7 @@ class SetWatchlocationAPITestCase(TestBase): # We should be stopped due to the breakpoint. Get frame #0. process = target.GetProcess() - self.assertTrue(process.GetState() == lldb.eStateStopped, + self.assertEqual(process.GetState(), lldb.eStateStopped, PROCESS_STOPPED) thread = lldbutil.get_stopped_thread( process, lldb.eStopReasonBreakpoint) diff --git a/lldb/test/API/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py b/lldb/test/API/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py index 53e794d..02632cb 100644 --- a/lldb/test/API/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py +++ b/lldb/test/API/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py @@ -49,7 +49,7 @@ class TargetWatchAddressAPITestCase(TestBase): # We should be stopped due to the breakpoint. Get frame #0. process = target.GetProcess() - self.assertTrue(process.GetState() == lldb.eStateStopped, + self.assertEqual(process.GetState(), lldb.eStateStopped, PROCESS_STOPPED) thread = lldbutil.get_stopped_thread( process, lldb.eStopReasonBreakpoint) @@ -124,7 +124,7 @@ class TargetWatchAddressAPITestCase(TestBase): # We should be stopped due to the breakpoint. Get frame #0. process = target.GetProcess() - self.assertTrue(process.GetState() == lldb.eStateStopped, + self.assertEqual(process.GetState(), lldb.eStateStopped, PROCESS_STOPPED) thread = lldbutil.get_stopped_thread( process, lldb.eStopReasonBreakpoint) |
