[all-commits] [llvm/llvm-project] 47de54: [lldb-dap] Fix TestDap_attach.py flakiness (#137278)

Wanyi via All-commits all-commits at lists.llvm.org
Mon Apr 28 15:33:12 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 47de54e9a2cb2b8433f53e751e1c3413fcd7aa78
      https://github.com/llvm/llvm-project/commit/47de54e9a2cb2b8433f53e751e1c3413fcd7aa78
  Author: Wanyi <wanyi at meta.com>
  Date:   2025-04-28 (Mon, 28 Apr 2025)

  Changed paths:
    M lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
    M lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py

  Log Message:
  -----------
  [lldb-dap] Fix TestDap_attach.py flakiness (#137278)

# Summary
This patch makes the `request_attach` wait for events `process` and
`initialized` just like `request_launch`. This ensure the DAP session
can move forward somewhat correctly.

Recently `TestDap_attach.test_terminate_commands` became flaky.
It's hitting:
```
lldbsuite/test/tools/lldb-dap/dap_server.py", line 350, in send_recv
    raise ValueError(desc)
ValueError: no response for "disconnect"
```
I took a look at the DAP msg from that test case and noticed:
- It's not using the regular attaching, instead it's using the
`attachCommands` to launch debug the binary and it will stop at entry.
- The `initialized` event returned after the `disconnect` request. Which
means lldb-dap didn't really get ready yet.

### NOTE
The `dap_server.py` is doing things to mimic the VSCode (or other dap
clients) but it had some assumptions. For example, it's still missing
the `configurationDone` request and response because it relies on a
continue action to trigger the `configurationDone` request.

# Test Plan
```
./bin/llvm-lit -va /Users/wanyi/llvm-upstream/llvm-project/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py
./bin/llvm-lit -va /Users/wanyi/llvm-upstream/llvm-project/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py
```

To test the `wait_for_events` timeout case
```
events = self.wait_for_events(["process", "initialized", "fake", "event"], 1)
if events:
    raise ValueError(f'no events {",".join(events)} found for within timeout 1')
```
Observed
<img width="696" alt="image"
src="https://github.com/user-attachments/assets/bc97c0ef-d91f-4561-8272-4d36f5f5d4e6"
/>

### Also
Looks like some test cases should be re-enabled in
https://github.com/llvm/llvm-project/commit/0b8dfb5762fdc350c5071c9eeffd4f7e4d495e98
But only comments was removed. The skip statements survived the change.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list