Skip to content

DEV-1198 Re-enable the three excluded ShimmerDriverPC simulator test classes - #326

Merged
JongChern merged 2 commits into
masterfrom
DEV-1198_reenable_excluded_driverpc_tests
Oct 21, 2026
Merged

JongChern merged 2 commits into
masterfrom
DEV-1198_reenable_excluded_driverpc_tests

Conversation

@JongChern

Copy link
Copy Markdown
Contributor

Re-enables the three ShimmerDriverPC simulator test classes excluded from the test task in February 2026 ("DEV-658 exclude failing test class", b253f7b / 214610a / fe9e6be):

  • API_0000X_ByteCommunicationShimmer3lns0_16_11_w_sd_only
  • API_0000X_ByteCommunicationShimmer3lns0_16_11_w_sync_master
  • API_0000X_ByteCommunicationShimmer3lns0_16_11_w_sync_slave

Why they should pass now

#325 found that the simulator connect tests deadlocked on Linux CI. The read-status timer starts with no delay and takes the device lock, then the instruction-list lock. At the same moment the IOThread, picking up the first post-connect instruction in getInstruction(), takes the same two locks the other way round. #325 avoids it in the tests: the simulator classes build their device through ByteCommunicationTestUtils.newShimmerPCWithoutStatusTimer(), so that timer never starts.

These three classes now do the same. Their February CI logs have expired, so the original failure cannot be confirmed. The deadlock fits it, though: these classes assert values from the post-connect config read (SD log sync, Bluetooth disabled, sync nodes, trial duration), which a stalled connect never reaches. w_sd_bt_streaming asserted only defaults, so it kept passing until #321 made it wait for the connect.

Changes

  • ShimmerDriverPC/build.gradle: the three exclude lines removed. The Shimmer2R exclude stays (it needs hardware).
  • The three classes use newShimmerPCWithoutStatusTimer() instead of new ShimmerPC().

Verification

  • Full ShimmerDriverPC suite locally (Windows, JDK 11): 5 runs of 5 green, 234 tests across ShimmerDriverPC, ShimmerDriver and ShimmerBluetoothManager.
  • Linux CI: this PR, run twice. If one of these classes fails, the connect-timeout thread dump from DEV-1198 Fix the ShimmerDriverPC connect test hang on Linux CI #325 shows where it stuck.

Kept separate from #325 so a failure here cannot turn master red.

🤖 Generated with Claude Code

API_0000X_ByteCommunicationShimmer3lns0_16_11_w_sd_only, _w_sync_master
and _w_sync_slave were excluded from the test task in Feb 2026 as failing
on CI. Their CI logs have expired, so the cause cannot be confirmed, but
it fits the read-status timer deadlock the previous commit avoids: these
classes assert values from the post-connect config read (SD log sync,
Bluetooth disabled, sync nodes, trial duration), which a stalled connect
never reaches. They now build their device through
newShimmerPCWithoutStatusTimer() like the other simulator classes, and
run again.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@MAzalya MAzalya left a comment

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.

Looks good to merge. The change is small and correct, and it has been checked. One note below about the underlying deadlock, which this PR doesn't need to fix.

What I checked

  • The re-enabled tests ran on CI and passed. The run log shows w_sd_only, w_sync_master and w_sync_slave each running test001 in about 1 s, and the run passed in both attempts.

  • The checks can actually fail. These classes use the Java assert(false) keyword, which does nothing unless assertions are enabled. Gradle's test task enables them by default and nothing in the build turns them off.

  • They wait for the real post-connect config read. Each class goes through connectAndWaitUntilInitialised and then asserts values that only that read sets:

    • w_sd_only: Bluetooth disabled.
    • w_sync_master: master shimmer, trial duration 5, and the two sync node MACs.
    • w_sync_slave: trial duration 5 and the two sync node MACs.

    This supports the description's argument about why w_sd_bt_streaming kept passing.

  • The setUp changes match the other simulator classes, and the Shimmer2R exclude, which needs real hardware, is correctly left in place.

  • Merging is safe. The branch is 12 commits behind master, but none of those commits touch the test or driver code involved.

  • The InterruptedException: sleep interrupted stack traces in stderr are not new. They come from teardown interrupting the IOThread, and every simulator class prints them. Optional cleanup in a later PR: they make the CI log look like something failed.

The deadlock is a real driver bug, and only the tests avoid it
The lock inversion is in the shipped driver on master (ShimmerDriver/.../bluetooth/ShimmerBluetooth.java):

  • getInstruction() (around line 5982) takes synchronized(mListofInstructions) and then calls getListofInstructions().
  • getListofInstructions() is a synchronized method, so it then takes the device lock. That is list first, device second.
  • Every other accessor takes them the other way round: writeInstruction, removeInstruction, clearAllInstructions and the rest are synchronized methods that then lock mListofInstructions.

In the real product the read-status timer is on, and it can run at the same time as the IOThread, so PC and Android users can hit this deadlock. #325 and #326 avoid it only in the tests, and I couldn't find a ticket for fixing the driver.

The likely fix is one line: in getInstruction(), read mListofInstructions.get(0) directly instead of calling getListofInstructions(). A regression test should then connect a plain new ShimmerPC(...) with the timer left on. Once that is in, newShimmerPCWithoutStatusTimer may no longer be needed. I suggest a follow-up ticket rather than adding it to this PR.

🤖 Generated with Claude Code

Copilot AI lite review requested due to automatic review settings October 21, 2026 06:06

Copilot AI left a comment

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@JongChern

Copy link
Copy Markdown
Contributor Author

Thanks for the thorough review, @MAzalya. Agreed on all of it.

The driver deadlock now has its own ticket: DEV-1266. It's a production bug in ShimmerBluetooth, affecting PC and Android. The ticket includes the thread dump from a real Shimmer3, caught by the Android HIL, where stopSDLogging() never returned. It also has your one-line getInstruction() fix and your regression test: a plain new ShimmerPC(...) with the status timer on. It's linked to DEV-1198, which can now close with this PR.

CI is green on the updated branch (b7fb77a, master merged in, including #330): 243 of 243 tests, and the three re-enabled classes pass in under a second each. The red "copilot-pull-request-reviewer" check is only Copilot's review quota running out, not a test failure.

The InterruptedException noise in the log is noted for a later cleanup PR.

Could you approve when you get a chance? Your review went in as a comment, so the PR still shows as needing an approving review.

🤖 Generated with Claude Code

@JongChern
JongChern merged commit dffb582 into master Oct 21, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants