Skip to content

[lldb-dap] Fix test_exit_status_message_sigterm test. #90223

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions lldb/test/API/tools/lldb-dap/console/TestDAP_console.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,15 @@

import dap_server
import lldbdap_testcase
import psutil
from collections import deque
from lldbsuite.test import lldbutil
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *


def get_subprocess(process_name):
queue = deque([psutil.Process(os.getpid())])
def get_subprocess(root_process, process_name):
queue = [root_process]
while queue:
process = queue.popleft()
process = queue.pop()
if process.name() == process_name:
return process
queue.extend(process.children())
Expand Down Expand Up @@ -131,7 +129,17 @@ def test_exit_status_message_sigterm(self):
process_name = (
"debugserver" if platform.system() in ["Darwin"] else "lldb-server"
)
process = get_subprocess(process_name)

try:
import psutil
except ImportError:
print(
"psutil not installed, please install using 'pip install psutil'. "
"Skipping test_exit_status_message_sigterm test.",
file=sys.stderr,
)
return
process = get_subprocess(psutil.Process(os.getpid()), process_name)
process.terminate()
process.wait()

Expand Down