llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-lldb Author: Raphael Isemann (Teemperor) <details> <summary>Changes</summary> ProcessAttach calls Destroy() on the test SBProcess when tearing down the test. However, Destroy() only detaches us from the process but keeps it running. The correct way would be to call Kill() which does the same as Destroy but also kills an process we attached to. To avoid this issue in future tests, I moved this tear down logic to the common test tear-down logic used for all tests. I don't see any reason for why we should not try to kill an alive test inferior at the end of a test. --- Full diff: https://github.com/llvm/llvm-project/pull/207181.diff 2 Files Affected: - (modified) lldb/packages/Python/lldbsuite/test/lldbtest.py (+12) - (modified) lldb/test/API/commands/process/attach/TestProcessAttach.py (-7) ``````````diff diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py b/lldb/packages/Python/lldbsuite/test/lldbtest.py index 416b357754015..7adec7d677b3f 100644 --- a/lldb/packages/Python/lldbsuite/test/lldbtest.py +++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py @@ -1203,6 +1203,18 @@ def tearDown(self): for dict in reversed(self.dicts): self.cleanup(dictionary=dict) + # Kill any process a target is still holding on to. + for i in range(self.dbg.GetNumTargets()): + process = self.dbg.GetTargetAtIndex(i).GetProcess() + # Only kill processes that are still alive. + if process.IsValid() and process.is_alive: + process.Kill() + self.assertEqual( + process.GetState(), + lldb.eStateExited, + "Failed to kill process during teardown", + ) + # Remove subprocesses created by the test. self.cleanupSubprocesses() diff --git a/lldb/test/API/commands/process/attach/TestProcessAttach.py b/lldb/test/API/commands/process/attach/TestProcessAttach.py index 5abcf69d0acba..f0fa9af4e4d0d 100644 --- a/lldb/test/API/commands/process/attach/TestProcessAttach.py +++ b/lldb/test/API/commands/process/attach/TestProcessAttach.py @@ -142,10 +142,3 @@ def test_attach_to_process_by_id_correct_executable_offset(self): ) self.runCmd("process continue") self.expect("v g_val", substrs=["12345"]) - - def tearDown(self): - # Destroy process before TestBase.tearDown() - self.dbg.GetSelectedTarget().GetProcess().Destroy() - - # Call super's tearDown(). - TestBase.tearDown(self) `````````` </details> https://github.com/llvm/llvm-project/pull/207181 _______________________________________________ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
