summaryrefslogtreecommitdiffstats
path: root/lldb/test/python_api
diff options
context:
space:
mode:
authorJohnny Chen <johnny.chen@apple.com>2011-05-24 18:22:45 +0000
committerJohnny Chen <johnny.chen@apple.com>2011-05-24 18:22:45 +0000
commit4ebd019b977b7d0bb5b9dc6fd10562e7a47c8de1 (patch)
tree7c017fb66ee57a8982cf69b765ffa0a1232b034e /lldb/test/python_api
parent97019c709db572b78e5e60a0c4eb13a03de8b709 (diff)
downloadbcm5719-llvm-4ebd019b977b7d0bb5b9dc6fd10562e7a47c8de1.tar.gz
bcm5719-llvm-4ebd019b977b7d0bb5b9dc6fd10562e7a47c8de1.zip
Now that we have added a post-processing step for adding truth value testing to
those lldb objects which implement the IsValid() method, let's change the rest of the test suite to use the more compact truth value testing pattern (the Python way). llvm-svn: 131970
Diffstat (limited to 'lldb/test/python_api')
-rw-r--r--lldb/test/python_api/event/TestEvents.py20
-rw-r--r--lldb/test/python_api/frame/TestFrames.py8
-rw-r--r--lldb/test/python_api/function_symbol/TestDisasmAPI.py12
-rw-r--r--lldb/test/python_api/function_symbol/TestSymbolAPI.py8
-rw-r--r--lldb/test/python_api/interpreter/TestCommandInterpreterAPI.py6
-rw-r--r--lldb/test/python_api/process/TestProcessAPI.py14
-rw-r--r--lldb/test/python_api/symbol-context/TestSymbolContext.py12
-rw-r--r--lldb/test/python_api/target/TestTargetAPI.py16
-rw-r--r--lldb/test/python_api/thread/TestThreadAPI.py24
9 files changed, 60 insertions, 60 deletions
diff --git a/lldb/test/python_api/event/TestEvents.py b/lldb/test/python_api/event/TestEvents.py
index 74da057463c..7b21df16dd0 100644
--- a/lldb/test/python_api/event/TestEvents.py
+++ b/lldb/test/python_api/event/TestEvents.py
@@ -50,12 +50,12 @@ class EventAPITestCase(TestBase):
# Create a target by the debugger.
target = self.dbg.CreateTarget(exe)
- self.assertTrue(target.IsValid(), VALID_TARGET)
+ self.assertTrue(target, VALID_TARGET)
# Now create a breakpoint on main.c by name 'c'.
breakpoint = target.BreakpointCreateByName('c', 'a.out')
#print "breakpoint:", breakpoint
- self.assertTrue(breakpoint.IsValid() and
+ self.assertTrue(breakpoint and
breakpoint.GetNumLocations() == 1,
VALID_BREAKPOINT)
@@ -67,15 +67,15 @@ class EventAPITestCase(TestBase):
self.process = target.Launch (listener, None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, error)
self.process = target.GetProcess()
- self.assertTrue(self.process.IsValid(), PROCESS_IS_VALID)
+ self.assertTrue(self.process, PROCESS_IS_VALID)
# Get a handle on the process's broadcaster.
broadcaster = self.process.GetBroadcaster()
- self.assertTrue(broadcaster.IsValid(), "Process with valid broadcaster")
+ self.assertTrue(broadcaster, "Process with valid broadcaster")
# Create an empty event object.
event = lldb.SBEvent()
- self.assertFalse(event.IsValid(), "Event should not be valid initially")
+ self.assertFalse(event, "Event should not be valid initially")
# Create MyListeningThread to wait for any kind of event.
import threading
@@ -103,7 +103,7 @@ class EventAPITestCase(TestBase):
# Wait until the 'MyListeningThread' terminates.
my_thread.join()
- self.assertTrue(event.IsValid(),
+ self.assertTrue(event,
"My listening thread successfully received an event")
def do_add_listener_to_broadcaster(self):
@@ -112,12 +112,12 @@ class EventAPITestCase(TestBase):
# Create a target by the debugger.
target = self.dbg.CreateTarget(exe)
- self.assertTrue(target.IsValid(), VALID_TARGET)
+ self.assertTrue(target, VALID_TARGET)
# Now create a breakpoint on main.c by name 'c'.
breakpoint = target.BreakpointCreateByName('c', 'a.out')
#print "breakpoint:", breakpoint
- self.assertTrue(breakpoint.IsValid() and
+ self.assertTrue(breakpoint and
breakpoint.GetNumLocations() == 1,
VALID_BREAKPOINT)
@@ -130,11 +130,11 @@ class EventAPITestCase(TestBase):
# Get a handle on the process's broadcaster.
broadcaster = self.process.GetBroadcaster()
- self.assertTrue(broadcaster.IsValid(), "Process with valid broadcaster")
+ self.assertTrue(broadcaster, "Process with valid broadcaster")
# Create an empty event object.
event = lldb.SBEvent()
- self.assertFalse(event.IsValid(), "Event should not be valid initially")
+ self.assertFalse(event, "Event should not be valid initially")
# Create a listener object and register with the broadcaster.
listener = lldb.SBListener("TestEvents.listener")
diff --git a/lldb/test/python_api/frame/TestFrames.py b/lldb/test/python_api/frame/TestFrames.py
index 7e920133abc..053da2453b6 100644
--- a/lldb/test/python_api/frame/TestFrames.py
+++ b/lldb/test/python_api/frame/TestFrames.py
@@ -31,12 +31,12 @@ class FrameAPITestCase(TestBase):
# Create a target by the debugger.
target = self.dbg.CreateTarget(exe)
- self.assertTrue(target.IsValid(), VALID_TARGET)
+ self.assertTrue(target, VALID_TARGET)
# Now create a breakpoint on main.c by name 'c'.
breakpoint = target.BreakpointCreateByName('c', 'a.out')
#print "breakpoint:", breakpoint
- self.assertTrue(breakpoint.IsValid() and
+ self.assertTrue(breakpoint and
breakpoint.GetNumLocations() == 1,
VALID_BREAKPOINT)
@@ -87,10 +87,10 @@ class FrameAPITestCase(TestBase):
# but they should be valid. Uses get_GPRs() from the lldbutil module.
gpr_reg_set = lldbutil.get_GPRs(frame)
pc_value = gpr_reg_set.GetChildMemberWithName("pc")
- self.assertTrue (pc_value.IsValid(), "We should have a valid PC.")
+ self.assertTrue (pc_value, "We should have a valid PC.")
self.assertTrue (int(pc_value.GetValue(frame), 0) == frame.GetPC(), "PC gotten as a value should equal frame's GetPC")
sp_value = gpr_reg_set.GetChildMemberWithName("sp")
- self.assertTrue (sp_value.IsValid(), "We should have a valid Stack Pointer.")
+ self.assertTrue (sp_value, "We should have a valid Stack Pointer.")
self.assertTrue (int(sp_value.GetValue(frame), 0) == frame.GetSP(), "SP gotten as a value should equal frame's GetSP")
print >> session, "---"
diff --git a/lldb/test/python_api/function_symbol/TestDisasmAPI.py b/lldb/test/python_api/function_symbol/TestDisasmAPI.py
index 662860564e1..1ac0d206650 100644
--- a/lldb/test/python_api/function_symbol/TestDisasmAPI.py
+++ b/lldb/test/python_api/function_symbol/TestDisasmAPI.py
@@ -38,17 +38,17 @@ class DisasmAPITestCase(TestBase):
# Create a target by the debugger.
target = self.dbg.CreateTarget(exe)
- self.assertTrue(target.IsValid(), VALID_TARGET)
+ self.assertTrue(target, VALID_TARGET)
# 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.assertTrue(breakpoint1.IsValid() and
+ self.assertTrue(breakpoint1 and
breakpoint1.GetNumLocations() == 1,
VALID_BREAKPOINT)
- self.assertTrue(breakpoint2.IsValid() and
+ self.assertTrue(breakpoint2 and
breakpoint2.GetNumLocations() == 1,
VALID_BREAKPOINT)
@@ -56,7 +56,7 @@ class DisasmAPITestCase(TestBase):
self.process = target.LaunchSimple(None, None, os.getcwd())
self.process = target.GetProcess()
- self.assertTrue(self.process.IsValid(), PROCESS_IS_VALID)
+ self.assertTrue(self.process, PROCESS_IS_VALID)
# Frame #0 should be on self.line1.
self.assertTrue(self.process.GetState() == lldb.eStateStopped)
@@ -72,7 +72,7 @@ class DisasmAPITestCase(TestBase):
# Now call SBTarget.ResolveSymbolContextForAddress() with address1.
context1 = target.ResolveSymbolContextForAddress(address1, lldb.eSymbolContextEverything)
- self.assertTrue(context1.IsValid())
+ self.assertTrue(context1)
if self.TraceOn():
print "context1:", context1
@@ -88,7 +88,7 @@ class DisasmAPITestCase(TestBase):
# Verify that the symbol and the function has the same address range per function 'a'.
symbol = context1.GetSymbol()
function = frame0.GetFunction()
- self.assertTrue(symbol.IsValid() and function.IsValid())
+ self.assertTrue(symbol and function)
disasm_output = lldbutil.disassemble(target, symbol)
if self.TraceOn():
diff --git a/lldb/test/python_api/function_symbol/TestSymbolAPI.py b/lldb/test/python_api/function_symbol/TestSymbolAPI.py
index df3759d436c..913543781bf 100644
--- a/lldb/test/python_api/function_symbol/TestSymbolAPI.py
+++ b/lldb/test/python_api/function_symbol/TestSymbolAPI.py
@@ -38,17 +38,17 @@ class SymbolAPITestCase(TestBase):
# Create a target by the debugger.
target = self.dbg.CreateTarget(exe)
- self.assertTrue(target.IsValid(), VALID_TARGET)
+ self.assertTrue(target, VALID_TARGET)
# 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.assertTrue(breakpoint1.IsValid() and
+ self.assertTrue(breakpoint1 and
breakpoint1.GetNumLocations() == 1,
VALID_BREAKPOINT)
- self.assertTrue(breakpoint2.IsValid() and
+ self.assertTrue(breakpoint2 and
breakpoint2.GetNumLocations() == 1,
VALID_BREAKPOINT)
@@ -56,7 +56,7 @@ class SymbolAPITestCase(TestBase):
self.process = target.LaunchSimple(None, None, os.getcwd())
self.process = target.GetProcess()
- self.assertTrue(self.process.IsValid(), PROCESS_IS_VALID)
+ self.assertTrue(self.process, PROCESS_IS_VALID)
# Frame #0 should be on self.line1.
self.assertTrue(self.process.GetState() == lldb.eStateStopped)
diff --git a/lldb/test/python_api/interpreter/TestCommandInterpreterAPI.py b/lldb/test/python_api/interpreter/TestCommandInterpreterAPI.py
index c448181f988..8620824005c 100644
--- a/lldb/test/python_api/interpreter/TestCommandInterpreterAPI.py
+++ b/lldb/test/python_api/interpreter/TestCommandInterpreterAPI.py
@@ -35,11 +35,11 @@ class CommandInterpreterAPICase(TestBase):
# Create a target by the debugger.
target = self.dbg.CreateTarget(exe)
- self.assertTrue(target.IsValid(), VALID_TARGET)
+ self.assertTrue(target, VALID_TARGET)
# Retrieve the associated command interpreter from our debugger.
ci = self.dbg.GetCommandInterpreter()
- self.assertTrue(ci.IsValid(), VALID_COMMAND_INTERPRETER)
+ self.assertTrue(ci, VALID_COMMAND_INTERPRETER)
# Exercise some APIs....
@@ -61,7 +61,7 @@ class CommandInterpreterAPICase(TestBase):
# Assigning to self.process so it gets cleaned up during test tear down.
self.process = ci.GetProcess()
- self.assertTrue(self.process.IsValid())
+ self.assertTrue(self.process)
import lldbutil
if self.process.GetState() != lldb.eStateStopped:
diff --git a/lldb/test/python_api/process/TestProcessAPI.py b/lldb/test/python_api/process/TestProcessAPI.py
index a2f432afe84..4e014cc3b3e 100644
--- a/lldb/test/python_api/process/TestProcessAPI.py
+++ b/lldb/test/python_api/process/TestProcessAPI.py
@@ -69,10 +69,10 @@ class ProcessAPITestCase(TestBase):
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
target = self.dbg.CreateTarget(exe)
- self.assertTrue(target.IsValid(), VALID_TARGET)
+ self.assertTrue(target, VALID_TARGET)
breakpoint = target.BreakpointCreateByLocation("main.cpp", self.line)
- self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT)
+ self.assertTrue(breakpoint, VALID_BREAKPOINT)
# Launch the process, and do not stop at the entry point.
error = lldb.SBError()
@@ -111,10 +111,10 @@ class ProcessAPITestCase(TestBase):
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
target = self.dbg.CreateTarget(exe)
- self.assertTrue(target.IsValid(), VALID_TARGET)
+ self.assertTrue(target, VALID_TARGET)
breakpoint = target.BreakpointCreateByLocation("main.cpp", self.line)
- self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT)
+ self.assertTrue(breakpoint, VALID_BREAKPOINT)
# Launch the process, and do not stop at the entry point.
error = lldb.SBError()
@@ -162,10 +162,10 @@ class ProcessAPITestCase(TestBase):
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
target = self.dbg.CreateTarget(exe)
- self.assertTrue(target.IsValid(), VALID_TARGET)
+ self.assertTrue(target, VALID_TARGET)
breakpoint = target.BreakpointCreateByLocation("main.cpp", self.line)
- self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT)
+ self.assertTrue(breakpoint, VALID_BREAKPOINT)
# Launch the process, and do not stop at the entry point.
error = lldb.SBError()
@@ -251,7 +251,7 @@ class ProcessAPITestCase(TestBase):
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
target = self.dbg.CreateTarget(exe)
- self.assertTrue(target.IsValid(), VALID_TARGET)
+ self.assertTrue(target, VALID_TARGET)
# Launch the process, and do not stop at the entry point.
error = lldb.SBError()
diff --git a/lldb/test/python_api/symbol-context/TestSymbolContext.py b/lldb/test/python_api/symbol-context/TestSymbolContext.py
index 6213490aea9..88386bcd45f 100644
--- a/lldb/test/python_api/symbol-context/TestSymbolContext.py
+++ b/lldb/test/python_api/symbol-context/TestSymbolContext.py
@@ -37,12 +37,12 @@ class SymbolContextAPITestCase(TestBase):
# Create a target by the debugger.
target = self.dbg.CreateTarget(exe)
- self.assertTrue(target.IsValid(), VALID_TARGET)
+ self.assertTrue(target, VALID_TARGET)
# Now create a breakpoint on main.c by name 'c'.
breakpoint = target.BreakpointCreateByName('c', 'a.out')
#print "breakpoint:", breakpoint
- self.assertTrue(breakpoint.IsValid() and
+ self.assertTrue(breakpoint and
breakpoint.GetNumLocations() == 1,
VALID_BREAKPOINT)
@@ -50,7 +50,7 @@ class SymbolContextAPITestCase(TestBase):
self.process = target.LaunchSimple(None, None, os.getcwd())
self.process = target.GetProcess()
- self.assertTrue(self.process.IsValid(), PROCESS_IS_VALID)
+ self.assertTrue(self.process, PROCESS_IS_VALID)
# Frame #0 should be on self.line.
from lldbutil import get_stopped_thread
@@ -61,7 +61,7 @@ class SymbolContextAPITestCase(TestBase):
# Now get the SBSymbolContext from this frame. We want everything. :-)
context = frame0.GetSymbolContext(lldb.eSymbolContextEverything)
- self.assertTrue(context.IsValid())
+ self.assertTrue(context)
# Get the description of this module.
module = context.GetModule()
@@ -74,11 +74,11 @@ class SymbolContextAPITestCase(TestBase):
substrs = [os.path.join(self.mydir, 'main.c')])
function = context.GetFunction()
- self.assertTrue(function.IsValid())
+ self.assertTrue(function)
#print "function:", function
block = context.GetBlock()
- self.assertTrue(block.IsValid())
+ self.assertTrue(block)
#print "block:", block
lineEntry = context.GetLineEntry()
diff --git a/lldb/test/python_api/target/TestTargetAPI.py b/lldb/test/python_api/target/TestTargetAPI.py
index e72d2e70daa..0de456396c7 100644
--- a/lldb/test/python_api/target/TestTargetAPI.py
+++ b/lldb/test/python_api/target/TestTargetAPI.py
@@ -64,7 +64,7 @@ class TargetAPITestCase(TestBase):
# Create a target by the debugger.
target = self.dbg.CreateTarget(exe)
- self.assertTrue(target.IsValid(), VALID_TARGET)
+ self.assertTrue(target, VALID_TARGET)
from lldbutil import get_description
@@ -91,7 +91,7 @@ class TargetAPITestCase(TestBase):
# Create a target by the debugger.
target = self.dbg.CreateTarget(exe)
- self.assertTrue(target.IsValid(), VALID_TARGET)
+ self.assertTrue(target, VALID_TARGET)
# Add an extra twist of stopping the inferior in a breakpoint, and then continue till it's done.
# We should still see the entire stdout redirected once the process is finished.
@@ -131,17 +131,17 @@ class TargetAPITestCase(TestBase):
# Create a target by the debugger.
target = self.dbg.CreateTarget(exe)
- self.assertTrue(target.IsValid(), VALID_TARGET)
+ self.assertTrue(target, VALID_TARGET)
# 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.assertTrue(breakpoint1.IsValid() and
+ self.assertTrue(breakpoint1 and
breakpoint1.GetNumLocations() == 1,
VALID_BREAKPOINT)
- self.assertTrue(breakpoint2.IsValid() and
+ self.assertTrue(breakpoint2 and
breakpoint2.GetNumLocations() == 1,
VALID_BREAKPOINT)
@@ -149,7 +149,7 @@ class TargetAPITestCase(TestBase):
self.process = target.LaunchSimple(None, None, os.getcwd())
self.process = target.GetProcess()
- self.assertTrue(self.process.IsValid(), PROCESS_IS_VALID)
+ self.assertTrue(self.process, PROCESS_IS_VALID)
# Frame #0 should be on self.line1.
self.assertTrue(self.process.GetState() == lldb.eStateStopped)
@@ -181,14 +181,14 @@ class TargetAPITestCase(TestBase):
context1 = target.ResolveSymbolContextForAddress(address1, lldb.eSymbolContextEverything)
context2 = target.ResolveSymbolContextForAddress(address2, lldb.eSymbolContextEverything)
- self.assertTrue(context1.IsValid() and context2.IsValid())
+ self.assertTrue(context1 and context2)
#print "context1:", context1
#print "context2:", context2
# Verify that the context point to the same function 'a'.
symbol1 = context1.GetSymbol()
symbol2 = context2.GetSymbol()
- self.assertTrue(symbol1.IsValid() and symbol2.IsValid())
+ self.assertTrue(symbol1 and symbol2)
#print "symbol1:", symbol1
#print "symbol2:", symbol2
diff --git a/lldb/test/python_api/thread/TestThreadAPI.py b/lldb/test/python_api/thread/TestThreadAPI.py
index 50bab95c787..aee34f04ea4 100644
--- a/lldb/test/python_api/thread/TestThreadAPI.py
+++ b/lldb/test/python_api/thread/TestThreadAPI.py
@@ -109,10 +109,10 @@ class ThreadAPITestCase(TestBase):
exe = os.path.join(os.getcwd(), "a.out")
target = self.dbg.CreateTarget(exe)
- self.assertTrue(target.IsValid(), VALID_TARGET)
+ self.assertTrue(target, VALID_TARGET)
breakpoint = target.BreakpointCreateByLocation("main.cpp", self.line)
- self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT)
+ self.assertTrue(breakpoint, VALID_BREAKPOINT)
self.runCmd("breakpoint list")
# Launch the process, and do not stop at the entry point.
@@ -131,10 +131,10 @@ class ThreadAPITestCase(TestBase):
exe = os.path.join(os.getcwd(), "a.out")
target = self.dbg.CreateTarget(exe)
- self.assertTrue(target.IsValid(), VALID_TARGET)
+ self.assertTrue(target, VALID_TARGET)
breakpoint = target.BreakpointCreateByLocation("main.cpp", self.line)
- self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT)
+ self.assertTrue(breakpoint, VALID_BREAKPOINT)
#self.runCmd("breakpoint list")
# Launch the process, and do not stop at the entry point.
@@ -156,10 +156,10 @@ class ThreadAPITestCase(TestBase):
exe = os.path.join(os.getcwd(), "a.out")
target = self.dbg.CreateTarget(exe)
- self.assertTrue(target.IsValid(), VALID_TARGET)
+ self.assertTrue(target, VALID_TARGET)
breakpoint = target.BreakpointCreateByName('malloc')
- self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT)
+ self.assertTrue(breakpoint, VALID_BREAKPOINT)
self.runCmd("breakpoint list")
# Launch the process, and do not stop at the entry point.
@@ -189,16 +189,16 @@ class ThreadAPITestCase(TestBase):
exe = os.path.join(os.getcwd(), "a.out")
target = self.dbg.CreateTarget(exe)
- self.assertTrue(target.IsValid(), VALID_TARGET)
+ self.assertTrue(target, VALID_TARGET)
breakpoint = target.BreakpointCreateByLocation('main2.cpp', self.line2)
- self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT)
+ self.assertTrue(breakpoint, VALID_BREAKPOINT)
self.runCmd("breakpoint list")
# Launch the process, and do not stop at the entry point.
self.process = target.LaunchSimple(None, None, os.getcwd())
- self.assertTrue(self.process.IsValid(), PROCESS_IS_VALID)
+ self.assertTrue(self.process, PROCESS_IS_VALID)
# Frame #0 should be on self.line2.
self.assertTrue(self.process.GetState() == lldb.eStateStopped)
@@ -230,16 +230,16 @@ class ThreadAPITestCase(TestBase):
exe = os.path.join(os.getcwd(), "a.out")
target = self.dbg.CreateTarget(exe)
- self.assertTrue(target.IsValid(), VALID_TARGET)
+ self.assertTrue(target, VALID_TARGET)
breakpoint = target.BreakpointCreateByLocation('main2.cpp', self.line2)
- self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT)
+ self.assertTrue(breakpoint, VALID_BREAKPOINT)
self.runCmd("breakpoint list")
# Launch the process, and do not stop at the entry point.
self.process = target.LaunchSimple(None, None, os.getcwd())
- self.assertTrue(self.process.IsValid(), PROCESS_IS_VALID)
+ self.assertTrue(self.process, PROCESS_IS_VALID)
# Frame #0 should be on self.line2.
self.assertTrue(self.process.GetState() == lldb.eStateStopped)
OpenPOWER on IntegriCloud