Skip to content

[#1178] Add loom test for spsc index queue#1267

Open
mox692 wants to merge 2 commits into
eclipse-iceoryx:mainfrom
mox692:iox2-1178-add_loom_test_spsc_index_queue
Open

[#1178] Add loom test for spsc index queue#1267
mox692 wants to merge 2 commits into
eclipse-iceoryx:mainfrom
mox692:iox2-1178-add_loom_test_spsc_index_queue

Conversation

@mox692

@mox692 mox692 commented Dec 18, 2025

Copy link
Copy Markdown

Notes for Reviewer

Ref: #1178

This PR adds loom test for spsc_index_queue. The UnsafeCell and other atomic types that are used in the index queue will use loom types during the loom test (#1194).

Pre-Review Checklist for the PR Author

  • Add sensible notes for the reviewer
  • PR title is short, expressive and meaningful
  • Consider switching the PR to a draft (Convert to draft)
    • as draft PR, the CI will be skipped for pushes
  • Relevant issues are linked in the References section
  • Branch follows the naming format (iox2-123-introduce-posix-ipc-example)
  • Commits messages are according to this guideline
    • Commit messages have the issue ID ([#123] Add posix ipc example)
    • Keep in mind to use the same email that was used to sign the Eclipse Contributor Agreement
  • Tests follow the best practice for testing
  • Changelog updated in the unreleased section including API breaking changes
  • Assign PR to reviewer
  • All checks have passed (except task-list-completed)

PR Reviewer Reminders

  • Commits are properly organized and messages are according to the guideline
  • Unit tests have been written for new behavior
  • Public API is documented
  • PR title describes the changes

@orecham

orecham commented Dec 19, 2025

Copy link
Copy Markdown
Contributor

@mox692

Had to make some tweaks to resolve some conflicts in: #1204
If I broke something by mistake feel free to ping me.

@mox692 mox692 force-pushed the iox2-1178-add_loom_test_spsc_index_queue branch 5 times, most recently from 8c11f2a to ef0b0e6 Compare January 21, 2026 05:21
@mox692

mox692 commented Jan 21, 2026

Copy link
Copy Markdown
Author

Sorry for the delay, I think the code is almost complete, but I'm having eclipsefdn/eca error ...
Do you know who I should contact to? It's a bit strange since I'm using the same email as this commit I pushed previously.

Update: it's fixed!

@mox692 mox692 force-pushed the iox2-1178-add_loom_test_spsc_index_queue branch from ef0b0e6 to c6cd8c5 Compare January 21, 2026 13:24
@mox692 mox692 marked this pull request as ready for review January 22, 2026 10:37
@codecov

codecov Bot commented Jan 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.83%. Comparing base (1bc76cc) to head (417ba5b).
⚠️ Report is 9 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1267      +/-   ##
==========================================
- Coverage   77.84%   77.83%   -0.02%     
==========================================
  Files         405      404       -1     
  Lines       38680    38687       +7     
  Branches     1256     1256              
==========================================
  Hits        30111    30111              
- Misses       7536     7543       +7     
  Partials     1033     1033              
Flag Coverage Δ
CPP 68.04% <ø> (ø)
Rust 77.68% <100.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
iceoryx2-bb/lock-free/src/spsc/index_queue.rs 85.16% <100.00%> (ø)
iceoryx2-pal/concurrency-sync/src/atomic.rs 96.53% <100.00%> (+0.05%) ⬆️
iceoryx2-pal/concurrency-sync/src/mutex.rs 94.11% <ø> (ø)
iceoryx2-pal/concurrency-sync/src/once.rs 90.69% <ø> (ø)
iceoryx2-pal/concurrency-sync/src/rwlock.rs 94.90% <ø> (-0.93%) ⬇️

... and 14 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mox692 mox692 force-pushed the iox2-1178-add_loom_test_spsc_index_queue branch from 33c317a to aa0746a Compare January 23, 2026 10:11
@mox692 mox692 force-pushed the iox2-1178-add_loom_test_spsc_index_queue branch from aa0746a to 417ba5b Compare January 23, 2026 10:18
@mox692

mox692 commented Jan 23, 2026

Copy link
Copy Markdown
Author

I think this is ready for review. In addition to adding the test, I made a few updates to ensure the code compiles. Let me know if I should squash these two commits.

@@ -0,0 +1,66 @@
// Copyright (c) 2026 Contributors to the Eclipse Foundation

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.

Can you please give us a short description of what this is, what problem it is supposed to solve and where it will be used.

use loom_oneshot::channel;

#[test]
fn spsc_index_queue_loom_tests() {

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.

For a first test, this is completely sufficient, but I think we also need a test where we verify the same setup by pushing increasing numbers into the queue. push might then fail since the queue is full, but this is acceptable, good behavior and should not lead to a test failure.

On the consumer side, we should then verify that increasing numbers are received without losing anything. This would require a loop in both threads, maybe from 1...100.000. A good reference would be that the test does not take longer than 10secs.

}
}

#[cfg(not(all(test, loom, feature = "std")))]

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 do we need those functions? The same functionality is already implemented with as_ptr(). If possible, I would remove them.


#[cfg(all(test, loom, feature = "std"))]
use loom::cell::UnsafeCell;
pub(crate) type UnsafeCell<T> = loom::cell::UnsafeCell<T>;

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.

Shouldn't this be pub type UnsafeCell<T> = loom::cell::UnsafeCell<T>;?

@elfenpiff

Copy link
Copy Markdown
Contributor

@mox692 I would really love to merge you contribution. Do you have by any chance some time to continue on this PR?

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