From 2b545fc75cb8beb6d49c26509fd07acc6a746545 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Gonz=C3=A1lez=20Moreno?= Date: Tue, 28 Mar 2017 09:32:31 +0200 Subject: [PATCH] Refs #1977. Fixing warnings. --- cmake/dev/compile_example.cmake | 6 ++- .../SecureHelloWorldExample/CMakeLists.txt | 6 +-- .../HelloWorldPublisher.cpp | 6 +-- .../HelloWorldSubscriber.cpp | 6 +-- src/cpp/rtps/messages/RTPSMessageGroup.cpp | 2 + .../rtps/participant/RTPSParticipantImpl.cpp | 4 ++ test/unittest/transport/CMakeLists.txt | 48 ++++++++++++------- test/unittest/transport/UDPv4Tests.cpp | 32 ++++++++----- test/unittest/transport/UDPv6Tests.cpp | 21 ++++---- test/unittest/transport/test_UDPv4Tests.cpp | 19 +++++--- 10 files changed, 94 insertions(+), 56 deletions(-) diff --git a/cmake/dev/compile_example.cmake b/cmake/dev/compile_example.cmake index 66051e26b39..fa9edb08df8 100644 --- a/cmake/dev/compile_example.cmake +++ b/cmake/dev/compile_example.cmake @@ -22,10 +22,14 @@ macro(compile_example example example_directory) # Separate CMAKE_PREFIX_PATH string(REPLACE ";" "|" CMAKE_PREFIX_PATH_ "${CMAKE_PREFIX_PATH}") set(${example}_CMAKE_ARGS - "-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}" "-DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX}" "-DCMAKE_PREFIX_PATH:PATH=${CMAKE_CURRENT_BINARY_DIR}/config|${CMAKE_PREFIX_PATH_}" "-DBIN_INSTALL_DIR:PATH=${BIN_INSTALL_DIR}") + if(UNIX) + list(APPEND ${example}_CMAKE_ARGS + "-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}" + ) + endif() list(APPEND ${example}_CMAKE_ARGS LIST_SEPARATOR "|") include(ExternalProject) diff --git a/examples/C++/SecureHelloWorldExample/CMakeLists.txt b/examples/C++/SecureHelloWorldExample/CMakeLists.txt index bbe739541a8..62ec501513b 100644 --- a/examples/C++/SecureHelloWorldExample/CMakeLists.txt +++ b/examples/C++/SecureHelloWorldExample/CMakeLists.txt @@ -42,6 +42,6 @@ install(TARGETS SecureHelloWorldExample RUNTIME DESTINATION examples/C++/SecureHelloWorldExample/${BIN_INSTALL_DIR}) add_custom_command(TARGET SecureHelloWorldExample POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy - ${PROJECT_SOURCE_DIR}/certs/*.pem - ${PROJECT_BINARY_DIR}) + COMMAND ${CMAKE_COMMAND} -E copy_directory + ${PROJECT_SOURCE_DIR}/certs + ${PROJECT_BINARY_DIR}/certs) diff --git a/examples/C++/SecureHelloWorldExample/HelloWorldPublisher.cpp b/examples/C++/SecureHelloWorldExample/HelloWorldPublisher.cpp index d0eaaedc281..e626c8a1e37 100644 --- a/examples/C++/SecureHelloWorldExample/HelloWorldPublisher.cpp +++ b/examples/C++/SecureHelloWorldExample/HelloWorldPublisher.cpp @@ -43,11 +43,11 @@ bool HelloWorldPublisher::init() participant_property_policy.properties().emplace_back("dds.sec.auth.plugin", "builtin.PKI-DH"); participant_property_policy.properties().emplace_back("dds.sec.auth.builtin.PKI-DH.identity_ca", - "file://maincacert.pem"); + "file://certs/maincacert.pem"); participant_property_policy.properties().emplace_back("dds.sec.auth.builtin.PKI-DH.identity_certificate", - "file://mainpubcert.pem"); + "file://certs/mainpubcert.pem"); participant_property_policy.properties().emplace_back("dds.sec.auth.builtin.PKI-DH.private_key", - "file://mainpubkey.pem"); + "file://certs/mainpubkey.pem"); participant_property_policy.properties().emplace_back("dds.sec.crypto.plugin", "builtin.AES-GCM-GMAC"); participant_property_policy.properties().emplace_back("rtps.participant.rtps_protection_kind", "ENCRYPT"); diff --git a/examples/C++/SecureHelloWorldExample/HelloWorldSubscriber.cpp b/examples/C++/SecureHelloWorldExample/HelloWorldSubscriber.cpp index d3673f268c8..2572fddc405 100644 --- a/examples/C++/SecureHelloWorldExample/HelloWorldSubscriber.cpp +++ b/examples/C++/SecureHelloWorldExample/HelloWorldSubscriber.cpp @@ -39,11 +39,11 @@ bool HelloWorldSubscriber::init() participant_property_policy.properties().emplace_back("dds.sec.auth.plugin", "builtin.PKI-DH"); participant_property_policy.properties().emplace_back("dds.sec.auth.builtin.PKI-DH.identity_ca", - "file://maincacert.pem"); + "file://certs/maincacert.pem"); participant_property_policy.properties().emplace_back("dds.sec.auth.builtin.PKI-DH.identity_certificate", - "file://mainsubcert.pem"); + "file://certs/mainsubcert.pem"); participant_property_policy.properties().emplace_back("dds.sec.auth.builtin.PKI-DH.private_key", - "file://mainsubkey.pem"); + "file://certs/mainsubkey.pem"); participant_property_policy.properties().emplace_back("dds.sec.crypto.plugin", "builtin.AES-GCM-GMAC"); participant_property_policy.properties().emplace_back("rtps.participant.rtps_protection_kind", "ENCRYPT"); diff --git a/src/cpp/rtps/messages/RTPSMessageGroup.cpp b/src/cpp/rtps/messages/RTPSMessageGroup.cpp index 056d26abbfb..37214b12ad5 100644 --- a/src/cpp/rtps/messages/RTPSMessageGroup.cpp +++ b/src/cpp/rtps/messages/RTPSMessageGroup.cpp @@ -258,6 +258,7 @@ bool RTPSMessageGroup::insert_submessage(const std::vector& remote_endpo bool RTPSMessageGroup::add_info_dst_in_buffer(CDRMessage_t* buffer, const std::vector& remote_endpoints) { + (void)remote_endpoints; bool added = false; #if HAVE_SECURITY @@ -310,6 +311,7 @@ bool RTPSMessageGroup::add_info_dst_in_buffer(CDRMessage_t* buffer, const std::v bool RTPSMessageGroup::add_info_ts_in_buffer(const std::vector& remote_readers) { + (void)remote_readers; logInfo(RTPS_WRITER, "Sending INFO_TS message"); #if HAVE_SECURITY diff --git a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp index 2c1846a8718..4340bcb93ef 100644 --- a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp +++ b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp @@ -450,6 +450,7 @@ bool RTPSParticipantImpl::createWriter(RTPSWriter** WriterOut, } // Get properties. +#if HAVE_SECURITY bool submessage_protection = false; const std::string* property_value = PropertyPolicyHelper::find_property(param.endpoint.properties, "rtps.endpoint.submessage_protection_kind"); @@ -461,6 +462,7 @@ bool RTPSParticipantImpl::createWriter(RTPSWriter** WriterOut, if(property_value != nullptr && property_value->compare("ENCRYPT") == 0) payload_protection = true; +#endif // Normalize unicast locators if (!param.endpoint.unicastLocatorList.empty()) @@ -575,6 +577,7 @@ bool RTPSParticipantImpl::createReader(RTPSReader** ReaderOut, } // Get properties. +#if HAVE_SECURITY bool submessage_protection = false; const std::string* property_value = PropertyPolicyHelper::find_property(param.endpoint.properties, "rtps.endpoint.submessage_protection_kind"); @@ -586,6 +589,7 @@ bool RTPSParticipantImpl::createReader(RTPSReader** ReaderOut, if(property_value != nullptr && property_value->compare("ENCRYPT") == 0) payload_protection = true; +#endif // Normalize unicast locators if (!param.endpoint.unicastLocatorList.empty()) diff --git a/test/unittest/transport/CMakeLists.txt b/test/unittest/transport/CMakeLists.txt index 8d77ab9fbea..e6f95b932a4 100644 --- a/test/unittest/transport/CMakeLists.txt +++ b/test/unittest/transport/CMakeLists.txt @@ -53,40 +53,52 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER)) include_directories(mock/) + string(RANDOM LENGTH 4 ALPHABET 0123456789 PORT_RANDOM_NUMBER) + math(EXPR PORT_RANDOM_NUMBER "${PORT_RANDOM_NUMBER} + 0") # Remove extra leading 0s. + if(PORT_RANDOM_NUMBER LESS 1025) + math(EXPR PORT_RANDOM_NUMBER "${PORT_RANDOM_NUMBER} + 1024") # Remove extra leading 0s. + endif() + add_executable(UDPv4Tests ${UDPV4TESTS_SOURCE}) - add_gtest(UDPv4Tests ${UDPV4TESTS_SOURCE}) + add_gtest(UDPv4Tests ${UDPV4TESTS_SOURCE} + ENVIRONMENT "PORT_RANDOM_NUMBER=${PORT_RANDOM_NUMBER}" + ) target_compile_definitions(UDPv4Tests PRIVATE FASTRTPS_NO_LIB) target_include_directories(UDPv4Tests PRIVATE ${GTEST_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include/${PROJECT_NAME}) target_link_libraries(UDPv4Tests ${GTEST_LIBRARIES} ${MOCKS} ) - if(MSVC OR MSVC_IDE) - target_link_libraries(UDPv4Tests ${PRIVACY} - iphlpapi Shlwapi - ) - endif() + if(MSVC OR MSVC_IDE) + target_link_libraries(UDPv4Tests ${PRIVACY} + iphlpapi Shlwapi + ) + endif() add_executable(UDPv6Tests ${UDPV6TESTS_SOURCE}) - add_gtest(UDPv6Tests ${UDPV6TESTS_SOURCE}) + add_gtest(UDPv6Tests ${UDPV6TESTS_SOURCE} + ENVIRONMENT "PORT_RANDOM_NUMBER=${PORT_RANDOM_NUMBER}" + ) target_compile_definitions(UDPv6Tests PRIVATE FASTRTPS_NO_LIB) target_include_directories(UDPv6Tests PRIVATE ${GTEST_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include/${PROJECT_NAME}) target_link_libraries(UDPv6Tests ${GTEST_LIBRARIES} ${MOCKS} ) - if(MSVC OR MSVC_IDE) - target_link_libraries(UDPv6Tests ${PRIVACY} - iphlpapi Shlwapi - ) - endif() + if(MSVC OR MSVC_IDE) + target_link_libraries(UDPv6Tests ${PRIVACY} + iphlpapi Shlwapi + ) + endif() add_executable(test_UDPv4Tests ${TEST_UDPV4TESTS_SOURCE}) - add_gtest(test_UDPv4Tests ${TEST_UDPV4TESTS_SOURCE}) + add_gtest(test_UDPv4Tests ${TEST_UDPV4TESTS_SOURCE} + ENVIRONMENT "PORT_RANDOM_NUMBER=${PORT_RANDOM_NUMBER}" + ) target_compile_definitions(test_UDPv4Tests PRIVATE FASTRTPS_NO_LIB) target_include_directories(test_UDPv4Tests PRIVATE ${GTEST_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include/${PROJECT_NAME}) target_link_libraries(test_UDPv4Tests ${GTEST_LIBRARIES} ${MOCKS} ) - if(MSVC OR MSVC_IDE) - target_link_libraries(test_UDPv4Tests ${PRIVACY} - iphlpapi Shlwapi - ) - endif() + if(MSVC OR MSVC_IDE) + target_link_libraries(test_UDPv4Tests ${PRIVACY} + iphlpapi Shlwapi + ) + endif() endif() endif() diff --git a/test/unittest/transport/UDPv4Tests.cpp b/test/unittest/transport/UDPv4Tests.cpp index 1bb09f9d6ab..b438d96cce2 100644 --- a/test/unittest/transport/UDPv4Tests.cpp +++ b/test/unittest/transport/UDPv4Tests.cpp @@ -28,6 +28,8 @@ using namespace eprosima::fastrtps::rtps; const uint32_t ReceiveBufferCapacity = 65536; #endif +static uint32_t g_default_port = 7400; + class UDPv4Tests: public ::testing::Test { public: @@ -72,7 +74,7 @@ TEST_F(UDPv4Tests, opening_and_closing_output_channel) Locator_t genericOutputChannelLocator; genericOutputChannelLocator.kind = LOCATOR_KIND_UDPv4; - genericOutputChannelLocator.port = 7400; // arbitrary + genericOutputChannelLocator.port = g_default_port; // arbitrary // Then ASSERT_FALSE (transportUnderTest.IsOutputChannelOpen(genericOutputChannelLocator)); @@ -91,7 +93,7 @@ TEST_F(UDPv4Tests, opening_and_closing_input_channel) Locator_t multicastFilterLocator; multicastFilterLocator.kind = LOCATOR_KIND_UDPv4; - multicastFilterLocator.port = 7410; // arbitrary + multicastFilterLocator.port = g_default_port; // arbitrary multicastFilterLocator.set_IP4_address(239, 255, 0, 1); // Then @@ -110,12 +112,12 @@ TEST_F(UDPv4Tests, send_and_receive_between_ports) transportUnderTest.init(); Locator_t multicastLocator; - multicastLocator.port = 7410; + multicastLocator.port = g_default_port; multicastLocator.kind = LOCATOR_KIND_UDPv4; multicastLocator.set_IP4_address(239, 255, 0, 1); Locator_t outputChannelLocator; - outputChannelLocator.port = 7400; + outputChannelLocator.port = g_default_port + 1; outputChannelLocator.kind = LOCATOR_KIND_UDPv4; ASSERT_TRUE(transportUnderTest.OpenOutputChannel(outputChannelLocator)); // Includes loopback ASSERT_TRUE(transportUnderTest.OpenInputChannel(multicastLocator)); @@ -148,12 +150,12 @@ TEST_F(UDPv4Tests, send_to_loopback) transportUnderTest.init(); Locator_t multicastLocator; - multicastLocator.port = 7410; + multicastLocator.port = g_default_port; multicastLocator.kind = LOCATOR_KIND_UDPv4; multicastLocator.set_IP4_address(239, 255, 0, 1); Locator_t outputChannelLocator; - outputChannelLocator.port = 7400; + outputChannelLocator.port = g_default_port + 1; outputChannelLocator.kind = LOCATOR_KIND_UDPv4; outputChannelLocator.set_IP4_address(127,0,0,1); // Loopback ASSERT_TRUE(transportUnderTest.OpenOutputChannel(outputChannelLocator)); @@ -163,7 +165,7 @@ TEST_F(UDPv4Tests, send_to_loopback) auto sendThreadFunction = [&]() { Locator_t destinationLocator; - destinationLocator.port = 7410; + destinationLocator.port = g_default_port; destinationLocator.kind = LOCATOR_KIND_UDPv4; EXPECT_TRUE(transportUnderTest.Send(message, 5, outputChannelLocator, multicastLocator)); }; @@ -193,12 +195,12 @@ TEST_F(UDPv4Tests, send_is_rejected_if_buffer_size_is_bigger_to_size_specified_i Locator_t genericOutputChannelLocator; genericOutputChannelLocator.kind = LOCATOR_KIND_UDPv4; - genericOutputChannelLocator.port = 7400; + genericOutputChannelLocator.port = g_default_port; transportUnderTest.OpenOutputChannel(genericOutputChannelLocator); Locator_t destinationLocator; destinationLocator.kind = LOCATOR_KIND_UDPv4; - destinationLocator.port = 7410; + destinationLocator.port = g_default_port + 1; // Then std::vector receiveBufferWrongSize(descriptor.sendBufferSize + 1); @@ -213,7 +215,7 @@ TEST_F(UDPv4Tests, Receive_is_rejected_if_buffer_size_is_smaller_than_size_speci Locator_t genericInputChannelLocator; genericInputChannelLocator.kind = LOCATOR_KIND_UDPv4; - genericInputChannelLocator.port = 7410; + genericInputChannelLocator.port = g_default_port; transportUnderTest.OpenInputChannel(genericInputChannelLocator); Locator_t originLocator; @@ -231,7 +233,7 @@ TEST_F(UDPv4Tests, RemoteToMainLocal_simply_strips_out_address_leaving_IP_ANY) Locator_t remoteLocator; remoteLocator.kind = LOCATOR_KIND_UDPv4; - remoteLocator.port = 7410; + remoteLocator.port = g_default_port; remoteLocator.set_IP4_address(222,222,222,222); // When @@ -250,7 +252,7 @@ TEST_F(UDPv4Tests, match_if_port_AND_address_matches) transportUnderTest.init(); Locator_t locatorAlpha; - locatorAlpha.port = 50000; + locatorAlpha.port = g_default_port; locatorAlpha.set_IP4_address(239, 255, 0, 1); Locator_t locatorBeta = locatorAlpha; @@ -268,7 +270,7 @@ TEST_F(UDPv4Tests, send_to_wrong_interface) transportUnderTest.init(); Locator_t outputChannelLocator; - outputChannelLocator.port = 7400; + outputChannelLocator.port = g_default_port; outputChannelLocator.kind = LOCATOR_KIND_UDPv4; outputChannelLocator.set_IP4_address(127,0,0,1); // Loopback ASSERT_TRUE(transportUnderTest.OpenOutputChannel(outputChannelLocator)); @@ -289,6 +291,10 @@ void UDPv4Tests::HELPER_SetDescriptorDefaults() int main(int argc, char **argv) { Log::SetVerbosity(Log::Info); + + if(const char* env_p = std::getenv("PORT_RANDOM_NUMBER")) + g_default_port = std::stoi(env_p); + testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } diff --git a/test/unittest/transport/UDPv6Tests.cpp b/test/unittest/transport/UDPv6Tests.cpp index e6de9b4e352..04494097fcf 100644 --- a/test/unittest/transport/UDPv6Tests.cpp +++ b/test/unittest/transport/UDPv6Tests.cpp @@ -27,6 +27,8 @@ using namespace eprosima::fastrtps; const uint32_t ReceiveBufferCapacity = 65536; #endif +static uint32_t g_default_port = 7400; + class UDPv6Tests: public ::testing::Test { public: @@ -99,7 +101,7 @@ TEST_F(UDPv6Tests, opening_and_closing_output_channel) Locator_t genericOutputChannelLocator; genericOutputChannelLocator.kind = LOCATOR_KIND_UDPv6; - genericOutputChannelLocator.port = 7400; // arbitrary + genericOutputChannelLocator.port = g_default_port; // arbitrary // Then ASSERT_FALSE (transportUnderTest.IsOutputChannelOpen(genericOutputChannelLocator)); @@ -119,7 +121,7 @@ TEST_F(UDPv6Tests, opening_and_closing_input_channel) Locator_t multicastFilterLocator; multicastFilterLocator.kind = LOCATOR_KIND_UDPv6; - multicastFilterLocator.port = 7410; // arbitrary + multicastFilterLocator.port = g_default_port; // arbitrary multicastFilterLocator.set_IP6_address(0xff31, 0, 0, 0, 0, 0, 0x8000, 0x1234); // Then @@ -137,12 +139,12 @@ TEST_F(UDPv6Tests, send_and_receive_between_ports) transportUnderTest.init(); Locator_t multicastLocator; - multicastLocator.port = 7410; + multicastLocator.port = g_default_port; multicastLocator.kind = LOCATOR_KIND_UDPv6; multicastLocator.set_IP6_address(0xff31, 0, 0, 0, 0, 0, 0, 0); Locator_t outputChannelLocator; - outputChannelLocator.port = 7400; + outputChannelLocator.port = g_default_port + 1; outputChannelLocator.kind = LOCATOR_KIND_UDPv6; ASSERT_TRUE(transportUnderTest.OpenOutputChannel(outputChannelLocator)); // Includes loopback ASSERT_TRUE(transportUnderTest.OpenInputChannel(multicastLocator)); @@ -151,7 +153,7 @@ TEST_F(UDPv6Tests, send_and_receive_between_ports) auto sendThreadFunction = [&]() { Locator_t destinationLocator; - destinationLocator.port = 7410; + destinationLocator.port = g_default_port; destinationLocator.kind = LOCATOR_KIND_UDPv6; EXPECT_TRUE(transportUnderTest.Send(message, 5, outputChannelLocator, multicastLocator)); }; @@ -178,12 +180,12 @@ TEST_F(UDPv6Tests, send_to_loopback) transportUnderTest.init(); Locator_t multicastLocator; - multicastLocator.port = 7410; + multicastLocator.port = g_default_port; multicastLocator.kind = LOCATOR_KIND_UDPv6; multicastLocator.set_IP6_address(0xff31, 0, 0, 0, 0, 0, 0, 0); Locator_t outputChannelLocator; - outputChannelLocator.port = 7400; + outputChannelLocator.port = g_default_port + 1; outputChannelLocator.kind = LOCATOR_KIND_UDPv6; outputChannelLocator.set_IP6_address(0,0,0,0,0,0,0,1); // Loopback ASSERT_TRUE(transportUnderTest.OpenOutputChannel(outputChannelLocator)); @@ -193,7 +195,7 @@ TEST_F(UDPv6Tests, send_to_loopback) auto sendThreadFunction = [&]() { Locator_t destinationLocator; - destinationLocator.port = 7410; + destinationLocator.port = g_default_port; destinationLocator.kind = LOCATOR_KIND_UDPv6; EXPECT_TRUE(transportUnderTest.Send(message, 5, outputChannelLocator, multicastLocator)); }; @@ -225,6 +227,9 @@ void UDPv6Tests::HELPER_SetDescriptorDefaults() int main(int argc, char **argv) { + if(const char* env_p = std::getenv("PORT_RANDOM_NUMBER")) + g_default_port = std::stoi(env_p); + testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } diff --git a/test/unittest/transport/test_UDPv4Tests.cpp b/test/unittest/transport/test_UDPv4Tests.cpp index c153ab4875b..7737f238c9e 100644 --- a/test/unittest/transport/test_UDPv4Tests.cpp +++ b/test/unittest/transport/test_UDPv4Tests.cpp @@ -23,6 +23,8 @@ #include #include +static uint32_t g_default_port = 7400; + using namespace eprosima::fastrtps::rtps; class test_UDPv4Tests: public ::testing::Test @@ -58,7 +60,7 @@ TEST_F(test_UDPv4Tests, DATA_messages_dropped) HELPER_FillDataMessage(testDataMessage, SequenceNumber_t()); HELPER_WarmUpOutput(transportUnderTest); Locator_t locator; - locator.port = 7400; + locator.port = g_default_port; locator.kind = LOCATOR_KIND_UDPv4; // Then @@ -75,7 +77,7 @@ TEST_F(test_UDPv4Tests, ACKNACK_messages_dropped) HELPER_FillAckNackMessage(testDataMessage); HELPER_WarmUpOutput(transportUnderTest); Locator_t locator; - locator.port = 7400; + locator.port = g_default_port; locator.kind = LOCATOR_KIND_UDPv4; // Then @@ -92,7 +94,7 @@ TEST_F(test_UDPv4Tests, HEARTBEAT_messages_dropped) HELPER_FillHeartbeatMessage(testDataMessage); HELPER_WarmUpOutput(transportUnderTest); Locator_t locator; - locator.port = 7400; + locator.port = g_default_port; locator.kind = LOCATOR_KIND_UDPv4; // Then @@ -109,7 +111,7 @@ TEST_F(test_UDPv4Tests, Dropping_by_random_chance) HELPER_FillAckNackMessage(testDataMessage); HELPER_WarmUpOutput(transportUnderTest); Locator_t locator; - locator.port = 7400; + locator.port = g_default_port; locator.kind = LOCATOR_KIND_UDPv4; // Then @@ -131,7 +133,7 @@ TEST_F(test_UDPv4Tests, dropping_by_sequence_number) HELPER_FillDataMessage(testDataMessage, sequenceNumbersToDrop.back()); HELPER_WarmUpOutput(transportUnderTest); Locator_t locator; - locator.port = 7400; + locator.port = g_default_port; locator.kind = LOCATOR_KIND_UDPv4; // Then @@ -151,7 +153,7 @@ TEST_F(test_UDPv4Tests, No_drops_when_unrequested) HELPER_FillAckNackMessage(testDataMessage); HELPER_WarmUpOutput(transportUnderTest); Locator_t locator; - locator.port = 7400; + locator.port = g_default_port; locator.kind = LOCATOR_KIND_UDPv4; locator.set_IP4_address(239, 255, 1, 4); @@ -176,7 +178,7 @@ void test_UDPv4Tests::HELPER_SetDescriptorDefaults() void test_UDPv4Tests::HELPER_WarmUpOutput(test_UDPv4Transport& transport) { Locator_t outputChannelLocator; - outputChannelLocator.port = 7400; + outputChannelLocator.port = g_default_port; outputChannelLocator.kind = LOCATOR_KIND_UDPv4; ASSERT_TRUE(transport.OpenOutputChannel(outputChannelLocator)); } @@ -211,6 +213,9 @@ void test_UDPv4Tests::HELPER_FillHeartbeatMessage(CDRMessage_t& message) int main(int argc, char **argv) { + if(const char* env_p = std::getenv("PORT_RANDOM_NUMBER")) + g_default_port = std::stoi(env_p); + testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); }