diff options
| author | Jonas Devlieghere <jonas@devlieghere.com> | 2020-05-25 10:59:39 -0700 |
|---|---|---|
| committer | Jonas Devlieghere <jonas@devlieghere.com> | 2020-05-25 11:11:46 -0700 |
| commit | b321b429416ec51691a3c5372cb59912bded5f08 (patch) | |
| tree | bd51fd5ca6cdd24d345e9eb93b1c1d4c7932c441 /lldb/test/API/python_api | |
| parent | 5bf2409a4e4d23018ecffe4eff39988a957e76f7 (diff) | |
| download | llvm-b321b429416ec51691a3c5372cb59912bded5f08.zip llvm-b321b429416ec51691a3c5372cb59912bded5f08.tar.gz llvm-b321b429416ec51691a3c5372cb59912bded5f08.tar.bz2 | |
[lldb/Test] Add a trace method to replace print statements.
Many tests use (commented out) print statement for debugging the test
itself. This patch adds a new trace method to lldbtest to reuse the
existing tracing infrastructure and replace these print statements.
Differential revision: https://reviews.llvm.org/D80448
Diffstat (limited to 'lldb/test/API/python_api')
8 files changed, 31 insertions, 35 deletions
diff --git a/lldb/test/API/python_api/breakpoint/TestBreakpointAPI.py b/lldb/test/API/python_api/breakpoint/TestBreakpointAPI.py index dd57846..1c0c334 100644 --- a/lldb/test/API/python_api/breakpoint/TestBreakpointAPI.py +++ b/lldb/test/API/python_api/breakpoint/TestBreakpointAPI.py @@ -25,7 +25,7 @@ class BreakpointAPITestCase(TestBase): # Now create a breakpoint on main.c by name 'AFunction'. breakpoint = target.BreakpointCreateByName('AFunction', 'a.out') - #print("breakpoint:", breakpoint) + self.trace("breakpoint:", breakpoint) self.assertTrue(breakpoint and breakpoint.GetNumLocations() == 1, VALID_BREAKPOINT) @@ -59,7 +59,7 @@ class BreakpointAPITestCase(TestBase): # Now create a breakpoint on main.c by name 'AFunction'. breakpoint = target.BreakpointCreateByName('AFunction', 'a.out') - #print("breakpoint:", breakpoint) + self.trace("breakpoint:", breakpoint) self.assertTrue(breakpoint and breakpoint.GetNumLocations() == 1, VALID_BREAKPOINT) diff --git a/lldb/test/API/python_api/event/TestEvents.py b/lldb/test/API/python_api/event/TestEvents.py index 97ebe8f..62ed195 100644 --- a/lldb/test/API/python_api/event/TestEvents.py +++ b/lldb/test/API/python_api/event/TestEvents.py @@ -135,7 +135,7 @@ class EventAPITestCase(TestBase): # Now create a breakpoint on main.c by name 'c'. breakpoint = target.BreakpointCreateByName('c', 'a.out') - #print("breakpoint:", breakpoint) + self.trace("breakpoint:", breakpoint) self.assertTrue(breakpoint and breakpoint.GetNumLocations() == 1, VALID_BREAKPOINT) @@ -171,9 +171,9 @@ class EventAPITestCase(TestBase): # Let's only try at most 3 times to retrieve any kind of event. while not count > 3: if listener.WaitForEvent(5, event): - #print("Got a valid event:", event) - #print("Event data flavor:", event.GetDataFlavor()) - #print("Event type:", lldbutil.state_type_to_str(event.GetType())) + self.trace("Got a valid event:", event) + self.trace("Event data flavor:", event.GetDataFlavor()) + self.trace("Event type:", lldbutil.state_type_to_str(event.GetType())) listener.Clear() return count = count + 1 @@ -215,7 +215,7 @@ class EventAPITestCase(TestBase): # Now create a breakpoint on main.c by name 'c'. breakpoint = target.BreakpointCreateByName('c', 'a.out') - #print("breakpoint:", breakpoint) + self.trace("breakpoint:", breakpoint) self.assertTrue(breakpoint and breakpoint.GetNumLocations() == 1, VALID_BREAKPOINT) @@ -256,7 +256,7 @@ class EventAPITestCase(TestBase): class MyListeningThread(threading.Thread): def run(self): - #print("Running MyListeningThread:", self) + self.trace("Running MyListeningThread:", self) # Regular expression pattern for the event description. pattern = re.compile("data = {.*, state = (.*)}$") @@ -266,7 +266,7 @@ class EventAPITestCase(TestBase): while True: if listener.WaitForEvent(5, event): desc = lldbutil.get_description(event) - #print("Event description:", desc) + self.trace("Event description:", desc) match = pattern.search(desc) if not match: break diff --git a/lldb/test/API/python_api/frame/TestFrames.py b/lldb/test/API/python_api/frame/TestFrames.py index 6d4b7b5..1ec66a3d 100644 --- a/lldb/test/API/python_api/frame/TestFrames.py +++ b/lldb/test/API/python_api/frame/TestFrames.py @@ -28,7 +28,7 @@ class FrameAPITestCase(TestBase): # Now create a breakpoint on main.c by name 'c'. breakpoint = target.BreakpointCreateByName('c', 'a.out') - #print("breakpoint:", breakpoint) + self.trace("breakpoint:", breakpoint) self.assertTrue(breakpoint and breakpoint.GetNumLocations() == 1, VALID_BREAKPOINT) @@ -131,7 +131,7 @@ class FrameAPITestCase(TestBase): # Now create a breakpoint on main.c by name 'c'. breakpoint = target.BreakpointCreateByName('c', 'a.out') - #print("breakpoint:", breakpoint) + self.trace("breakpoint:", breakpoint) self.assertTrue(breakpoint and breakpoint.GetNumLocations() == 1, VALID_BREAKPOINT) @@ -173,7 +173,7 @@ class FrameAPITestCase(TestBase): # Now create a breakpoint on main.c by name 'c'. breakpoint = target.BreakpointCreateByName('c', 'a.out') - #print("breakpoint:", breakpoint) + self.trace("breakpoint:", breakpoint) self.assertTrue(breakpoint and breakpoint.GetNumLocations() == 1, VALID_BREAKPOINT) diff --git a/lldb/test/API/python_api/frame/inlines/TestInlinedFrame.py b/lldb/test/API/python_api/frame/inlines/TestInlinedFrame.py index da4e9cb..eb40b4c 100644 --- a/lldb/test/API/python_api/frame/inlines/TestInlinedFrame.py +++ b/lldb/test/API/python_api/frame/inlines/TestInlinedFrame.py @@ -37,7 +37,7 @@ class InlinedFrameAPITestCase(TestBase): # Now create a breakpoint on main.c by the name of 'inner_inline'. breakpoint = target.BreakpointCreateByName('inner_inline', 'a.out') - #print("breakpoint:", breakpoint) + self.trace("breakpoint:", breakpoint) self.assertTrue(breakpoint and breakpoint.GetNumLocations() > 1, VALID_BREAKPOINT) diff --git a/lldb/test/API/python_api/function_symbol/TestDisasmAPI.py b/lldb/test/API/python_api/function_symbol/TestDisasmAPI.py index 2278d69..01d26da0 100644 --- a/lldb/test/API/python_api/function_symbol/TestDisasmAPI.py +++ b/lldb/test/API/python_api/function_symbol/TestDisasmAPI.py @@ -38,8 +38,8 @@ class DisasmAPITestCase(TestBase): # Now create the two breakpoints inside function 'a'. breakpoint1 = target.BreakpointCreateByLocation('main.c', self.line1) breakpoint2 = target.BreakpointCreateByLocation('main.c', self.line2) - #print("breakpoint1:", breakpoint1) - #print("breakpoint2:", breakpoint2) + self.trace("breakpoint1:", breakpoint1) + self.trace("breakpoint2:", breakpoint2) self.assertTrue(breakpoint1 and breakpoint1.GetNumLocations() == 1, VALID_BREAKPOINT) @@ -64,7 +64,7 @@ class DisasmAPITestCase(TestBase): self.assertTrue(lineEntry.GetLine() == self.line1) address1 = lineEntry.GetStartAddress() - #print("address1:", address1) + self.trace("address1:", address1) # Now call SBTarget.ResolveSymbolContextForAddress() with address1. context1 = target.ResolveSymbolContextForAddress( @@ -103,15 +103,11 @@ class DisasmAPITestCase(TestBase): print("disassembly=>\n", disasm_output) sa1 = symbol.GetStartAddress() - #print("sa1:", sa1) - #print("sa1.GetFileAddress():", hex(sa1.GetFileAddress())) - #ea1 = symbol.GetEndAddress() - #print("ea1:", ea1) + self.trace("sa1:", sa1) + self.trace("sa1.GetFileAddress():", hex(sa1.GetFileAddress())) sa2 = function.GetStartAddress() - #print("sa2:", sa2) - #print("sa2.GetFileAddress():", hex(sa2.GetFileAddress())) - #ea2 = function.GetEndAddress() - #print("ea2:", ea2) + self.trace("sa2:", sa2) + self.trace("sa2.GetFileAddress():", hex(sa2.GetFileAddress())) self.assertTrue(sa1 and sa2 and sa1 == sa2, "The two starting addresses should be the same") diff --git a/lldb/test/API/python_api/function_symbol/TestSymbolAPI.py b/lldb/test/API/python_api/function_symbol/TestSymbolAPI.py index 56fa73c..c5bcb15 100644 --- a/lldb/test/API/python_api/function_symbol/TestSymbolAPI.py +++ b/lldb/test/API/python_api/function_symbol/TestSymbolAPI.py @@ -38,8 +38,8 @@ class SymbolAPITestCase(TestBase): # Now create the two breakpoints inside function 'a'. breakpoint1 = target.BreakpointCreateByLocation('main.c', self.line1) breakpoint2 = target.BreakpointCreateByLocation('main.c', self.line2) - #print("breakpoint1:", breakpoint1) - #print("breakpoint2:", breakpoint2) + self.trace("breakpoint1:", breakpoint1) + self.trace("breakpoint2:", breakpoint2) self.assertTrue(breakpoint1 and breakpoint1.GetNumLocations() == 1, VALID_BREAKPOINT) diff --git a/lldb/test/API/python_api/target/TestTargetAPI.py b/lldb/test/API/python_api/target/TestTargetAPI.py index c5b9605..0167547 100644 --- a/lldb/test/API/python_api/target/TestTargetAPI.py +++ b/lldb/test/API/python_api/target/TestTargetAPI.py @@ -359,8 +359,8 @@ class TargetAPITestCase(TestBase): # Now create the two breakpoints inside function 'a'. breakpoint1 = target.BreakpointCreateByLocation('main.c', self.line1) breakpoint2 = target.BreakpointCreateByLocation('main.c', self.line2) - #print("breakpoint1:", breakpoint1) - #print("breakpoint2:", breakpoint2) + self.trace("breakpoint1:", breakpoint1) + self.trace("breakpoint2:", breakpoint2) self.assertTrue(breakpoint1 and breakpoint1.GetNumLocations() == 1, VALID_BREAKPOINT) @@ -402,8 +402,8 @@ class TargetAPITestCase(TestBase): address2 = lineEntry.GetStartAddress() - #print("address1:", address1) - #print("address2:", address2) + self.trace("address1:", address1) + self.trace("address2:", address2) # Now call SBTarget.ResolveSymbolContextForAddress() with the addresses # from our line entry. @@ -413,15 +413,15 @@ class TargetAPITestCase(TestBase): address2, lldb.eSymbolContextEverything) self.assertTrue(context1 and context2) - #print("context1:", context1) - #print("context2:", context2) + self.trace("context1:", context1) + self.trace("context2:", context2) # Verify that the context point to the same function 'a'. symbol1 = context1.GetSymbol() symbol2 = context2.GetSymbol() self.assertTrue(symbol1 and symbol2) - #print("symbol1:", symbol1) - #print("symbol2:", symbol2) + self.trace("symbol1:", symbol1) + self.trace("symbol2:", symbol2) from lldbsuite.test.lldbutil import get_description desc1 = get_description(symbol1) diff --git a/lldb/test/API/python_api/thread/TestThreadAPI.py b/lldb/test/API/python_api/thread/TestThreadAPI.py index 144f062..2101527 100644 --- a/lldb/test/API/python_api/thread/TestThreadAPI.py +++ b/lldb/test/API/python_api/thread/TestThreadAPI.py @@ -100,7 +100,7 @@ class ThreadAPITestCase(TestBase): self.runCmd("process status") proc_of_thread = thread.GetProcess() - #print("proc_of_thread:", proc_of_thread) + self.trace("proc_of_thread:", proc_of_thread) self.assertTrue(proc_of_thread.GetProcessID() == process.GetProcessID()) |
