It speeds up running the full test suite on my HP z620 Ubuntu machine with 32 hyperthreaded CPUs from 11 minutes to about 1m13s (about 9x). The default behavior is to run single-threaded as before. If the environment variable LLDB_TEST_THREADS is set, a Python work queue is set up with that many worker threads. To avoid collisions within a test directory where multiple tests make use of the same prebuilt executable, the unit of work for the worker threads is a single directory (that is, all tests within a directory are processed in the normal serial way by a single thread). tfiala & I have run this way a number of times; the only issue I found was that the TestProcessAttach.py test failed once, when attempting to attach to the process "a.out" by name. I assume this is because some other thread was running an executable of that name at the same time, and we were attempting to attach to the wrong one, so I changed that test to use a different executable name (that change is also included in this commit). llvm-svn: 203180
86 lines
2.2 KiB
Python
86 lines
2.2 KiB
Python
"""
|
|
Test process attach.
|
|
"""
|
|
|
|
import os, time
|
|
import unittest2
|
|
import lldb
|
|
from lldbtest import *
|
|
import lldbutil
|
|
|
|
exe_name = "ProcessAttach" # Must match Makefile
|
|
|
|
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(), exe_name)
|
|
|
|
# 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(), exe_name)
|
|
|
|
# Spawn a new process
|
|
popen = self.spawnSubprocess(exe)
|
|
self.addTearDownHook(self.cleanupSubprocesses)
|
|
|
|
self.runCmd("process attach -n " + exe_name)
|
|
|
|
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()
|