Skip to content

Conversation

@mox692
Copy link

@mox692 mox692 commented Nov 24, 2025

Notes for Reviewer

This PR adds the setup for loom tests. The actual loom tests will be added in follow-up PRs.

A couple of notes:

  • There are two ways to enable loom tests: via a Cargo feature or via a cfg flag. I chose cfg because I assume we don’t want to introduce a new Cargo feature across several crates just for this purpose. Using cfg avoids having to touch Cargo.toml in many places.
  • There are some places where we need to branch explicitly when using loom:
    • I added some non-const helper functions for loom tests, since some loom primitives don’t support const initialization.
    • For the same reason, I changed some static variables that would otherwise cause a runtime error when executed under loom.

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
  • Every source code file has a copyright header with SPDX-License-Identifier: Apache-2.0 OR MIT
  • Branch follows the naming format (iox2-123-introduce-posix-ipc-example)
  • Commits messages are according to this guideline
  • 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)

Checklist for the PR Reviewer

  • 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

Post-review Checklist for the PR Author

  • All open points are addressed and tracked via issues

References

Relates to #1178.

@elfenpiff
Copy link
Contributor

@mox692 Thanks you for the pull requests and taking care of loom!

@codecov
Copy link

codecov bot commented Nov 24, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.84%. Comparing base (9b9737c) to head (ada36e6).
⚠️ Report is 39 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1194      +/-   ##
==========================================
- Coverage   77.87%   77.84%   -0.04%     
==========================================
  Files         360      360              
  Lines       38833    38843      +10     
  Branches      816      816              
==========================================
- Hits        30242    30238       -4     
- Misses       7944     7958      +14     
  Partials      647      647              
Flag Coverage Δ
CPP 65.75% <ø> (ø)
Rust 77.80% <100.00%> (-0.04%) ⬇️

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

Files with missing lines Coverage Δ
iceoryx2-bb/elementary/src/lazy_singleton.rs 50.00% <ø> (ø)
iceoryx2-bb/elementary/src/unique_id.rs 100.00% <ø> (ø)
iceoryx2-bb/lock-free/src/spsc/index_queue.rs 87.26% <100.00%> (+0.49%) ⬆️
iceoryx2-bb/log/src/lib.rs 46.37% <ø> (ø)
iceoryx2-bb/posix/src/signal.rs 77.90% <ø> (ø)
iceoryx2-bb/posix/src/unique_system_id.rs 96.20% <100.00%> (+0.09%) ⬆️
iceoryx2-pal/concurrency-sync/src/iox_atomic.rs 96.19% <100.00%> (ø)
iceoryx2-pal/concurrency-sync/src/mutex.rs 94.54% <ø> (ø)
iceoryx2-pal/concurrency-sync/src/once.rs 90.90% <ø> (ø)
iceoryx2-pal/concurrency-sync/src/rwlock.rs 95.63% <ø> (ø)
... and 1 more

... and 9 files with indirect coverage changes

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

Copy link
Contributor

@elfenpiff elfenpiff left a comment

Choose a reason for hiding this comment

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

I reviewed it and you implemented it exactly how we intended to integrate loom into iceoryx2 - well done, thank you!

Since it is a crucial part in iceoryx2 I ask @elBoberido that he reviews the PR as well and approves it. Then we can merge it.

Copy link
Member

@elBoberido elBoberido left a comment

Choose a reason for hiding this comment

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

Looks good. Just some questions regarding no_std and documentation. Nothing blocking if no_std is still possible, which I assume.


impl<T> LazySingleton<T> {
/// Creates a new [`LazySingleton`] where the underlying value is not yet initialized.
#[cfg(not(all(test, loom)))]
Copy link
Member

Choose a reason for hiding this comment

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

We want to make iceoryx2 no_std. Has this a negative effect on this goal?

Copy link
Contributor

Choose a reason for hiding this comment

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

@mox692 @elBoberido Is there a chance to wait for #1156 before proceeding with this? It's hard to tell how those changes will interfere with this.

I am actively working to get it merged now. Pending reviews it should be in sometime this week...

Copy link
Contributor

Choose a reason for hiding this comment

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

#1156 Is merged. If you can rebase this PR and adapt as required, should be good to go.

Comment on lines +68 to +75
#[cfg(all(test, loom))]
pub fn new() -> Self {
Self {
data: UnsafeCell::new(None),
is_initialized: IoxAtomicBool::new(false),
is_finalized: IoxAtomicBool::new(false),
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Can we document that loom cannot handle const functions somewhere? I mean in case we introduce a new function and loom breaks. A good option would be to add the error message and the fix to FAQ_ICEORYX_DEVS.md.

#[cfg(not(all(test, loom)))]
static COUNTER: IoxAtomicU64 = IoxAtomicU64::new(0);
#[cfg(all(test, loom))]
static COUNTER: std::sync::LazyLock<IoxAtomicU64> = std::sync::LazyLock::new(|| {
Copy link
Member

Choose a reason for hiding this comment

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

@orecham I guess this is not an issue for no_std as long as iceoryx2 is build with std support.

Copy link
Contributor

Choose a reason for hiding this comment

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

This would work fine, but would mean only the std build is being validated - maybe OK, at least for the first steps?

@mox692
Copy link
Author

mox692 commented Nov 30, 2025

Thank you for the review!

no_std

Yes good catch, I think this PR should probably be modified so that the loom tests are gated behind the std feature. At this moment, loom does not support no_std environment.

Would it be acceptable to enable loom support only for the targets that are built with std?

@orecham
Copy link
Contributor

orecham commented Nov 30, 2025

Would it be acceptable to enable loom support only for the targets that are built with std?

@mox692 Yup, makes sense to me :)

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.

4 participants