From ee880ea48142b06358d1bbc01e8962095159bdfb Mon Sep 17 00:00:00 2001 From: xieyuschen Date: Wed, 16 Oct 2024 17:12:19 +0800 Subject: [PATCH 1/2] [#476] Introduce test feature in iceoryx-bb for bump_allocator --- iceoryx2-bb/container/Cargo.toml | 1 + iceoryx2-bb/elementary/Cargo.toml | 2 ++ iceoryx2-bb/elementary/src/bump_allocator.rs | 1 - iceoryx2-bb/elementary/src/lib.rs | 2 ++ 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/iceoryx2-bb/container/Cargo.toml b/iceoryx2-bb/container/Cargo.toml index 03a915943..d2c4c19e8 100644 --- a/iceoryx2-bb/container/Cargo.toml +++ b/iceoryx2-bb/container/Cargo.toml @@ -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"]} \ No newline at end of file diff --git a/iceoryx2-bb/elementary/Cargo.toml b/iceoryx2-bb/elementary/Cargo.toml index 2ebb07476..c34eeb59a 100644 --- a/iceoryx2-bb/elementary/Cargo.toml +++ b/iceoryx2-bb/elementary/Cargo.toml @@ -18,3 +18,5 @@ iceoryx2-bb-testing = { workspace = true } generic-tests = { workspace = true } +[features] +testing = [] \ No newline at end of file diff --git a/iceoryx2-bb/elementary/src/bump_allocator.rs b/iceoryx2-bb/elementary/src/bump_allocator.rs index 9bdd0d846..f5bc5cb55 100644 --- a/iceoryx2-bb/elementary/src/bump_allocator.rs +++ b/iceoryx2-bb/elementary/src/bump_allocator.rs @@ -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, diff --git a/iceoryx2-bb/elementary/src/lib.rs b/iceoryx2-bb/elementary/src/lib.rs index 3b1bfb0df..78f7b0ddb 100644 --- a/iceoryx2-bb/elementary/src/lib.rs +++ b/iceoryx2-bb/elementary/src/lib.rs @@ -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; From 8ffa846ddeb6bab020c408fdd8987632c6a4aa3b Mon Sep 17 00:00:00 2001 From: xieyuschen Date: Tue, 22 Oct 2024 23:13:05 +0800 Subject: [PATCH 2/2] [#476] Enable testing feature for test_suite only in bazel --- iceoryx2-bb/container/BUILD.bazel | 6 ++++++ iceoryx2-bb/elementary/BUILD.bazel | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/iceoryx2-bb/container/BUILD.bazel b/iceoryx2-bb/container/BUILD.bazel index 45b876a3a..4e0d025c4 100644 --- a/iceoryx2-bb/container/BUILD.bazel +++ b/iceoryx2-bb/container/BUILD.bazel @@ -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"]), diff --git a/iceoryx2-bb/elementary/BUILD.bazel b/iceoryx2-bb/elementary/BUILD.bazel index ceb655b3a..04f9490d8 100644 --- a/iceoryx2-bb/elementary/BUILD.bazel +++ b/iceoryx2-bb/elementary/BUILD.bazel @@ -22,6 +22,16 @@ filegroup( rust_library( name = "iceoryx2-bb-elementary", srcs = glob(["src/**/*.rs"]), + crate_features = [ "testing" ], + 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", ],