This revision was automatically updated to reflect the committed changes. Closed by commit rG4aafc479f28c: [lldb/Test] Always set the cleanupSubprocesses tear down hook (authored by JDevlieghere). Herald added a project: LLDB.
Changed prior to commit: https://reviews.llvm.org/D83787?vs=277877&id=277969#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83787/new/ https://reviews.llvm.org/D83787 Files: lldb/packages/Python/lldbsuite/test/lldbtest.py lldb/test/API/commands/platform/process/list/TestProcessList.py lldb/test/API/commands/process/attach-resume/TestAttachResume.py lldb/test/API/commands/process/attach/TestProcessAttach.py lldb/test/API/commands/process/attach/attach_denied/TestAttachDenied.py lldb/test/API/commands/register/register/register_command/TestRegisters.py lldb/test/API/commands/target/auto-install-main-executable/TestAutoInstallMainExecutable.py lldb/test/API/functionalities/deleted-executable/TestDeletedExecutable.py lldb/test/API/functionalities/process_group/TestChangeProcessGroup.py lldb/test/API/functionalities/reproducers/attach/TestReproducerAttach.py lldb/test/API/functionalities/thread/create_after_attach/TestCreateAfterAttach.py lldb/test/API/macosx/find-dsym/bundle-with-dot-in-filename/TestBundleWithDotInFilename.py lldb/test/API/macosx/find-dsym/deep-bundle/TestDeepBundle.py lldb/test/API/macosx/function-starts/TestFunctionStarts.py lldb/test/API/macosx/universal/TestUniversal.py lldb/test/API/python_api/hello_world/TestHelloWorld.py lldb/test/API/tools/lldb-server/platform-process-connect/TestPlatformProcessConnect.py lldb/test/API/tools/lldb-vscode/attach/TestVSCode_attach.py
Index: lldb/test/API/tools/lldb-vscode/attach/TestVSCode_attach.py =================================================================== --- lldb/test/API/tools/lldb-vscode/attach/TestVSCode_attach.py +++ lldb/test/API/tools/lldb-vscode/attach/TestVSCode_attach.py @@ -90,7 +90,6 @@ self.addTearDownHook(cleanup) popen = self.spawnSubprocess(program, [pid_file_path]) - self.addTearDownHook(self.cleanupSubprocesses) pid = lldbutil.wait_for_file_on_target(self, pid_file_path) Index: lldb/test/API/tools/lldb-server/platform-process-connect/TestPlatformProcessConnect.py =================================================================== --- lldb/test/API/tools/lldb-server/platform-process-connect/TestPlatformProcessConnect.py +++ lldb/test/API/tools/lldb-server/platform-process-connect/TestPlatformProcessConnect.py @@ -54,7 +54,6 @@ self.debug_monitor_exe, commandline_args, install_remote=False) - self.addTearDownHook(self.cleanupSubprocesses) socket_id = lldbutil.wait_for_file_on_target(self, port_file) Index: lldb/test/API/python_api/hello_world/TestHelloWorld.py =================================================================== --- lldb/test/API/python_api/hello_world/TestHelloWorld.py +++ lldb/test/API/python_api/hello_world/TestHelloWorld.py @@ -91,7 +91,6 @@ if os.path.exists(token): os.remove(token) popen = self.spawnSubprocess(self.getBuildArtifact(exe), [token]) - self.addTearDownHook(self.cleanupSubprocesses) lldbutil.wait_for_file_on_target(self, token) listener = lldb.SBListener("my.attach.listener") @@ -126,7 +125,6 @@ if os.path.exists(token): os.remove(token) popen = self.spawnSubprocess(self.getBuildArtifact(exe), [token]) - self.addTearDownHook(self.cleanupSubprocesses) lldbutil.wait_for_file_on_target(self, token) listener = lldb.SBListener("my.attach.listener") Index: lldb/test/API/macosx/universal/TestUniversal.py =================================================================== --- lldb/test/API/macosx/universal/TestUniversal.py +++ lldb/test/API/macosx/universal/TestUniversal.py @@ -137,7 +137,6 @@ "Our main breakpoint has locations.") popen = self.spawnSubprocess(exe, ["keep_waiting"]) - self.addTearDownHook(self.cleanupSubprocesses) error = lldb.SBError() empty_listener = lldb.SBListener() Index: lldb/test/API/macosx/function-starts/TestFunctionStarts.py =================================================================== --- lldb/test/API/macosx/function-starts/TestFunctionStarts.py +++ lldb/test/API/macosx/function-starts/TestFunctionStarts.py @@ -53,7 +53,6 @@ (pid_file_path))) popen = self.spawnSubprocess(exe, [pid_file_path]) - self.addTearDownHook(self.cleanupSubprocesses) # Wait until process has fully started up. pid = lldbutil.wait_for_file_on_target(self, pid_file_path) Index: lldb/test/API/macosx/find-dsym/deep-bundle/TestDeepBundle.py =================================================================== --- lldb/test/API/macosx/find-dsym/deep-bundle/TestDeepBundle.py +++ lldb/test/API/macosx/find-dsym/deep-bundle/TestDeepBundle.py @@ -36,7 +36,6 @@ exe = self.getBuildArtifact(exe_name) self.build() popen = self.spawnSubprocess(exe, [self.getBuildDir()]) - self.addTearDownHook(self.cleanupSubprocesses) # Give the inferior time to start up, dlopen a bundle, remove the bundle it linked in sleep(5) Index: lldb/test/API/macosx/find-dsym/bundle-with-dot-in-filename/TestBundleWithDotInFilename.py =================================================================== --- lldb/test/API/macosx/find-dsym/bundle-with-dot-in-filename/TestBundleWithDotInFilename.py +++ lldb/test/API/macosx/find-dsym/bundle-with-dot-in-filename/TestBundleWithDotInFilename.py @@ -38,7 +38,6 @@ self.build() os.chdir(self.getBuildDir()); popen = self.spawnSubprocess(exe) - self.addTearDownHook(self.cleanupSubprocesses) # Give the inferior time to start up, dlopen a bundle, remove the bundle it linked in sleep(5) Index: lldb/test/API/functionalities/thread/create_after_attach/TestCreateAfterAttach.py =================================================================== --- lldb/test/API/functionalities/thread/create_after_attach/TestCreateAfterAttach.py +++ lldb/test/API/functionalities/thread/create_after_attach/TestCreateAfterAttach.py @@ -56,7 +56,6 @@ else: popen = self.spawnSubprocess(exe) pid = popen.pid - self.addTearDownHook(self.cleanupSubprocesses) # Attach to the spawned process self.runCmd("process attach -p " + str(pid)) Index: lldb/test/API/functionalities/reproducers/attach/TestReproducerAttach.py =================================================================== --- lldb/test/API/functionalities/reproducers/attach/TestReproducerAttach.py +++ lldb/test/API/functionalities/reproducers/attach/TestReproducerAttach.py @@ -37,7 +37,6 @@ pass self.build(dictionary={'EXE': exe}) - self.addTearDownHook(self.cleanupSubprocesses) inferior = self.spawnSubprocess(self.getBuildArtifact(exe), [token]) pid = inferior.pid Index: lldb/test/API/functionalities/process_group/TestChangeProcessGroup.py =================================================================== --- lldb/test/API/functionalities/process_group/TestChangeProcessGroup.py +++ lldb/test/API/functionalities/process_group/TestChangeProcessGroup.py @@ -38,7 +38,6 @@ (pid_file_path))) popen = self.spawnSubprocess(exe, [pid_file_path]) - self.addTearDownHook(self.cleanupSubprocesses) pid = lldbutil.wait_for_file_on_target(self, pid_file_path) Index: lldb/test/API/functionalities/deleted-executable/TestDeletedExecutable.py =================================================================== --- lldb/test/API/functionalities/deleted-executable/TestDeletedExecutable.py +++ lldb/test/API/functionalities/deleted-executable/TestDeletedExecutable.py @@ -35,7 +35,6 @@ # Spawn a new process popen = self.spawnSubprocess(exe, [pid_file_path]) - self.addTearDownHook(self.cleanupSubprocesses) # Wait until process has fully started up. pid = lldbutil.wait_for_file_on_target(self, pid_file_path) Index: lldb/test/API/commands/target/auto-install-main-executable/TestAutoInstallMainExecutable.py =================================================================== --- lldb/test/API/commands/target/auto-install-main-executable/TestAutoInstallMainExecutable.py +++ lldb/test/API/commands/target/auto-install-main-executable/TestAutoInstallMainExecutable.py @@ -48,7 +48,6 @@ self.debug_monitor_exe, commandline_args, install_remote=False) - self.addTearDownHook(self.cleanupSubprocesses) # Wait for the new process gets ready. time.sleep(0.1) Index: lldb/test/API/commands/register/register/register_command/TestRegisters.py =================================================================== --- lldb/test/API/commands/register/register/register_command/TestRegisters.py +++ lldb/test/API/commands/register/register/register_command/TestRegisters.py @@ -457,7 +457,6 @@ # Spawn a new process pid = self.spawnSubprocess(exe, ['wait_for_attach']).pid - self.addTearDownHook(self.cleanupSubprocesses) if self.TraceOn(): print("pid of spawned process: %d" % pid) Index: lldb/test/API/commands/process/attach/attach_denied/TestAttachDenied.py =================================================================== --- lldb/test/API/commands/process/attach/attach_denied/TestAttachDenied.py +++ lldb/test/API/commands/process/attach/attach_denied/TestAttachDenied.py @@ -37,7 +37,6 @@ # Spawn a new process popen = self.spawnSubprocess(exe, [pid_file_path]) - self.addTearDownHook(self.cleanupSubprocesses) pid = lldbutil.wait_for_file_on_target(self, pid_file_path) Index: lldb/test/API/commands/process/attach/TestProcessAttach.py =================================================================== --- lldb/test/API/commands/process/attach/TestProcessAttach.py +++ lldb/test/API/commands/process/attach/TestProcessAttach.py @@ -29,7 +29,6 @@ # Spawn a new process popen = self.spawnSubprocess(exe) - self.addTearDownHook(self.cleanupSubprocesses) self.runCmd("process attach -p " + str(popen.pid)) @@ -55,7 +54,6 @@ # Spawn a new process popen = self.spawnSubprocess(exe) - self.addTearDownHook(self.cleanupSubprocesses) os.chdir(newdir) self.addTearDownHook(lambda: os.chdir(testdir)) @@ -74,7 +72,6 @@ # Spawn a new process popen = self.spawnSubprocess(exe) - self.addTearDownHook(self.cleanupSubprocesses) self.runCmd("process attach -n " + exe_name) Index: lldb/test/API/commands/process/attach-resume/TestAttachResume.py =================================================================== --- lldb/test/API/commands/process/attach-resume/TestAttachResume.py +++ lldb/test/API/commands/process/attach-resume/TestAttachResume.py @@ -33,7 +33,6 @@ exe = self.getBuildArtifact(exe_name) popen = self.spawnSubprocess(exe) - self.addTearDownHook(self.cleanupSubprocesses) self.runCmd("process attach -p " + str(popen.pid)) Index: lldb/test/API/commands/platform/process/list/TestProcessList.py =================================================================== --- lldb/test/API/commands/platform/process/list/TestProcessList.py +++ lldb/test/API/commands/platform/process/list/TestProcessList.py @@ -25,7 +25,6 @@ # Spawn a new process popen = self.spawnSubprocess(exe, args=["arg1", "--arg2", "arg3"]) - self.addTearDownHook(self.cleanupSubprocesses) substrs = [str(popen.pid), "TestProcess arg1 --arg2 arg3"] Index: lldb/packages/Python/lldbsuite/test/lldbtest.py =================================================================== --- lldb/packages/Python/lldbsuite/test/lldbtest.py +++ lldb/packages/Python/lldbsuite/test/lldbtest.py @@ -891,23 +891,18 @@ for p in self.subprocesses: p.terminate() del p - self.subprocesses.clear() + del self.subprocesses[:] # Ensure any forked processes are cleaned up for pid in self.forkedProcessPids: try: os.kill(pid, signal.SIGTERM) except OSError: pass - self.forkedProcessPids.clear() + del self.forkedProcessPids[:] def spawnSubprocess(self, executable, args=[], install_remote=True): """ Creates a subprocess.Popen object with the specified executable and arguments, saves it in self.subprocesses, and returns the object. - NOTE: if using this function, ensure you also call: - - self.addTearDownHook(self.cleanupSubprocesses) - - otherwise the test suite will leak processes. """ proc = _RemoteProcess( install_remote) if lldb.remote_platform else _LocalProcess(self.TraceOn()) @@ -917,11 +912,6 @@ def forkSubprocess(self, executable, args=[]): """ Fork a subprocess with its own group ID. - NOTE: if using this function, ensure you also call: - - self.addTearDownHook(self.cleanupSubprocesses) - - otherwise the test suite will leak processes. """ child_pid = os.fork() if child_pid == 0: @@ -1025,9 +1015,6 @@ def tearDown(self): """Fixture for unittest test case teardown.""" - #import traceback - # traceback.print_stack() - self.deletePexpectChild() # Check and run any hook functions. @@ -1054,6 +1041,9 @@ for dict in reversed(self.dicts): self.cleanup(dictionary=dict) + # Remove subprocesses created by the test. + self.cleanupSubprocesses() + # This must be the last statement, otherwise teardown hooks or other # lines might depend on this still being active. lldb.SBDebugger.Destroy(self.dbg)
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits