Add test cases to exercise the SBThread.GetProcess() API. We launch the process using the

SBTarget.Launch() API, stop at a breakpoint, get the stopped thread, and verify that the
pid of the stopped thread's process is equal to the pid of the process returned by
SBTarget.Launch().

llvm-svn: 127444
This commit is contained in:
Johnny Chen
2011-03-11 01:16:03 +00:00
parent d025498271
commit fdc94ff97e

View File

@@ -12,6 +12,19 @@ class ThreadAPITestCase(TestBase):
mydir = os.path.join("python_api", "thread")
@unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
@python_api_test
def test_get_process_with_dsym(self):
"""Test Python SBThread.GetProcess() API."""
self.buildDsym()
self.get_process()
@python_api_test
def test_get_process_with_dwarf(self):
"""Test Python SBThread.GetProcess() API."""
self.buildDwarf()
self.get_process()
@unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
@python_api_test
def test_get_stop_description_with_dsym(self):
@@ -25,6 +38,25 @@ class ThreadAPITestCase(TestBase):
self.buildDwarf()
self.get_stop_description()
@unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
@python_api_test
def test_run_to_address_with_dsym(self):
"""Test Python SBThread.RunToAddress() API."""
# We build a different executable than the default buildDwarf() does.
d = {'CXX_SOURCES': 'main2.cpp'}
self.buildDsym(dictionary=d)
self.setTearDownCleanup(dictionary=d)
self.run_to_address()
@python_api_test
def test_run_to_address_with_dwarf(self):
"""Test Python SBThread.RunToAddress() API."""
# We build a different executable than the default buildDwarf() does.
d = {'CXX_SOURCES': 'main2.cpp'}
self.buildDwarf(dictionary=d)
self.setTearDownCleanup(dictionary=d)
self.run_to_address()
@unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
@python_api_test
def test_step_out_of_malloc_into_function_b_with_dsym(self):
@@ -72,8 +104,32 @@ class ThreadAPITestCase(TestBase):
self.line2 = line_number("main2.cpp", "// thread step-out of malloc into function b.")
self.line3 = line_number("main2.cpp", "// we should reach here after 3 step-over's.")
def get_process(self):
"""Test Python SBThread.GetProcess() API."""
exe = os.path.join(os.getcwd(), "a.out")
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
target = self.dbg.CreateTarget(exe)
self.assertTrue(target.IsValid(), VALID_TARGET)
breakpoint = target.BreakpointCreateByLocation("main.cpp", self.line)
self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT)
self.runCmd("breakpoint list")
# Launch the process, and do not stop at the entry point.
error = lldb.SBError()
self.process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, error)
thread = get_stopped_thread(self.process, lldb.eStopReasonBreakpoint)
self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint")
self.runCmd("process status")
proc_of_thread = thread.GetProcess()
#print "proc_of_thread:", proc_of_thread
self.assertTrue(proc_of_thread.GetProcessID() == self.process.GetProcessID())
def get_stop_description(self):
"""Test Python SBProcess.ReadMemory() API."""
"""Test Python SBThread.GetStopDescription() API."""
exe = os.path.join(os.getcwd(), "a.out")
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
@@ -172,7 +228,7 @@ class ThreadAPITestCase(TestBase):
self.assertTrue(thread.GetStopReason() == lldb.eStopReasonPlanComplete)
self.assertTrue(lineEntry.GetLine() == self.line3)
def test_run_to_address(self):
def run_to_address(self):
"""Test Python SBThread.RunToAddress() API."""
# We build a different executable than the default buildDwarf() does.
d = {'CXX_SOURCES': 'main2.cpp'}