Skip to content

Commit

Permalink
Make messages_sent an object attribute
Browse files Browse the repository at this point in the history
Signed-off-by: Juan López Fernández <[email protected]>
  • Loading branch information
juanlofer-eprosima committed Jul 7, 2023
1 parent dbb0d65 commit 9f47201
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/cpp/rtps/transport/test_UDPv4Transport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<const test_UDPv4TransportDescriptor*, test_UDPv4Transport*> test_UDPv4Transport::created_transports{};
std::vector<std::vector<octet>> test_UDPv4Transport::test_UDPv4Transport_DropLog;
std::atomic<uint32_t> test_UDPv4Transport::test_UDPv4Transport_DropLogLength(0);
std::atomic<bool> test_UDPv4Transport::test_UDPv4Transport_ShutdownAllNetwork(false);
Expand All @@ -41,7 +42,6 @@ test_UDPv4TransportDescriptor::DestinationLocatorFilter test_UDPv4Transport::loc
{
return false;
});
std::map<uint32_t, uint32_t> test_UDPv4Transport::messages_sent{};

test_UDPv4Transport::test_UDPv4Transport(
const test_UDPv4TransportDescriptor& descriptor)
Expand Down Expand Up @@ -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 ==(
Expand Down
3 changes: 2 additions & 1 deletion src/cpp/rtps/transport/test_UDPv4Transport.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class test_UDPv4Transport : public UDPv4Transport
virtual LocatorList NormalizeLocator(
const Locator& locator) override;

RTPS_DllAPI static std::map<const test_UDPv4TransportDescriptor*, test_UDPv4Transport*> created_transports;
RTPS_DllAPI static std::atomic<bool> 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<std::vector<fastrtps::rtps::octet>> test_UDPv4Transport_DropLog;
Expand All @@ -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<uint32_t, uint32_t> messages_sent;
RTPS_DllAPI std::map<uint32_t, uint32_t> messages_sent;

protected:

Expand Down
2 changes: 1 addition & 1 deletion test/blackbox/common/DDSBlackboxTestsTransportSHMUDP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit 9f47201

Please sign in to comment.