Skip to content

Commit

Permalink
Fix compilation error in Ubuntu 24.04 (#5217)
Browse files Browse the repository at this point in the history
Signed-off-by: Ricardo González Moreno <[email protected]>
  • Loading branch information
richiware committed Sep 11, 2024
1 parent 13767c2 commit 35dbc4b
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 22 deletions.
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ if(MSVC OR MSVC_IDE)
else()
# Add some generic warnings common to all compilers
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -Wall -pedantic -Wextra -Wno-unknown-pragmas -Wno-error=deprecated-declarations -Wno-switch-bool")
"${CMAKE_CXX_FLAGS} -Wall -Wpedantic -Wextra -Wno-unknown-pragmas -Wno-error=deprecated-declarations -Wno-switch-bool")
# Add compiler specific options
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-psabi")
Expand All @@ -82,6 +82,10 @@ else()
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl")
endif()

if(EPROSIMA_EXTRA_CMAKE_CXX_FLAGS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EPROSIMA_EXTRA_CMAKE_CXX_FLAGS}")
endif()

if(EPROSIMA_BUILD)
string(REPLACE "-DNDEBUG" "" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
endif()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ class NetworkFactory
{
public:

NetworkFactory()
NetworkFactory(
const RTPSParticipantAttributes&)
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,10 @@ class RTPSParticipantImpl

MOCK_CONST_METHOD0(getGuid, const GUID_t& ());

MOCK_CONST_METHOD0(network_factory, const NetworkFactory& ());
const NetworkFactory& network_factory()
{
return network_factory_;
}

MOCK_METHOD0(is_intraprocess_only, bool());

Expand Down Expand Up @@ -416,10 +419,12 @@ class RTPSParticipantImpl

MockParticipantListener listener_;

ResourceEvent events_;

RTPSParticipantAttributes attr_;

NetworkFactory network_factory_ {attr_};

ResourceEvent events_;

std::map<GUID_t, Endpoint*> endpoints_;

GUID_t generate_endpoint_guid() const
Expand Down
3 changes: 2 additions & 1 deletion test/unittest/rtps/builtin/BuiltinDataSerializationTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ namespace rtps {
constexpr size_t max_unicast_locators = 4u;
constexpr size_t max_multicast_locators = 1u;

NetworkFactory network;
RTPSParticipantAttributes participant_attributes;
NetworkFactory network {participant_attributes};

/*** Auxiliary functions ***/
inline uint32_t string_cdr_serialized_size(
Expand Down
1 change: 1 addition & 0 deletions test/unittest/rtps/discovery/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ target_compile_definitions(EdpTests PRIVATE
target_include_directories(EdpTests PRIVATE
${PROJECT_SOURCE_DIR}/test/mock/rtps/PDP
${PROJECT_SOURCE_DIR}/test/mock/rtps/external_locators
${PROJECT_SOURCE_DIR}/test/mock/rtps/NetworkFactory
${PROJECT_SOURCE_DIR}/test/mock/rtps/RTPSParticipantImpl
${PROJECT_SOURCE_DIR}/test/mock/rtps/Endpoint
${PROJECT_SOURCE_DIR}/test/mock/rtps/ReaderProxyData
Expand Down
1 change: 0 additions & 1 deletion test/unittest/rtps/discovery/EdpTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#include <rtps/builtin/discovery/endpoint/EDP.h>
#include <rtps/builtin/discovery/participant/PDP.h>
#include <rtps/participant/RTPSParticipantImpl.h>
#include <rtps/participant/RTPSParticipantImpl.h>

#if HAVE_SECURITY
#include <rtps/security/accesscontrol/ParticipantSecurityAttributes.h>
Expand Down
30 changes: 15 additions & 15 deletions test/unittest/rtps/security/SecurityTests.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,20 @@ class MockParticipantCrypto

typedef HandleImpl<MockParticipantCrypto, SecurityTest> MockParticipantCryptoHandle;

struct SecurityTestsGlobalDefaultValues
{
// Default Values
RTPSParticipantAttributes pattr;

SecurityTestsGlobalDefaultValues()
{
::testing::DefaultValue<const RTPSParticipantAttributes&>::Set(pattr);
}

};

static SecurityTestsGlobalDefaultValues g_security_default_values_;

class SecurityTest : public ::testing::Test
{
protected:
Expand Down Expand Up @@ -182,7 +196,7 @@ class SecurityTest : public ::testing::Test
bool security_activated_;

// Default Values
NetworkFactory network;
NetworkFactory network{g_security_default_values_.pattr};
GUID_t guid;
CDRMessage_t default_cdr_message;

Expand Down Expand Up @@ -218,18 +232,4 @@ class SecurityTest : public ::testing::Test

};

struct SecurityTestsGlobalDefaultValues
{
// Default Values
RTPSParticipantAttributes pattr;

SecurityTestsGlobalDefaultValues()
{
::testing::DefaultValue<const RTPSParticipantAttributes&>::Set(pattr);
}

};

static SecurityTestsGlobalDefaultValues g_security_default_values_;

#endif // __TEST_UNITTEST_RTPS_SECURITY_SECURITYTESTS_HPP__

0 comments on commit 35dbc4b

Please sign in to comment.