Skip to content

Commit

Permalink
[lldb/Test] Remove custom tearDownHooks from GDB Remote tests
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
JDevlieghere committed Jul 15, 2020
1 parent eed19bd commit 8b85f68
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 32 deletions.
4 changes: 2 additions & 2 deletions lldb/packages/Python/lldbsuite/test/lldbtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -884,8 +884,8 @@ def setAsync(self, value):
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[:]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,6 @@ def launch_debug_monitor(self, attach_pid=None, logfile=None):
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
Expand All @@ -418,15 +417,6 @@ def connect_to_debug_monitor(self, attach_pid=None):
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

Expand All @@ -445,15 +435,6 @@ def shutdown_debug_monitor():
# 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

Expand Down Expand Up @@ -506,17 +487,7 @@ def launch_process_for_attach(
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,
Expand Down

0 comments on commit 8b85f68

Please sign in to comment.