Skip to content

[lldb-dap] Fix TestDap_attach.py flakiness #137278

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,15 @@ def wait_for_event(self, filter=None, timeout=None):
)
return None

def wait_for_events(self, events, timeout=None):
"""Wait for a list of events in `events` in any order.
Return the events not hit before the timeout expired"""
events = events[:] # Make a copy to avoid modifying the input
while events:
event = self.wait_for_event(filter=events, timeout=timeout)
events.remove(event["event"])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we hit a timeout, wont event be None?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah it looks like its not handling the timeout correctly.

return events

def wait_for_stopped(self, timeout=None):
stopped_events = []
stopped_event = self.wait_for_event(
Expand Down Expand Up @@ -612,7 +621,11 @@ def request_attach(
if gdbRemoteHostname is not None:
args_dict["gdb-remote-hostname"] = gdbRemoteHostname
command_dict = {"command": "attach", "type": "request", "arguments": args_dict}
return self.send_recv(command_dict)
response = self.send_recv(command_dict)

if response["success"]:
self.wait_for_events(["process", "initialized"])
return response

def request_breakpointLocations(
self, file_path, line, end_line=None, column=None, end_column=None
Expand Down Expand Up @@ -866,9 +879,7 @@ def request_launch(
response = self.send_recv(command_dict)

if response["success"]:
# Wait for a 'process' and 'initialized' event in any order
self.wait_for_event(filter=["process", "initialized"])
self.wait_for_event(filter=["process", "initialized"])
self.wait_for_events(["process", "initialized"])
return response

def request_next(self, threadId, granularity="statement"):
Expand Down
3 changes: 0 additions & 3 deletions lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ def cleanup():
self.set_and_hit_breakpoint(continueToExit=True)

@skipUnlessDarwin
@skipIfDarwin
@skipIfNetBSD # Hangs on NetBSD as well
def test_by_name_waitFor(self):
"""
Expand All @@ -114,7 +113,6 @@ def test_by_name_waitFor(self):
self.attach(program=program, waitFor=True)
self.set_and_hit_breakpoint(continueToExit=True)

@skipIfDarwin
@skipIfNetBSD # Hangs on NetBSD as well
def test_commands(self):
"""
Expand Down Expand Up @@ -201,7 +199,6 @@ def test_commands(self):
self.verify_commands("exitCommands", output, exitCommands)
self.verify_commands("terminateCommands", output, terminateCommands)

@skipIfDarwin
@skipIfNetBSD # Hangs on NetBSD as well
@skipIf(
archs=["arm", "aarch64"]
Expand Down
Loading