Files
clang-p2996/lldb/test/functionalities/process_attach/TestProcessAttach.py
Greg Clayton 4570d3eba0 Massive test suite cleanup to stop everyone from manually having to compute "mydir" inside each test case.
This has led to many test suite failures because of copy and paste where new test cases were based off of other test cases and the "mydir" variable wasn't updated.

Now you can call your superclasses "compute_mydir()" function with "__file__" as the sole argument and the relative path will be computed for you. 

llvm-svn: 196985
2013-12-10 23:19:29 +00:00

84 lines
2.1 KiB
Python

"""
Test process attach.
"""
import os, time
import unittest2
import lldb
from lldbtest import *
import lldbutil
class ProcessAttachTestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
@unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
@dsym_test
def test_attach_to_process_by_id_with_dsym(self):
"""Test attach by process id"""
self.buildDsym()
self.process_attach_by_id()
@dwarf_test
def test_attach_to_process_by_id_with_dwarf(self):
"""Test attach by process id"""
self.buildDwarf()
self.process_attach_by_id()
@unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
@dsym_test
def test_attach_to_process_by_name_with_dsym(self):
"""Test attach by process name"""
self.buildDsym()
self.process_attach_by_name()
@dwarf_test
def test_attach_to_process_by_name_with_dwarf(self):
"""Test attach by process name"""
self.buildDwarf()
self.process_attach_by_name()
def setUp(self):
# Call super's setUp().
TestBase.setUp(self)
def process_attach_by_id(self):
"""Test attach by process id"""
exe = os.path.join(os.getcwd(), "a.out")
# Spawn a new process
popen = self.spawnSubprocess(exe)
self.addTearDownHook(self.cleanupSubprocesses)
self.runCmd("process attach -p " + str(popen.pid))
target = self.dbg.GetSelectedTarget()
process = target.GetProcess()
self.assertTrue(process, PROCESS_IS_VALID)
def process_attach_by_name(self):
"""Test attach by process name"""
exe = os.path.join(os.getcwd(), "a.out")
# Spawn a new process
popen = self.spawnSubprocess(exe)
self.addTearDownHook(self.cleanupSubprocesses)
self.runCmd("process attach -n a.out")
target = self.dbg.GetSelectedTarget()
process = target.GetProcess()
self.assertTrue(process, PROCESS_IS_VALID)
if __name__ == '__main__':
import atexit
lldb.SBDebugger.Initialize()
atexit.register(lambda: lldb.SBDebugger.Terminate())
unittest2.main()