From 9f47201864da9ea7a6f585f34df98e72ab62a54b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20L=C3=B3pez=20Fern=C3=A1ndez?= Date: Fri, 7 Jul 2023 12:31:46 +0200 Subject: [PATCH] Make messages_sent an object attribute MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Juan López Fernández --- src/cpp/rtps/transport/test_UDPv4Transport.cpp | 6 ++++-- src/cpp/rtps/transport/test_UDPv4Transport.h | 3 ++- test/blackbox/common/DDSBlackboxTestsTransportSHMUDP.cpp | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/cpp/rtps/transport/test_UDPv4Transport.cpp b/src/cpp/rtps/transport/test_UDPv4Transport.cpp index 122f2c04452..6c89b1e5b38 100644 --- a/src/cpp/rtps/transport/test_UDPv4Transport.cpp +++ b/src/cpp/rtps/transport/test_UDPv4Transport.cpp @@ -32,6 +32,7 @@ using SubmessageHeader_t = fastrtps::rtps::SubmessageHeader_t; using SequenceNumber_t = fastrtps::rtps::SequenceNumber_t; using EntityId_t = fastrtps::rtps::EntityId_t; +std::map test_UDPv4Transport::created_transports{}; std::vector> test_UDPv4Transport::test_UDPv4Transport_DropLog; std::atomic test_UDPv4Transport::test_UDPv4Transport_DropLogLength(0); std::atomic test_UDPv4Transport::test_UDPv4Transport_ShutdownAllNetwork(false); @@ -41,7 +42,6 @@ test_UDPv4TransportDescriptor::DestinationLocatorFilter test_UDPv4Transport::loc { return false; }); -std::map test_UDPv4Transport::messages_sent{}; test_UDPv4Transport::test_UDPv4Transport( const test_UDPv4TransportDescriptor& descriptor) @@ -122,7 +122,9 @@ test_UDPv4TransportDescriptor::test_UDPv4TransportDescriptor() TransportInterface* test_UDPv4TransportDescriptor::create_transport() const { - return new test_UDPv4Transport(*this); + test_UDPv4Transport* transport = new test_UDPv4Transport(*this); + test_UDPv4Transport::created_transports[this] = transport; + return transport; } bool test_UDPv4TransportDescriptor::operator ==( diff --git a/src/cpp/rtps/transport/test_UDPv4Transport.h b/src/cpp/rtps/transport/test_UDPv4Transport.h index c9145ddbe86..c2deaccd5b8 100644 --- a/src/cpp/rtps/transport/test_UDPv4Transport.h +++ b/src/cpp/rtps/transport/test_UDPv4Transport.h @@ -53,6 +53,7 @@ class test_UDPv4Transport : public UDPv4Transport virtual LocatorList NormalizeLocator( const Locator& locator) override; + RTPS_DllAPI static std::map created_transports; RTPS_DllAPI static std::atomic test_UDPv4Transport_ShutdownAllNetwork; // Handle to a persistent log of dropped packets. Defaults to length 0 (no logging) to prevent wasted resources. RTPS_DllAPI static std::vector> test_UDPv4Transport_DropLog; @@ -63,7 +64,7 @@ class test_UDPv4Transport : public UDPv4Transport RTPS_DllAPI static test_UDPv4TransportDescriptor::DestinationLocatorFilter locator_filter; // Record the number of packages sent to the different ports (key) - RTPS_DllAPI static std::map messages_sent; + RTPS_DllAPI std::map messages_sent; protected: diff --git a/test/blackbox/common/DDSBlackboxTestsTransportSHMUDP.cpp b/test/blackbox/common/DDSBlackboxTestsTransportSHMUDP.cpp index 4c1348e7ba6..54f8052afd1 100644 --- a/test/blackbox/common/DDSBlackboxTestsTransportSHMUDP.cpp +++ b/test/blackbox/common/DDSBlackboxTestsTransportSHMUDP.cpp @@ -148,7 +148,7 @@ void run_parametrized_test( // even and user ones odd. // uint32_t n_packages_sent = test_UDPv4Transport::messages_sent[conditions.sub_unicast_port]; uint32_t n_packages_sent = 0; - for (const auto& item : test_UDPv4Transport::messages_sent) + for (const auto& item : test_UDPv4Transport::created_transports[pub_udp_descriptor.get()]->messages_sent) { if (item.first % 2) {