diff --git a/doc/how-to-create-an-iceoryx2-release.md b/doc/how-to-create-an-iceoryx2-release.md index dfdf9f69f..d5a5d1e04 100644 --- a/doc/how-to-create-an-iceoryx2-release.md +++ b/doc/how-to-create-an-iceoryx2-release.md @@ -79,10 +79,11 @@ number is `Xold.Yold.Zold`. 10. Adjust the `` to `X.Y.Z` in `$GIT_ROOT$/package.xml`. 11. Call `rg "Xold\.Yold\.Zold"` and adjust all findings. * C and C++ examples, `BUILD.bazel` & `CMakeLists.txt` -12. **Merge all changes to `main`.** -13. Set tag on GitHub and add the release document as notes to the tag +12. Adjust the major, minor and patch version number in `iceoryx2_bb_elementary::PackageVersion` +13. **Merge all changes to `main`.** +14. Set tag on GitHub and add the release document as notes to the tag description. Add also a link to the file. -14. Check the order of all dependencies in +15. Check the order of all dependencies in `$GIT_ROOT$/./internal/scripts/crates_io_publish_script.sh`. When calling `cargo publish -p $PACKAGE$` all dependencies, also dev-dependencies, must be already published to `crates.io` via `cargo publish -p`. Verify the @@ -92,7 +93,7 @@ number is `Xold.Yold.Zold`. * If the publish script was started and a crate requires a dependency which is not available on `crates.io` the release has to be redone and the patch version has to increase by one for the whole workspace. -15. Call `$GIT_ROOT$/./internal/scripts/crates_io_publish_script.sh` and publish +16. Call `$GIT_ROOT$/./internal/scripts/crates_io_publish_script.sh` and publish all crates on `crates.io` and `docs.rs`. -16. Verify that the release looks fine on `docs.rs` (click through the +17. Verify that the release looks fine on `docs.rs` (click through the documentation to check if everything was generated correctly) diff --git a/iceoryx2-bb/elementary/src/package_version.rs b/iceoryx2-bb/elementary/src/package_version.rs index 82a0368c6..d38753cd7 100644 --- a/iceoryx2-bb/elementary/src/package_version.rs +++ b/iceoryx2-bb/elementary/src/package_version.rs @@ -10,8 +10,7 @@ // // SPDX-License-Identifier: Apache-2.0 OR MIT -use iceoryx2_pal_concurrency_sync::iox_atomic::IoxAtomicU64; -use std::{fmt::Display, sync::atomic::Ordering}; +use std::fmt::Display; /// Represents the crates version acquired through the internal environment variables set by cargo, /// ("CARGO_PKG_VERSION_{MAJOR|MINOR|PATCH}"). @@ -63,26 +62,11 @@ impl PackageVersion { /// Returns the current [`PackageVersion`] pub fn get() -> PackageVersion { - static PACKAGE_VERSION: IoxAtomicU64 = IoxAtomicU64::new(0); + const MAJOR: u16 = 0; + const MINOR: u16 = 4; + const PATCH: u16 = 1; - if PACKAGE_VERSION.load(Ordering::Relaxed) == 0 { - let major = option_env!("CARGO_PKG_VERSION_MAJOR") - .and_then(|s| s.parse::().ok()) - .unwrap_or(u16::MAX); - let minor = option_env!("CARGO_PKG_VERSION_MINOR") - .and_then(|s| s.parse::().ok()) - .unwrap_or(u16::MAX); - let patch = option_env!("CARGO_PKG_VERSION_PATCH") - .and_then(|s| s.parse::().ok()) - .unwrap_or(u16::MAX); - - PACKAGE_VERSION.store( - PackageVersion::from_version(major, minor, patch).0, - Ordering::Relaxed, - ); - } - - PackageVersion::from_u64(PACKAGE_VERSION.load(Ordering::Relaxed)) + PackageVersion::from_version(MAJOR, MINOR, PATCH) } } diff --git a/iceoryx2-bb/elementary/tests/package_version_tests.rs b/iceoryx2-bb/elementary/tests/package_version_tests.rs new file mode 100644 index 000000000..ecdc4134e --- /dev/null +++ b/iceoryx2-bb/elementary/tests/package_version_tests.rs @@ -0,0 +1,35 @@ +// Copyright (c) 2024 Contributors to the Eclipse Foundation +// +// See the NOTICE file(s) distributed with this work for additional +// information regarding copyright ownership. +// +// This program and the accompanying materials are made available under the +// terms of the Apache Software License 2.0 which is available at +// https://www.apache.org/licenses/LICENSE-2.0, or the MIT license +// which is available at https://opensource.org/licenses/MIT. +// +// SPDX-License-Identifier: Apache-2.0 OR MIT + +use iceoryx2_bb_elementary::package_version::PackageVersion; +use iceoryx2_bb_testing::assert_that; + +#[test] +fn package_version_works() { + let major = option_env!("CARGO_PKG_VERSION_MAJOR") + .and_then(|s| s.parse::().ok()) + .expect("Contains a valid major version number."); + let minor = option_env!("CARGO_PKG_VERSION_MINOR") + .and_then(|s| s.parse::().ok()) + .expect("Contains a valid minor version number."); + let patch = option_env!("CARGO_PKG_VERSION_PATCH") + .and_then(|s| s.parse::().ok()) + .expect("Contains a valid patch version number."); + + let sut = PackageVersion::get(); + + assert_that!(sut.major(), eq major); + assert_that!(sut.minor(), eq minor); + assert_that!(sut.patch(), eq patch); + + assert_that!(major == 0 && minor == 0 && patch == 0, eq false); +} diff --git a/iceoryx2-cal/src/dynamic_storage/posix_shared_memory.rs b/iceoryx2-cal/src/dynamic_storage/posix_shared_memory.rs index 1bc2c90a4..bd467e810 100644 --- a/iceoryx2-cal/src/dynamic_storage/posix_shared_memory.rs +++ b/iceoryx2-cal/src/dynamic_storage/posix_shared_memory.rs @@ -215,18 +215,18 @@ impl<'builder, T: Send + Sync + Debug> Builder<'builder, T> { let init_state = shm.base_address().as_ptr() as *const Data; - // The mem-sync is actually not required since an uninitialized dynamic storage has - // only write permissions and can be therefore not consumed. - // This is only for the case that this strategy fails on an obscure POSIX platform. - // - ////////////////////////////////////////// - // SYNC POINT: read Data::data - ////////////////////////////////////////// - let package_version = unsafe { &(*init_state) } - .version - .load(std::sync::atomic::Ordering::SeqCst); - loop { + // The mem-sync is actually not required since an uninitialized dynamic storage has + // only write permissions and can be therefore not consumed. + // This is only for the case that this strategy fails on an obscure POSIX platform. + // + ////////////////////////////////////////// + // SYNC POINT: read Data::data + ////////////////////////////////////////// + let package_version = unsafe { &(*init_state) } + .version + .load(std::sync::atomic::Ordering::SeqCst); + let package_version = PackageVersion::from_u64(package_version); if package_version.to_u64() == 0 { if elapsed_time >= self.timeout { diff --git a/iceoryx2-ffi/cxx/tests/src/service_event_tests.cpp b/iceoryx2-ffi/cxx/tests/src/service_event_tests.cpp index 757a313f2..cbe30fbd5 100644 --- a/iceoryx2-ffi/cxx/tests/src/service_event_tests.cpp +++ b/iceoryx2-ffi/cxx/tests/src/service_event_tests.cpp @@ -10,6 +10,8 @@ // // SPDX-License-Identifier: Apache-2.0 OR MIT +#include + #include "iox2/node.hpp" #include "iox2/node_name.hpp" #include "iox2/service.hpp" @@ -24,8 +26,7 @@ constexpr iox::units::Duration TIMEOUT = iox::units::Duration::fromMilliseconds( template struct ServiceEventTest : public ::testing::Test { ServiceEventTest() - : service_name_value { "We all love the hypnotoad!" } - , service_name { ServiceName::create(service_name_value).expect("") } + : service_name { iox2_testing::generate_service_name() } , node { NodeBuilder().create().expect("") } , service { node.service_builder(service_name).event().create().expect("") } , notifier { service.notifier_builder().create().expect("") } @@ -37,7 +38,6 @@ struct ServiceEventTest : public ::testing::Test { static std::atomic event_id_counter; static constexpr ServiceType TYPE = T::TYPE; //NOLINTBEGIN(misc-non-private-member-variables-in-classes), required for tests - const char* service_name_value { nullptr }; ServiceName service_name; Node node; PortFactoryEvent service; @@ -56,8 +56,7 @@ TYPED_TEST_SUITE(ServiceEventTest, iox2_testing::ServiceTypes); TYPED_TEST(ServiceEventTest, created_service_does_exist) { constexpr ServiceType SERVICE_TYPE = TestFixture::TYPE; - const auto* name_value = "First time we met, I saw the ocean, it was wet!"; - const auto service_name = ServiceName::create(name_value).expect(""); + const auto service_name = iox2_testing::generate_service_name(); ASSERT_FALSE( Service::does_exist(service_name, Config::global_config(), MessagingPattern::Event).expect("")); @@ -78,8 +77,7 @@ TYPED_TEST(ServiceEventTest, created_service_does_exist) { TYPED_TEST(ServiceEventTest, creating_existing_service_fails) { constexpr ServiceType SERVICE_TYPE = TestFixture::TYPE; - const auto* name_value = "First time we met, I saw the ocean, it was wet!"; - const auto service_name = ServiceName::create(name_value).expect(""); + const auto service_name = iox2_testing::generate_service_name(); auto node = NodeBuilder().create().expect(""); auto sut = node.service_builder(service_name).event().create().expect(""); @@ -94,8 +92,7 @@ TYPED_TEST(ServiceEventTest, service_settings_are_applied) { constexpr uint64_t NUMBER_OF_NOTIFIERS = 5; constexpr uint64_t NUMBER_OF_LISTENERS = 7; - const auto* name_value = "First time we met, I saw the ocean, it was wet!"; - const auto service_name = ServiceName::create(name_value).expect(""); + const auto service_name = iox2_testing::generate_service_name(); auto node = NodeBuilder().create().expect(""); auto sut = node.service_builder(service_name) @@ -115,8 +112,7 @@ TYPED_TEST(ServiceEventTest, open_fails_with_incompatible_max_notifiers_requirem constexpr ServiceType SERVICE_TYPE = TestFixture::TYPE; constexpr uint64_t NUMBER_OF_NOTIFIERS = 5; - const auto* name_value = "First time we met, I saw the ocean, it was wet!"; - const auto service_name = ServiceName::create(name_value).expect(""); + const auto service_name = iox2_testing::generate_service_name(); auto node = NodeBuilder().create().expect(""); auto sut = node.service_builder(service_name).event().max_notifiers(NUMBER_OF_NOTIFIERS).create().expect(""); @@ -130,8 +126,7 @@ TYPED_TEST(ServiceEventTest, open_fails_with_incompatible_max_listeners_requirem constexpr ServiceType SERVICE_TYPE = TestFixture::TYPE; constexpr uint64_t NUMBER_OF_LISTENERS = 7; - const auto* name_value = "First time we met, I saw the ocean, it was wet!"; - const auto service_name = ServiceName::create(name_value).expect(""); + const auto service_name = iox2_testing::generate_service_name(); auto node = NodeBuilder().create().expect(""); auto sut = node.service_builder(service_name).event().max_listeners(NUMBER_OF_LISTENERS).create().expect(""); @@ -144,8 +139,7 @@ TYPED_TEST(ServiceEventTest, open_fails_with_incompatible_max_listeners_requirem TYPED_TEST(ServiceEventTest, open_or_create_service_does_exist) { constexpr ServiceType SERVICE_TYPE = TestFixture::TYPE; - const auto* name_value = "First time we met, I saw the ocean, it was wet!"; - const auto service_name = ServiceName::create(name_value).expect(""); + const auto service_name = iox2_testing::generate_service_name(); ASSERT_FALSE( Service::does_exist(service_name, Config::global_config(), MessagingPattern::Event).expect("")); @@ -180,8 +174,7 @@ TYPED_TEST(ServiceEventTest, open_or_create_service_does_exist) { TYPED_TEST(ServiceEventTest, opening_non_existing_service_fails) { constexpr ServiceType SERVICE_TYPE = TestFixture::TYPE; - const auto* name_value = "First time we met, I saw the ocean, it was wet!"; - const auto service_name = ServiceName::create(name_value).expect(""); + const auto service_name = iox2_testing::generate_service_name(); auto node = NodeBuilder().create().expect(""); auto sut = node.service_builder(service_name).event().open(); @@ -192,8 +185,7 @@ TYPED_TEST(ServiceEventTest, opening_non_existing_service_fails) { TYPED_TEST(ServiceEventTest, opening_existing_service_works) { constexpr ServiceType SERVICE_TYPE = TestFixture::TYPE; - const auto* name_value = "First time we met, I saw the ocean, it was wet!"; - const auto service_name = ServiceName::create(name_value).expect(""); + const auto service_name = iox2_testing::generate_service_name(); auto node = NodeBuilder().create().expect(""); auto sut_create = node.service_builder(service_name).event().create(); @@ -204,8 +196,7 @@ TYPED_TEST(ServiceEventTest, opening_existing_service_works) { TYPED_TEST(ServiceEventTest, service_name_is_set) { constexpr ServiceType SERVICE_TYPE = TestFixture::TYPE; - const auto* name_value = "Another one bites the toad."; - const auto service_name = ServiceName::create(name_value).expect(""); + const auto service_name = iox2_testing::generate_service_name(); auto node = NodeBuilder().create().expect(""); auto sut = node.service_builder(service_name).event().create().expect(""); diff --git a/iceoryx2-ffi/cxx/tests/src/service_publish_subscribe_tests.cpp b/iceoryx2-ffi/cxx/tests/src/service_publish_subscribe_tests.cpp index 4f6bcabbb..d9bb1c071 100644 --- a/iceoryx2-ffi/cxx/tests/src/service_publish_subscribe_tests.cpp +++ b/iceoryx2-ffi/cxx/tests/src/service_publish_subscribe_tests.cpp @@ -36,8 +36,7 @@ TYPED_TEST_SUITE(ServicePublishSubscribeTest, iox2_testing::ServiceTypes); TYPED_TEST(ServicePublishSubscribeTest, created_service_does_exist) { constexpr ServiceType SERVICE_TYPE = TestFixture::TYPE; - const auto* name_value = "I am floating through the galaxy of my brain. Oh the colors!"; - const auto service_name = ServiceName::create(name_value).expect(""); + const auto service_name = iox2_testing::generate_service_name(); ASSERT_FALSE( Service::does_exist(service_name, Config::global_config(), MessagingPattern::PublishSubscribe) @@ -60,8 +59,7 @@ TYPED_TEST(ServicePublishSubscribeTest, created_service_does_exist) { TYPED_TEST(ServicePublishSubscribeTest, creating_existing_service_fails) { constexpr ServiceType SERVICE_TYPE = TestFixture::TYPE; - const auto* name_value = "I am floating through the galaxy of my brain. Oh the colors!"; - const auto service_name = ServiceName::create(name_value).expect(""); + const auto service_name = iox2_testing::generate_service_name(); ASSERT_FALSE( Service::does_exist(service_name, Config::global_config(), MessagingPattern::PublishSubscribe) @@ -78,8 +76,7 @@ TYPED_TEST(ServicePublishSubscribeTest, creating_existing_service_fails) { TYPED_TEST(ServicePublishSubscribeTest, open_or_create_service_does_exist) { constexpr ServiceType SERVICE_TYPE = TestFixture::TYPE; - const auto* name_value = "I am floating through the galaxy of my brain. Oh the colors!"; - const auto service_name = ServiceName::create(name_value).expect(""); + const auto service_name = iox2_testing::generate_service_name(); ASSERT_FALSE( Service::does_exist(service_name, Config::global_config(), MessagingPattern::PublishSubscribe) @@ -119,8 +116,7 @@ TYPED_TEST(ServicePublishSubscribeTest, open_or_create_service_does_exist) { TYPED_TEST(ServicePublishSubscribeTest, opening_non_existing_service_fails) { constexpr ServiceType SERVICE_TYPE = TestFixture::TYPE; - const auto* name_value = "I am floating through the galaxy of my brain. Oh the colors!"; - const auto service_name = ServiceName::create(name_value).expect(""); + const auto service_name = iox2_testing::generate_service_name(); auto node = NodeBuilder().create().expect(""); auto sut = node.service_builder(service_name).template publish_subscribe().open(); @@ -131,8 +127,7 @@ TYPED_TEST(ServicePublishSubscribeTest, opening_non_existing_service_fails) { TYPED_TEST(ServicePublishSubscribeTest, opening_existing_service_works) { constexpr ServiceType SERVICE_TYPE = TestFixture::TYPE; - const auto* name_value = "I am floating through the galaxy of my brain. Oh the colors!"; - const auto service_name = ServiceName::create(name_value).expect(""); + const auto service_name = iox2_testing::generate_service_name(); auto node = NodeBuilder().create().expect(""); auto sut_create = node.service_builder(service_name).template publish_subscribe().create(); @@ -143,8 +138,7 @@ TYPED_TEST(ServicePublishSubscribeTest, opening_existing_service_works) { TYPED_TEST(ServicePublishSubscribeTest, opening_existing_service_with_wrong_payload_type_fails) { constexpr ServiceType SERVICE_TYPE = TestFixture::TYPE; - const auto* name_value = "I am floating through the galaxy of my brain. Oh the colors!"; - const auto service_name = ServiceName::create(name_value).expect(""); + const auto service_name = iox2_testing::generate_service_name(); auto node = NodeBuilder().create().expect(""); auto sut_create = node.service_builder(service_name).template publish_subscribe().create(); @@ -156,8 +150,7 @@ TYPED_TEST(ServicePublishSubscribeTest, opening_existing_service_with_wrong_payl TYPED_TEST(ServicePublishSubscribeTest, open_or_create_existing_service_with_wrong_payload_type_fails) { constexpr ServiceType SERVICE_TYPE = TestFixture::TYPE; - const auto* name_value = "I am floating through the galaxy of my brain. Oh the colors!"; - const auto service_name = ServiceName::create(name_value).expect(""); + const auto service_name = iox2_testing::generate_service_name(); auto node = NodeBuilder().create().expect(""); auto sut_create = node.service_builder(service_name).template publish_subscribe().create(); @@ -169,8 +162,7 @@ TYPED_TEST(ServicePublishSubscribeTest, open_or_create_existing_service_with_wro TYPED_TEST(ServicePublishSubscribeTest, send_copy_receive_works) { constexpr ServiceType SERVICE_TYPE = TestFixture::TYPE; - const auto* name_value = "I am floating through the galaxy of my brain. Oh the colors!"; - const auto service_name = ServiceName::create(name_value).expect(""); + const auto service_name = iox2_testing::generate_service_name(); auto node = NodeBuilder().create().expect(""); auto service = node.service_builder(service_name).template publish_subscribe().create().expect(""); @@ -189,8 +181,7 @@ TYPED_TEST(ServicePublishSubscribeTest, send_copy_receive_works) { TYPED_TEST(ServicePublishSubscribeTest, loan_uninit_send_receive_works) { constexpr ServiceType SERVICE_TYPE = TestFixture::TYPE; - const auto* name_value = "I am floating through the galaxy of my brain. Oh the colors!"; - const auto service_name = ServiceName::create(name_value).expect(""); + const auto service_name = iox2_testing::generate_service_name(); auto node = NodeBuilder().create().expect(""); auto service = node.service_builder(service_name).template publish_subscribe().create().expect(""); @@ -211,8 +202,7 @@ TYPED_TEST(ServicePublishSubscribeTest, loan_uninit_send_receive_works) { TYPED_TEST(ServicePublishSubscribeTest, loan_send_receive_works) { constexpr ServiceType SERVICE_TYPE = TestFixture::TYPE; - const auto* name_value = "I am floating through the galaxy of my brain. Oh the colors!"; - const auto service_name = ServiceName::create(name_value).expect(""); + const auto service_name = iox2_testing::generate_service_name(); auto node = NodeBuilder().create().expect(""); auto service = node.service_builder(service_name).template publish_subscribe().create().expect(""); @@ -233,8 +223,7 @@ TYPED_TEST(ServicePublishSubscribeTest, loan_send_receive_works) { TYPED_TEST(ServicePublishSubscribeTest, update_connections_delivers_history) { constexpr ServiceType SERVICE_TYPE = TestFixture::TYPE; - const auto* name_value = "Whoop here it is - the publishers historyyyy!"; - const auto service_name = ServiceName::create(name_value).expect(""); + const auto service_name = iox2_testing::generate_service_name(); auto node = NodeBuilder().create().expect(""); auto service = node.service_builder(service_name).template publish_subscribe().create().expect(""); @@ -264,8 +253,7 @@ TYPED_TEST(ServicePublishSubscribeTest, setting_service_properties_works) { constexpr uint64_t SUBSCRIBER_MAX_BUFFER_SIZE = 14; constexpr uint64_t SUBSCRIBER_MAX_BORROWED_SAMPLES = 15; - const auto* name_value = "I am floating through the galaxy of my brain. Oh the colors!"; - const auto service_name = ServiceName::create(name_value).expect(""); + const auto service_name = iox2_testing::generate_service_name(); auto node = NodeBuilder().create().expect(""); auto service = node.service_builder(service_name) @@ -295,8 +283,7 @@ TYPED_TEST(ServicePublishSubscribeTest, setting_service_properties_works) { TYPED_TEST(ServicePublishSubscribeTest, safe_overflow_can_be_set) { constexpr ServiceType SERVICE_TYPE = TestFixture::TYPE; - const auto* name_value = "I am floating through the galaxy of my brain. Oh the colors!"; - const auto service_name = ServiceName::create(name_value).expect(""); + const auto service_name = iox2_testing::generate_service_name(); auto node = NodeBuilder().create().expect(""); @@ -317,8 +304,7 @@ TYPED_TEST(ServicePublishSubscribeTest, open_fails_with_incompatible_publisher_r constexpr ServiceType SERVICE_TYPE = TestFixture::TYPE; constexpr uint64_t NUMBER_OF_PUBLISHERS = 11; - const auto* name_value = "I am floating through the galaxy of my brain. Oh the colors!"; - const auto service_name = ServiceName::create(name_value).expect(""); + const auto service_name = iox2_testing::generate_service_name(); auto node = NodeBuilder().create().expect(""); auto service = node.service_builder(service_name) @@ -340,8 +326,7 @@ TYPED_TEST(ServicePublishSubscribeTest, open_fails_with_incompatible_subscriber_ constexpr ServiceType SERVICE_TYPE = TestFixture::TYPE; constexpr uint64_t NUMBER_OF_SUBSCRIBERS = 12; - const auto* name_value = "I am floating through the galaxy of my brain. Oh the colors!"; - const auto service_name = ServiceName::create(name_value).expect(""); + const auto service_name = iox2_testing::generate_service_name(); auto node = NodeBuilder().create().expect(""); auto service = node.service_builder(service_name) @@ -362,8 +347,7 @@ TYPED_TEST(ServicePublishSubscribeTest, open_fails_with_incompatible_subscriber_ TYPED_TEST(ServicePublishSubscribeTest, publisher_applies_unable_to_deliver_strategy) { constexpr ServiceType SERVICE_TYPE = TestFixture::TYPE; - const auto* name_value = "I am floating through the galaxy of my brain. Oh the colors!"; - const auto service_name = ServiceName::create(name_value).expect(""); + const auto service_name = iox2_testing::generate_service_name(); auto node = NodeBuilder().create().expect(""); auto service = node.service_builder(service_name).template publish_subscribe().create().expect(""); @@ -382,8 +366,7 @@ TYPED_TEST(ServicePublishSubscribeTest, publisher_applies_unable_to_deliver_stra TYPED_TEST(ServicePublishSubscribeTest, send_receive_with_user_header_works) { constexpr ServiceType SERVICE_TYPE = TestFixture::TYPE; - const auto* name_value = "I am floating through the galaxy of my brain. Oh the colors!"; - const auto service_name = ServiceName::create(name_value).expect(""); + const auto service_name = iox2_testing::generate_service_name(); auto node = NodeBuilder().create().expect(""); auto service_pub = node.service_builder(service_name) @@ -420,8 +403,7 @@ TYPED_TEST(ServicePublishSubscribeTest, send_receive_with_user_header_works) { TYPED_TEST(ServicePublishSubscribeTest, has_sample_works) { constexpr ServiceType SERVICE_TYPE = TestFixture::TYPE; - const auto* name_value = "I am floating through the galaxy of my brain. Oh the colors!"; - const auto service_name = ServiceName::create(name_value).expect(""); + const auto service_name = iox2_testing::generate_service_name(); auto node = NodeBuilder().create().expect(""); auto service = node.service_builder(service_name).template publish_subscribe().create().expect(""); @@ -437,6 +419,4 @@ TYPED_TEST(ServicePublishSubscribeTest, has_sample_works) { auto sample = sut_subscriber.receive().expect(""); ASSERT_FALSE(*sut_subscriber.has_samples()); } - - } // namespace diff --git a/iceoryx2-ffi/cxx/tests/src/test.hpp b/iceoryx2-ffi/cxx/tests/src/test.hpp index 396a33c7a..2a3ad1aad 100644 --- a/iceoryx2-ffi/cxx/tests/src/test.hpp +++ b/iceoryx2-ffi/cxx/tests/src/test.hpp @@ -16,6 +16,7 @@ #include #include +#include "iox2/service_name.hpp" #include "iox2/service_type.hpp" using namespace ::testing; @@ -31,6 +32,15 @@ using ServiceTypeLocal = TypeServiceType; using ServiceTypes = ::testing::Types; +inline auto generate_service_name() -> ServiceName { + static std::atomic COUNTER = 0; + const auto now = std::chrono::system_clock::now().time_since_epoch().count(); + const auto random_number = rand(); // NOLINT(cert-msc30-c,cert-msc50-cpp) + return ServiceName::create((std::string("service_event_tests_") + std::to_string(COUNTER.fetch_add(1)) + "_" + + std::to_string(now) + "_" + std::to_string(random_number)) + .c_str()) + .expect(""); +} } // namespace iox2_testing #endif // IOX2_CXX_TESTS_TEST_HPP diff --git a/iceoryx2-ffi/cxx/tests/src/unique_port_id_tests.cpp b/iceoryx2-ffi/cxx/tests/src/unique_port_id_tests.cpp index 966cb53d1..939e4ec34 100644 --- a/iceoryx2-ffi/cxx/tests/src/unique_port_id_tests.cpp +++ b/iceoryx2-ffi/cxx/tests/src/unique_port_id_tests.cpp @@ -25,19 +25,13 @@ namespace { using namespace iox2; -auto generate_name() -> ServiceName { - static std::atomic COUNTER = 0; - return ServiceName::create((std::string("unique_port_id_tests_") + std::to_string(COUNTER.fetch_add(1))).c_str()) - .expect(""); -} - template struct UniquePortIdTest : public ::testing::Test { static constexpr ServiceType TYPE = T::TYPE; UniquePortIdTest() : node { NodeBuilder().create().expect("") } - , service_name { generate_name() } + , service_name { iox2_testing::generate_service_name() } , event { node.service_builder(service_name).event().create().expect("") } , pubsub { node.service_builder(service_name).template publish_subscribe().create().expect("") } , listener_1 { event.listener_builder().create().expect("") }