From fbd329cf77c51dbea7e6310645f4f64f3f3a7e4c Mon Sep 17 00:00:00 2001 From: Eduardo Ponz Segrelles Date: Mon, 27 Nov 2023 06:51:23 +0100 Subject: [PATCH 1/3] Add missing thread include (#4045) * Refs #19887: Add missing thread include Signed-off-by: EduPonz * Refs #19887. Update `ReturnCode_t` comparison operators. Signed-off-by: Miguel Company * Refs #19887: Uncrustify Signed-off-by: EduPonz --------- Signed-off-by: EduPonz Signed-off-by: Miguel Company Co-authored-by: Miguel Company (cherry picked from commit 6390715a1df8eb487fd20ad501893870da281117) # Conflicts: # test/blackbox/common/BlackboxTestsPubSubHistory.cpp # test/blackbox/common/DDSBlackboxTestsListeners.cpp # test/blackbox/common/DDSBlackboxTestsOwnershipQos.cpp # test/unittest/dds/publisher/DataWriterTests.cpp # test/unittest/rtps/flowcontrol/FlowControllerPublishModesOnAsyncTests.cpp # test/unittest/rtps/flowcontrol/FlowControllerPublishModesOnLimitedAsyncTests.cpp # test/unittest/rtps/flowcontrol/FlowControllerPublishModesOnPureSyncTests.cpp # test/unittest/rtps/flowcontrol/FlowControllerPublishModesOnSyncTests.cpp # test/unittest/rtps/flowcontrol/FlowControllerSchedulersTests.cpp # test/unittest/statistics/rtps/RTPSStatisticsTests.cpp --- include/fastrtps/types/TypesBase.h | 28 +- .../common/BlackboxTestsDeadlineQos.cpp | 13 +- .../BlackboxTestsPubSubFlowControllers.cpp | 10 +- .../common/BlackboxTestsPubSubFragments.cpp | 9 +- .../common/BlackboxTestsPubSubHistory.cpp | 15 + .../common/BlackboxTestsReliability.cpp | 9 +- .../common/DDSBlackboxTestsContentFilter.cpp | 13 +- .../common/DDSBlackboxTestsDataReader.cpp | 10 +- .../common/DDSBlackboxTestsDataSharing.cpp | 15 +- .../common/DDSBlackboxTestsListeners.cpp | 13 + .../common/DDSBlackboxTestsOwnershipQos.cpp | 2184 +++++++++++++++++ .../common/DDSBlackboxTestsPersistence.cpp | 14 +- test/performance/video/VideoTestPublisher.cpp | 134 +- .../performance/video/VideoTestSubscriber.cpp | 13 +- test/performance/video/main_VideoTest.cpp | 20 +- test/profiling/MemoryTestPublisher.cpp | 150 +- test/profiling/MemoryTestSubscriber.cpp | 125 +- .../allocations/AllocTestPublisher.cpp | 10 +- .../allocations/AllocTestSubscriber.cpp | 10 +- test/profiling/main_MemoryTest.cpp | 19 +- .../dds/core/condition/ConditionTests.cpp | 10 +- test/unittest/dds/core/entity/EntityTests.cpp | 9 +- .../dds/publisher/DataWriterTests.cpp | 25 +- .../unittest/logging/log_macros/LogMacros.hpp | 6 +- ...FlowControllerPublishModesOnAsyncTests.cpp | 21 + ...trollerPublishModesOnLimitedAsyncTests.cpp | 21 + ...wControllerPublishModesOnPureSyncTests.cpp | 21 + .../FlowControllerPublishModesOnSyncTests.cpp | 21 + .../FlowControllerSchedulersTests.cpp | 22 + .../security/logging/LoggingPluginTests.hpp | 122 +- .../statistics/rtps/RTPSStatisticsTests.cpp | 16 +- 31 files changed, 2795 insertions(+), 313 deletions(-) create mode 100644 test/blackbox/common/DDSBlackboxTestsOwnershipQos.cpp diff --git a/include/fastrtps/types/TypesBase.h b/include/fastrtps/types/TypesBase.h index e9f346b8ef1..be281047aa5 100644 --- a/include/fastrtps/types/TypesBase.h +++ b/include/fastrtps/types/TypesBase.h @@ -246,20 +246,32 @@ class RTPS_DllAPI ReturnCode_t }; -template -typename std::enable_if::value || std::is_enum::value, bool>::type -operator ==( - T a, +RTPS_DllAPI inline bool operator ==( + ReturnCode_t::ReturnCodeValue a, const ReturnCode_t& b) { return b.operator ==( a); } -template -typename std::enable_if::value || std::is_enum::value, bool>::type -operator !=( - T a, +RTPS_DllAPI inline bool operator !=( + ReturnCode_t::ReturnCodeValue a, + const ReturnCode_t& b) +{ + return b.operator !=( + a); +} + +RTPS_DllAPI inline bool operator ==( + uint32_t a, + const ReturnCode_t& b) +{ + return b.operator ==( + a); +} + +RTPS_DllAPI inline bool operator !=( + uint32_t a, const ReturnCode_t& b) { return b.operator !=( diff --git a/test/blackbox/common/BlackboxTestsDeadlineQos.cpp b/test/blackbox/common/BlackboxTestsDeadlineQos.cpp index 3be213bced2..b97bd366859 100644 --- a/test/blackbox/common/BlackboxTestsDeadlineQos.cpp +++ b/test/blackbox/common/BlackboxTestsDeadlineQos.cpp @@ -12,18 +12,19 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "BlackboxTests.hpp" - -#include "PubSubReader.hpp" -#include "PubSubWriter.hpp" -#include "ReqRepAsReliableHelloWorldRequester.hpp" -#include "ReqRepAsReliableHelloWorldReplier.hpp" +#include #include #include #include +#include "BlackboxTests.hpp" +#include "PubSubReader.hpp" +#include "PubSubWriter.hpp" +#include "ReqRepAsReliableHelloWorldReplier.hpp" +#include "ReqRepAsReliableHelloWorldRequester.hpp" + using namespace eprosima::fastrtps; using namespace eprosima::fastrtps::rtps; diff --git a/test/blackbox/common/BlackboxTestsPubSubFlowControllers.cpp b/test/blackbox/common/BlackboxTestsPubSubFlowControllers.cpp index bde2389b62e..439ad1c548e 100644 --- a/test/blackbox/common/BlackboxTestsPubSubFlowControllers.cpp +++ b/test/blackbox/common/BlackboxTestsPubSubFlowControllers.cpp @@ -12,14 +12,16 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "BlackboxTests.hpp" +#include + +#include + +#include +#include "BlackboxTests.hpp" #include "PubSubReader.hpp" #include "PubSubWriter.hpp" #include "PubSubWriterReader.hpp" -#include - -#include using namespace eprosima::fastrtps; using namespace eprosima::fastrtps::rtps; diff --git a/test/blackbox/common/BlackboxTestsPubSubFragments.cpp b/test/blackbox/common/BlackboxTestsPubSubFragments.cpp index 122fd61ff82..9df48268914 100644 --- a/test/blackbox/common/BlackboxTestsPubSubFragments.cpp +++ b/test/blackbox/common/BlackboxTestsPubSubFragments.cpp @@ -12,13 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "BlackboxTests.hpp" - -#include "PubSubReader.hpp" -#include "PubSubWriter.hpp" +#include #include #include + +#include "BlackboxTests.hpp" +#include "PubSubReader.hpp" +#include "PubSubWriter.hpp" #include using namespace eprosima::fastrtps; diff --git a/test/blackbox/common/BlackboxTestsPubSubHistory.cpp b/test/blackbox/common/BlackboxTestsPubSubHistory.cpp index 3a43ecb2567..26b94c14fc1 100644 --- a/test/blackbox/common/BlackboxTestsPubSubHistory.cpp +++ b/test/blackbox/common/BlackboxTestsPubSubHistory.cpp @@ -12,15 +12,30 @@ // See the License for the specific language governing permissions and // limitations under the License. +<<<<<<< HEAD #include "BlackboxTests.hpp" #include "PubSubReader.hpp" #include "PubSubWriter.hpp" +======= +#include +#include +#include + +#include +>>>>>>> 6390715a1 (Add missing thread include (#4045)) #include + +#include "BlackboxTests.hpp" +#include "PubSubReader.hpp" +#include "PubSubWriter.hpp" #include +<<<<<<< HEAD #include #include +======= +>>>>>>> 6390715a1 (Add missing thread include (#4045)) using namespace eprosima::fastrtps; using namespace eprosima::fastdds::rtps; diff --git a/test/blackbox/common/BlackboxTestsReliability.cpp b/test/blackbox/common/BlackboxTestsReliability.cpp index ed910e7b8b3..50e37c33f42 100644 --- a/test/blackbox/common/BlackboxTestsReliability.cpp +++ b/test/blackbox/common/BlackboxTestsReliability.cpp @@ -12,14 +12,15 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "BlackboxTests.hpp" - -#include "PubSubReader.hpp" -#include "PubSubWriter.hpp" +#include #include #include + +#include "BlackboxTests.hpp" +#include "PubSubReader.hpp" +#include "PubSubWriter.hpp" #include using namespace eprosima::fastrtps; diff --git a/test/blackbox/common/DDSBlackboxTestsContentFilter.cpp b/test/blackbox/common/DDSBlackboxTestsContentFilter.cpp index b94ede92d67..cbf730495a8 100644 --- a/test/blackbox/common/DDSBlackboxTestsContentFilter.cpp +++ b/test/blackbox/common/DDSBlackboxTestsContentFilter.cpp @@ -13,26 +13,23 @@ // limitations under the License. #include +#include #include #include -#include #include - +#include #include - #include #include -#include "BlackboxTests.hpp" - -#include "PubSubReader.hpp" -#include "PubSubWriter.hpp" - #include "../types/HelloWorldTypeObject.h" #include "../types/TestRegression3361PubSubTypes.h" #include "../types/TestRegression3361TypeObject.h" +#include "BlackboxTests.hpp" +#include "PubSubReader.hpp" +#include "PubSubWriter.hpp" namespace eprosima { namespace fastdds { diff --git a/test/blackbox/common/DDSBlackboxTestsDataReader.cpp b/test/blackbox/common/DDSBlackboxTestsDataReader.cpp index ab4ce661d3f..46778700c49 100644 --- a/test/blackbox/common/DDSBlackboxTestsDataReader.cpp +++ b/test/blackbox/common/DDSBlackboxTestsDataReader.cpp @@ -12,14 +12,16 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "BlackboxTests.hpp" +#include + +#include + +#include +#include "BlackboxTests.hpp" #include "PubSubParticipant.hpp" #include "PubSubReader.hpp" #include "PubSubWriter.hpp" -#include - -#include using namespace eprosima::fastrtps; using namespace eprosima::fastrtps::rtps; diff --git a/test/blackbox/common/DDSBlackboxTestsDataSharing.cpp b/test/blackbox/common/DDSBlackboxTestsDataSharing.cpp index 0695bc70ba3..f8877ea43a1 100644 --- a/test/blackbox/common/DDSBlackboxTestsDataSharing.cpp +++ b/test/blackbox/common/DDSBlackboxTestsDataSharing.cpp @@ -12,18 +12,19 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "BlackboxTests.hpp" +#include +#include +#include -#include +#include -#include "PubSubReader.hpp" -#include "PubSubWriter.hpp" +#include #include #include -#include -#include -#include +#include "BlackboxTests.hpp" +#include "PubSubReader.hpp" +#include "PubSubWriter.hpp" using namespace eprosima::fastrtps; using namespace eprosima::fastrtps::rtps; diff --git a/test/blackbox/common/DDSBlackboxTestsListeners.cpp b/test/blackbox/common/DDSBlackboxTestsListeners.cpp index 17e7eb65b56..855d1c74177 100644 --- a/test/blackbox/common/DDSBlackboxTestsListeners.cpp +++ b/test/blackbox/common/DDSBlackboxTestsListeners.cpp @@ -12,6 +12,19 @@ // See the License for the specific language governing permissions and // limitations under the License. +<<<<<<< HEAD +======= +#include +#include +#include + +#include +#include +#include +#include +#include + +>>>>>>> 6390715a1 (Add missing thread include (#4045)) #include "BlackboxTests.hpp" #include "PubSubReader.hpp" diff --git a/test/blackbox/common/DDSBlackboxTestsOwnershipQos.cpp b/test/blackbox/common/DDSBlackboxTestsOwnershipQos.cpp new file mode 100644 index 00000000000..dc2b92d9ac7 --- /dev/null +++ b/test/blackbox/common/DDSBlackboxTestsOwnershipQos.cpp @@ -0,0 +1,2184 @@ +// Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include + +#include + +#include +#include + +#include "BlackboxTests.hpp" +#include "PubSubReader.hpp" +#include "PubSubWriter.hpp" + +using namespace eprosima::fastrtps; +using namespace eprosima::fastrtps::rtps; + +enum communication_type +{ + TRANSPORT, + INTRAPROCESS, + DATASHARING +}; + +class OwnershipQos : public testing::TestWithParam +{ +public: + + void SetUp() override + { + LibrarySettingsAttributes library_settings; + switch (GetParam()) + { + case INTRAPROCESS: + library_settings.intraprocess_delivery = IntraprocessDeliveryType::INTRAPROCESS_FULL; + xmlparser::XMLProfileManager::library_settings(library_settings); + break; + case DATASHARING: + enable_datasharing = true; + break; + case TRANSPORT: + default: + break; + } + } + + void TearDown() override + { + LibrarySettingsAttributes library_settings; + switch (GetParam()) + { + case INTRAPROCESS: + library_settings.intraprocess_delivery = IntraprocessDeliveryType::INTRAPROCESS_OFF; + xmlparser::XMLProfileManager::library_settings(library_settings); + break; + case DATASHARING: + enable_datasharing = false; + break; + case TRANSPORT: + default: + break; + } + } + +}; + +void exclusive_kind_non_keyed_sample_reception( + bool reliable) +{ + PubSubReader reader(TEST_TOPIC_NAME); + PubSubWriter writer1(TEST_TOPIC_NAME); + PubSubWriter writer2(TEST_TOPIC_NAME); + PubSubWriter writer3(TEST_TOPIC_NAME); + + reader.ownership_exclusive().reliability( + reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS + ).init(); + writer1.ownership_strength(1).reliability( + reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS + ).init(); + writer2.ownership_strength(2).reliability( + reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS + ).init(); + writer3.ownership_strength(3).reliability( + reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS + ).init(); + + ASSERT_TRUE(reader.isInitialized()); + ASSERT_TRUE(writer1.isInitialized()); + ASSERT_TRUE(writer2.isInitialized()); + ASSERT_TRUE(writer3.isInitialized()); + + // Wait for discovery. + writer1.wait_discovery(); + writer2.wait_discovery(); + writer3.wait_discovery(); + reader.wait_discovery(std::chrono::seconds(1), 3); + + std::function&)> wait_functor = + [](PubSubWriter&) + { + std::this_thread::sleep_for(std::chrono::milliseconds(50)); + }; + + if (reliable) + { + wait_functor = [](PubSubWriter& writer) + { + writer.waitForAllAcked(std::chrono::milliseconds(100)); + }; + } + + auto data = default_helloworld_data_generator(13); + reader.startReception(data); + + decltype(data) denied_samples; + + // DW1 sends a sample. + writer1.send_sample(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW2 sends a sample. + writer2.send_sample(data.front()); + data.pop_front(); + wait_functor(writer2); + + // DW1 sends a sample. + writer1.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW2 sends a sample. + writer2.send_sample(data.front()); + data.pop_front(); + wait_functor(writer2); + + // DW3 sends a sample. + writer3.send_sample(data.front()); + data.pop_front(); + wait_functor(writer3); + + // DW1 sends a sample. + writer1.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW2 sends a sample. + writer2.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer2); + + // DW3 sends a sample. + writer3.send_sample(data.front()); + data.pop_front(); + wait_functor(writer3); + + // DW2 changes its strength to 4. + ASSERT_TRUE(writer2.ownership_strength(4).set_qos()); + std::this_thread::sleep_for(std::chrono::milliseconds(100)); // Wait the reader receives the update + + // DW3 sends a sample. + writer3.send_sample(data.front()); + data.pop_front(); + wait_functor(writer3); + + // DW3 changes its strength to 1. + ASSERT_TRUE(writer3.ownership_strength(1).set_qos()); + std::this_thread::sleep_for(std::chrono::milliseconds(100)); // Wait the reader receives the update + + // DW3 sends a sample. + writer3.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer3); + + // DW1 sends a sample. + writer1.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW2 sends a sample. + writer2.send_sample(data.front()); + data.pop_front(); + wait_functor(writer2); + + // DW3 sends a sample. + writer3.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer3); + + reader.block_for_at_least(7); + ASSERT_EQ(denied_samples.size(), reader.data_not_received().size()); + ASSERT_EQ(denied_samples, reader.data_not_received()); +} + +/*! + * @test DDS-OWN-SAMPLE-01 Tests samples reception works successfully with Non-Keyed types, Reliable, Ownership QoS + * EXCLUSIVE and dynamic change of strength. + */ +TEST_P(OwnershipQos, exclusive_kind_non_keyed_reliable_sample_reception) +{ + exclusive_kind_non_keyed_sample_reception(true); +} + +void exclusive_kind_keyed_sample_reception( + bool reliable) +{ + PubSubReader reader(TEST_TOPIC_NAME); + PubSubWriter writer1(TEST_TOPIC_NAME); + PubSubWriter writer2(TEST_TOPIC_NAME); + PubSubWriter writer3(TEST_TOPIC_NAME); + PubSubWriter writer4(TEST_TOPIC_NAME); + + reader.ownership_exclusive().reliability( + reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS + ).init(); + writer1.ownership_strength(1).reliability( + reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS + ).init(); + writer2.ownership_strength(2).reliability( + reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS + ).init(); + writer3.ownership_strength(3).reliability( + reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS + ).init(); + writer4.ownership_strength(4).reliability( + reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS + ).init(); + + ASSERT_TRUE(reader.isInitialized()); + ASSERT_TRUE(writer1.isInitialized()); + ASSERT_TRUE(writer2.isInitialized()); + ASSERT_TRUE(writer3.isInitialized()); + ASSERT_TRUE(writer4.isInitialized()); + + // Wait for discovery. + writer1.wait_discovery(); + writer2.wait_discovery(); + writer3.wait_discovery(); + writer4.wait_discovery(); + reader.wait_discovery(std::chrono::seconds(1), 4); + + std::function&)> wait_functor = + [](PubSubWriter&) + { + std::this_thread::sleep_for(std::chrono::milliseconds(50)); + }; + + if (reliable) + { + wait_functor = [](PubSubWriter& writer) + { + writer.waitForAllAcked(std::chrono::milliseconds(100)); + }; + } + + auto data = default_keyedhelloworld_data_generator(23); + reader.startReception(data); + + decltype(data) denied_samples; + + // DW1 sends a sample of instance 1. + writer1.send_sample(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW2 sends a sample of instance 2. + writer2.send_sample(data.front()); + data.pop_front(); + wait_functor(writer2); + + // DW2 sends a sample of instance 1. + writer2.send_sample(data.front()); + data.pop_front(); + wait_functor(writer2); + + // DW3 sends a sample of instance 2. + writer3.send_sample(data.front()); + data.pop_front(); + wait_functor(writer3); + + // DW1 sends a sample of instance 1. + writer1.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW1 sends a sample of instance 2. + writer1.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW2 sends a sample of instance 1. + writer2.send_sample(data.front()); + data.pop_front(); + wait_functor(writer2); + + // DW2 sends a sample of instance 2. + writer2.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer2); + + // DW4 sends a sample of instance 1. + writer4.send_sample(data.front()); + data.pop_front(); + wait_functor(writer4); + + // DW2 sends a sample of instance 2. + writer2.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer2); + + // DW1 sends a sample of instance 1. + writer1.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW1 sends a sample of instance 2. + writer1.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW2 sends a sample of instance 1. + writer2.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer2); + + // DW2 sends a sample of instance 2. + writer2.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer2); + + // DW2 changes its strength to 4. + ASSERT_TRUE(writer2.ownership_strength(4).set_qos()); + std::this_thread::sleep_for(std::chrono::milliseconds(100)); // Wait the reader receives the update + + // DW1 sends a sample of instance 1. + writer1.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW3 sends a sample of instance 2. + writer3.send_sample(data.front()); + data.pop_front(); + wait_functor(writer3); + + // DW4 sends a sample of instance 1. + writer4.send_sample(data.front()); + data.pop_front(); + wait_functor(writer4); + + // DW3 changes its strength to 1. + ASSERT_TRUE(writer3.ownership_strength(1).set_qos()); + std::this_thread::sleep_for(std::chrono::milliseconds(100)); // Wait the reader receives the update + + // DW3 sends a sample of instance 2. + writer3.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer3); + + // DW1 sends a sample of instance 1. + writer1.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW2 sends a sample of instance 2. + writer2.send_sample(data.front()); + data.pop_front(); + wait_functor(writer2); + + // DW1 sends a sample of instance 1. + writer1.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW3 sends a sample of instance 2. + writer3.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer3); + + // DW4 sends a sample of instance 1. + writer4.send_sample(data.front()); + data.pop_front(); + wait_functor(writer4); + + reader.block_for_at_least(10); + ASSERT_EQ(denied_samples.size(), reader.data_not_received().size()); + ASSERT_EQ(denied_samples, reader.data_not_received()); +} + +/*! + * @test DDS-OWN-SAMPLE-02 Tests samples reception works successfully with Keyed types, Reliable, Ownership QoS + * EXCLUSIVE and dynamic change of strength. + */ +TEST_P(OwnershipQos, exclusive_kind_keyed_reliable_sample_reception) +{ + exclusive_kind_keyed_sample_reception(true); +} + +/*! + * @test DDS-OWN-SAMPLE-03 Tests samples reception works successfully with Non-Keyed types, BestEffort, Ownership QoS + * EXCLUSIVE and dynamic change of strength. + */ +TEST_P(OwnershipQos, exclusive_kind_non_keyed_besteffort_sample_reception) +{ + exclusive_kind_non_keyed_sample_reception(false); +} + +/*! + * @test DDS-OWN-SAMPLE-04 Tests samples reception works successfully with Keyed types, BestEffort, Ownership QoS + * EXCLUSIVE and dynamic change of strength. + */ +TEST_P(OwnershipQos, exclusive_kind_keyed_besteffort_sample_reception) +{ + exclusive_kind_keyed_sample_reception(false); +} + +void exclusive_kind_non_keyed_writers_same_guid( + bool reliable) +{ + PubSubReader reader(TEST_TOPIC_NAME); + PubSubWriter writer1(TEST_TOPIC_NAME); + PubSubWriter writer2(TEST_TOPIC_NAME); + PubSubWriter writer3(TEST_TOPIC_NAME); + + reader.ownership_exclusive().reliability( + reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS + ).init(); + writer1.ownership_strength(10).reliability( + reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS + ).init(); + writer2.ownership_strength(10).reliability( + reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS + ).init(); + writer3.ownership_strength(10).reliability( + reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS + ).init(); + + ASSERT_TRUE(reader.isInitialized()); + ASSERT_TRUE(writer1.isInitialized()); + ASSERT_TRUE(writer2.isInitialized()); + ASSERT_TRUE(writer3.isInitialized()); + + // Wait for discovery. + writer1.wait_discovery(); + writer2.wait_discovery(); + writer3.wait_discovery(); + reader.wait_discovery(std::chrono::seconds(1), 3); + + std::function&)> wait_functor = + [](PubSubWriter&) + { + std::this_thread::sleep_for(std::chrono::milliseconds(50)); + }; + + if (reliable) + { + wait_functor = [](PubSubWriter& writer) + { + writer.waitForAllAcked(std::chrono::milliseconds(100)); + }; + } + + auto data = default_helloworld_data_generator(7); + reader.startReception(data); + + decltype(data) denied_samples; + + // DW2 sends a sample. + writer2.send_sample(data.front()); + data.pop_front(); + wait_functor(writer2); + + // DW3 sends a sample. + writer3.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer3); + + // DW2 sends a sample. + writer2.send_sample(data.front()); + data.pop_front(); + wait_functor(writer2); + + // DW1 sends a sample. + writer1.send_sample(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW3 sends a sample. + writer3.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer3); + + // DW2 sends a sample. + writer2.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer2); + + // DW1 sends a sample. + writer1.send_sample(data.front()); + data.pop_front(); + wait_functor(writer1); + + reader.block_for_at_least(4); + ASSERT_EQ(denied_samples.size(), reader.data_not_received().size()); + ASSERT_EQ(denied_samples, reader.data_not_received()); +} + +/*! + * @test DDS-OWN-SAMPLE-05 Tests samples reception works successfully with Non-Keyed types, Reliable, Ownership QoS + * EXCLUSIVE and several writers with same GUID. + */ +TEST_P(OwnershipQos, exclusive_kind_non_keyed_reliable_writers_same_guid) +{ + exclusive_kind_non_keyed_writers_same_guid(true); +} + +void exclusive_kind_keyed_writers_same_guid( + bool reliable) +{ + PubSubReader reader(TEST_TOPIC_NAME); + PubSubWriter writer1(TEST_TOPIC_NAME); + PubSubWriter writer2(TEST_TOPIC_NAME); + PubSubWriter writer3(TEST_TOPIC_NAME); + PubSubWriter writer4(TEST_TOPIC_NAME); + + reader.ownership_exclusive().reliability( + reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS + ).init(); + writer1.ownership_strength(10).reliability( + reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS + ).init(); + writer2.ownership_strength(10).reliability( + reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS + ).init(); + writer3.ownership_strength(10).reliability( + reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS + ).init(); + writer4.ownership_strength(10).reliability( + reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS + ).init(); + + ASSERT_TRUE(reader.isInitialized()); + ASSERT_TRUE(writer1.isInitialized()); + ASSERT_TRUE(writer2.isInitialized()); + ASSERT_TRUE(writer3.isInitialized()); + ASSERT_TRUE(writer4.isInitialized()); + + // Wait for discovery. + writer1.wait_discovery(); + writer2.wait_discovery(); + writer3.wait_discovery(); + writer4.wait_discovery(); + reader.wait_discovery(std::chrono::seconds(1), 4); + + std::function&)> wait_functor = + [](PubSubWriter&) + { + std::this_thread::sleep_for(std::chrono::milliseconds(50)); + }; + + if (reliable) + { + wait_functor = [](PubSubWriter& writer) + { + writer.waitForAllAcked(std::chrono::milliseconds(100)); + }; + } + + auto data = default_keyedhelloworld_data_generator(10); + reader.startReception(data); + + decltype(data) denied_samples; + + // DW2 sends a sample of instance 1. + writer2.send_sample(data.front()); + data.pop_front(); + wait_functor(writer2); + + // DW3 sends a sample of instance 2. + writer3.send_sample(data.front()); + data.pop_front(); + wait_functor(writer3); + + // DW4 sends a sample of instance 1. + writer4.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer4); + + // DW4 sends a sample of instance 2. + writer4.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer4); + + // DW2 sends a sample of instance 1. + writer2.send_sample(data.front()); + data.pop_front(); + wait_functor(writer2); + + // DW3 sends a sample of instance 2. + writer3.send_sample(data.front()); + data.pop_front(); + wait_functor(writer3); + + // DW1 sends a sample of instance 1. + writer1.send_sample(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW1 sends a sample of instance 2. + writer1.send_sample(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW2 sends a sample of instance 1. + writer2.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer2); + + // DW3 sends a sample of instance 2. + writer2.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer2); + + reader.block_for_at_least(6); + ASSERT_EQ(denied_samples.size(), reader.data_not_received().size()); + ASSERT_EQ(denied_samples, reader.data_not_received()); +} + +/*! + * @test DDS-OWN-SAMPLE-06 Tests samples reception works successfully with Keyed types, Reliable, Ownership QoS + * EXCLUSIVE and several writers with same GUID. + */ +TEST_P(OwnershipQos, exclusive_kind_keyed_reliable_writers_same_guid) +{ + exclusive_kind_keyed_writers_same_guid(true); +} + +/*! + * @test DDS-OWN-SAMPLE-07 Tests samples reception works successfully with Keyed types, BestEffort, Ownership QoS + * EXCLUSIVE and several writers with same GUID. + */ +TEST_P(OwnershipQos, exclusive_kind_non_keyed_besteffort_writers_same_guid) +{ + exclusive_kind_non_keyed_writers_same_guid(false); +} + +/*! + * @test DDS-OWN-SAMPLE-08 Tests samples reception works successfully with Keyed types, BestEffort, Ownership QoS + * EXCLUSIVE and several writers with same GUID. + */ +TEST_P(OwnershipQos, exclusive_kind_keyed_besteffort_writers_same_guid) +{ + exclusive_kind_keyed_writers_same_guid(false); +} + +/*! + * @test DDS-OWN-DEADLINE-01 Tests Ownership changes when the current owner doesn't comply with deadline QoS, in a + * Reliable communication with Non-Keyed types. + */ +TEST_P(OwnershipQos, exclusive_kind_non_keyed_reliable_deadline) +{ + + PubSubReader reader(TEST_TOPIC_NAME); + PubSubWriter writer1(TEST_TOPIC_NAME); + PubSubWriter writer2(TEST_TOPIC_NAME); + + reader.ownership_exclusive().reliability(RELIABLE_RELIABILITY_QOS).deadline_period({0, 100000000}).init(); + writer1.ownership_strength(1).deadline_period({0, 100000000}).init(); + writer2.ownership_strength(2).deadline_period({0, 100000000}).init(); + + ASSERT_TRUE(reader.isInitialized()); + ASSERT_TRUE(writer1.isInitialized()); + ASSERT_TRUE(writer2.isInitialized()); + + // Wait for discovery. + writer1.wait_discovery(); + writer2.wait_discovery(); + reader.wait_discovery(std::chrono::seconds(1), 2); + + auto data = default_helloworld_data_generator(10); + reader.startReception(data); + + decltype(data) denied_samples; + + writer1.send_sample(data.front()); + data.pop_front(); + std::this_thread::sleep_for(std::chrono::milliseconds(50)); + + writer2.send_sample(data.front()); + data.pop_front(); + std::this_thread::sleep_for(std::chrono::milliseconds(50)); + + writer1.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + std::this_thread::sleep_for(std::chrono::milliseconds(50)); + + writer2.send_sample(data.front()); + data.pop_front(); + std::this_thread::sleep_for(std::chrono::milliseconds(50)); + + writer1.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + std::this_thread::sleep_for(std::chrono::milliseconds(50)); + + writer2.send_sample(data.front()); + data.pop_front(); + std::this_thread::sleep_for(std::chrono::milliseconds(50)); + + writer1.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + std::this_thread::sleep_for(std::chrono::milliseconds(50)); + + writer1.send_sample(data.front()); + data.pop_front(); + std::this_thread::sleep_for(std::chrono::milliseconds(50)); + + writer1.send_sample(data.front()); + data.pop_front(); + std::this_thread::sleep_for(std::chrono::milliseconds(50)); + + writer1.send_sample(data.front()); + data.pop_front(); + std::this_thread::sleep_for(std::chrono::milliseconds(50)); + + reader.block_for_seq({0, 7}); + ASSERT_EQ(denied_samples.size(), reader.data_not_received().size()); + ASSERT_EQ(denied_samples, reader.data_not_received()); +} + +/*! + * @test DDS-OWN-DEADLINE-02 Tests Ownership changes when the current owner doesn't comply with deadline QoS, in a + * Reliable communication with Keyed types. + */ +TEST_P(OwnershipQos, exclusive_kind_keyed_reliable_deadline) +{ + + PubSubReader reader(TEST_TOPIC_NAME); + PubSubWriter writer1(TEST_TOPIC_NAME); + PubSubWriter writer2(TEST_TOPIC_NAME); + + reader.ownership_exclusive().reliability(RELIABLE_RELIABILITY_QOS).deadline_period({0, 100000000}).init(); + writer1.ownership_strength(1).deadline_period({0, 100000000}).init(); + writer2.ownership_strength(2).deadline_period({0, 100000000}).init(); + + ASSERT_TRUE(reader.isInitialized()); + ASSERT_TRUE(writer1.isInitialized()); + ASSERT_TRUE(writer2.isInitialized()); + + // Wait for discovery. + writer1.wait_discovery(); + writer2.wait_discovery(); + reader.wait_discovery(std::chrono::seconds(1), 2); + + auto data = default_keyedhelloworld_data_generator(26); + reader.startReception(data); + + decltype(data) denied_samples; + + writer1.send_sample(data.front()); + data.pop_front(); + writer1.send_sample(data.front()); + data.pop_front(); + std::this_thread::sleep_for(std::chrono::milliseconds(50)); + + writer2.send_sample(data.front()); + data.pop_front(); + writer2.send_sample(data.front()); + data.pop_front(); + std::this_thread::sleep_for(std::chrono::milliseconds(50)); + + writer1.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + writer1.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + std::this_thread::sleep_for(std::chrono::milliseconds(50)); + + writer2.send_sample(data.front()); + data.pop_front(); + writer2.send_sample(data.front()); + data.pop_front(); + std::this_thread::sleep_for(std::chrono::milliseconds(50)); + + writer1.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + writer1.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + std::this_thread::sleep_for(std::chrono::milliseconds(50)); + + writer2.send_sample(data.front()); + data.pop_front(); + writer2.send_sample(data.front()); + data.pop_front(); + std::this_thread::sleep_for(std::chrono::milliseconds(50)); + + writer1.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + writer1.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + std::this_thread::sleep_for(std::chrono::milliseconds(50)); + + writer1.send_sample(data.front()); + data.pop_front(); + writer2.send_sample(data.front()); + data.pop_front(); + denied_samples.push_back(data.front()); + data.pop_front(); + writer1.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + std::this_thread::sleep_for(std::chrono::milliseconds(50)); + + writer1.send_sample(data.front()); + data.pop_front(); + writer2.send_sample(data.front()); + data.pop_front(); + denied_samples.push_back(data.front()); + data.pop_front(); + writer1.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + std::this_thread::sleep_for(std::chrono::milliseconds(50)); + + writer1.send_sample(data.front()); + data.pop_front(); + writer2.send_sample(data.front()); + data.pop_front(); + denied_samples.push_back(data.front()); + data.pop_front(); + writer1.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + std::this_thread::sleep_for(std::chrono::milliseconds(50)); + + reader.block_for_seq({0, 13}); + ASSERT_EQ(denied_samples.size(), reader.data_not_received().size()); + ASSERT_EQ(denied_samples, reader.data_not_received()); +} + +void exclusive_kind_non_keyed_undiscovered_writer( + bool reliable) +{ + PubSubReader reader(TEST_TOPIC_NAME); + PubSubWriter writer1(TEST_TOPIC_NAME); + PubSubWriter writer2(TEST_TOPIC_NAME); + PubSubWriter writer3(TEST_TOPIC_NAME); + + reader.ownership_exclusive().reliability( + reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS + ).init(); + writer1.ownership_strength(1).reliability( + reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS + ).init(); + writer2.ownership_strength(2).reliability( + reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS + ).init(); + writer3.ownership_strength(3).reliability( + reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS + ).init(); + + ASSERT_TRUE(reader.isInitialized()); + ASSERT_TRUE(writer1.isInitialized()); + ASSERT_TRUE(writer2.isInitialized()); + ASSERT_TRUE(writer3.isInitialized()); + + // Wait for discovery. + writer1.wait_discovery(); + writer2.wait_discovery(); + writer3.wait_discovery(); + reader.wait_discovery(std::chrono::seconds(1), 3); + + std::function&)> wait_functor = + [](PubSubWriter&) + { + std::this_thread::sleep_for(std::chrono::milliseconds(50)); + }; + + if (reliable) + { + wait_functor = [](PubSubWriter& writer) + { + writer.waitForAllAcked(std::chrono::milliseconds(100)); + }; + } + + auto data = default_helloworld_data_generator(11); + reader.startReception(data); + + decltype(data) denied_samples; + + // DW1 sends a sample. + writer1.send_sample(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW2 sends a sample. + writer2.send_sample(data.front()); + data.pop_front(); + wait_functor(writer2); + + // DW1 sends a sample. + writer1.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW2 sends a sample. + writer2.send_sample(data.front()); + data.pop_front(); + wait_functor(writer2); + + // DW3 sends a sample. + writer3.send_sample(data.front()); + data.pop_front(); + wait_functor(writer3); + + // DW1 sends a sample. + writer1.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW2 sends a sample. + writer2.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer2); + + // DW3 sends a sample. + writer3.send_sample(data.front()); + data.pop_front(); + wait_functor(writer3); + + // DW3 is detroyed + writer3.destroy(); + reader.wait_writer_undiscovery(2); + + // DW1 sends a sample. + writer1.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW2 sends a sample. + writer2.send_sample(data.front()); + data.pop_front(); + wait_functor(writer2); + + // DW1 is detroyed + writer1.destroy(); + reader.wait_writer_undiscovery(1); + + // DW2 sends a sample. + writer2.send_sample(data.front()); + data.pop_front(); + wait_functor(writer2); + + reader.block_for_at_least(7); + ASSERT_EQ(denied_samples.size(), reader.data_not_received().size()); + ASSERT_EQ(denied_samples, reader.data_not_received()); +} + +/*! + * @test DDS-OWN-UNDISC-01 Tests Ownership changes when writer removes himself, in a Reliable communication with + * Non-Keyed types. + */ +TEST_P(OwnershipQos, exclusive_kind_non_keyed_reliable_undiscovered_writer) +{ + exclusive_kind_non_keyed_undiscovered_writer(true); +} + +void exclusive_kind_keyed_undiscovered_writer( + bool reliable) +{ + PubSubReader reader(TEST_TOPIC_NAME); + PubSubWriter writer1(TEST_TOPIC_NAME); + PubSubWriter writer2(TEST_TOPIC_NAME); + PubSubWriter writer3(TEST_TOPIC_NAME); + PubSubWriter writer4(TEST_TOPIC_NAME); + + reader.ownership_exclusive().reliability( + reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS + ).init(); + writer1.ownership_strength(1).reliability( + reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS + ).init(); + writer2.ownership_strength(2).reliability( + reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS + ).init(); + writer3.ownership_strength(3).reliability( + reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS + ).init(); + writer4.ownership_strength(4).reliability( + reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS + ).init(); + + ASSERT_TRUE(reader.isInitialized()); + ASSERT_TRUE(writer1.isInitialized()); + ASSERT_TRUE(writer2.isInitialized()); + ASSERT_TRUE(writer3.isInitialized()); + ASSERT_TRUE(writer4.isInitialized()); + + // Wait for discovery. + writer1.wait_discovery(); + writer2.wait_discovery(); + writer3.wait_discovery(); + writer4.wait_discovery(); + reader.wait_discovery(std::chrono::seconds(1), 4); + + std::function&)> wait_functor = + [](PubSubWriter&) + { + std::this_thread::sleep_for(std::chrono::milliseconds(50)); + }; + + if (reliable) + { + wait_functor = [](PubSubWriter& writer) + { + writer.waitForAllAcked(std::chrono::milliseconds(100)); + }; + } + + auto data = default_keyedhelloworld_data_generator(24); + reader.startReception(data); + + decltype(data) denied_samples; + + // DW1 sends a sample in instance 1. + writer1.send_sample(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW1 sends a sample in instance 2. + writer1.send_sample(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW2 sends a sample in instance 1. + writer2.send_sample(data.front()); + data.pop_front(); + wait_functor(writer2); + + // DW3 sends a sample in instance 2. + writer3.send_sample(data.front()); + data.pop_front(); + wait_functor(writer3); + + // DW1 sends a sample in instance 1. + writer1.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW1 sends a sample in instance 2. + writer1.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW4 sends a sample in instance 1. + writer4.send_sample(data.front()); + data.pop_front(); + wait_functor(writer4); + + // DW3 sends a sample in instance 2. + writer3.send_sample(data.front()); + data.pop_front(); + wait_functor(writer3); + + // DW1 sends a sample in instance 1. + writer1.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW1 sends a sample in instance 2. + writer1.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW2 sends a sample in instance 1. + writer2.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer2); + + // DW3 sends a sample in instance 2. + writer3.send_sample(data.front()); + data.pop_front(); + wait_functor(writer3); + + // DW3 is destroyed. + writer3.destroy(); + reader.wait_writer_undiscovery(3); + + // DW1 sends a sample in instance 1. + writer1.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW1 sends a sample in instance 2. + writer1.send_sample(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW2 sends a sample in instance 1. + writer2.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer2); + + // DW1 sends a sample in instance 2. + writer1.send_sample(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW4 sends a sample in instance 1. + writer4.send_sample(data.front()); + data.pop_front(); + wait_functor(writer4); + + // DW1 sends a sample in instance 2. + writer1.send_sample(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW2 is destroyed. + writer2.destroy(); + reader.wait_writer_undiscovery(2); + + // DW1 sends a sample in instance 1. + writer1.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW1 sends a sample in instance 2. + writer1.send_sample(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW4 sends a sample in instance 1. + writer4.send_sample(data.front()); + data.pop_front(); + wait_functor(writer4); + + // DW1 sends a sample in instance 2. + writer1.send_sample(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW4 is destroyed. + writer4.destroy(); + reader.wait_writer_undiscovery(1); + + // DW1 sends a sample in instance 1. + writer1.send_sample(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW1 sends a sample in instance 2. + writer1.send_sample(data.front()); + data.pop_front(); + wait_functor(writer1); + + reader.block_for_at_least(16); + ASSERT_EQ(denied_samples.size(), reader.data_not_received().size()); + ASSERT_EQ(denied_samples, reader.data_not_received()); +} + +/*! + * @test DDS-OWN-UNDISC-02 Tests Ownership changes when writer removes himself, in a Reliable communication with + * Keyed types. + */ +TEST_P(OwnershipQos, exclusive_kind_keyed_reliable_undiscovered_writer) +{ + exclusive_kind_keyed_undiscovered_writer(true); +} + +/*! + * @test DDS-OWN-UNDISC-03 Tests Ownership changes when writer removes himself, in a BestEffort communication with + * Non-Keyed types. + */ +TEST_P(OwnershipQos, exclusive_kind_non_keyed_besteffort_undiscovered_writer) +{ + exclusive_kind_non_keyed_undiscovered_writer(false); +} + +/*! + * @test DDS-OWN-UNDISC-04 Tests Ownership changes when writer removes himself, in a BestEffort communication with + * Keyed types. + */ +TEST_P(OwnershipQos, exclusive_kind_keyed_besteffort_undiscovered_writer) +{ + exclusive_kind_keyed_undiscovered_writer(false); +} + +void exclusive_kind_non_keyed_lost_liveliness( + bool reliable) +{ + PubSubReader reader(TEST_TOPIC_NAME); + PubSubWriter writer1(TEST_TOPIC_NAME); + PubSubWriter writer2(TEST_TOPIC_NAME); + PubSubWriter writer3(TEST_TOPIC_NAME); + + std::atomic drop_messages1(false); + auto testTransport1 = std::make_shared(); + testTransport1->messages_filter_ = [&drop_messages1](eprosima::fastrtps::rtps::CDRMessage_t&) + { + return drop_messages1.load(); + }; + std::atomic drop_messages3(false); + auto testTransport3 = std::make_shared(); + testTransport3->messages_filter_ = [&drop_messages3](eprosima::fastrtps::rtps::CDRMessage_t&) + { + return drop_messages3.load(); + }; + + reader.ownership_exclusive().reliability( + reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS + ) + .lease_duration({1, 0}, {0, 500000000}) + .init(); + writer1.ownership_strength(1).reliability( + reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS + ) + .add_user_transport_to_pparams(testTransport1) + .disable_builtin_transport() + .lease_duration({1, 0}, {0, 500000000}) + .init(); + writer2.ownership_strength(2).reliability( + reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS + ) + .lease_duration({1, 0}, {0, 500000000}) + .init(); + writer3.ownership_strength(3).reliability( + reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS + ) + .add_user_transport_to_pparams(testTransport3) + .disable_builtin_transport() + .lease_duration({1, 0}, {0, 500000000}) + .init(); + + ASSERT_TRUE(reader.isInitialized()); + ASSERT_TRUE(writer1.isInitialized()); + ASSERT_TRUE(writer2.isInitialized()); + ASSERT_TRUE(writer3.isInitialized()); + + // Wait for discovery. + writer1.wait_discovery(); + writer2.wait_discovery(); + writer3.wait_discovery(); + reader.wait_discovery(std::chrono::seconds(1), 3); + + std::function&)> wait_functor = + [](PubSubWriter&) + { + std::this_thread::sleep_for(std::chrono::milliseconds(50)); + }; + + if (reliable) + { + wait_functor = [](PubSubWriter& writer) + { + writer.waitForAllAcked(std::chrono::milliseconds(100)); + }; + } + + auto data = default_helloworld_data_generator(11); + reader.startReception(data); + + decltype(data) denied_samples; + + // DW1 sends a sample. + writer1.send_sample(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW2 sends a sample. + writer2.send_sample(data.front()); + data.pop_front(); + wait_functor(writer2); + + // DW1 sends a sample. + writer1.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW2 sends a sample. + writer2.send_sample(data.front()); + data.pop_front(); + wait_functor(writer2); + + // DW3 sends a sample. + writer3.send_sample(data.front()); + data.pop_front(); + wait_functor(writer3); + + // DW1 sends a sample. + writer1.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW2 sends a sample. + writer2.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer2); + + // DW3 sends a sample. + writer3.send_sample(data.front()); + data.pop_front(); + wait_functor(writer3); + + // DW3 liveliness lost. + drop_messages3 = true; + reader.wait_writer_undiscovery(2); + + // DW1 sends a sample. + writer1.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW2 sends a sample. + writer2.send_sample(data.front()); + data.pop_front(); + wait_functor(writer2); + + // DW1 liveliness lost. + drop_messages1 = true; + reader.wait_writer_undiscovery(1); + + // DW2 sends a sample. + writer2.send_sample(data.front()); + data.pop_front(); + wait_functor(writer2); + + reader.block_for_at_least(7); + ASSERT_EQ(denied_samples.size(), reader.data_not_received().size()); + ASSERT_EQ(denied_samples, reader.data_not_received()); +} + +/*! + * @test DDS-OWN-LIVE-01 Tests Ownership changes when writer removes himself, in a Reliable communication with + * Non-Keyed types. + */ +TEST_P(OwnershipQos, exclusive_kind_non_keyed_reliable_lost_liveliness) +{ + exclusive_kind_non_keyed_lost_liveliness(true); +} + +void exclusive_kind_keyed_lost_liveliness( + bool reliable) +{ + PubSubReader reader(TEST_TOPIC_NAME); + PubSubWriter writer1(TEST_TOPIC_NAME); + PubSubWriter writer2(TEST_TOPIC_NAME); + PubSubWriter writer3(TEST_TOPIC_NAME); + PubSubWriter writer4(TEST_TOPIC_NAME); + + std::atomic drop_messages2(false); + auto testTransport2 = std::make_shared(); + testTransport2->messages_filter_ = [&drop_messages2](eprosima::fastrtps::rtps::CDRMessage_t&) + { + return drop_messages2.load(); + }; + std::atomic drop_messages3(false); + auto testTransport3 = std::make_shared(); + testTransport3->messages_filter_ = [&drop_messages3](eprosima::fastrtps::rtps::CDRMessage_t&) + { + return drop_messages3.load(); + }; + std::atomic drop_messages4(false); + auto testTransport4 = std::make_shared(); + testTransport4->messages_filter_ = [&drop_messages4](eprosima::fastrtps::rtps::CDRMessage_t&) + { + return drop_messages4.load(); + }; + + reader.ownership_exclusive().reliability( + reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS + ) + .lease_duration({1, 0}, {0, 500000000}) + .init(); + writer1.ownership_strength(1).reliability( + reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS + ) + .lease_duration({1, 0}, {0, 500000000}) + .init(); + writer2.ownership_strength(2).reliability( + reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS + ) + .add_user_transport_to_pparams(testTransport2) + .disable_builtin_transport() + .lease_duration({1, 0}, {0, 500000000}) + .init(); + writer3.ownership_strength(3).reliability( + reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS + ) + .add_user_transport_to_pparams(testTransport3) + .disable_builtin_transport() + .lease_duration({1, 0}, {0, 500000000}) + .init(); + writer4.ownership_strength(4).reliability( + reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS + ) + .add_user_transport_to_pparams(testTransport4) + .disable_builtin_transport() + .lease_duration({1, 0}, {0, 500000000}) + .init(); + + ASSERT_TRUE(reader.isInitialized()); + ASSERT_TRUE(writer1.isInitialized()); + ASSERT_TRUE(writer2.isInitialized()); + ASSERT_TRUE(writer3.isInitialized()); + ASSERT_TRUE(writer4.isInitialized()); + + // Wait for discovery. + writer1.wait_discovery(); + writer2.wait_discovery(); + writer3.wait_discovery(); + writer4.wait_discovery(); + reader.wait_discovery(std::chrono::seconds(1), 4); + + std::function&)> wait_functor = + [](PubSubWriter&) + { + std::this_thread::sleep_for(std::chrono::milliseconds(50)); + }; + + if (reliable) + { + wait_functor = [](PubSubWriter& writer) + { + writer.waitForAllAcked(std::chrono::milliseconds(100)); + }; + } + + auto data = default_keyedhelloworld_data_generator(24); + reader.startReception(data); + + decltype(data) denied_samples; + + // DW1 sends a sample in instance 1. + writer1.send_sample(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW1 sends a sample in instance 2. + writer1.send_sample(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW2 sends a sample in instance 1. + writer2.send_sample(data.front()); + data.pop_front(); + wait_functor(writer2); + + // DW3 sends a sample in instance 2. + writer3.send_sample(data.front()); + data.pop_front(); + wait_functor(writer3); + + // DW1 sends a sample in instance 1. + writer1.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW1 sends a sample in instance 2. + writer1.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW4 sends a sample in instance 1. + writer4.send_sample(data.front()); + data.pop_front(); + wait_functor(writer4); + + // DW3 sends a sample in instance 2. + writer3.send_sample(data.front()); + data.pop_front(); + wait_functor(writer3); + + // DW1 sends a sample in instance 1. + writer1.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW1 sends a sample in instance 2. + writer1.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW2 sends a sample in instance 1. + writer2.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer2); + + // DW3 sends a sample in instance 2. + writer3.send_sample(data.front()); + data.pop_front(); + wait_functor(writer3); + + // DW3 losses liveliness. + drop_messages3 = true; + reader.wait_writer_undiscovery(3); + + // DW1 sends a sample in instance 1. + writer1.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW1 sends a sample in instance 2. + writer1.send_sample(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW2 sends a sample in instance 1. + writer2.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer2); + + // DW1 sends a sample in instance 2. + writer1.send_sample(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW4 sends a sample in instance 1. + writer4.send_sample(data.front()); + data.pop_front(); + wait_functor(writer4); + + // DW1 sends a sample in instance 2. + writer1.send_sample(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW2 losses liveliness. + drop_messages2 = true; + reader.wait_writer_undiscovery(2); + + // DW1 sends a sample in instance 1. + writer1.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW1 sends a sample in instance 2. + writer1.send_sample(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW4 sends a sample in instance 1. + writer4.send_sample(data.front()); + data.pop_front(); + wait_functor(writer4); + + // DW1 sends a sample in instance 2. + writer1.send_sample(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW4 losses liveliness. + drop_messages4 = true; + reader.wait_writer_undiscovery(1); + + // DW1 sends a sample in instance 1. + writer1.send_sample(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW1 sends a sample in instance 2. + writer1.send_sample(data.front()); + data.pop_front(); + wait_functor(writer1); + + reader.block_for_at_least(16); + ASSERT_EQ(denied_samples.size(), reader.data_not_received().size()); + ASSERT_EQ(denied_samples, reader.data_not_received()); +} + +/*! + * @test DDS-OWN-LIVE-02 Tests Ownership changes when writer removes himself, in a Reliable communication with + * Keyed types. + */ +TEST_P(OwnershipQos, exclusive_kind_keyed_reliable_lost_liveliness) +{ + exclusive_kind_keyed_lost_liveliness(true); +} + +/*! + * @test DDS-OWN-LIVE-03 Tests Ownership changes when writer removes himself, in a BestEffort communication with + * Non-Keyed types. + */ +TEST_P(OwnershipQos, exclusive_kind_non_keyed_besteffort_lost_liveliness) +{ + exclusive_kind_non_keyed_lost_liveliness(false); +} + +/*! + * @test DDS-OWN-LIVE-04 Tests Ownership changes when writer removes himself, in a BestEffort communication with + * Keyed types. + */ +TEST_P(OwnershipQos, exclusive_kind_keyed_besteffort_lost_liveliness) +{ + exclusive_kind_keyed_lost_liveliness(false); +} + +void exclusive_kind_keyed_unregistering_instance( + bool reliable) +{ + PubSubReader reader(TEST_TOPIC_NAME); + PubSubWriter writer1(TEST_TOPIC_NAME); + PubSubWriter writer2(TEST_TOPIC_NAME); + PubSubWriter writer3(TEST_TOPIC_NAME); + PubSubWriter writer4(TEST_TOPIC_NAME); + + reader.ownership_exclusive().reliability( + reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS + ).init(); + writer1.ownership_strength(1).reliability( + reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS + ).init(); + writer2.ownership_strength(2).reliability( + reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS + ).init(); + writer3.ownership_strength(3).reliability( + reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS + ).init(); + writer4.ownership_strength(4).reliability( + reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS + ).init(); + + ASSERT_TRUE(reader.isInitialized()); + ASSERT_TRUE(writer1.isInitialized()); + ASSERT_TRUE(writer2.isInitialized()); + ASSERT_TRUE(writer3.isInitialized()); + ASSERT_TRUE(writer4.isInitialized()); + + // Wait for discovery. + writer1.wait_discovery(); + writer2.wait_discovery(); + writer3.wait_discovery(); + writer4.wait_discovery(); + reader.wait_discovery(std::chrono::seconds(1), 4); + + std::function&)> wait_functor = + [](PubSubWriter&) + { + std::this_thread::sleep_for(std::chrono::milliseconds(50)); + }; + + if (reliable) + { + wait_functor = [](PubSubWriter& writer) + { + writer.waitForAllAcked(std::chrono::milliseconds(100)); + }; + } + + auto data = default_keyedhelloworld_data_generator(24); + reader.startReception(data); + + decltype(data) denied_samples; + + // DW1 sends a sample in instance 1. + InstanceHandle_t instance_1 = writer1.register_instance(data.front()); + writer1.send_sample(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW1 sends a sample in instance 2. + InstanceHandle_t instance_2 = writer1.register_instance(data.front()); + writer1.send_sample(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW2 sends a sample in instance 1. + writer2.send_sample(data.front()); + data.pop_front(); + wait_functor(writer2); + + // DW3 sends a sample in instance 2. + writer3.send_sample(data.front()); + data.pop_front(); + wait_functor(writer3); + + // DW1 sends a sample in instance 1. + writer1.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW1 sends a sample in instance 2. + writer1.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW4 sends a sample in instance 1. + writer4.send_sample(data.front()); + data.pop_front(); + wait_functor(writer4); + + // DW3 sends a sample in instance 2. + writer3.send_sample(data.front()); + data.pop_front(); + wait_functor(writer3); + + // DW1 sends a sample in instance 1. + writer1.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW1 sends a sample in instance 2. + writer1.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW2 sends a sample in instance 1. + writer2.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer2); + + // DW3 sends a sample in instance 2. + writer3.send_sample(data.front()); + wait_functor(writer3); + + // DW3 unregisters instance 2. + writer3.unregister_instance(data.front(), instance_2); + data.pop_front(); + + // DW1 sends a sample in instance 1. + writer1.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW1 sends a sample in instance 2. + writer1.send_sample(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW2 sends a sample in instance 1. + writer2.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer2); + + // DW1 sends a sample in instance 2. + writer1.send_sample(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW4 sends a sample in instance 1. + writer4.send_sample(data.front()); + data.pop_front(); + wait_functor(writer4); + + // DW1 sends a sample in instance 2. + writer1.send_sample(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW2 unregisters instance 1. + writer2.unregister_instance(data.front(), instance_1); + wait_functor(writer2); + + // DW1 sends a sample in instance 1. + writer1.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW1 sends a sample in instance 2. + writer1.send_sample(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW4 sends a sample in instance 1. + writer4.send_sample(data.front()); + data.pop_front(); + wait_functor(writer4); + + // DW1 sends a sample in instance 2. + writer1.send_sample(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW4 is destroyed. + writer4.unregister_instance(data.front(), instance_1); + wait_functor(writer4); + + // DW1 sends a sample in instance 1. + writer1.send_sample(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW1 sends a sample in instance 2. + writer1.send_sample(data.front()); + data.pop_front(); + wait_functor(writer1); + + reader.block_for_at_least(16); + ASSERT_EQ(denied_samples.size(), reader.data_not_received().size()); + ASSERT_EQ(denied_samples, reader.data_not_received()); +} + +/*! + * @test DDS-OWN-UNREG-01 Tests Ownership changes when writer unregisters an instance, in a Reliable communication with + * Keyed types. + */ +TEST_P(OwnershipQos, exclusive_kind_keyed_reliable_unregistering_instance) +{ + exclusive_kind_keyed_unregistering_instance(true); +} + +/*! + * @test DDS-OWN-UNREG-02 Tests Ownership changes when writer unregisters an instance, in a BestEffort communication with + * Keyed types. + */ +TEST_P(OwnershipQos, exclusive_kind_keyed_besteffort_unregistering_instance) +{ + exclusive_kind_keyed_unregistering_instance(false); +} + +void exclusive_kind_keyed_disposing_instance( + bool reliable) +{ + PubSubReader reader(TEST_TOPIC_NAME); + PubSubWriter writer1(TEST_TOPIC_NAME); + PubSubWriter writer2(TEST_TOPIC_NAME); + PubSubWriter writer3(TEST_TOPIC_NAME); + PubSubWriter writer4(TEST_TOPIC_NAME); + + reader.ownership_exclusive().reliability( + reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS + ).init(); + writer1.ownership_strength(1).reliability( + reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS + ).init(); + writer2.ownership_strength(2).reliability( + reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS + ).init(); + writer3.ownership_strength(3).reliability( + reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS + ).init(); + writer4.ownership_strength(4).reliability( + reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS + ).init(); + + ASSERT_TRUE(reader.isInitialized()); + ASSERT_TRUE(writer1.isInitialized()); + ASSERT_TRUE(writer2.isInitialized()); + ASSERT_TRUE(writer3.isInitialized()); + ASSERT_TRUE(writer4.isInitialized()); + + // Wait for discovery. + writer1.wait_discovery(); + writer2.wait_discovery(); + writer3.wait_discovery(); + writer4.wait_discovery(); + reader.wait_discovery(std::chrono::seconds(1), 4); + + std::function&)> wait_functor = + [](PubSubWriter&) + { + std::this_thread::sleep_for(std::chrono::milliseconds(50)); + }; + + if (reliable) + { + wait_functor = [](PubSubWriter& writer) + { + writer.waitForAllAcked(std::chrono::milliseconds(100)); + }; + } + + auto data = default_keyedhelloworld_data_generator(30); + reader.startReception(data); + + decltype(data) denied_samples; + + // DW1 sends a sample in instance 1. + InstanceHandle_t instance_1 = writer1.register_instance(data.front()); + writer1.send_sample(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW1 sends a sample in instance 2. + InstanceHandle_t instance_2 = writer1.register_instance(data.front()); + writer1.send_sample(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW2 sends a sample in instance 1. + writer2.send_sample(data.front()); + data.pop_front(); + wait_functor(writer2); + + // DW3 sends a sample in instance 2. + writer3.send_sample(data.front()); + data.pop_front(); + wait_functor(writer3); + + // DW1 sends a sample in instance 1. + writer1.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW1 sends a sample in instance 2. + writer1.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW4 sends a sample in instance 1. + writer4.send_sample(data.front()); + data.pop_front(); + wait_functor(writer4); + + // DW3 sends a sample in instance 2. + writer3.send_sample(data.front()); + data.pop_front(); + wait_functor(writer3); + + // DW1 sends a sample in instance 1. + writer1.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW1 sends a sample in instance 2. + writer1.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW2 sends a sample in instance 1. + writer2.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer2); + + // DW3 sends a sample in instance 2. + writer3.send_sample(data.front()); + wait_functor(writer3); + + // DW3 disposes instance 2. + writer3.dispose(data.front(), instance_2); + data.pop_front(); + wait_functor(writer3); + + // DW1 sends a sample in instance 1. + writer1.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW1 sends a sample in instance 2. + writer1.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW2 sends a sample in instance 1. + writer2.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer2); + + // DW1 sends a sample in instance 2. + writer1.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW4 sends a sample in instance 1. + writer4.send_sample(data.front()); + data.pop_front(); + wait_functor(writer4); + + // DW1 sends a sample in instance 2. + writer1.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW2 disposes instance 1. + writer2.dispose(data.front(), instance_1); + + // DW1 sends a sample in instance 1. + writer1.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW1 sends a sample in instance 2. + writer1.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW4 sends a sample in instance 1. + writer4.send_sample(data.front()); + data.pop_front(); + wait_functor(writer4); + + // DW1 sends a sample in instance 2. + writer1.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW4 is destroyed. + writer4.dispose(data.front(), instance_1); + wait_functor(writer4); + + // DW1 sends a sample in instance 1. + writer1.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW1 sends a sample in instance 2. + writer1.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW2 changes its strength to 5. + ASSERT_TRUE(writer2.ownership_strength(5).set_qos()); + std::this_thread::sleep_for(std::chrono::milliseconds(100)); // Wait the reader receives the update + // + // DW2 sends a sample in instance 1. + writer2.send_sample(data.front()); + data.pop_front(); + wait_functor(writer2); + + // DW3 sends a sample in instance 2. + writer3.send_sample(data.front()); + data.pop_front(); + wait_functor(writer3); + + // DW1 sends a sample in instance 1. + writer1.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW1 sends a sample in instance 2. + writer1.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer1); + + // DW4 sends a sample in instance 1. + writer4.send_sample(data.front()); + denied_samples.push_back(data.front()); + data.pop_front(); + wait_functor(writer4); + + // DW3 disposes instance 2. + writer3.dispose(data.front(), instance_2); + wait_functor(writer3); + + // DW3 is detroyed + writer3.destroy(); + reader.wait_writer_undiscovery(3); + + // DW1 sends a sample in instance 2. + writer1.send_sample(data.front()); + data.pop_front(); + wait_functor(writer1); + + reader.block_for_at_least(12); + ASSERT_EQ(denied_samples.size(), reader.data_not_received().size()); + ASSERT_EQ(denied_samples, reader.data_not_received()); +} + +/*! + * @test DDS-OWN-DISP-01 Tests Ownership changes when writer disposes an instance, in a Reliable communication with + * Keyed types. + */ +TEST_P(OwnershipQos, exclusive_kind_keyed_reliable_disposing_instance) +{ + exclusive_kind_keyed_disposing_instance(true); +} + +/*! + * @test DDS-OWN-DISP-02 Tests Ownership changes when writer disposes an instance, in a BestEffort communication with + * Keyed types. + */ +TEST_P(OwnershipQos, exclusive_kind_keyed_besteffort_disposing_instance) +{ + exclusive_kind_keyed_disposing_instance(false); +} + +#ifdef INSTANTIATE_TEST_SUITE_P +#define GTEST_INSTANTIATE_TEST_MACRO(x, y, z, w) INSTANTIATE_TEST_SUITE_P(x, y, z, w) +#else +#define GTEST_INSTANTIATE_TEST_MACRO(x, y, z, w) INSTANTIATE_TEST_CASE_P(x, y, z, w) +#endif // ifdef INSTANTIATE_TEST_SUITE_P + +GTEST_INSTANTIATE_TEST_MACRO(OwnershipQos, + OwnershipQos, + testing::Values(TRANSPORT, INTRAPROCESS, DATASHARING), + [](const testing::TestParamInfo& info) + { + switch (info.param) + { + case INTRAPROCESS: + return "Intraprocess"; + break; + case DATASHARING: + return "Datasharing"; + break; + case TRANSPORT: + default: + return "Transport"; + } + }); diff --git a/test/blackbox/common/DDSBlackboxTestsPersistence.cpp b/test/blackbox/common/DDSBlackboxTestsPersistence.cpp index bf99f6f8bdf..ee515c36e06 100644 --- a/test/blackbox/common/DDSBlackboxTestsPersistence.cpp +++ b/test/blackbox/common/DDSBlackboxTestsPersistence.cpp @@ -12,16 +12,18 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "BlackboxTests.hpp" +#include + +#include -#include "PubSubReader.hpp" -#include "PubSubWriter.hpp" -#include "ReqRepAsReliableHelloWorldRequester.hpp" -#include "ReqRepAsReliableHelloWorldReplier.hpp" #include #include -#include +#include "BlackboxTests.hpp" +#include "PubSubReader.hpp" +#include "PubSubWriter.hpp" +#include "ReqRepAsReliableHelloWorldReplier.hpp" +#include "ReqRepAsReliableHelloWorldRequester.hpp" using namespace eprosima::fastrtps; using namespace eprosima::fastrtps::rtps; diff --git a/test/performance/video/VideoTestPublisher.cpp b/test/performance/video/VideoTestPublisher.cpp index 48eb52bf576..52eadbcecb5 100644 --- a/test/performance/video/VideoTestPublisher.cpp +++ b/test/performance/video/VideoTestPublisher.cpp @@ -18,12 +18,14 @@ */ #include "VideoTestPublisher.hpp" -#include -#include "fastrtps/log/Colors.h" -#include +#include #include -#include +#include + +#include +#include +#include #define TIME_LIMIT_US 10000 @@ -91,11 +93,23 @@ VideoTestPublisher::~VideoTestPublisher() Domain::removeParticipant(mp_participant); } - -bool VideoTestPublisher::init(int n_sub, int n_sam, bool reliable, uint32_t pid, bool hostname, - const PropertyPolicy& part_property_policy, const PropertyPolicy& property_policy, bool large_data, - const std::string& sXMLConfigFile, int test_time, int drop_rate, int max_sleep_time, - int forced_domain, int videoWidth, int videoHeight, int videoFrameRate) +bool VideoTestPublisher::init( + int n_sub, + int n_sam, + bool reliable, + uint32_t pid, + bool hostname, + const PropertyPolicy& part_property_policy, + const PropertyPolicy& property_policy, + bool large_data, + const std::string& sXMLConfigFile, + int test_time, + int drop_rate, + int max_sleep_time, + int forced_domain, + int videoWidth, + int videoHeight, + int videoFrameRate) { large_data = true; m_testTime = test_time; @@ -127,13 +141,13 @@ bool VideoTestPublisher::init(int n_sub, int n_sam, bool reliable, uint32_t pid, PParam.rtps.properties = part_property_policy; PParam.rtps.setName("video_test_publisher"); - if(m_sXMLConfigFile.length() > 0) + if (m_sXMLConfigFile.length() > 0) { if (m_forcedDomain >= 0) { ParticipantAttributes participant_att; if (eprosima::fastrtps::xmlparser::XMLP_ret::XML_OK == - eprosima::fastrtps::xmlparser::XMLProfileManager::fillParticipantAttributes(participant_profile_name, + eprosima::fastrtps::xmlparser::XMLProfileManager::fillParticipantAttributes(participant_profile_name, participant_att)) { participant_att.domainId = m_forcedDomain; @@ -150,7 +164,7 @@ bool VideoTestPublisher::init(int n_sub, int n_sam, bool reliable, uint32_t pid, mp_participant = Domain::createParticipant(PParam); } - if(mp_participant == nullptr) + if (mp_participant == nullptr) { return false; } @@ -175,7 +189,7 @@ bool VideoTestPublisher::init(int n_sub, int n_sam, bool reliable, uint32_t pid, PubDataparam.qos.m_publishMode.kind = eprosima::fastrtps::ASYNCHRONOUS_PUBLISH_MODE; } - if(m_sXMLConfigFile.length() > 0) + if (m_sXMLConfigFile.length() > 0) { eprosima::fastrtps::xmlparser::XMLProfileManager::fillPublisherAttributes(profile_name, PubDataparam); } @@ -246,16 +260,18 @@ bool VideoTestPublisher::init(int n_sub, int n_sam, bool reliable, uint32_t pid, return true; } -void VideoTestPublisher::DataPubListener::onPublicationMatched(Publisher* /*pub*/, MatchingInfo& info) +void VideoTestPublisher::DataPubListener::onPublicationMatched( + Publisher* /*pub*/, + MatchingInfo& info) { std::unique_lock lock(mp_up->mutex_); - if(info.status == MATCHED_MATCHING) + if (info.status == MATCHED_MATCHING) { - cout << C_MAGENTA << "Data Pub Matched "< mp_up->n_subscribers) + if (n_matched > mp_up->n_subscribers) { std::cout << "More matched subscribers than expected" << std::endl; mp_up->m_status = -1; @@ -272,16 +288,18 @@ void VideoTestPublisher::DataPubListener::onPublicationMatched(Publisher* /*pub* mp_up->disc_cond_.notify_one(); } -void VideoTestPublisher::CommandPubListener::onPublicationMatched(Publisher* /*pub*/, MatchingInfo& info) +void VideoTestPublisher::CommandPubListener::onPublicationMatched( + Publisher* /*pub*/, + MatchingInfo& info) { std::unique_lock lock(mp_up->mutex_); - if(info.status == MATCHED_MATCHING) + if (info.status == MATCHED_MATCHING) { - cout << C_MAGENTA << "Command Pub Matched "< mp_up->n_subscribers) + if (n_matched > mp_up->n_subscribers) { std::cout << "More matched subscribers than expected" << std::endl; mp_up->m_status = -1; @@ -298,15 +316,17 @@ void VideoTestPublisher::CommandPubListener::onPublicationMatched(Publisher* /*p mp_up->disc_cond_.notify_one(); } -void VideoTestPublisher::CommandSubListener::onSubscriptionMatched(Subscriber* /*sub*/,MatchingInfo& info) +void VideoTestPublisher::CommandSubListener::onSubscriptionMatched( + Subscriber* /*sub*/, + MatchingInfo& info) { std::unique_lock lock(mp_up->mutex_); - if(info.status == MATCHED_MATCHING) + if (info.status == MATCHED_MATCHING) { - cout << C_MAGENTA << "Command Sub Matched "< mp_up->n_subscribers) + if (n_matched > mp_up->n_subscribers) { std::cout << "More matched subscribers than expected" << std::endl; mp_up->m_status = -1; @@ -323,17 +343,18 @@ void VideoTestPublisher::CommandSubListener::onSubscriptionMatched(Subscriber* / mp_up->disc_cond_.notify_one(); } -void VideoTestPublisher::CommandSubListener::onNewDataMessage(Subscriber* subscriber) +void VideoTestPublisher::CommandSubListener::onNewDataMessage( + Subscriber* subscriber) { TestCommandType command; SampleInfo_t info; // cout << "COMMAND RECEIVED"<takeNextData((void*)&command,&info)) + if (subscriber->takeNextData((void*)&command, &info)) { - if(info.sampleKind == ALIVE) + if (info.sampleKind == ALIVE) { //cout << "ALIVE "<mutex_.lock(); @@ -344,7 +365,9 @@ void VideoTestPublisher::CommandSubListener::onNewDataMessage(Subscriber* subscr } } else - cout<< "Problem reading"< disc_lock(mutex_); - disc_cond_.wait(disc_lock, [&]() { return disc_count_ >= (n_subscribers * 3); }); + disc_cond_.wait(disc_lock, [&]() + { + return disc_count_ >= (n_subscribers * 3); + }); disc_lock.unlock(); - cout << C_B_MAGENTA << "DISCOVERY COMPLETE "<test(0); - cout << "REMOVING PUBLISHER"<mp_commandpub); - cout << "REMOVING SUBSCRIBER"< lock(mutex_); // Wait for all the subscribers - comm_cond_.wait(lock, [&]() { - return comm_count_ >= n_subscribers; - }); + comm_cond_.wait(lock, [&]() + { + return comm_count_ >= n_subscribers; + }); --comm_count_; // BEGIN THE TEST @@ -400,9 +428,10 @@ bool VideoTestPublisher::test(uint32_t datasize) // Get start time send_start_ = std::chrono::steady_clock::now(); // Wait until timer returns "finished" - timer_cond_.wait(lock, [&]() { - return timer_on_; - }); + timer_cond_.wait(lock, [&]() + { + return timer_on_; + }); // Paused the sending gst_element_set_state(pipeline, GST_STATE_PAUSED); @@ -412,13 +441,14 @@ bool VideoTestPublisher::test(uint32_t datasize) mp_commandpub->write(&command); // Wait until all subscribers unmatch - disc_cond_.wait(lock, [&]() { - return disc_count_ == 0; - }); + disc_cond_.wait(lock, [&]() + { + return disc_count_ == 0; + }); - if(m_status !=0) + if (m_status != 0) { - cout << "Error in test "<mp_video_out != nullptr) @@ -541,7 +573,7 @@ GstFlowReturn VideoTestPublisher::new_sample(GstElement *sink, VideoTestPublishe std::chrono::steady_clock::time_point send_end = std::chrono::steady_clock::now(); std::unique_lock lock(sub->mutex_); - if(std::chrono::duration>(send_end - sub->send_start_).count() >= sub->m_testTime) + if (std::chrono::duration>(send_end - sub->send_start_).count() >= sub->m_testTime) { sub->timer_on_ = true; sub->timer_cond_.notify_one(); diff --git a/test/performance/video/VideoTestSubscriber.cpp b/test/performance/video/VideoTestSubscriber.cpp index 7b9caeae519..95695a31397 100644 --- a/test/performance/video/VideoTestSubscriber.cpp +++ b/test/performance/video/VideoTestSubscriber.cpp @@ -17,13 +17,16 @@ * */ -#include "VideoTestSubscriber.hpp" -#include -#include "fastrtps/log/Colors.h" -#include -#include #include #include +#include +#include + +#include +#include +#include + +#include "VideoTestSubscriber.hpp" using namespace eprosima; using namespace eprosima::fastrtps; diff --git a/test/performance/video/main_VideoTest.cpp b/test/performance/video/main_VideoTest.cpp index 4f518cbd2a0..45726a6c023 100644 --- a/test/performance/video/main_VideoTest.cpp +++ b/test/performance/video/main_VideoTest.cpp @@ -12,24 +12,26 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "VideoTestPublisher.hpp" -#include "VideoTestSubscriber.hpp" - -#include - -#include -#include -#include -#include #include #include +#include +#include +#include +#include +#include + #include +#include + #include #include #include #include +#include "VideoTestPublisher.hpp" +#include "VideoTestSubscriber.hpp" + #if defined(_MSC_VER) #pragma warning (push) #pragma warning (disable:4512) diff --git a/test/profiling/MemoryTestPublisher.cpp b/test/profiling/MemoryTestPublisher.cpp index af368bb196f..91b04e6dc60 100644 --- a/test/profiling/MemoryTestPublisher.cpp +++ b/test/profiling/MemoryTestPublisher.cpp @@ -18,19 +18,20 @@ */ #include "MemoryTestPublisher.h" -#include -#include "fastrtps/log/Colors.h" - -#include -#include #include +#include #include -#include +#include +#include + +#include +#include +#include #ifndef _WIN32 #define localtime_s(X, Y) localtime_r(Y, X) -#endif +#endif // ifndef _WIN32 #define TIME_LIMIT_US 10000 @@ -72,11 +73,19 @@ MemoryTestPublisher::~MemoryTestPublisher() Domain::removeParticipant(mp_participant); } - -bool MemoryTestPublisher::init(int n_sub, int n_sam, bool reliable, uint32_t pid, bool hostname, bool export_csv, - const std::string& export_prefix, const PropertyPolicy& part_property_policy, - const PropertyPolicy& property_policy, const std::string& sXMLConfigFile, - uint32_t data_size, bool dynamic_types) +bool MemoryTestPublisher::init( + int n_sub, + int n_sam, + bool reliable, + uint32_t pid, + bool hostname, + bool export_csv, + const std::string& export_prefix, + const PropertyPolicy& part_property_policy, + const PropertyPolicy& property_policy, + const std::string& sXMLConfigFile, + uint32_t data_size, + bool dynamic_types) { m_sXMLConfigFile = sXMLConfigFile; n_samples = n_sam; @@ -95,9 +104,9 @@ bool MemoryTestPublisher::init(int n_sub, int n_sam, bool reliable, uint32_t pid // Add members to the struct. struct_type_builder->add_member(0, "seqnum", DynamicTypeBuilderFactory::get_instance()->create_uint32_type()); struct_type_builder->add_member(1, "data", - DynamicTypeBuilderFactory::get_instance()->create_sequence_builder( - DynamicTypeBuilderFactory::get_instance()->create_byte_type(), ::dds::core::LENGTH_UNLIMITED - )); + DynamicTypeBuilderFactory::get_instance()->create_sequence_builder( + DynamicTypeBuilderFactory::get_instance()->create_byte_type(), ::dds::core::LENGTH_UNLIMITED + )); struct_type_builder->set_name("MemoryType"); m_pDynType = struct_type_builder->build(); @@ -144,7 +153,9 @@ bool MemoryTestPublisher::init(int n_sub, int n_sam, bool reliable, uint32_t pid std::ostringstream pt; pt << "MemoryTest_"; if (hostname) + { pt << asio::ip::host_name() << "_"; + } pt << pid << "_PUB2SUB"; PubDataparam.topic.topicName = pt.str(); if (!reliable) @@ -160,11 +171,13 @@ bool MemoryTestPublisher::init(int n_sub, int n_sam, bool reliable, uint32_t pid if (m_sXMLConfigFile.length() > 0) { - mp_datapub = Domain::createPublisher(mp_participant, profile_name, (PublisherListener*)&this->m_datapublistener); + mp_datapub = + Domain::createPublisher(mp_participant, profile_name, (PublisherListener*)&this->m_datapublistener); } else { - mp_datapub = Domain::createPublisher(mp_participant, PubDataparam, (PublisherListener*)&this->m_datapublistener); + mp_datapub = + Domain::createPublisher(mp_participant, PubDataparam, (PublisherListener*)&this->m_datapublistener); } if (mp_datapub == nullptr) @@ -180,7 +193,9 @@ bool MemoryTestPublisher::init(int n_sub, int n_sam, bool reliable, uint32_t pid std::ostringstream pct; pct << "MemoryTest_Command_"; if (hostname) + { pct << asio::ip::host_name() << "_"; + } pct << pid << "_PUB2SUB"; PubCommandParam.topic.topicName = pct.str(); PubCommandParam.topic.historyQos.kind = KEEP_ALL_HISTORY_QOS; @@ -201,7 +216,9 @@ bool MemoryTestPublisher::init(int n_sub, int n_sam, bool reliable, uint32_t pid std::ostringstream sct; sct << "MemoryTest_Command_"; if (hostname) + { sct << asio::ip::host_name() << "_"; + } sct << pid << "_SUB2PUB"; SubCommandParam.topic.topicName = sct.str(); SubCommandParam.topic.historyQos.kind = KEEP_ALL_HISTORY_QOS; @@ -226,16 +243,18 @@ bool MemoryTestPublisher::init(int n_sub, int n_sam, bool reliable, uint32_t pid return true; } -void MemoryTestPublisher::DataPubListener::onPublicationMatched(Publisher* /*pub*/, MatchingInfo& info) +void MemoryTestPublisher::DataPubListener::onPublicationMatched( + Publisher* /*pub*/, + MatchingInfo& info) { std::unique_lock lock(mp_up->mutex_); - if(info.status == MATCHED_MATCHING) + if (info.status == MATCHED_MATCHING) { - cout << C_MAGENTA << "Data Pub Matched "< mp_up->n_subscribers) + if (n_matched > mp_up->n_subscribers) { std::cout << "More matched subscribers than expected" << std::endl; mp_up->m_status = -1; @@ -245,7 +264,7 @@ void MemoryTestPublisher::DataPubListener::onPublicationMatched(Publisher* /*pub } else { - cout << C_MAGENTA << "Data Pub Unmatched "<disc_count_; } @@ -253,16 +272,18 @@ void MemoryTestPublisher::DataPubListener::onPublicationMatched(Publisher* /*pub mp_up->disc_cond_.notify_one(); } -void MemoryTestPublisher::CommandPubListener::onPublicationMatched(Publisher* /*pub*/, MatchingInfo& info) +void MemoryTestPublisher::CommandPubListener::onPublicationMatched( + Publisher* /*pub*/, + MatchingInfo& info) { std::unique_lock lock(mp_up->mutex_); - if(info.status == MATCHED_MATCHING) + if (info.status == MATCHED_MATCHING) { - cout << C_MAGENTA << "Command Pub Matched "< mp_up->n_subscribers) + if (n_matched > mp_up->n_subscribers) { std::cout << "More matched subscribers than expected" << std::endl; mp_up->m_status = -1; @@ -272,7 +293,7 @@ void MemoryTestPublisher::CommandPubListener::onPublicationMatched(Publisher* /* } else { - cout << C_MAGENTA << "Command Pub unmatched "<disc_count_; } @@ -280,16 +301,18 @@ void MemoryTestPublisher::CommandPubListener::onPublicationMatched(Publisher* /* mp_up->disc_cond_.notify_one(); } -void MemoryTestPublisher::CommandSubListener::onSubscriptionMatched(Subscriber* /*sub*/,MatchingInfo& info) +void MemoryTestPublisher::CommandSubListener::onSubscriptionMatched( + Subscriber* /*sub*/, + MatchingInfo& info) { std::unique_lock lock(mp_up->mutex_); - if(info.status == MATCHED_MATCHING) + if (info.status == MATCHED_MATCHING) { - cout << C_MAGENTA << "Command Sub Matched "< mp_up->n_subscribers) + if (n_matched > mp_up->n_subscribers) { std::cout << "More matched subscribers than expected" << std::endl; mp_up->m_status = -1; @@ -299,7 +322,7 @@ void MemoryTestPublisher::CommandSubListener::onSubscriptionMatched(Subscriber* } else { - cout << C_MAGENTA << "Command Sub unmatched "<disc_count_; } @@ -307,17 +330,18 @@ void MemoryTestPublisher::CommandSubListener::onSubscriptionMatched(Subscriber* mp_up->disc_cond_.notify_one(); } -void MemoryTestPublisher::CommandSubListener::onNewDataMessage(Subscriber* subscriber) +void MemoryTestPublisher::CommandSubListener::onNewDataMessage( + Subscriber* subscriber) { TestCommandType command; SampleInfo_t info; // cout << "COMMAND RECEIVED"<takeNextData((void*)&command,&info)) + if (subscriber->takeNextData((void*)&command, &info)) { - if(info.sampleKind == ALIVE) + if (info.sampleKind == ALIVE) { //cout << "ALIVE "<mutex_.lock(); @@ -328,29 +352,35 @@ void MemoryTestPublisher::CommandSubListener::onNewDataMessage(Subscriber* subsc } } else - cout<< "Problem reading"< disc_lock(mutex_); - disc_cond_.wait(disc_lock, [&](){ - return disc_count_ >= (n_subscribers * 3); - }); + disc_cond_.wait(disc_lock, [&]() + { + return disc_count_ >= (n_subscribers * 3); + }); disc_lock.unlock(); test(test_time, m_data_size); std::this_thread::sleep_for(std::chrono::milliseconds(100)); - cout << "REMOVING PUBLISHER"<mp_commandpub); - cout << "REMOVING SUBSCRIBER"<add_member(0, "seqnum", DynamicTypeBuilderFactory::get_instance()->create_uint32_type()); struct_type_builder->add_member(1, "data", - DynamicTypeBuilderFactory::get_instance()->create_sequence_builder( - DynamicTypeBuilderFactory::get_instance()->create_byte_type(), datasize - )); + DynamicTypeBuilderFactory::get_instance()->create_sequence_builder( + DynamicTypeBuilderFactory::get_instance()->create_byte_type(), datasize + )); struct_type_builder->set_name("MemoryType"); m_pDynType = struct_type_builder->build(); @@ -380,7 +410,7 @@ bool MemoryTestPublisher::test(uint32_t test_time, uint32_t datasize) m_DynData = DynamicDataFactory::get_instance()->create_data(m_pDynType); MemberId id; - DynamicData *my_data = m_DynData->loan_value(m_DynData->get_member_id_at_index(1)); + DynamicData* my_data = m_DynData->loan_value(m_DynData->get_member_id_at_index(1)); for (uint32_t i = 0; i < datasize; ++i) { my_data->insert_sequence_data(id); @@ -397,11 +427,12 @@ bool MemoryTestPublisher::test(uint32_t test_time, uint32_t datasize) // Finally Data matching std::unique_lock disc_lock(mutex_); - disc_cond_.wait(disc_lock, [&](){ - return disc_count_ >= (n_subscribers * 3); - }); + disc_cond_.wait(disc_lock, [&]() + { + return disc_count_ >= (n_subscribers * 3); + }); disc_lock.unlock(); - cout << C_B_MAGENTA << "DISCOVERY COMPLETE "< lock(mutex_); - comm_cond_.wait(lock, [&](){ - return comm_count_ == n_subscribers; - }); + comm_cond_.wait(lock, [&]() + { + return comm_count_ == n_subscribers; + }); --comm_count_; lock.unlock(); //cout << endl; @@ -421,7 +453,7 @@ bool MemoryTestPublisher::test(uint32_t test_time, uint32_t datasize) while (std::chrono::duration(t_end_ - t_start_) < test_time_us) { - for(unsigned int count = 1; count <= n_samples; ++count) + for (unsigned int count = 1; count <= n_samples; ++count) { if (dynamic_data) { @@ -440,13 +472,13 @@ bool MemoryTestPublisher::test(uint32_t test_time, uint32_t datasize) command.m_command = STOP; mp_commandpub->write(&command); - if(m_status !=0) + if (m_status != 0) { - cout << "Error in test "<removeAllChange(&removed); //cout << " REMOVED: "<< removed< -#include "fastrtps/log/Colors.h" + +#include #include +#include +#include using namespace eprosima::fastrtps; using namespace eprosima::fastrtps::rtps; @@ -60,9 +62,17 @@ MemoryTestSubscriber::~MemoryTestSubscriber() Domain::removeParticipant(mp_participant); } -bool MemoryTestSubscriber::init(bool echo, int nsam, bool reliable, uint32_t pid, bool hostname, - const PropertyPolicy& part_property_policy, const PropertyPolicy& property_policy, - const std::string& sXMLConfigFile, uint32_t data_size, bool dynamic_types) +bool MemoryTestSubscriber::init( + bool echo, + int nsam, + bool reliable, + uint32_t pid, + bool hostname, + const PropertyPolicy& part_property_policy, + const PropertyPolicy& property_policy, + const std::string& sXMLConfigFile, + uint32_t data_size, + bool dynamic_types) { m_sXMLConfigFile = sXMLConfigFile; m_echo = echo; @@ -78,9 +88,9 @@ bool MemoryTestSubscriber::init(bool echo, int nsam, bool reliable, uint32_t pid // Add members to the struct. struct_type_builder->add_member(0, "seqnum", DynamicTypeBuilderFactory::get_instance()->create_uint32_type()); struct_type_builder->add_member(1, "data", - DynamicTypeBuilderFactory::get_instance()->create_sequence_builder( - DynamicTypeBuilderFactory::get_instance()->create_byte_type(), ::dds::core::LENGTH_UNLIMITED - )); + DynamicTypeBuilderFactory::get_instance()->create_sequence_builder( + DynamicTypeBuilderFactory::get_instance()->create_byte_type(), ::dds::core::LENGTH_UNLIMITED + )); struct_type_builder->set_name("MemoryType"); m_pDynType = struct_type_builder->build(); @@ -126,7 +136,9 @@ bool MemoryTestSubscriber::init(bool echo, int nsam, bool reliable, uint32_t pid std::ostringstream st; st << "MemoryTest_"; if (hostname) + { st << asio::ip::host_name() << "_"; + } st << pid << "_PUB2SUB"; SubDataparam.topic.topicName = st.str(); if (reliable) @@ -160,7 +172,9 @@ bool MemoryTestSubscriber::init(bool echo, int nsam, bool reliable, uint32_t pid std::ostringstream pct; pct << "MemoryTest_Command_"; if (hostname) + { pct << asio::ip::host_name() << "_"; + } pct << pid << "_SUB2PUB"; PubCommandParam.topic.topicName = pct.str(); PubCommandParam.topic.historyQos.kind = KEEP_ALL_HISTORY_QOS; @@ -181,7 +195,9 @@ bool MemoryTestSubscriber::init(bool echo, int nsam, bool reliable, uint32_t pid std::ostringstream sct; sct << "MemoryTest_Command_"; if (hostname) + { sct << asio::ip::host_name() << "_"; + } sct << pid << "_PUB2SUB"; SubCommandParam.topic.topicName = sct.str(); SubCommandParam.topic.historyQos.kind = KEEP_ALL_HISTORY_QOS; @@ -206,18 +222,20 @@ bool MemoryTestSubscriber::init(bool echo, int nsam, bool reliable, uint32_t pid return true; } -void MemoryTestSubscriber::DataSubListener::onSubscriptionMatched(Subscriber* /*sub*/,MatchingInfo& info) +void MemoryTestSubscriber::DataSubListener::onSubscriptionMatched( + Subscriber* /*sub*/, + MatchingInfo& info) { std::unique_lock lock(mp_up->mutex_); - if(info.status == MATCHED_MATCHING) + if (info.status == MATCHED_MATCHING) { - cout << C_MAGENTA << "Data Sub Matched "<disc_count_; } else { - cout << C_MAGENTA << "Data Sub unmatched "<disc_count_; } @@ -225,18 +243,20 @@ void MemoryTestSubscriber::DataSubListener::onSubscriptionMatched(Subscriber* /* mp_up->disc_cond_.notify_one(); } -void MemoryTestSubscriber::CommandPubListener::onPublicationMatched(Publisher* /*pub*/,MatchingInfo& info) +void MemoryTestSubscriber::CommandPubListener::onPublicationMatched( + Publisher* /*pub*/, + MatchingInfo& info) { std::unique_lock lock(mp_up->mutex_); - if(info.status == MATCHED_MATCHING) + if (info.status == MATCHED_MATCHING) { - cout << C_MAGENTA << "Command Pub Matched "<disc_count_; } else { - cout << C_MAGENTA << "Command Pub unmatched "<disc_count_; } @@ -244,18 +264,20 @@ void MemoryTestSubscriber::CommandPubListener::onPublicationMatched(Publisher* / mp_up->disc_cond_.notify_one(); } -void MemoryTestSubscriber::CommandSubListener::onSubscriptionMatched(Subscriber* /*sub*/,MatchingInfo& info) +void MemoryTestSubscriber::CommandSubListener::onSubscriptionMatched( + Subscriber* /*sub*/, + MatchingInfo& info) { std::unique_lock lock(mp_up->mutex_); - if(info.status == MATCHED_MATCHING) + if (info.status == MATCHED_MATCHING) { - cout << C_MAGENTA << "Command Sub Matched "<disc_count_; } else { - cout << C_MAGENTA << "Command Sub unmatched "<disc_count_; } @@ -263,21 +285,22 @@ void MemoryTestSubscriber::CommandSubListener::onSubscriptionMatched(Subscriber* mp_up->disc_cond_.notify_one(); } -void MemoryTestSubscriber::CommandSubListener::onNewDataMessage(Subscriber* subscriber) +void MemoryTestSubscriber::CommandSubListener::onNewDataMessage( + Subscriber* subscriber) { TestCommandType command; - if(subscriber->takeNextData(&command,&mp_up->m_sampleinfo)) + if (subscriber->takeNextData(&command, &mp_up->m_sampleinfo)) { - cout << "RCOMMAND: "<< command.m_command << endl; - if(command.m_command == READY) + cout << "RCOMMAND: " << command.m_command << endl; + if (command.m_command == READY) { - cout << "Publisher has new test ready..."<mutex_.lock(); ++mp_up->comm_count_; mp_up->mutex_.unlock(); mp_up->comm_cond_.notify_one(); } - else if(command.m_command == STOP) + else if (command.m_command == STOP) { cout << "Publisher has stopped the test" << endl; mp_up->mutex_.lock(); @@ -285,7 +308,7 @@ void MemoryTestSubscriber::CommandSubListener::onNewDataMessage(Subscriber* subs mp_up->mutex_.unlock(); mp_up->data_cond_.notify_one(); } - else if(command.m_command == STOP_ERROR) + else if (command.m_command == STOP_ERROR) { cout << "Publisher has canceled the test" << endl; mp_up->m_status = -1; @@ -294,14 +317,15 @@ void MemoryTestSubscriber::CommandSubListener::onNewDataMessage(Subscriber* subs mp_up->mutex_.unlock(); mp_up->data_cond_.notify_one(); } - else if(command.m_command == DEFAULT) + else if (command.m_command == DEFAULT) { std::cout << "Something is wrong" << std::endl; } } } -void MemoryTestSubscriber::DataSubListener::onNewDataMessage(Subscriber* subscriber) +void MemoryTestSubscriber::DataSubListener::onNewDataMessage( + Subscriber* subscriber) { if (mp_up->dynamic_data) { @@ -310,12 +334,12 @@ void MemoryTestSubscriber::DataSubListener::onNewDataMessage(Subscriber* subscri if (mp_up->m_echo) { std::cout << "Received data: " << mp_up->m_DynData->get_uint32_value(0) - << "(" << mp_up->n_received << ")" << std::endl; + << "(" << mp_up->n_received << ")" << std::endl; } } else { - subscriber->takeNextData((void*)mp_up->mp_memory,&mp_up->m_sampleinfo); + subscriber->takeNextData((void*)mp_up->mp_memory, &mp_up->m_sampleinfo); ++mp_up->n_received; if (mp_up->m_echo) { @@ -324,21 +348,22 @@ void MemoryTestSubscriber::DataSubListener::onNewDataMessage(Subscriber* subscri } } - void MemoryTestSubscriber::run() { //WAIT FOR THE DISCOVERY PROCESS FO FINISH: //EACH SUBSCRIBER NEEDS 3 Matchings (Comd Pub+Sub and publisher or subscriber) std::unique_lock disc_lock(mutex_); - disc_cond_.wait(disc_lock, [&](){ - return disc_count_ >= 3; - }); + disc_cond_.wait(disc_lock, [&]() + { + return disc_count_ >= 3; + }); disc_lock.unlock(); test(m_data_size); } -bool MemoryTestSubscriber::test(uint32_t datasize) +bool MemoryTestSubscriber::test( + uint32_t datasize) { cout << "Preparing test with data size: " << datasize + 4 << endl; @@ -351,11 +376,11 @@ bool MemoryTestSubscriber::test(uint32_t datasize) // Add members to the struct. struct_type_builder->add_member(0, "seqnum", - DynamicTypeBuilderFactory::get_instance()->create_uint32_type()); + DynamicTypeBuilderFactory::get_instance()->create_uint32_type()); struct_type_builder->add_member(1, "data", - DynamicTypeBuilderFactory::get_instance()->create_sequence_builder( - DynamicTypeBuilderFactory::get_instance()->create_byte_type(), datasize - )); + DynamicTypeBuilderFactory::get_instance()->create_sequence_builder( + DynamicTypeBuilderFactory::get_instance()->create_byte_type(), datasize + )); struct_type_builder->set_name("MemoryType"); m_pDynType = struct_type_builder->build(); @@ -375,15 +400,19 @@ bool MemoryTestSubscriber::test(uint32_t datasize) // Finally data matching std::unique_lock disc_lock(mutex_); - disc_cond_.wait(disc_lock, [&](){ - return disc_count_ >= 3; - }); + disc_cond_.wait(disc_lock, [&]() + { + return disc_count_ >= 3; + }); disc_lock.unlock(); - cout << C_B_MAGENTA << "DISCOVERY COMPLETE "< lock(mutex_); - if (comm_count_ == 0) comm_cond_.wait(lock); + if (comm_count_ == 0) + { + comm_cond_.wait(lock); + } --comm_count_; lock.unlock(); @@ -396,9 +425,9 @@ bool MemoryTestSubscriber::test(uint32_t datasize) lock.lock(); data_cond_.wait(lock, [&]() - { - return data_count_ > 0; - }); + { + return data_count_ > 0; + }); --data_count_; lock.unlock(); diff --git a/test/profiling/allocations/AllocTestPublisher.cpp b/test/profiling/allocations/AllocTestPublisher.cpp index 7ad93cc3c01..dd4209b5233 100644 --- a/test/profiling/allocations/AllocTestPublisher.cpp +++ b/test/profiling/allocations/AllocTestPublisher.cpp @@ -18,14 +18,18 @@ */ #include "AllocTestPublisher.h" -#include "AllocTestCommon.h" -#include + +#include + #include #include -#include #include +#include +#include #include +#include "AllocTestCommon.h" + using namespace eprosima::fastrtps; using namespace eprosima::fastrtps::rtps; diff --git a/test/profiling/allocations/AllocTestSubscriber.cpp b/test/profiling/allocations/AllocTestSubscriber.cpp index 724edf45860..4cf416fedfe 100644 --- a/test/profiling/allocations/AllocTestSubscriber.cpp +++ b/test/profiling/allocations/AllocTestSubscriber.cpp @@ -18,14 +18,18 @@ */ #include "AllocTestSubscriber.h" -#include "AllocTestCommon.h" -#include + +#include + #include #include -#include #include +#include +#include #include +#include "AllocTestCommon.h" + using namespace eprosima::fastrtps; using namespace eprosima::fastrtps::rtps; diff --git a/test/profiling/main_MemoryTest.cpp b/test/profiling/main_MemoryTest.cpp index b22646f6045..cfdd6f75b11 100644 --- a/test/profiling/main_MemoryTest.cpp +++ b/test/profiling/main_MemoryTest.cpp @@ -12,23 +12,24 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "MemoryTestPublisher.h" -#include "MemoryTestSubscriber.h" - -#include - -#include -#include -#include -#include #include #include +#include +#include +#include +#include +#include + +#include #include #include #include #include +#include "MemoryTestPublisher.h" +#include "MemoryTestSubscriber.h" + #if defined(_MSC_VER) #pragma warning (push) #pragma warning (disable:4512) diff --git a/test/unittest/dds/core/condition/ConditionTests.cpp b/test/unittest/dds/core/condition/ConditionTests.cpp index 31a58e7ff37..61bae7efaad 100644 --- a/test/unittest/dds/core/condition/ConditionTests.cpp +++ b/test/unittest/dds/core/condition/ConditionTests.cpp @@ -12,19 +12,21 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "../../../logging/mock/MockConsumer.h" -#include +#include + #include -#include +#include #include #include #include #include +#include +#include #include #include -#include +#include "../../../logging/mock/MockConsumer.h" using eprosima::fastrtps::types::ReturnCode_t; diff --git a/test/unittest/dds/core/entity/EntityTests.cpp b/test/unittest/dds/core/entity/EntityTests.cpp index a708907629d..79a425dcaf8 100644 --- a/test/unittest/dds/core/entity/EntityTests.cpp +++ b/test/unittest/dds/core/entity/EntityTests.cpp @@ -12,18 +12,21 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "../../../logging/mock/MockConsumer.h" -#include "mock/MockEntity.hpp" -#include +#include + #include #include #include #include #include +#include #include #include +#include "../../../logging/mock/MockConsumer.h" +#include "mock/MockEntity.hpp" + using namespace eprosima::fastdds::dds; using namespace std; diff --git a/test/unittest/dds/publisher/DataWriterTests.cpp b/test/unittest/dds/publisher/DataWriterTests.cpp index 94320dab99b..aa22006b248 100644 --- a/test/unittest/dds/publisher/DataWriterTests.cpp +++ b/test/unittest/dds/publisher/DataWriterTests.cpp @@ -12,9 +12,17 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include +#include +#include + #include #include +#include +#include +#include +#include #include #include #include @@ -24,20 +32,27 @@ #include #include #include +<<<<<<< HEAD +======= +#include +#include +#include +#include +#include +>>>>>>> 6390715a1 (Add missing thread include (#4045)) #include #include -#include -#include -#include -#include - #include "../../logging/mock/MockConsumer.h" +<<<<<<< HEAD #include #include #include +======= +#include "../../common/CustomPayloadPool.hpp" +>>>>>>> 6390715a1 (Add missing thread include (#4045)) namespace eprosima { namespace fastdds { diff --git a/test/unittest/logging/log_macros/LogMacros.hpp b/test/unittest/logging/log_macros/LogMacros.hpp index fe887688718..1c6e54046cc 100644 --- a/test/unittest/logging/log_macros/LogMacros.hpp +++ b/test/unittest/logging/log_macros/LogMacros.hpp @@ -15,12 +15,16 @@ #ifndef LOG_MACROS_HPP #define LOG_MACROS_HPP +#include + +#include + #include #include #include #include + #include "../mock/MockConsumer.h" -#include using namespace eprosima::fastdds::dds; using namespace std; diff --git a/test/unittest/rtps/flowcontrol/FlowControllerPublishModesOnAsyncTests.cpp b/test/unittest/rtps/flowcontrol/FlowControllerPublishModesOnAsyncTests.cpp index 4050360c81c..d9054299e0d 100644 --- a/test/unittest/rtps/flowcontrol/FlowControllerPublishModesOnAsyncTests.cpp +++ b/test/unittest/rtps/flowcontrol/FlowControllerPublishModesOnAsyncTests.cpp @@ -1,5 +1,26 @@ +<<<<<<< HEAD +======= +// Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +>>>>>>> 6390715a1 (Add missing thread include (#4045)) #include "FlowControllerPublishModesTests.hpp" +#include + +#include + using namespace eprosima::fastdds::rtps; using namespace testing; diff --git a/test/unittest/rtps/flowcontrol/FlowControllerPublishModesOnLimitedAsyncTests.cpp b/test/unittest/rtps/flowcontrol/FlowControllerPublishModesOnLimitedAsyncTests.cpp index bbc810a7396..a4d24789a13 100644 --- a/test/unittest/rtps/flowcontrol/FlowControllerPublishModesOnLimitedAsyncTests.cpp +++ b/test/unittest/rtps/flowcontrol/FlowControllerPublishModesOnLimitedAsyncTests.cpp @@ -1,5 +1,26 @@ +<<<<<<< HEAD +======= +// Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +>>>>>>> 6390715a1 (Add missing thread include (#4045)) #include "FlowControllerPublishModesTests.hpp" +#include + +#include + using namespace eprosima::fastdds::rtps; using namespace testing; diff --git a/test/unittest/rtps/flowcontrol/FlowControllerPublishModesOnPureSyncTests.cpp b/test/unittest/rtps/flowcontrol/FlowControllerPublishModesOnPureSyncTests.cpp index 73a08987d95..60478011899 100644 --- a/test/unittest/rtps/flowcontrol/FlowControllerPublishModesOnPureSyncTests.cpp +++ b/test/unittest/rtps/flowcontrol/FlowControllerPublishModesOnPureSyncTests.cpp @@ -1,5 +1,26 @@ +<<<<<<< HEAD +======= +// Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +>>>>>>> 6390715a1 (Add missing thread include (#4045)) #include "FlowControllerPublishModesTests.hpp" +#include + +#include + using namespace eprosima::fastdds::rtps; using namespace testing; diff --git a/test/unittest/rtps/flowcontrol/FlowControllerPublishModesOnSyncTests.cpp b/test/unittest/rtps/flowcontrol/FlowControllerPublishModesOnSyncTests.cpp index d8438a25ae6..c81d993b834 100644 --- a/test/unittest/rtps/flowcontrol/FlowControllerPublishModesOnSyncTests.cpp +++ b/test/unittest/rtps/flowcontrol/FlowControllerPublishModesOnSyncTests.cpp @@ -1,5 +1,26 @@ +<<<<<<< HEAD +======= +// Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +>>>>>>> 6390715a1 (Add missing thread include (#4045)) #include "FlowControllerPublishModesTests.hpp" +#include + +#include + using namespace eprosima::fastdds::rtps; using namespace testing; diff --git a/test/unittest/rtps/flowcontrol/FlowControllerSchedulersTests.cpp b/test/unittest/rtps/flowcontrol/FlowControllerSchedulersTests.cpp index 7ffe0ba2bab..add2ccf862e 100644 --- a/test/unittest/rtps/flowcontrol/FlowControllerSchedulersTests.cpp +++ b/test/unittest/rtps/flowcontrol/FlowControllerSchedulersTests.cpp @@ -1,4 +1,26 @@ +<<<<<<< HEAD #include +======= +// Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include + +#include + +#include +>>>>>>> 6390715a1 (Add missing thread include (#4045)) #include #include diff --git a/test/unittest/security/logging/LoggingPluginTests.hpp b/test/unittest/security/logging/LoggingPluginTests.hpp index f648296e6f8..d7ddb44a8ee 100644 --- a/test/unittest/security/logging/LoggingPluginTests.hpp +++ b/test/unittest/security/logging/LoggingPluginTests.hpp @@ -15,11 +15,14 @@ #ifndef _UNITTEST_SECURITY_LOGGING_LOGGINGPLUGINTESTS_HPP_ #define _UNITTEST_SECURITY_LOGGING_LOGGINGPLUGINTESTS_HPP_ -#include -#include +#include #include +#include + +#include + class LoggingPluginTest : public ::testing::Test { protected: @@ -89,82 +92,85 @@ TEST_F(LoggingPluginTest, DefaultBehavior) TEST_F(LoggingPluginTest, AsyncFileLogging) { - // First remove previous executions file - std::remove(security_log_filename.c_str()); + // First remove previous executions file + std::remove(security_log_filename.c_str()); - eprosima::fastrtps::rtps::security::LogOptions log_options; + eprosima::fastrtps::rtps::security::LogOptions log_options; - log_options.distribute = false; - log_options.log_file = security_log_filename; - log_options.log_level = eprosima::fastrtps::rtps::security::LoggingLevel::DEBUG_LEVEL; + log_options.distribute = false; + log_options.log_file = security_log_filename; + log_options.log_level = eprosima::fastrtps::rtps::security::LoggingLevel::DEBUG_LEVEL; - eprosima::fastrtps::rtps::security::SecurityException exception; + eprosima::fastrtps::rtps::security::SecurityException exception; -// plugin->set_domain_id(); -// plugin->set_guid(); + // plugin->set_domain_id(); + // plugin->set_guid(); - EXPECT_TRUE(plugin->set_log_options(log_options, exception)); - EXPECT_TRUE(plugin->options_set()); - EXPECT_TRUE(plugin->enable_logging(exception)) << exception.what(); - EXPECT_TRUE(plugin->enabled()); + EXPECT_TRUE(plugin->set_log_options(log_options, exception)); + EXPECT_TRUE(plugin->options_set()); + EXPECT_TRUE(plugin->enable_logging(exception)) << exception.what(); + EXPECT_TRUE(plugin->enabled()); - std::vector> threads; - for (long i = 0; i < NUM_LOG_LEVELS; ++i) { - threads.emplace_back(new std::thread([this, i, &exception]{ - plugin->log( - static_cast(i), - std::string("Report from thread ") + std::to_string(i), - "Logging,fileloggingtest", - exception); - })); - } + std::vector> threads; + for (long i = 0; i < NUM_LOG_LEVELS; ++i) + { + threads.emplace_back(new std::thread([this, i, &exception] + { + plugin->log( + static_cast(i), + std::string("Report from thread ") + std::to_string(i), + "Logging,fileloggingtest", + exception); + })); + } - for (auto& thread: threads) { - thread->join(); - } + for (auto& thread: threads) + { + thread->join(); + } - // give a chance to the logger to log all messages - std::this_thread::sleep_for(std::chrono::milliseconds(100)); + // give a chance to the logger to log all messages + std::this_thread::sleep_for(std::chrono::milliseconds(100)); - std::ifstream ifs(security_log_filename); + std::ifstream ifs(security_log_filename); - if (!ifs.is_open()) - { - GTEST_FAIL(); - } + if (!ifs.is_open()) + { + GTEST_FAIL(); + } - std::string line; - long count = 0; + std::string line; + long count = 0; - // log format is: - // [] [] message - while (std::getline(ifs, line)) - { - // check stamp - std::regex regex("\\[[0-9]+.[0-9]+\\]"); - EXPECT_TRUE(std::regex_search(line, regex)) << line; + // log format is: + // [] [] message + while (std::getline(ifs, line)) + { + // check stamp + std::regex regex("\\[[0-9]+.[0-9]+\\]"); + EXPECT_TRUE(std::regex_search(line, regex)) << line; - // check verbosity - regex = std::regex("[EMERGENCY|ALERT|CRITICAL|ERROR|WARNING|NOTICE|INFORMATIONAL|DEBUG]"); - EXPECT_TRUE(std::regex_search(line, regex)) << line; + // check verbosity + regex = std::regex("[EMERGENCY|ALERT|CRITICAL|ERROR|WARNING|NOTICE|INFORMATIONAL|DEBUG]"); + EXPECT_TRUE(std::regex_search(line, regex)) << line; - //@TODO(artivis) check guid + //@TODO(artivis) check guid - //@TODO(artivis) check domain_id + //@TODO(artivis) check domain_id - // check call site - regex = std::regex("Logging::fileloggingtest : "); - EXPECT_TRUE(std::regex_search(line, regex)) << line; + // check call site + regex = std::regex("Logging::fileloggingtest : "); + EXPECT_TRUE(std::regex_search(line, regex)) << line; - // check message - regex = std::regex("Report from thread [0-9]{1}"); - EXPECT_TRUE(std::regex_search(line, regex)) << line; + // check message + regex = std::regex("Report from thread [0-9]{1}"); + EXPECT_TRUE(std::regex_search(line, regex)) << line; - ++count; - } + ++count; + } - EXPECT_EQ(NUM_LOG_LEVELS, count); + EXPECT_EQ(NUM_LOG_LEVELS, count); } #endif // _UNITTEST_SECURITY_LOGGING_LOGGINGPLUGINTESTS_HPP_ diff --git a/test/unittest/statistics/rtps/RTPSStatisticsTests.cpp b/test/unittest/statistics/rtps/RTPSStatisticsTests.cpp index 2786dc0f436..a7b0a2f36c1 100644 --- a/test/unittest/statistics/rtps/RTPSStatisticsTests.cpp +++ b/test/unittest/statistics/rtps/RTPSStatisticsTests.cpp @@ -13,6 +13,15 @@ // limitations under the License. #include +<<<<<<< HEAD +======= +#include +#if defined(_WIN32) +#include +#else +#include +#endif // if defined(_WIN32) +>>>>>>> 6390715a1 (Add missing thread include (#4045)) #include #include @@ -20,16 +29,16 @@ #include #include #include -#include #include -#include #include +#include #include #include #include #include #include #include +#include #include #include #include @@ -40,9 +49,8 @@ #include #include -#include - #include +#include #include namespace eprosima { From 165c0b1c5f7c417f724d31e1b05a77db8d18f5b8 Mon Sep 17 00:00:00 2001 From: EduPonz Date: Fri, 1 Dec 2023 08:16:51 +0100 Subject: [PATCH 2/3] Fix conflicts Signed-off-by: EduPonz --- .../common/BlackboxTestsPubSubHistory.cpp | 12 - .../common/DDSBlackboxTestsListeners.cpp | 17 +- .../common/DDSBlackboxTestsOwnershipQos.cpp | 2184 ----------------- .../dds/publisher/DataWriterTests.cpp | 17 +- ...FlowControllerPublishModesOnAsyncTests.cpp | 5 - ...trollerPublishModesOnLimitedAsyncTests.cpp | 5 - ...wControllerPublishModesOnPureSyncTests.cpp | 5 - .../FlowControllerPublishModesOnSyncTests.cpp | 5 - .../FlowControllerSchedulersTests.cpp | 7 +- .../statistics/rtps/RTPSStatisticsTests.cpp | 8 - 10 files changed, 6 insertions(+), 2259 deletions(-) delete mode 100644 test/blackbox/common/DDSBlackboxTestsOwnershipQos.cpp diff --git a/test/blackbox/common/BlackboxTestsPubSubHistory.cpp b/test/blackbox/common/BlackboxTestsPubSubHistory.cpp index 26b94c14fc1..d34c1e727a7 100644 --- a/test/blackbox/common/BlackboxTestsPubSubHistory.cpp +++ b/test/blackbox/common/BlackboxTestsPubSubHistory.cpp @@ -12,18 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -<<<<<<< HEAD -#include "BlackboxTests.hpp" - -#include "PubSubReader.hpp" -#include "PubSubWriter.hpp" -======= #include #include #include #include ->>>>>>> 6390715a1 (Add missing thread include (#4045)) #include @@ -31,11 +24,6 @@ #include "PubSubReader.hpp" #include "PubSubWriter.hpp" #include -<<<<<<< HEAD -#include -#include -======= ->>>>>>> 6390715a1 (Add missing thread include (#4045)) using namespace eprosima::fastrtps; using namespace eprosima::fastdds::rtps; diff --git a/test/blackbox/common/DDSBlackboxTestsListeners.cpp b/test/blackbox/common/DDSBlackboxTestsListeners.cpp index 855d1c74177..4a099c579fd 100644 --- a/test/blackbox/common/DDSBlackboxTestsListeners.cpp +++ b/test/blackbox/common/DDSBlackboxTestsListeners.cpp @@ -12,32 +12,23 @@ // See the License for the specific language governing permissions and // limitations under the License. -<<<<<<< HEAD -======= #include #include #include +#include + #include #include #include #include #include ->>>>>>> 6390715a1 (Add missing thread include (#4045)) -#include "BlackboxTests.hpp" +#include +#include "BlackboxTests.hpp" #include "PubSubReader.hpp" #include "PubSubWriter.hpp" -#include - -#include -#include -#include - -#include - -#include using namespace eprosima::fastrtps; using namespace eprosima::fastrtps::rtps; diff --git a/test/blackbox/common/DDSBlackboxTestsOwnershipQos.cpp b/test/blackbox/common/DDSBlackboxTestsOwnershipQos.cpp deleted file mode 100644 index dc2b92d9ac7..00000000000 --- a/test/blackbox/common/DDSBlackboxTestsOwnershipQos.cpp +++ /dev/null @@ -1,2184 +0,0 @@ -// Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include - -#include - -#include -#include - -#include "BlackboxTests.hpp" -#include "PubSubReader.hpp" -#include "PubSubWriter.hpp" - -using namespace eprosima::fastrtps; -using namespace eprosima::fastrtps::rtps; - -enum communication_type -{ - TRANSPORT, - INTRAPROCESS, - DATASHARING -}; - -class OwnershipQos : public testing::TestWithParam -{ -public: - - void SetUp() override - { - LibrarySettingsAttributes library_settings; - switch (GetParam()) - { - case INTRAPROCESS: - library_settings.intraprocess_delivery = IntraprocessDeliveryType::INTRAPROCESS_FULL; - xmlparser::XMLProfileManager::library_settings(library_settings); - break; - case DATASHARING: - enable_datasharing = true; - break; - case TRANSPORT: - default: - break; - } - } - - void TearDown() override - { - LibrarySettingsAttributes library_settings; - switch (GetParam()) - { - case INTRAPROCESS: - library_settings.intraprocess_delivery = IntraprocessDeliveryType::INTRAPROCESS_OFF; - xmlparser::XMLProfileManager::library_settings(library_settings); - break; - case DATASHARING: - enable_datasharing = false; - break; - case TRANSPORT: - default: - break; - } - } - -}; - -void exclusive_kind_non_keyed_sample_reception( - bool reliable) -{ - PubSubReader reader(TEST_TOPIC_NAME); - PubSubWriter writer1(TEST_TOPIC_NAME); - PubSubWriter writer2(TEST_TOPIC_NAME); - PubSubWriter writer3(TEST_TOPIC_NAME); - - reader.ownership_exclusive().reliability( - reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS - ).init(); - writer1.ownership_strength(1).reliability( - reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS - ).init(); - writer2.ownership_strength(2).reliability( - reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS - ).init(); - writer3.ownership_strength(3).reliability( - reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS - ).init(); - - ASSERT_TRUE(reader.isInitialized()); - ASSERT_TRUE(writer1.isInitialized()); - ASSERT_TRUE(writer2.isInitialized()); - ASSERT_TRUE(writer3.isInitialized()); - - // Wait for discovery. - writer1.wait_discovery(); - writer2.wait_discovery(); - writer3.wait_discovery(); - reader.wait_discovery(std::chrono::seconds(1), 3); - - std::function&)> wait_functor = - [](PubSubWriter&) - { - std::this_thread::sleep_for(std::chrono::milliseconds(50)); - }; - - if (reliable) - { - wait_functor = [](PubSubWriter& writer) - { - writer.waitForAllAcked(std::chrono::milliseconds(100)); - }; - } - - auto data = default_helloworld_data_generator(13); - reader.startReception(data); - - decltype(data) denied_samples; - - // DW1 sends a sample. - writer1.send_sample(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW2 sends a sample. - writer2.send_sample(data.front()); - data.pop_front(); - wait_functor(writer2); - - // DW1 sends a sample. - writer1.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW2 sends a sample. - writer2.send_sample(data.front()); - data.pop_front(); - wait_functor(writer2); - - // DW3 sends a sample. - writer3.send_sample(data.front()); - data.pop_front(); - wait_functor(writer3); - - // DW1 sends a sample. - writer1.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW2 sends a sample. - writer2.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer2); - - // DW3 sends a sample. - writer3.send_sample(data.front()); - data.pop_front(); - wait_functor(writer3); - - // DW2 changes its strength to 4. - ASSERT_TRUE(writer2.ownership_strength(4).set_qos()); - std::this_thread::sleep_for(std::chrono::milliseconds(100)); // Wait the reader receives the update - - // DW3 sends a sample. - writer3.send_sample(data.front()); - data.pop_front(); - wait_functor(writer3); - - // DW3 changes its strength to 1. - ASSERT_TRUE(writer3.ownership_strength(1).set_qos()); - std::this_thread::sleep_for(std::chrono::milliseconds(100)); // Wait the reader receives the update - - // DW3 sends a sample. - writer3.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer3); - - // DW1 sends a sample. - writer1.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW2 sends a sample. - writer2.send_sample(data.front()); - data.pop_front(); - wait_functor(writer2); - - // DW3 sends a sample. - writer3.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer3); - - reader.block_for_at_least(7); - ASSERT_EQ(denied_samples.size(), reader.data_not_received().size()); - ASSERT_EQ(denied_samples, reader.data_not_received()); -} - -/*! - * @test DDS-OWN-SAMPLE-01 Tests samples reception works successfully with Non-Keyed types, Reliable, Ownership QoS - * EXCLUSIVE and dynamic change of strength. - */ -TEST_P(OwnershipQos, exclusive_kind_non_keyed_reliable_sample_reception) -{ - exclusive_kind_non_keyed_sample_reception(true); -} - -void exclusive_kind_keyed_sample_reception( - bool reliable) -{ - PubSubReader reader(TEST_TOPIC_NAME); - PubSubWriter writer1(TEST_TOPIC_NAME); - PubSubWriter writer2(TEST_TOPIC_NAME); - PubSubWriter writer3(TEST_TOPIC_NAME); - PubSubWriter writer4(TEST_TOPIC_NAME); - - reader.ownership_exclusive().reliability( - reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS - ).init(); - writer1.ownership_strength(1).reliability( - reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS - ).init(); - writer2.ownership_strength(2).reliability( - reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS - ).init(); - writer3.ownership_strength(3).reliability( - reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS - ).init(); - writer4.ownership_strength(4).reliability( - reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS - ).init(); - - ASSERT_TRUE(reader.isInitialized()); - ASSERT_TRUE(writer1.isInitialized()); - ASSERT_TRUE(writer2.isInitialized()); - ASSERT_TRUE(writer3.isInitialized()); - ASSERT_TRUE(writer4.isInitialized()); - - // Wait for discovery. - writer1.wait_discovery(); - writer2.wait_discovery(); - writer3.wait_discovery(); - writer4.wait_discovery(); - reader.wait_discovery(std::chrono::seconds(1), 4); - - std::function&)> wait_functor = - [](PubSubWriter&) - { - std::this_thread::sleep_for(std::chrono::milliseconds(50)); - }; - - if (reliable) - { - wait_functor = [](PubSubWriter& writer) - { - writer.waitForAllAcked(std::chrono::milliseconds(100)); - }; - } - - auto data = default_keyedhelloworld_data_generator(23); - reader.startReception(data); - - decltype(data) denied_samples; - - // DW1 sends a sample of instance 1. - writer1.send_sample(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW2 sends a sample of instance 2. - writer2.send_sample(data.front()); - data.pop_front(); - wait_functor(writer2); - - // DW2 sends a sample of instance 1. - writer2.send_sample(data.front()); - data.pop_front(); - wait_functor(writer2); - - // DW3 sends a sample of instance 2. - writer3.send_sample(data.front()); - data.pop_front(); - wait_functor(writer3); - - // DW1 sends a sample of instance 1. - writer1.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW1 sends a sample of instance 2. - writer1.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW2 sends a sample of instance 1. - writer2.send_sample(data.front()); - data.pop_front(); - wait_functor(writer2); - - // DW2 sends a sample of instance 2. - writer2.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer2); - - // DW4 sends a sample of instance 1. - writer4.send_sample(data.front()); - data.pop_front(); - wait_functor(writer4); - - // DW2 sends a sample of instance 2. - writer2.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer2); - - // DW1 sends a sample of instance 1. - writer1.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW1 sends a sample of instance 2. - writer1.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW2 sends a sample of instance 1. - writer2.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer2); - - // DW2 sends a sample of instance 2. - writer2.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer2); - - // DW2 changes its strength to 4. - ASSERT_TRUE(writer2.ownership_strength(4).set_qos()); - std::this_thread::sleep_for(std::chrono::milliseconds(100)); // Wait the reader receives the update - - // DW1 sends a sample of instance 1. - writer1.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW3 sends a sample of instance 2. - writer3.send_sample(data.front()); - data.pop_front(); - wait_functor(writer3); - - // DW4 sends a sample of instance 1. - writer4.send_sample(data.front()); - data.pop_front(); - wait_functor(writer4); - - // DW3 changes its strength to 1. - ASSERT_TRUE(writer3.ownership_strength(1).set_qos()); - std::this_thread::sleep_for(std::chrono::milliseconds(100)); // Wait the reader receives the update - - // DW3 sends a sample of instance 2. - writer3.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer3); - - // DW1 sends a sample of instance 1. - writer1.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW2 sends a sample of instance 2. - writer2.send_sample(data.front()); - data.pop_front(); - wait_functor(writer2); - - // DW1 sends a sample of instance 1. - writer1.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW3 sends a sample of instance 2. - writer3.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer3); - - // DW4 sends a sample of instance 1. - writer4.send_sample(data.front()); - data.pop_front(); - wait_functor(writer4); - - reader.block_for_at_least(10); - ASSERT_EQ(denied_samples.size(), reader.data_not_received().size()); - ASSERT_EQ(denied_samples, reader.data_not_received()); -} - -/*! - * @test DDS-OWN-SAMPLE-02 Tests samples reception works successfully with Keyed types, Reliable, Ownership QoS - * EXCLUSIVE and dynamic change of strength. - */ -TEST_P(OwnershipQos, exclusive_kind_keyed_reliable_sample_reception) -{ - exclusive_kind_keyed_sample_reception(true); -} - -/*! - * @test DDS-OWN-SAMPLE-03 Tests samples reception works successfully with Non-Keyed types, BestEffort, Ownership QoS - * EXCLUSIVE and dynamic change of strength. - */ -TEST_P(OwnershipQos, exclusive_kind_non_keyed_besteffort_sample_reception) -{ - exclusive_kind_non_keyed_sample_reception(false); -} - -/*! - * @test DDS-OWN-SAMPLE-04 Tests samples reception works successfully with Keyed types, BestEffort, Ownership QoS - * EXCLUSIVE and dynamic change of strength. - */ -TEST_P(OwnershipQos, exclusive_kind_keyed_besteffort_sample_reception) -{ - exclusive_kind_keyed_sample_reception(false); -} - -void exclusive_kind_non_keyed_writers_same_guid( - bool reliable) -{ - PubSubReader reader(TEST_TOPIC_NAME); - PubSubWriter writer1(TEST_TOPIC_NAME); - PubSubWriter writer2(TEST_TOPIC_NAME); - PubSubWriter writer3(TEST_TOPIC_NAME); - - reader.ownership_exclusive().reliability( - reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS - ).init(); - writer1.ownership_strength(10).reliability( - reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS - ).init(); - writer2.ownership_strength(10).reliability( - reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS - ).init(); - writer3.ownership_strength(10).reliability( - reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS - ).init(); - - ASSERT_TRUE(reader.isInitialized()); - ASSERT_TRUE(writer1.isInitialized()); - ASSERT_TRUE(writer2.isInitialized()); - ASSERT_TRUE(writer3.isInitialized()); - - // Wait for discovery. - writer1.wait_discovery(); - writer2.wait_discovery(); - writer3.wait_discovery(); - reader.wait_discovery(std::chrono::seconds(1), 3); - - std::function&)> wait_functor = - [](PubSubWriter&) - { - std::this_thread::sleep_for(std::chrono::milliseconds(50)); - }; - - if (reliable) - { - wait_functor = [](PubSubWriter& writer) - { - writer.waitForAllAcked(std::chrono::milliseconds(100)); - }; - } - - auto data = default_helloworld_data_generator(7); - reader.startReception(data); - - decltype(data) denied_samples; - - // DW2 sends a sample. - writer2.send_sample(data.front()); - data.pop_front(); - wait_functor(writer2); - - // DW3 sends a sample. - writer3.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer3); - - // DW2 sends a sample. - writer2.send_sample(data.front()); - data.pop_front(); - wait_functor(writer2); - - // DW1 sends a sample. - writer1.send_sample(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW3 sends a sample. - writer3.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer3); - - // DW2 sends a sample. - writer2.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer2); - - // DW1 sends a sample. - writer1.send_sample(data.front()); - data.pop_front(); - wait_functor(writer1); - - reader.block_for_at_least(4); - ASSERT_EQ(denied_samples.size(), reader.data_not_received().size()); - ASSERT_EQ(denied_samples, reader.data_not_received()); -} - -/*! - * @test DDS-OWN-SAMPLE-05 Tests samples reception works successfully with Non-Keyed types, Reliable, Ownership QoS - * EXCLUSIVE and several writers with same GUID. - */ -TEST_P(OwnershipQos, exclusive_kind_non_keyed_reliable_writers_same_guid) -{ - exclusive_kind_non_keyed_writers_same_guid(true); -} - -void exclusive_kind_keyed_writers_same_guid( - bool reliable) -{ - PubSubReader reader(TEST_TOPIC_NAME); - PubSubWriter writer1(TEST_TOPIC_NAME); - PubSubWriter writer2(TEST_TOPIC_NAME); - PubSubWriter writer3(TEST_TOPIC_NAME); - PubSubWriter writer4(TEST_TOPIC_NAME); - - reader.ownership_exclusive().reliability( - reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS - ).init(); - writer1.ownership_strength(10).reliability( - reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS - ).init(); - writer2.ownership_strength(10).reliability( - reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS - ).init(); - writer3.ownership_strength(10).reliability( - reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS - ).init(); - writer4.ownership_strength(10).reliability( - reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS - ).init(); - - ASSERT_TRUE(reader.isInitialized()); - ASSERT_TRUE(writer1.isInitialized()); - ASSERT_TRUE(writer2.isInitialized()); - ASSERT_TRUE(writer3.isInitialized()); - ASSERT_TRUE(writer4.isInitialized()); - - // Wait for discovery. - writer1.wait_discovery(); - writer2.wait_discovery(); - writer3.wait_discovery(); - writer4.wait_discovery(); - reader.wait_discovery(std::chrono::seconds(1), 4); - - std::function&)> wait_functor = - [](PubSubWriter&) - { - std::this_thread::sleep_for(std::chrono::milliseconds(50)); - }; - - if (reliable) - { - wait_functor = [](PubSubWriter& writer) - { - writer.waitForAllAcked(std::chrono::milliseconds(100)); - }; - } - - auto data = default_keyedhelloworld_data_generator(10); - reader.startReception(data); - - decltype(data) denied_samples; - - // DW2 sends a sample of instance 1. - writer2.send_sample(data.front()); - data.pop_front(); - wait_functor(writer2); - - // DW3 sends a sample of instance 2. - writer3.send_sample(data.front()); - data.pop_front(); - wait_functor(writer3); - - // DW4 sends a sample of instance 1. - writer4.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer4); - - // DW4 sends a sample of instance 2. - writer4.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer4); - - // DW2 sends a sample of instance 1. - writer2.send_sample(data.front()); - data.pop_front(); - wait_functor(writer2); - - // DW3 sends a sample of instance 2. - writer3.send_sample(data.front()); - data.pop_front(); - wait_functor(writer3); - - // DW1 sends a sample of instance 1. - writer1.send_sample(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW1 sends a sample of instance 2. - writer1.send_sample(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW2 sends a sample of instance 1. - writer2.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer2); - - // DW3 sends a sample of instance 2. - writer2.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer2); - - reader.block_for_at_least(6); - ASSERT_EQ(denied_samples.size(), reader.data_not_received().size()); - ASSERT_EQ(denied_samples, reader.data_not_received()); -} - -/*! - * @test DDS-OWN-SAMPLE-06 Tests samples reception works successfully with Keyed types, Reliable, Ownership QoS - * EXCLUSIVE and several writers with same GUID. - */ -TEST_P(OwnershipQos, exclusive_kind_keyed_reliable_writers_same_guid) -{ - exclusive_kind_keyed_writers_same_guid(true); -} - -/*! - * @test DDS-OWN-SAMPLE-07 Tests samples reception works successfully with Keyed types, BestEffort, Ownership QoS - * EXCLUSIVE and several writers with same GUID. - */ -TEST_P(OwnershipQos, exclusive_kind_non_keyed_besteffort_writers_same_guid) -{ - exclusive_kind_non_keyed_writers_same_guid(false); -} - -/*! - * @test DDS-OWN-SAMPLE-08 Tests samples reception works successfully with Keyed types, BestEffort, Ownership QoS - * EXCLUSIVE and several writers with same GUID. - */ -TEST_P(OwnershipQos, exclusive_kind_keyed_besteffort_writers_same_guid) -{ - exclusive_kind_keyed_writers_same_guid(false); -} - -/*! - * @test DDS-OWN-DEADLINE-01 Tests Ownership changes when the current owner doesn't comply with deadline QoS, in a - * Reliable communication with Non-Keyed types. - */ -TEST_P(OwnershipQos, exclusive_kind_non_keyed_reliable_deadline) -{ - - PubSubReader reader(TEST_TOPIC_NAME); - PubSubWriter writer1(TEST_TOPIC_NAME); - PubSubWriter writer2(TEST_TOPIC_NAME); - - reader.ownership_exclusive().reliability(RELIABLE_RELIABILITY_QOS).deadline_period({0, 100000000}).init(); - writer1.ownership_strength(1).deadline_period({0, 100000000}).init(); - writer2.ownership_strength(2).deadline_period({0, 100000000}).init(); - - ASSERT_TRUE(reader.isInitialized()); - ASSERT_TRUE(writer1.isInitialized()); - ASSERT_TRUE(writer2.isInitialized()); - - // Wait for discovery. - writer1.wait_discovery(); - writer2.wait_discovery(); - reader.wait_discovery(std::chrono::seconds(1), 2); - - auto data = default_helloworld_data_generator(10); - reader.startReception(data); - - decltype(data) denied_samples; - - writer1.send_sample(data.front()); - data.pop_front(); - std::this_thread::sleep_for(std::chrono::milliseconds(50)); - - writer2.send_sample(data.front()); - data.pop_front(); - std::this_thread::sleep_for(std::chrono::milliseconds(50)); - - writer1.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - std::this_thread::sleep_for(std::chrono::milliseconds(50)); - - writer2.send_sample(data.front()); - data.pop_front(); - std::this_thread::sleep_for(std::chrono::milliseconds(50)); - - writer1.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - std::this_thread::sleep_for(std::chrono::milliseconds(50)); - - writer2.send_sample(data.front()); - data.pop_front(); - std::this_thread::sleep_for(std::chrono::milliseconds(50)); - - writer1.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - std::this_thread::sleep_for(std::chrono::milliseconds(50)); - - writer1.send_sample(data.front()); - data.pop_front(); - std::this_thread::sleep_for(std::chrono::milliseconds(50)); - - writer1.send_sample(data.front()); - data.pop_front(); - std::this_thread::sleep_for(std::chrono::milliseconds(50)); - - writer1.send_sample(data.front()); - data.pop_front(); - std::this_thread::sleep_for(std::chrono::milliseconds(50)); - - reader.block_for_seq({0, 7}); - ASSERT_EQ(denied_samples.size(), reader.data_not_received().size()); - ASSERT_EQ(denied_samples, reader.data_not_received()); -} - -/*! - * @test DDS-OWN-DEADLINE-02 Tests Ownership changes when the current owner doesn't comply with deadline QoS, in a - * Reliable communication with Keyed types. - */ -TEST_P(OwnershipQos, exclusive_kind_keyed_reliable_deadline) -{ - - PubSubReader reader(TEST_TOPIC_NAME); - PubSubWriter writer1(TEST_TOPIC_NAME); - PubSubWriter writer2(TEST_TOPIC_NAME); - - reader.ownership_exclusive().reliability(RELIABLE_RELIABILITY_QOS).deadline_period({0, 100000000}).init(); - writer1.ownership_strength(1).deadline_period({0, 100000000}).init(); - writer2.ownership_strength(2).deadline_period({0, 100000000}).init(); - - ASSERT_TRUE(reader.isInitialized()); - ASSERT_TRUE(writer1.isInitialized()); - ASSERT_TRUE(writer2.isInitialized()); - - // Wait for discovery. - writer1.wait_discovery(); - writer2.wait_discovery(); - reader.wait_discovery(std::chrono::seconds(1), 2); - - auto data = default_keyedhelloworld_data_generator(26); - reader.startReception(data); - - decltype(data) denied_samples; - - writer1.send_sample(data.front()); - data.pop_front(); - writer1.send_sample(data.front()); - data.pop_front(); - std::this_thread::sleep_for(std::chrono::milliseconds(50)); - - writer2.send_sample(data.front()); - data.pop_front(); - writer2.send_sample(data.front()); - data.pop_front(); - std::this_thread::sleep_for(std::chrono::milliseconds(50)); - - writer1.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - writer1.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - std::this_thread::sleep_for(std::chrono::milliseconds(50)); - - writer2.send_sample(data.front()); - data.pop_front(); - writer2.send_sample(data.front()); - data.pop_front(); - std::this_thread::sleep_for(std::chrono::milliseconds(50)); - - writer1.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - writer1.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - std::this_thread::sleep_for(std::chrono::milliseconds(50)); - - writer2.send_sample(data.front()); - data.pop_front(); - writer2.send_sample(data.front()); - data.pop_front(); - std::this_thread::sleep_for(std::chrono::milliseconds(50)); - - writer1.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - writer1.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - std::this_thread::sleep_for(std::chrono::milliseconds(50)); - - writer1.send_sample(data.front()); - data.pop_front(); - writer2.send_sample(data.front()); - data.pop_front(); - denied_samples.push_back(data.front()); - data.pop_front(); - writer1.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - std::this_thread::sleep_for(std::chrono::milliseconds(50)); - - writer1.send_sample(data.front()); - data.pop_front(); - writer2.send_sample(data.front()); - data.pop_front(); - denied_samples.push_back(data.front()); - data.pop_front(); - writer1.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - std::this_thread::sleep_for(std::chrono::milliseconds(50)); - - writer1.send_sample(data.front()); - data.pop_front(); - writer2.send_sample(data.front()); - data.pop_front(); - denied_samples.push_back(data.front()); - data.pop_front(); - writer1.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - std::this_thread::sleep_for(std::chrono::milliseconds(50)); - - reader.block_for_seq({0, 13}); - ASSERT_EQ(denied_samples.size(), reader.data_not_received().size()); - ASSERT_EQ(denied_samples, reader.data_not_received()); -} - -void exclusive_kind_non_keyed_undiscovered_writer( - bool reliable) -{ - PubSubReader reader(TEST_TOPIC_NAME); - PubSubWriter writer1(TEST_TOPIC_NAME); - PubSubWriter writer2(TEST_TOPIC_NAME); - PubSubWriter writer3(TEST_TOPIC_NAME); - - reader.ownership_exclusive().reliability( - reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS - ).init(); - writer1.ownership_strength(1).reliability( - reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS - ).init(); - writer2.ownership_strength(2).reliability( - reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS - ).init(); - writer3.ownership_strength(3).reliability( - reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS - ).init(); - - ASSERT_TRUE(reader.isInitialized()); - ASSERT_TRUE(writer1.isInitialized()); - ASSERT_TRUE(writer2.isInitialized()); - ASSERT_TRUE(writer3.isInitialized()); - - // Wait for discovery. - writer1.wait_discovery(); - writer2.wait_discovery(); - writer3.wait_discovery(); - reader.wait_discovery(std::chrono::seconds(1), 3); - - std::function&)> wait_functor = - [](PubSubWriter&) - { - std::this_thread::sleep_for(std::chrono::milliseconds(50)); - }; - - if (reliable) - { - wait_functor = [](PubSubWriter& writer) - { - writer.waitForAllAcked(std::chrono::milliseconds(100)); - }; - } - - auto data = default_helloworld_data_generator(11); - reader.startReception(data); - - decltype(data) denied_samples; - - // DW1 sends a sample. - writer1.send_sample(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW2 sends a sample. - writer2.send_sample(data.front()); - data.pop_front(); - wait_functor(writer2); - - // DW1 sends a sample. - writer1.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW2 sends a sample. - writer2.send_sample(data.front()); - data.pop_front(); - wait_functor(writer2); - - // DW3 sends a sample. - writer3.send_sample(data.front()); - data.pop_front(); - wait_functor(writer3); - - // DW1 sends a sample. - writer1.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW2 sends a sample. - writer2.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer2); - - // DW3 sends a sample. - writer3.send_sample(data.front()); - data.pop_front(); - wait_functor(writer3); - - // DW3 is detroyed - writer3.destroy(); - reader.wait_writer_undiscovery(2); - - // DW1 sends a sample. - writer1.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW2 sends a sample. - writer2.send_sample(data.front()); - data.pop_front(); - wait_functor(writer2); - - // DW1 is detroyed - writer1.destroy(); - reader.wait_writer_undiscovery(1); - - // DW2 sends a sample. - writer2.send_sample(data.front()); - data.pop_front(); - wait_functor(writer2); - - reader.block_for_at_least(7); - ASSERT_EQ(denied_samples.size(), reader.data_not_received().size()); - ASSERT_EQ(denied_samples, reader.data_not_received()); -} - -/*! - * @test DDS-OWN-UNDISC-01 Tests Ownership changes when writer removes himself, in a Reliable communication with - * Non-Keyed types. - */ -TEST_P(OwnershipQos, exclusive_kind_non_keyed_reliable_undiscovered_writer) -{ - exclusive_kind_non_keyed_undiscovered_writer(true); -} - -void exclusive_kind_keyed_undiscovered_writer( - bool reliable) -{ - PubSubReader reader(TEST_TOPIC_NAME); - PubSubWriter writer1(TEST_TOPIC_NAME); - PubSubWriter writer2(TEST_TOPIC_NAME); - PubSubWriter writer3(TEST_TOPIC_NAME); - PubSubWriter writer4(TEST_TOPIC_NAME); - - reader.ownership_exclusive().reliability( - reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS - ).init(); - writer1.ownership_strength(1).reliability( - reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS - ).init(); - writer2.ownership_strength(2).reliability( - reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS - ).init(); - writer3.ownership_strength(3).reliability( - reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS - ).init(); - writer4.ownership_strength(4).reliability( - reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS - ).init(); - - ASSERT_TRUE(reader.isInitialized()); - ASSERT_TRUE(writer1.isInitialized()); - ASSERT_TRUE(writer2.isInitialized()); - ASSERT_TRUE(writer3.isInitialized()); - ASSERT_TRUE(writer4.isInitialized()); - - // Wait for discovery. - writer1.wait_discovery(); - writer2.wait_discovery(); - writer3.wait_discovery(); - writer4.wait_discovery(); - reader.wait_discovery(std::chrono::seconds(1), 4); - - std::function&)> wait_functor = - [](PubSubWriter&) - { - std::this_thread::sleep_for(std::chrono::milliseconds(50)); - }; - - if (reliable) - { - wait_functor = [](PubSubWriter& writer) - { - writer.waitForAllAcked(std::chrono::milliseconds(100)); - }; - } - - auto data = default_keyedhelloworld_data_generator(24); - reader.startReception(data); - - decltype(data) denied_samples; - - // DW1 sends a sample in instance 1. - writer1.send_sample(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW1 sends a sample in instance 2. - writer1.send_sample(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW2 sends a sample in instance 1. - writer2.send_sample(data.front()); - data.pop_front(); - wait_functor(writer2); - - // DW3 sends a sample in instance 2. - writer3.send_sample(data.front()); - data.pop_front(); - wait_functor(writer3); - - // DW1 sends a sample in instance 1. - writer1.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW1 sends a sample in instance 2. - writer1.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW4 sends a sample in instance 1. - writer4.send_sample(data.front()); - data.pop_front(); - wait_functor(writer4); - - // DW3 sends a sample in instance 2. - writer3.send_sample(data.front()); - data.pop_front(); - wait_functor(writer3); - - // DW1 sends a sample in instance 1. - writer1.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW1 sends a sample in instance 2. - writer1.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW2 sends a sample in instance 1. - writer2.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer2); - - // DW3 sends a sample in instance 2. - writer3.send_sample(data.front()); - data.pop_front(); - wait_functor(writer3); - - // DW3 is destroyed. - writer3.destroy(); - reader.wait_writer_undiscovery(3); - - // DW1 sends a sample in instance 1. - writer1.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW1 sends a sample in instance 2. - writer1.send_sample(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW2 sends a sample in instance 1. - writer2.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer2); - - // DW1 sends a sample in instance 2. - writer1.send_sample(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW4 sends a sample in instance 1. - writer4.send_sample(data.front()); - data.pop_front(); - wait_functor(writer4); - - // DW1 sends a sample in instance 2. - writer1.send_sample(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW2 is destroyed. - writer2.destroy(); - reader.wait_writer_undiscovery(2); - - // DW1 sends a sample in instance 1. - writer1.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW1 sends a sample in instance 2. - writer1.send_sample(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW4 sends a sample in instance 1. - writer4.send_sample(data.front()); - data.pop_front(); - wait_functor(writer4); - - // DW1 sends a sample in instance 2. - writer1.send_sample(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW4 is destroyed. - writer4.destroy(); - reader.wait_writer_undiscovery(1); - - // DW1 sends a sample in instance 1. - writer1.send_sample(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW1 sends a sample in instance 2. - writer1.send_sample(data.front()); - data.pop_front(); - wait_functor(writer1); - - reader.block_for_at_least(16); - ASSERT_EQ(denied_samples.size(), reader.data_not_received().size()); - ASSERT_EQ(denied_samples, reader.data_not_received()); -} - -/*! - * @test DDS-OWN-UNDISC-02 Tests Ownership changes when writer removes himself, in a Reliable communication with - * Keyed types. - */ -TEST_P(OwnershipQos, exclusive_kind_keyed_reliable_undiscovered_writer) -{ - exclusive_kind_keyed_undiscovered_writer(true); -} - -/*! - * @test DDS-OWN-UNDISC-03 Tests Ownership changes when writer removes himself, in a BestEffort communication with - * Non-Keyed types. - */ -TEST_P(OwnershipQos, exclusive_kind_non_keyed_besteffort_undiscovered_writer) -{ - exclusive_kind_non_keyed_undiscovered_writer(false); -} - -/*! - * @test DDS-OWN-UNDISC-04 Tests Ownership changes when writer removes himself, in a BestEffort communication with - * Keyed types. - */ -TEST_P(OwnershipQos, exclusive_kind_keyed_besteffort_undiscovered_writer) -{ - exclusive_kind_keyed_undiscovered_writer(false); -} - -void exclusive_kind_non_keyed_lost_liveliness( - bool reliable) -{ - PubSubReader reader(TEST_TOPIC_NAME); - PubSubWriter writer1(TEST_TOPIC_NAME); - PubSubWriter writer2(TEST_TOPIC_NAME); - PubSubWriter writer3(TEST_TOPIC_NAME); - - std::atomic drop_messages1(false); - auto testTransport1 = std::make_shared(); - testTransport1->messages_filter_ = [&drop_messages1](eprosima::fastrtps::rtps::CDRMessage_t&) - { - return drop_messages1.load(); - }; - std::atomic drop_messages3(false); - auto testTransport3 = std::make_shared(); - testTransport3->messages_filter_ = [&drop_messages3](eprosima::fastrtps::rtps::CDRMessage_t&) - { - return drop_messages3.load(); - }; - - reader.ownership_exclusive().reliability( - reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS - ) - .lease_duration({1, 0}, {0, 500000000}) - .init(); - writer1.ownership_strength(1).reliability( - reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS - ) - .add_user_transport_to_pparams(testTransport1) - .disable_builtin_transport() - .lease_duration({1, 0}, {0, 500000000}) - .init(); - writer2.ownership_strength(2).reliability( - reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS - ) - .lease_duration({1, 0}, {0, 500000000}) - .init(); - writer3.ownership_strength(3).reliability( - reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS - ) - .add_user_transport_to_pparams(testTransport3) - .disable_builtin_transport() - .lease_duration({1, 0}, {0, 500000000}) - .init(); - - ASSERT_TRUE(reader.isInitialized()); - ASSERT_TRUE(writer1.isInitialized()); - ASSERT_TRUE(writer2.isInitialized()); - ASSERT_TRUE(writer3.isInitialized()); - - // Wait for discovery. - writer1.wait_discovery(); - writer2.wait_discovery(); - writer3.wait_discovery(); - reader.wait_discovery(std::chrono::seconds(1), 3); - - std::function&)> wait_functor = - [](PubSubWriter&) - { - std::this_thread::sleep_for(std::chrono::milliseconds(50)); - }; - - if (reliable) - { - wait_functor = [](PubSubWriter& writer) - { - writer.waitForAllAcked(std::chrono::milliseconds(100)); - }; - } - - auto data = default_helloworld_data_generator(11); - reader.startReception(data); - - decltype(data) denied_samples; - - // DW1 sends a sample. - writer1.send_sample(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW2 sends a sample. - writer2.send_sample(data.front()); - data.pop_front(); - wait_functor(writer2); - - // DW1 sends a sample. - writer1.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW2 sends a sample. - writer2.send_sample(data.front()); - data.pop_front(); - wait_functor(writer2); - - // DW3 sends a sample. - writer3.send_sample(data.front()); - data.pop_front(); - wait_functor(writer3); - - // DW1 sends a sample. - writer1.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW2 sends a sample. - writer2.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer2); - - // DW3 sends a sample. - writer3.send_sample(data.front()); - data.pop_front(); - wait_functor(writer3); - - // DW3 liveliness lost. - drop_messages3 = true; - reader.wait_writer_undiscovery(2); - - // DW1 sends a sample. - writer1.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW2 sends a sample. - writer2.send_sample(data.front()); - data.pop_front(); - wait_functor(writer2); - - // DW1 liveliness lost. - drop_messages1 = true; - reader.wait_writer_undiscovery(1); - - // DW2 sends a sample. - writer2.send_sample(data.front()); - data.pop_front(); - wait_functor(writer2); - - reader.block_for_at_least(7); - ASSERT_EQ(denied_samples.size(), reader.data_not_received().size()); - ASSERT_EQ(denied_samples, reader.data_not_received()); -} - -/*! - * @test DDS-OWN-LIVE-01 Tests Ownership changes when writer removes himself, in a Reliable communication with - * Non-Keyed types. - */ -TEST_P(OwnershipQos, exclusive_kind_non_keyed_reliable_lost_liveliness) -{ - exclusive_kind_non_keyed_lost_liveliness(true); -} - -void exclusive_kind_keyed_lost_liveliness( - bool reliable) -{ - PubSubReader reader(TEST_TOPIC_NAME); - PubSubWriter writer1(TEST_TOPIC_NAME); - PubSubWriter writer2(TEST_TOPIC_NAME); - PubSubWriter writer3(TEST_TOPIC_NAME); - PubSubWriter writer4(TEST_TOPIC_NAME); - - std::atomic drop_messages2(false); - auto testTransport2 = std::make_shared(); - testTransport2->messages_filter_ = [&drop_messages2](eprosima::fastrtps::rtps::CDRMessage_t&) - { - return drop_messages2.load(); - }; - std::atomic drop_messages3(false); - auto testTransport3 = std::make_shared(); - testTransport3->messages_filter_ = [&drop_messages3](eprosima::fastrtps::rtps::CDRMessage_t&) - { - return drop_messages3.load(); - }; - std::atomic drop_messages4(false); - auto testTransport4 = std::make_shared(); - testTransport4->messages_filter_ = [&drop_messages4](eprosima::fastrtps::rtps::CDRMessage_t&) - { - return drop_messages4.load(); - }; - - reader.ownership_exclusive().reliability( - reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS - ) - .lease_duration({1, 0}, {0, 500000000}) - .init(); - writer1.ownership_strength(1).reliability( - reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS - ) - .lease_duration({1, 0}, {0, 500000000}) - .init(); - writer2.ownership_strength(2).reliability( - reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS - ) - .add_user_transport_to_pparams(testTransport2) - .disable_builtin_transport() - .lease_duration({1, 0}, {0, 500000000}) - .init(); - writer3.ownership_strength(3).reliability( - reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS - ) - .add_user_transport_to_pparams(testTransport3) - .disable_builtin_transport() - .lease_duration({1, 0}, {0, 500000000}) - .init(); - writer4.ownership_strength(4).reliability( - reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS - ) - .add_user_transport_to_pparams(testTransport4) - .disable_builtin_transport() - .lease_duration({1, 0}, {0, 500000000}) - .init(); - - ASSERT_TRUE(reader.isInitialized()); - ASSERT_TRUE(writer1.isInitialized()); - ASSERT_TRUE(writer2.isInitialized()); - ASSERT_TRUE(writer3.isInitialized()); - ASSERT_TRUE(writer4.isInitialized()); - - // Wait for discovery. - writer1.wait_discovery(); - writer2.wait_discovery(); - writer3.wait_discovery(); - writer4.wait_discovery(); - reader.wait_discovery(std::chrono::seconds(1), 4); - - std::function&)> wait_functor = - [](PubSubWriter&) - { - std::this_thread::sleep_for(std::chrono::milliseconds(50)); - }; - - if (reliable) - { - wait_functor = [](PubSubWriter& writer) - { - writer.waitForAllAcked(std::chrono::milliseconds(100)); - }; - } - - auto data = default_keyedhelloworld_data_generator(24); - reader.startReception(data); - - decltype(data) denied_samples; - - // DW1 sends a sample in instance 1. - writer1.send_sample(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW1 sends a sample in instance 2. - writer1.send_sample(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW2 sends a sample in instance 1. - writer2.send_sample(data.front()); - data.pop_front(); - wait_functor(writer2); - - // DW3 sends a sample in instance 2. - writer3.send_sample(data.front()); - data.pop_front(); - wait_functor(writer3); - - // DW1 sends a sample in instance 1. - writer1.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW1 sends a sample in instance 2. - writer1.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW4 sends a sample in instance 1. - writer4.send_sample(data.front()); - data.pop_front(); - wait_functor(writer4); - - // DW3 sends a sample in instance 2. - writer3.send_sample(data.front()); - data.pop_front(); - wait_functor(writer3); - - // DW1 sends a sample in instance 1. - writer1.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW1 sends a sample in instance 2. - writer1.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW2 sends a sample in instance 1. - writer2.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer2); - - // DW3 sends a sample in instance 2. - writer3.send_sample(data.front()); - data.pop_front(); - wait_functor(writer3); - - // DW3 losses liveliness. - drop_messages3 = true; - reader.wait_writer_undiscovery(3); - - // DW1 sends a sample in instance 1. - writer1.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW1 sends a sample in instance 2. - writer1.send_sample(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW2 sends a sample in instance 1. - writer2.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer2); - - // DW1 sends a sample in instance 2. - writer1.send_sample(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW4 sends a sample in instance 1. - writer4.send_sample(data.front()); - data.pop_front(); - wait_functor(writer4); - - // DW1 sends a sample in instance 2. - writer1.send_sample(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW2 losses liveliness. - drop_messages2 = true; - reader.wait_writer_undiscovery(2); - - // DW1 sends a sample in instance 1. - writer1.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW1 sends a sample in instance 2. - writer1.send_sample(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW4 sends a sample in instance 1. - writer4.send_sample(data.front()); - data.pop_front(); - wait_functor(writer4); - - // DW1 sends a sample in instance 2. - writer1.send_sample(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW4 losses liveliness. - drop_messages4 = true; - reader.wait_writer_undiscovery(1); - - // DW1 sends a sample in instance 1. - writer1.send_sample(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW1 sends a sample in instance 2. - writer1.send_sample(data.front()); - data.pop_front(); - wait_functor(writer1); - - reader.block_for_at_least(16); - ASSERT_EQ(denied_samples.size(), reader.data_not_received().size()); - ASSERT_EQ(denied_samples, reader.data_not_received()); -} - -/*! - * @test DDS-OWN-LIVE-02 Tests Ownership changes when writer removes himself, in a Reliable communication with - * Keyed types. - */ -TEST_P(OwnershipQos, exclusive_kind_keyed_reliable_lost_liveliness) -{ - exclusive_kind_keyed_lost_liveliness(true); -} - -/*! - * @test DDS-OWN-LIVE-03 Tests Ownership changes when writer removes himself, in a BestEffort communication with - * Non-Keyed types. - */ -TEST_P(OwnershipQos, exclusive_kind_non_keyed_besteffort_lost_liveliness) -{ - exclusive_kind_non_keyed_lost_liveliness(false); -} - -/*! - * @test DDS-OWN-LIVE-04 Tests Ownership changes when writer removes himself, in a BestEffort communication with - * Keyed types. - */ -TEST_P(OwnershipQos, exclusive_kind_keyed_besteffort_lost_liveliness) -{ - exclusive_kind_keyed_lost_liveliness(false); -} - -void exclusive_kind_keyed_unregistering_instance( - bool reliable) -{ - PubSubReader reader(TEST_TOPIC_NAME); - PubSubWriter writer1(TEST_TOPIC_NAME); - PubSubWriter writer2(TEST_TOPIC_NAME); - PubSubWriter writer3(TEST_TOPIC_NAME); - PubSubWriter writer4(TEST_TOPIC_NAME); - - reader.ownership_exclusive().reliability( - reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS - ).init(); - writer1.ownership_strength(1).reliability( - reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS - ).init(); - writer2.ownership_strength(2).reliability( - reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS - ).init(); - writer3.ownership_strength(3).reliability( - reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS - ).init(); - writer4.ownership_strength(4).reliability( - reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS - ).init(); - - ASSERT_TRUE(reader.isInitialized()); - ASSERT_TRUE(writer1.isInitialized()); - ASSERT_TRUE(writer2.isInitialized()); - ASSERT_TRUE(writer3.isInitialized()); - ASSERT_TRUE(writer4.isInitialized()); - - // Wait for discovery. - writer1.wait_discovery(); - writer2.wait_discovery(); - writer3.wait_discovery(); - writer4.wait_discovery(); - reader.wait_discovery(std::chrono::seconds(1), 4); - - std::function&)> wait_functor = - [](PubSubWriter&) - { - std::this_thread::sleep_for(std::chrono::milliseconds(50)); - }; - - if (reliable) - { - wait_functor = [](PubSubWriter& writer) - { - writer.waitForAllAcked(std::chrono::milliseconds(100)); - }; - } - - auto data = default_keyedhelloworld_data_generator(24); - reader.startReception(data); - - decltype(data) denied_samples; - - // DW1 sends a sample in instance 1. - InstanceHandle_t instance_1 = writer1.register_instance(data.front()); - writer1.send_sample(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW1 sends a sample in instance 2. - InstanceHandle_t instance_2 = writer1.register_instance(data.front()); - writer1.send_sample(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW2 sends a sample in instance 1. - writer2.send_sample(data.front()); - data.pop_front(); - wait_functor(writer2); - - // DW3 sends a sample in instance 2. - writer3.send_sample(data.front()); - data.pop_front(); - wait_functor(writer3); - - // DW1 sends a sample in instance 1. - writer1.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW1 sends a sample in instance 2. - writer1.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW4 sends a sample in instance 1. - writer4.send_sample(data.front()); - data.pop_front(); - wait_functor(writer4); - - // DW3 sends a sample in instance 2. - writer3.send_sample(data.front()); - data.pop_front(); - wait_functor(writer3); - - // DW1 sends a sample in instance 1. - writer1.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW1 sends a sample in instance 2. - writer1.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW2 sends a sample in instance 1. - writer2.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer2); - - // DW3 sends a sample in instance 2. - writer3.send_sample(data.front()); - wait_functor(writer3); - - // DW3 unregisters instance 2. - writer3.unregister_instance(data.front(), instance_2); - data.pop_front(); - - // DW1 sends a sample in instance 1. - writer1.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW1 sends a sample in instance 2. - writer1.send_sample(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW2 sends a sample in instance 1. - writer2.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer2); - - // DW1 sends a sample in instance 2. - writer1.send_sample(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW4 sends a sample in instance 1. - writer4.send_sample(data.front()); - data.pop_front(); - wait_functor(writer4); - - // DW1 sends a sample in instance 2. - writer1.send_sample(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW2 unregisters instance 1. - writer2.unregister_instance(data.front(), instance_1); - wait_functor(writer2); - - // DW1 sends a sample in instance 1. - writer1.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW1 sends a sample in instance 2. - writer1.send_sample(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW4 sends a sample in instance 1. - writer4.send_sample(data.front()); - data.pop_front(); - wait_functor(writer4); - - // DW1 sends a sample in instance 2. - writer1.send_sample(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW4 is destroyed. - writer4.unregister_instance(data.front(), instance_1); - wait_functor(writer4); - - // DW1 sends a sample in instance 1. - writer1.send_sample(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW1 sends a sample in instance 2. - writer1.send_sample(data.front()); - data.pop_front(); - wait_functor(writer1); - - reader.block_for_at_least(16); - ASSERT_EQ(denied_samples.size(), reader.data_not_received().size()); - ASSERT_EQ(denied_samples, reader.data_not_received()); -} - -/*! - * @test DDS-OWN-UNREG-01 Tests Ownership changes when writer unregisters an instance, in a Reliable communication with - * Keyed types. - */ -TEST_P(OwnershipQos, exclusive_kind_keyed_reliable_unregistering_instance) -{ - exclusive_kind_keyed_unregistering_instance(true); -} - -/*! - * @test DDS-OWN-UNREG-02 Tests Ownership changes when writer unregisters an instance, in a BestEffort communication with - * Keyed types. - */ -TEST_P(OwnershipQos, exclusive_kind_keyed_besteffort_unregistering_instance) -{ - exclusive_kind_keyed_unregistering_instance(false); -} - -void exclusive_kind_keyed_disposing_instance( - bool reliable) -{ - PubSubReader reader(TEST_TOPIC_NAME); - PubSubWriter writer1(TEST_TOPIC_NAME); - PubSubWriter writer2(TEST_TOPIC_NAME); - PubSubWriter writer3(TEST_TOPIC_NAME); - PubSubWriter writer4(TEST_TOPIC_NAME); - - reader.ownership_exclusive().reliability( - reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS - ).init(); - writer1.ownership_strength(1).reliability( - reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS - ).init(); - writer2.ownership_strength(2).reliability( - reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS - ).init(); - writer3.ownership_strength(3).reliability( - reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS - ).init(); - writer4.ownership_strength(4).reliability( - reliable ? RELIABLE_RELIABILITY_QOS : BEST_EFFORT_RELIABILITY_QOS - ).init(); - - ASSERT_TRUE(reader.isInitialized()); - ASSERT_TRUE(writer1.isInitialized()); - ASSERT_TRUE(writer2.isInitialized()); - ASSERT_TRUE(writer3.isInitialized()); - ASSERT_TRUE(writer4.isInitialized()); - - // Wait for discovery. - writer1.wait_discovery(); - writer2.wait_discovery(); - writer3.wait_discovery(); - writer4.wait_discovery(); - reader.wait_discovery(std::chrono::seconds(1), 4); - - std::function&)> wait_functor = - [](PubSubWriter&) - { - std::this_thread::sleep_for(std::chrono::milliseconds(50)); - }; - - if (reliable) - { - wait_functor = [](PubSubWriter& writer) - { - writer.waitForAllAcked(std::chrono::milliseconds(100)); - }; - } - - auto data = default_keyedhelloworld_data_generator(30); - reader.startReception(data); - - decltype(data) denied_samples; - - // DW1 sends a sample in instance 1. - InstanceHandle_t instance_1 = writer1.register_instance(data.front()); - writer1.send_sample(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW1 sends a sample in instance 2. - InstanceHandle_t instance_2 = writer1.register_instance(data.front()); - writer1.send_sample(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW2 sends a sample in instance 1. - writer2.send_sample(data.front()); - data.pop_front(); - wait_functor(writer2); - - // DW3 sends a sample in instance 2. - writer3.send_sample(data.front()); - data.pop_front(); - wait_functor(writer3); - - // DW1 sends a sample in instance 1. - writer1.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW1 sends a sample in instance 2. - writer1.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW4 sends a sample in instance 1. - writer4.send_sample(data.front()); - data.pop_front(); - wait_functor(writer4); - - // DW3 sends a sample in instance 2. - writer3.send_sample(data.front()); - data.pop_front(); - wait_functor(writer3); - - // DW1 sends a sample in instance 1. - writer1.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW1 sends a sample in instance 2. - writer1.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW2 sends a sample in instance 1. - writer2.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer2); - - // DW3 sends a sample in instance 2. - writer3.send_sample(data.front()); - wait_functor(writer3); - - // DW3 disposes instance 2. - writer3.dispose(data.front(), instance_2); - data.pop_front(); - wait_functor(writer3); - - // DW1 sends a sample in instance 1. - writer1.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW1 sends a sample in instance 2. - writer1.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW2 sends a sample in instance 1. - writer2.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer2); - - // DW1 sends a sample in instance 2. - writer1.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW4 sends a sample in instance 1. - writer4.send_sample(data.front()); - data.pop_front(); - wait_functor(writer4); - - // DW1 sends a sample in instance 2. - writer1.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW2 disposes instance 1. - writer2.dispose(data.front(), instance_1); - - // DW1 sends a sample in instance 1. - writer1.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW1 sends a sample in instance 2. - writer1.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW4 sends a sample in instance 1. - writer4.send_sample(data.front()); - data.pop_front(); - wait_functor(writer4); - - // DW1 sends a sample in instance 2. - writer1.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW4 is destroyed. - writer4.dispose(data.front(), instance_1); - wait_functor(writer4); - - // DW1 sends a sample in instance 1. - writer1.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW1 sends a sample in instance 2. - writer1.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW2 changes its strength to 5. - ASSERT_TRUE(writer2.ownership_strength(5).set_qos()); - std::this_thread::sleep_for(std::chrono::milliseconds(100)); // Wait the reader receives the update - // - // DW2 sends a sample in instance 1. - writer2.send_sample(data.front()); - data.pop_front(); - wait_functor(writer2); - - // DW3 sends a sample in instance 2. - writer3.send_sample(data.front()); - data.pop_front(); - wait_functor(writer3); - - // DW1 sends a sample in instance 1. - writer1.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW1 sends a sample in instance 2. - writer1.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer1); - - // DW4 sends a sample in instance 1. - writer4.send_sample(data.front()); - denied_samples.push_back(data.front()); - data.pop_front(); - wait_functor(writer4); - - // DW3 disposes instance 2. - writer3.dispose(data.front(), instance_2); - wait_functor(writer3); - - // DW3 is detroyed - writer3.destroy(); - reader.wait_writer_undiscovery(3); - - // DW1 sends a sample in instance 2. - writer1.send_sample(data.front()); - data.pop_front(); - wait_functor(writer1); - - reader.block_for_at_least(12); - ASSERT_EQ(denied_samples.size(), reader.data_not_received().size()); - ASSERT_EQ(denied_samples, reader.data_not_received()); -} - -/*! - * @test DDS-OWN-DISP-01 Tests Ownership changes when writer disposes an instance, in a Reliable communication with - * Keyed types. - */ -TEST_P(OwnershipQos, exclusive_kind_keyed_reliable_disposing_instance) -{ - exclusive_kind_keyed_disposing_instance(true); -} - -/*! - * @test DDS-OWN-DISP-02 Tests Ownership changes when writer disposes an instance, in a BestEffort communication with - * Keyed types. - */ -TEST_P(OwnershipQos, exclusive_kind_keyed_besteffort_disposing_instance) -{ - exclusive_kind_keyed_disposing_instance(false); -} - -#ifdef INSTANTIATE_TEST_SUITE_P -#define GTEST_INSTANTIATE_TEST_MACRO(x, y, z, w) INSTANTIATE_TEST_SUITE_P(x, y, z, w) -#else -#define GTEST_INSTANTIATE_TEST_MACRO(x, y, z, w) INSTANTIATE_TEST_CASE_P(x, y, z, w) -#endif // ifdef INSTANTIATE_TEST_SUITE_P - -GTEST_INSTANTIATE_TEST_MACRO(OwnershipQos, - OwnershipQos, - testing::Values(TRANSPORT, INTRAPROCESS, DATASHARING), - [](const testing::TestParamInfo& info) - { - switch (info.param) - { - case INTRAPROCESS: - return "Intraprocess"; - break; - case DATASHARING: - return "Datasharing"; - break; - case TRANSPORT: - default: - return "Transport"; - } - }); diff --git a/test/unittest/dds/publisher/DataWriterTests.cpp b/test/unittest/dds/publisher/DataWriterTests.cpp index aa22006b248..9912b4276c0 100644 --- a/test/unittest/dds/publisher/DataWriterTests.cpp +++ b/test/unittest/dds/publisher/DataWriterTests.cpp @@ -19,10 +19,6 @@ #include #include -#include -#include -#include -#include #include #include #include @@ -32,27 +28,16 @@ #include #include #include -<<<<<<< HEAD -======= #include #include #include #include -#include ->>>>>>> 6390715a1 (Add missing thread include (#4045)) #include #include -#include "../../logging/mock/MockConsumer.h" - -<<<<<<< HEAD #include -#include -#include -======= -#include "../../common/CustomPayloadPool.hpp" ->>>>>>> 6390715a1 (Add missing thread include (#4045)) +#include "../../logging/mock/MockConsumer.h" namespace eprosima { namespace fastdds { diff --git a/test/unittest/rtps/flowcontrol/FlowControllerPublishModesOnAsyncTests.cpp b/test/unittest/rtps/flowcontrol/FlowControllerPublishModesOnAsyncTests.cpp index d9054299e0d..9570b4fa5f8 100644 --- a/test/unittest/rtps/flowcontrol/FlowControllerPublishModesOnAsyncTests.cpp +++ b/test/unittest/rtps/flowcontrol/FlowControllerPublishModesOnAsyncTests.cpp @@ -1,5 +1,3 @@ -<<<<<<< HEAD -======= // Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,13 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. ->>>>>>> 6390715a1 (Add missing thread include (#4045)) #include "FlowControllerPublishModesTests.hpp" #include -#include - using namespace eprosima::fastdds::rtps; using namespace testing; diff --git a/test/unittest/rtps/flowcontrol/FlowControllerPublishModesOnLimitedAsyncTests.cpp b/test/unittest/rtps/flowcontrol/FlowControllerPublishModesOnLimitedAsyncTests.cpp index a4d24789a13..169091d0ae4 100644 --- a/test/unittest/rtps/flowcontrol/FlowControllerPublishModesOnLimitedAsyncTests.cpp +++ b/test/unittest/rtps/flowcontrol/FlowControllerPublishModesOnLimitedAsyncTests.cpp @@ -1,5 +1,3 @@ -<<<<<<< HEAD -======= // Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,13 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. ->>>>>>> 6390715a1 (Add missing thread include (#4045)) #include "FlowControllerPublishModesTests.hpp" #include -#include - using namespace eprosima::fastdds::rtps; using namespace testing; diff --git a/test/unittest/rtps/flowcontrol/FlowControllerPublishModesOnPureSyncTests.cpp b/test/unittest/rtps/flowcontrol/FlowControllerPublishModesOnPureSyncTests.cpp index 60478011899..2b2ea81e964 100644 --- a/test/unittest/rtps/flowcontrol/FlowControllerPublishModesOnPureSyncTests.cpp +++ b/test/unittest/rtps/flowcontrol/FlowControllerPublishModesOnPureSyncTests.cpp @@ -1,5 +1,3 @@ -<<<<<<< HEAD -======= // Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,13 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. ->>>>>>> 6390715a1 (Add missing thread include (#4045)) #include "FlowControllerPublishModesTests.hpp" #include -#include - using namespace eprosima::fastdds::rtps; using namespace testing; diff --git a/test/unittest/rtps/flowcontrol/FlowControllerPublishModesOnSyncTests.cpp b/test/unittest/rtps/flowcontrol/FlowControllerPublishModesOnSyncTests.cpp index c81d993b834..6949a4a8f53 100644 --- a/test/unittest/rtps/flowcontrol/FlowControllerPublishModesOnSyncTests.cpp +++ b/test/unittest/rtps/flowcontrol/FlowControllerPublishModesOnSyncTests.cpp @@ -1,5 +1,3 @@ -<<<<<<< HEAD -======= // Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,13 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. ->>>>>>> 6390715a1 (Add missing thread include (#4045)) #include "FlowControllerPublishModesTests.hpp" #include -#include - using namespace eprosima::fastdds::rtps; using namespace testing; diff --git a/test/unittest/rtps/flowcontrol/FlowControllerSchedulersTests.cpp b/test/unittest/rtps/flowcontrol/FlowControllerSchedulersTests.cpp index add2ccf862e..35348ab637b 100644 --- a/test/unittest/rtps/flowcontrol/FlowControllerSchedulersTests.cpp +++ b/test/unittest/rtps/flowcontrol/FlowControllerSchedulersTests.cpp @@ -1,6 +1,3 @@ -<<<<<<< HEAD -#include -======= // Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -19,11 +16,9 @@ #include -#include ->>>>>>> 6390715a1 (Add missing thread include (#4045)) #include -#include +#include namespace eprosima { namespace fastrtps { diff --git a/test/unittest/statistics/rtps/RTPSStatisticsTests.cpp b/test/unittest/statistics/rtps/RTPSStatisticsTests.cpp index a7b0a2f36c1..b80389ccbb3 100644 --- a/test/unittest/statistics/rtps/RTPSStatisticsTests.cpp +++ b/test/unittest/statistics/rtps/RTPSStatisticsTests.cpp @@ -13,15 +13,7 @@ // limitations under the License. #include -<<<<<<< HEAD -======= #include -#if defined(_WIN32) -#include -#else -#include -#endif // if defined(_WIN32) ->>>>>>> 6390715a1 (Add missing thread include (#4045)) #include #include From 1c5f3468808f060087e46e7b4fc24e8ba277b42b Mon Sep 17 00:00:00 2001 From: EduPonz Date: Fri, 1 Dec 2023 08:34:25 +0100 Subject: [PATCH 3/3] Uncrustify Signed-off-by: EduPonz --- .../performance/video/VideoTestSubscriber.cpp | 143 ++++++++++++------ 1 file changed, 94 insertions(+), 49 deletions(-) diff --git a/test/performance/video/VideoTestSubscriber.cpp b/test/performance/video/VideoTestSubscriber.cpp index 95695a31397..d90c0cca750 100644 --- a/test/performance/video/VideoTestSubscriber.cpp +++ b/test/performance/video/VideoTestSubscriber.cpp @@ -88,10 +88,21 @@ VideoTestSubscriber::~VideoTestSubscriber() thread_.join(); } -bool VideoTestSubscriber::init(int nsam, bool reliable, uint32_t pid, bool hostname, - const PropertyPolicy& part_property_policy, const PropertyPolicy& property_policy, bool large_data, - const std::string& sXMLConfigFile, bool export_csv, const std::string& export_prefix, - int forced_domain, int video_width, int video_height, int frame_rate) +bool VideoTestSubscriber::init( + int nsam, + bool reliable, + uint32_t pid, + bool hostname, + const PropertyPolicy& part_property_policy, + const PropertyPolicy& property_policy, + bool large_data, + const std::string& sXMLConfigFile, + bool export_csv, + const std::string& export_prefix, + int forced_domain, + int video_width, + int video_height, + int frame_rate) { large_data = true; m_sXMLConfigFile = sXMLConfigFile; @@ -127,7 +138,7 @@ bool VideoTestSubscriber::init(int nsam, bool reliable, uint32_t pid, bool hostn { ParticipantAttributes participant_att; if (eprosima::fastrtps::xmlparser::XMLP_ret::XML_OK == - eprosima::fastrtps::xmlparser::XMLProfileManager::fillParticipantAttributes(participant_profile_name, + eprosima::fastrtps::xmlparser::XMLProfileManager::fillParticipantAttributes(participant_profile_name, participant_att)) { participant_att.domainId = m_forcedDomain; @@ -234,12 +245,14 @@ bool VideoTestSubscriber::init(int nsam, bool reliable, uint32_t pid, bool hostn return true; } -void VideoTestSubscriber::DataSubListener::onSubscriptionMatched(Subscriber* /*sub*/,MatchingInfo& info) +void VideoTestSubscriber::DataSubListener::onSubscriptionMatched( + Subscriber* /*sub*/, + MatchingInfo& info) { std::unique_lock lock(mp_up->mutex_); - if(info.status == MATCHED_MATCHING) + if (info.status == MATCHED_MATCHING) { - logInfo(VideoTest,"Data Sub Matched "); + logInfo(VideoTest, "Data Sub Matched "); std::cout << "Data Sub Matched " << std::endl; ++mp_up->disc_count_; } @@ -254,11 +267,13 @@ void VideoTestSubscriber::DataSubListener::onSubscriptionMatched(Subscriber* /*s mp_up->disc_cond_.notify_one(); } -void VideoTestSubscriber::CommandPubListener::onPublicationMatched(Publisher* /*pub*/,MatchingInfo& info) +void VideoTestSubscriber::CommandPubListener::onPublicationMatched( + Publisher* /*pub*/, + MatchingInfo& info) { std::unique_lock lock(mp_up->mutex_); - if(info.status == MATCHED_MATCHING) + if (info.status == MATCHED_MATCHING) { logInfo(VideoTest, "Command Pub Matched "); std::cout << "Command Pub Matched " << std::endl; @@ -275,10 +290,12 @@ void VideoTestSubscriber::CommandPubListener::onPublicationMatched(Publisher* /* mp_up->disc_cond_.notify_one(); } -void VideoTestSubscriber::CommandSubListener::onSubscriptionMatched(Subscriber* /*sub*/,MatchingInfo& info) +void VideoTestSubscriber::CommandSubListener::onSubscriptionMatched( + Subscriber* /*sub*/, + MatchingInfo& info) { std::unique_lock lock(mp_up->mutex_); - if(info.status == MATCHED_MATCHING) + if (info.status == MATCHED_MATCHING) { logInfo(VideoTest, "Command Sub Matched "); std::cout << "Command Sub Matched " << std::endl; @@ -295,21 +312,22 @@ void VideoTestSubscriber::CommandSubListener::onSubscriptionMatched(Subscriber* mp_up->disc_cond_.notify_one(); } -void VideoTestSubscriber::CommandSubListener::onNewDataMessage(Subscriber* subscriber) +void VideoTestSubscriber::CommandSubListener::onNewDataMessage( + Subscriber* subscriber) { TestCommandType command; - if(subscriber->takeNextData(&command,&mp_up->m_sampleinfo)) + if (subscriber->takeNextData(&command, &mp_up->m_sampleinfo)) { //cout << "RCOMMAND: "<< command.m_command << endl; - if(command.m_command == READY) + if (command.m_command == READY) { - cout << "Publisher has new test ready..."<mutex_.lock(); ++mp_up->comm_count_; mp_up->mutex_.unlock(); mp_up->comm_cond_.notify_one(); } - else if(command.m_command == STOP) + else if (command.m_command == STOP) { cout << "Publisher has stopped the test" << endl; mp_up->mutex_.lock(); @@ -318,7 +336,7 @@ void VideoTestSubscriber::CommandSubListener::onNewDataMessage(Subscriber* subsc mp_up->comm_cond_.notify_one(); mp_up->data_cond_.notify_one(); } - else if(command.m_command == STOP_ERROR) + else if (command.m_command == STOP_ERROR) { cout << "Publisher has canceled the test" << endl; mp_up->m_status = -1; @@ -328,14 +346,15 @@ void VideoTestSubscriber::CommandSubListener::onNewDataMessage(Subscriber* subsc mp_up->comm_cond_.notify_one(); mp_up->data_cond_.notify_one(); } - else if(command.m_command == DEFAULT) + else if (command.m_command == DEFAULT) { std::cout << "Something is wrong" << std::endl; } } } -void VideoTestSubscriber::DataSubListener::onNewDataMessage(Subscriber* subscriber) +void VideoTestSubscriber::DataSubListener::onNewDataMessage( + Subscriber* subscriber) { VideoType videoData; eprosima::fastrtps::SampleInfo_t info; @@ -345,21 +364,24 @@ void VideoTestSubscriber::DataSubListener::onNewDataMessage(Subscriber* subscrib } } - void VideoTestSubscriber::run() { //WAIT FOR THE DISCOVERY PROCESS FO FINISH: //EACH SUBSCRIBER NEEDS 4 Matchings (2 publishers and 2 subscribers) std::unique_lock disc_lock(mutex_); - disc_cond_.wait(disc_lock, [&]() { return disc_count_ >= 3; }); + disc_cond_.wait(disc_lock, [&]() + { + return disc_count_ >= 3; + }); disc_lock.unlock(); - cout << C_B_MAGENTA << "DISCOVERY COMPLETE "<test(); } -void VideoTestSubscriber::gst_run(VideoTestSubscriber* sub) +void VideoTestSubscriber::gst_run( + VideoTestSubscriber* sub) { if (!sub) { @@ -397,9 +419,9 @@ bool VideoTestSubscriber::test() lock.lock(); data_cond_.wait(lock, [&]() - { - return data_count_ > 0; - }); + { + return data_count_ > 0; + }); --data_count_; lock.unlock(); @@ -419,8 +441,12 @@ bool VideoTestSubscriber::test() return true; } -void VideoTestSubscriber::fps_stats_cb(GstElement* /*source*/, gdouble /*fps*/, gdouble /*droprate*/, - gdouble avgfps, VideoTestSubscriber* sub) +void VideoTestSubscriber::fps_stats_cb( + GstElement* /*source*/, + gdouble /*fps*/, + gdouble /*droprate*/, + gdouble avgfps, + VideoTestSubscriber* sub) { std::unique_lock lock(sub->stats_mutex_); @@ -456,9 +482,9 @@ void VideoTestSubscriber::InitGStreamer() g_object_set(appsrc, "do-timestamp", TRUE, NULL); g_signal_connect(appsrc, "need-data", G_CALLBACK(start_feed_cb), this); g_signal_connect(appsrc, "enough-data", G_CALLBACK(stop_feed_cb), this); - GstCaps *caps = gst_caps_new_simple("video/x-raw", "format", G_TYPE_STRING, "I420", - "width", G_TYPE_INT, m_videoWidth, "height", G_TYPE_INT, m_videoHeight, - "framerate", GST_TYPE_FRACTION, m_videoFrameRate, 1, NULL); + GstCaps* caps = gst_caps_new_simple("video/x-raw", "format", G_TYPE_STRING, "I420", + "width", G_TYPE_INT, m_videoWidth, "height", G_TYPE_INT, m_videoHeight, + "framerate", GST_TYPE_FRACTION, m_videoFrameRate, 1, NULL); gst_app_src_set_caps(GST_APP_SRC(appsrc), caps); gst_caps_unref(caps); @@ -495,7 +521,10 @@ void VideoTestSubscriber::InitGStreamer() } } -void VideoTestSubscriber::start_feed_cb(GstElement* /*source*/, guint /*size*/, VideoTestSubscriber* sub) +void VideoTestSubscriber::start_feed_cb( + GstElement* /*source*/, + guint /*size*/, + VideoTestSubscriber* sub) { if (sub->source_id_ == 0) { @@ -503,7 +532,9 @@ void VideoTestSubscriber::start_feed_cb(GstElement* /*source*/, guint /*size*/, } } -void VideoTestSubscriber::stop_feed_cb(GstElement* /*source*/, VideoTestSubscriber* sub) +void VideoTestSubscriber::stop_feed_cb( + GstElement* /*source*/, + VideoTestSubscriber* sub) { if (sub->source_id_ != 0) { @@ -513,12 +544,13 @@ void VideoTestSubscriber::stop_feed_cb(GstElement* /*source*/, VideoTestSubscrib } #define WAIT_AFTER_LAST_FEED_MS 2000 -gboolean VideoTestSubscriber::push_data_cb(VideoTestSubscriber* sub) +gboolean VideoTestSubscriber::push_data_cb( + VideoTestSubscriber* sub) { std::unique_lock lock(sub->gst_mutex_); if (sub->m_bRunning) { - GstBuffer *buffer; + GstBuffer* buffer; GstFlowReturn ret; GstMapInfo map; //gint16 *raw; @@ -577,7 +609,10 @@ void VideoTestSubscriber::stop() gst_element_set_state(pipeline, GST_STATE_NULL); } -void VideoTestSubscriber::message_cb(GstBus* /*bus*/, GstMessage* message, gpointer /*user_data*/) +void VideoTestSubscriber::message_cb( + GstBus* /*bus*/, + GstMessage* message, + gpointer /*user_data*/) { GError* err = nullptr; gchar* debug_info = nullptr; @@ -587,7 +622,8 @@ void VideoTestSubscriber::message_cb(GstBus* /*bus*/, GstMessage* message, gpoin { gst_message_parse_error(message, &err, &debug_info); - printf("# GST INTERNAL # Error received from element: %s; message: %s\n", GST_OBJECT_NAME(message->src), err->message); + printf("# GST INTERNAL # Error received from element: %s; message: %s\n", GST_OBJECT_NAME( + message->src), err->message); printf("# GST INTERNAL # Debugging information: %s\n", debug_info ? debug_info : "none"); g_clear_error(&err); @@ -607,7 +643,8 @@ void VideoTestSubscriber::message_cb(GstBus* /*bus*/, GstMessage* message, gpoin { gst_message_parse_warning(message, &err, &debug_info); - printf("# GST INTERNAL # Warning received from element: %s; message: %s\n", GST_OBJECT_NAME(message->src), err->message); + printf("# GST INTERNAL # Warning received from element: %s; message: %s\n", GST_OBJECT_NAME( + message->src), err->message); printf("# GST INTERNAL # Debugging information: %s\n", debug_info ? debug_info : "none"); g_clear_error(&err); @@ -625,7 +662,8 @@ void VideoTestSubscriber::message_cb(GstBus* /*bus*/, GstMessage* message, gpoin { gst_message_parse_info(message, &err, &debug_info); - printf("# GST INTERNAL # Info received from element: %s; message: %s\n", GST_OBJECT_NAME(message->src), err->message); + printf("# GST INTERNAL # Info received from element: %s; message: %s\n", GST_OBJECT_NAME( + message->src), err->message); printf("# GST INTERNAL # Debugging information: %s\n", debug_info ? debug_info : "none"); g_clear_error(&err); @@ -843,8 +881,8 @@ void VideoTestSubscriber::analyzeTimes() } } - -void VideoTestSubscriber::printStat(TimeStats& TS) +void VideoTestSubscriber::printStat( + TimeStats& TS) { std::ofstream outFile; std::ofstream outMeanFile; @@ -856,22 +894,29 @@ void VideoTestSubscriber::printStat(TimeStats& TS) str_reliable = "reliable"; } - output_file_csv << "Samples, Avg stdev, Avg Mean, min Avg, Avg 50 %%, Avg 90 %%, Avg 99 %%, \ + output_file_csv << + "Samples, Avg stdev, Avg Mean, min Avg, Avg 50 %%, Avg 90 %%, Avg 99 %%, \ Avg 99.99%%, Avg max, Drop stdev, Drop Mean, min Drop, Drop 50 %%, Drop 90 %%, Drop 99 %%, \ Drop 99.99%%, Drop max" << std::endl; output_mean_csv << "Avg Mean" << std::endl; printf("Statistics for video test \n"); - printf(" Samples, Avg stdev, Avg Mean, min Avg, Avg 50%%, Avg 90%%, Avg 99%%, Avg 99.99%%, Avg max\n"); - printf("-----------,-----------,-----------,-----------,-----------,-----------,-----------,-------------,-----------\n"); + printf( + " Samples, Avg stdev, Avg Mean, min Avg, Avg 50%%, Avg 90%%, Avg 99%%, Avg 99.99%%, Avg max\n"); + printf( + "-----------,-----------,-----------,-----------,-----------,-----------,-----------,-------------,-----------\n"); printf("%11u,%11.2f,%11.2f,%11.2f,%11.2f,%11.2f,%11.2f,%13.2f,%11.2f \n\n\n", - TS.received, TS.pAvgStdev, TS.pAvgMean, TS.m_minAvg, TS.pAvg50, TS.pAvg90, TS.pAvg99, TS.pAvg9999, TS.m_maxAvg); + TS.received, TS.pAvgStdev, TS.pAvgMean, TS.m_minAvg, TS.pAvg50, TS.pAvg90, TS.pAvg99, TS.pAvg9999, + TS.m_maxAvg); - printf(" Samples, FameDrop stdev, FameDrop Mean, min FameDrop, FameDrop 50%%, FameDrop 90%%, FameDrop 99%%, FameDrop 99.99%%, FameDrop max\n"); - printf("-----------,---------------,--------------,-------------,--------------,--------------,--------------,----------------,--------------\n"); + printf( + " Samples, FameDrop stdev, FameDrop Mean, min FameDrop, FameDrop 50%%, FameDrop 90%%, FameDrop 99%%, FameDrop 99.99%%, FameDrop max\n"); + printf( + "-----------,---------------,--------------,-------------,--------------,--------------,--------------,----------------,--------------\n"); printf("%11u,%15.2f,%14.2f,%13.2f,%14.2f,%14.2f,%14.2f,%16.2f,%14.2f \n", - TS.received, TS.pDropStdev, TS.pDropMean, TS.m_minDrop, TS.pDrop50, TS.pDrop90, TS.pDrop99, TS.pDrop9999, TS.m_maxDrop); + TS.received, TS.pDropStdev, TS.pDropMean, TS.m_minDrop, TS.pDrop50, TS.pDrop90, TS.pDrop99, TS.pDrop9999, + TS.m_maxDrop); output_file_csv << TS.received << "," << TS.pAvgStdev << "," << TS.pAvgMean << "," << TS.m_minAvg << "," << TS.pAvg50 << "," << TS.pAvg90 << "," << TS.pAvg99 << "," << TS.pAvg9999 << "," << TS.m_maxAvg << "," <<