Skip to content

Port live/test-deadlock.cpp to pytest - #15427

Merged
Nir-Az merged 2 commits into
realsenseai:developmentfrom
Nir-Az:port-deadlock-test
Jul 16, 2026
Merged

Nir-Az merged 2 commits into
realsenseai:developmentfrom
Nir-Az:port-deadlock-test

Conversation

@Nir-Az

@Nir-Az Nir-Az commented Jul 15, 2026 •

Copy link
Copy Markdown
Collaborator

Overview: Port the C++ hw-reset deadlock regression test to pytest and drop the .cpp.

Tracked on [RSDSO-21706]

Why

unit-tests/live/test-deadlock.cpp is one of the last live C++ exe tests. The deadlock it guards (RSDSO-19304 / GH #10482) lives in the native core β€” both C++ and Python funnel into the same C API (rs2_query_devices, rs2_hardware_reset, rs2_delete_device), so the pytest port keeps full regression coverage.

Summary

  • Add unit-tests/live/hw-reset/pytest-deadlock.py: query devices, hardware_reset() all, sleep 6s, re-query, then assign + release each device handle β€” releasing the handle right away (del, mirroring the C++ scope-end destructor) is what triggered the original deadlock.
  • Directives carried over: device D400* β†’ device_each("D400*"), donotrun:!nightly β†’ context("nightly"), timeout 12 β†’ pytest.mark.timeout(12) (deadlock is detected by timeout).
  • Delete unit-tests/live/test-deadlock.cpp; it is auto-discovered, no CMake change needed.

Test plan

  • Ran locally on D455: pytest live/hw-reset/pytest-deadlock.py -v --context nightly β€” 1 passed
  • Nightly CI run on D400 benches

Test build 17279/

πŸ€– Generated by AI

@sysrsbuild-gh-agentic sysrsbuild-gh-agentic left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

πŸ€– rs-agentic bot β€” automated review

Summary: Good port overall. A few issues noted below as inline comments.

@Nir-Az
Nir-Az requested a review from Binyaminp July 15, 2026 16:22
log.info("%d devices after reset", len(device_list))

log.info("This caused deadlock")
for dev_idx in range(len(device_list)):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why not use for d in device_list?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Kept the index loop to mirror the C++ original 1:1 (for dev_idx ... list[dev_idx]) per the minimal-diff migration convention. for d in device_list is functionally equivalent β€” happy to switch if you prefer.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sure was just an enhancement recommendation

@Nir-Az
Nir-Az merged commit c3d9517 into realsenseai:development Jul 16, 2026
29 checks passed
@Nir-Az
Nir-Az deleted the port-deadlock-test branch July 16, 2026 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants