Skip to content

Add vmlens interleaving analysis tests for StreamBuffer#106

Merged
bernardladenthin merged 2 commits into
mainfrom
claude/focused-cray-mgzh1e
Jun 15, 2026
Merged

Add vmlens interleaving analysis tests for StreamBuffer#106
bernardladenthin merged 2 commits into
mainfrom
claude/focused-cray-mgzh1e

Conversation

@bernardladenthin

Copy link
Copy Markdown
Owner

Summary

  • Add two new vmlens interleaving-analysis tests: a smoke test (VmlensInterleavingSmokeTest) demonstrating the vmlens setup with atomic operations, and a comprehensive reader/writer concurrency test (StreamBufferReaderWriterInterleavingTest) that verifies byte-accounting invariants under all thread interleavings
  • Add vmlens API dependency to test classpath and configure maven-surefire-plugin to exclude vmlens tests from ordinary runs (they only execute under the vmlens profile with the vmlens agent)

Details

The new tests provide deterministic interleaving coverage that complements existing concurrency testing:

  • VmlensInterleavingSmokeTest: A minimal baseline test that verifies two concurrent atomic increments always sum to two, demonstrating the vmlens setup is working correctly. Kept in sync with sibling repos.

  • StreamBufferReaderWriterInterleavingTest: Drives a writer thread and reader thread through every possible interleaving and asserts the write/read/buffered byte-accounting invariant (totalBytesWritten == totalBytesRead + availableBytes) holds at quiescence. This covers the critical hand-off between the lock-free wait gate (waitForAtLeast) and lock-protected mutations that existing coverage (Lincheck, jcstress) does not reach.

The vmlens API dependency is promoted from the vmlens profile to the main test classpath (it is transitive-dependency-free) so the smoke test compiles in every build, keeping it in sync with sibling repos. Execution is gated by the vmlens profile and surefire exclusions; without the vmlens agent, AllInterleavings.hasNext() returns false and the loop body is skipped.

Test plan

  • New vmlens tests added and excluded from ordinary surefire runs
  • Existing unit tests pass locally
  • CI is green on this branch (vmlens profile run validates interleaving coverage)

Related issues / PRs

Closes #18

Checklist

  • I have read CONTRIBUTING.md and CODE_OF_CONDUCT.md
  • My commits follow Conventional Commits
  • No security-sensitive changes

https://claude.ai/code/session_01HzCYFLjZZGFs4BsuUty35N

claude added 2 commits June 14, 2026 21:50
streambuffer already ran vmlens over the whole suite but had no dedicated
VmlensInterleavingSmokeTest; add the same one the three sibling repos carry so
the deterministic "is vmlens wired up?" baseline is identical across all four.

- New net.ladenthin.streambuffer.vmlens.VmlensInterleavingSmokeTest: two threads
  increment a shared AtomicLong inside an AllInterleavings loop, asserting the sum
  is always 2.
- pom: promote com.vmlens:api out of the vmlens profile into the main test
  <dependencies> (transitive-dep-free, convergence-safe) so the test compiles in
  every build; add a managed surefire <exclude> so the ordinary suite skips it
  (vacuous without the agent). The vmlens profile's whole-suite run still picks
  it up.

Verified green under the vmlens agent.

https://claude.ai/code/session_01HzCYFLjZZGFs4BsuUty35N
First real (beyond-smoke) vmlens target for this repo: a writer and a reader race
on a StreamBuffer and the byte-accounting invariant
totalBytesWritten == totalBytesRead + availableBytes must hold at quiescence for
every interleaving. This covers the interleaving class neither existing tool
reaches — Lincheck excludes read() (can't progress past a parked reader) and the
jcstress close/unblock races assert only termination, not the resulting
accounting (the reader's waitForAtLeast gate reads availableBytes/streamClosed
outside bufferLock while the writer mutates them under it).

- New net.ladenthin.streambuffer.vmlens.StreamBufferReaderWriterInterleavingTest.
- pom: widen the managed surefire <exclude> to the whole vmlens package
  (**/vmlens/*.java) so new interleaving tests are auto-excluded from the ordinary
  suite; the vmlens profile's whole-suite run still picks them up.

Verified green under the vmlens agent.

https://claude.ai/code/session_01HzCYFLjZZGFs4BsuUty35N
@sonarqubecloud

Copy link
Copy Markdown

@bernardladenthin bernardladenthin merged commit 0d3ffad into main Jun 15, 2026
12 of 13 checks passed
@bernardladenthin bernardladenthin deleted the claude/focused-cray-mgzh1e branch June 15, 2026 11:06
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.

2 participants