Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#476] Introduce test feature in iceoryx-bb for bump_allocator #478

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions iceoryx2-bb/container/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ rust_library(
],
)

# alias the library which enables the testing feature to avoid the cargo reports iceoryx2-bb-elementary is missed.
alias(
name = "iceoryx2-bb-elementary",
actual = "//iceoryx2-bb/elementary:iceoryx2-bb-elementary-with-feature-testing",
)

rust_test_suite(
name = "iceoryx2-bb-container-tests",
srcs = glob(["tests/**/*.rs"]),
Expand Down
1 change: 1 addition & 0 deletions iceoryx2-bb/container/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ serde = { workspace = true }
generic-tests = { workspace = true }
iceoryx2-bb-testing = { workspace = true }
serde_test = { workspace = true }
iceoryx2-bb-elementary = { workspace = true, features = ["testing"]}
10 changes: 10 additions & 0 deletions iceoryx2-bb/elementary/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ filegroup(
rust_library(
name = "iceoryx2-bb-elementary",
srcs = glob(["src/**/*.rs"]),
crate_features = [ "testing" ],
Copy link
Member

Choose a reason for hiding this comment

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

Okay, I think here we have a problem. I totally overlooked that this one needs to be part of rust_test_suite. But in that won't work and if it is part of rust_library all consumers of iceoryx2-bb-elementary will have access to the BumpAllocator.

It seems what we want to achieve is not compatible with bazel :/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

probably we can define 2 rust_library for different purposes, one for users and one for testing. I will try it today to see whether it works or not.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@elBoberido never mind, I have defined a new rust_library inside elementary with testing feature and define an alias inside container for the test cases. So it doesn't affect the common rust_library definitions.

deps = [
"//iceoryx2-pal/concurrency-sync:iceoryx2-pal-concurrency-sync",
],
)

rust_library(
name = "iceoryx2-bb-elementary-with-feature-testing",
srcs = glob(["src/**/*.rs"]),
crate_features = [ "testing" ],
deps = [
"//iceoryx2-pal/concurrency-sync:iceoryx2-pal-concurrency-sync",
],
Expand Down
2 changes: 2 additions & 0 deletions iceoryx2-bb/elementary/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ iceoryx2-bb-testing = { workspace = true }

generic-tests = { workspace = true }

[features]
testing = []
1 change: 0 additions & 1 deletion iceoryx2-bb/elementary/src/bump_allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ use std::sync::atomic::Ordering;

/// Simple BumpAllocator for testing purposes. Do not use this in production. If you are looking
/// for a production ready BumpAllocator use the one from iceoryx2_bb_memory::bump_allocator
#[doc(hidden)]
pub struct BumpAllocator {
start: usize,
pos: IoxAtomicUsize,
Expand Down
2 changes: 2 additions & 0 deletions iceoryx2-bb/elementary/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ pub mod enum_gen;
/// A strong type that represents the alignment part of [`std::alloc::Layout`]
pub mod alignment;
pub mod allocator;

#[cfg(feature = "testing")]
pub mod bump_allocator;
pub mod lazy_singleton;
pub mod math;
Expand Down
Loading