[lldb/Test] Remove custom tearDownHooks from GDB Remote tests

Remove custom tearDownHooks from GDB Remote tests as we now cleanup
subprocesses unconditionally. This also changes the termination order to
be the reverse of the creation order. I don't think anything is relying
on that right now, but it better fits the setup/teardown paradigm.
This commit is contained in:
Jonas Devlieghere 2020-07-15 09:59:54 -07:00
parent eed19bd844
commit 8b85f68ee2
2 changed files with 3 additions and 32 deletions

View File

@ -884,8 +884,8 @@ class Base(unittest2.TestCase):
self.addTearDownHook(lambda: self.dbg.SetAsync(old_async))
def cleanupSubprocesses(self):
# Ensure any subprocesses are cleaned up
for p in self.subprocesses:
# Terminate subprocesses in reverse order from how they were created.
for p in reversed(self.subprocesses):
p.terminate()
del p
del self.subprocesses[:]

View File

@ -402,7 +402,6 @@ class GdbRemoteTestCaseBase(TestBase):
self.debug_monitor_exe,
commandline_args,
install_remote=False)
self.addTearDownHook(self.cleanupSubprocesses)
self.assertIsNotNone(server)
# If we're receiving the stub's listening port from the named pipe, do
@ -418,15 +417,6 @@ class GdbRemoteTestCaseBase(TestBase):
server = self.launch_debug_monitor(attach_pid=attach_pid)
self.assertIsNotNone(server)
def shutdown_debug_monitor():
try:
server.terminate()
except:
logger.warning(
"failed to terminate server for debug monitor: {}; ignoring".format(
sys.exc_info()[0]))
self.addTearDownHook(shutdown_debug_monitor)
# Schedule debug monitor to be shut down during teardown.
logger = self.logger
@ -445,15 +435,6 @@ class GdbRemoteTestCaseBase(TestBase):
# Schedule debug monitor to be shut down during teardown.
logger = self.logger
def shutdown_debug_monitor():
try:
server.terminate()
except:
logger.warning(
"failed to terminate server for debug monitor: {}; ignoring".format(
sys.exc_info()[0]))
self.addTearDownHook(shutdown_debug_monitor)
connect_attemps = 0
MAX_CONNECT_ATTEMPTS = 10
@ -506,17 +487,7 @@ class GdbRemoteTestCaseBase(TestBase):
if sleep_seconds:
args.append("sleep:%d" % sleep_seconds)
inferior = self.spawnSubprocess(exe_path, args)
def shutdown_process_for_attach():
try:
inferior.terminate()
except:
logger.warning(
"failed to terminate inferior process for attach: {}; ignoring".format(
sys.exc_info()[0]))
self.addTearDownHook(shutdown_process_for_attach)
return inferior
return self.spawnSubprocess(exe_path, args)
def prep_debug_monitor_and_inferior(
self,