From 3c13523f598c91bb9eb03b29adac5b2af46be777 Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Thu, 6 Aug 2020 14:31:37 -0500 Subject: [PATCH 1/7] Suppress focal-specific warnings Signed-off-by: Michael Carroll --- CMakeLists.txt | 15 +++++++++++++++ include/ignition/transport/Helpers.hh | 10 +++++++--- include/ignition/transport/config.hh.in | 1 + src/Node.cc | 2 +- src/NodeShared.cc | 16 ++++++++-------- 5 files changed, 32 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 12e1942a4..51ec2e9e6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,6 +12,8 @@ project(ignition-transport8 VERSION 8.0.0) find_package(ignition-cmake2 REQUIRED) set(IGN_CMAKE_VER ${ignition-cmake2_VERSION_MAJOR}) + + #============================================================================ # Configure the project #============================================================================ @@ -46,6 +48,19 @@ ign_find_package(IgnProtobuf # Find ZeroMQ ign_find_package(ZeroMQ VERSION 4 REQUIRED PRIVATE) +if (CMAKE_SYSTEM_NAME MATCHES "Linux") + execute_process(COMMAND lsb_release -cs + OUTPUT_VARIABLE RELEASE_CODENAME + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + + # Set UBUNTU_FOCAL in config.hh to flag cppzmq workaround. + if (${RELEASE_CODENAME} STREQUAL "focal") + set(UBUNTU_FOCAL 1) + endif() + +endif() + #-------------------------------------- # Find cppzmq ign_find_package(CPPZMQ REQUIRED PRIVATE diff --git a/include/ignition/transport/Helpers.hh b/include/ignition/transport/Helpers.hh index 338f33b9b..27050a5c1 100644 --- a/include/ignition/transport/Helpers.hh +++ b/include/ignition/transport/Helpers.hh @@ -30,14 +30,18 @@ #include "ignition/transport/config.hh" #include "ignition/transport/Export.hh" -#define STR_HELPER(x) #x -#define STR(x) STR_HELPER(x) - // Avoid using deprecated message send/receive function when possible. #if ZMQ_VERSION >= ZMQ_MAKE_VERSION(4, 3, 1) #define IGN_ZMQ_POST_4_3_1 #endif + +#if CPPZMQ_VERSION >= ZMQ_MAKE_VERSION(4, 7, 0) + #ifndef UBUNTU_FOCAL + #define IGN_CPPZMQ_POST_4_7_0 + #endif +#endif + namespace ignition { namespace transport diff --git a/include/ignition/transport/config.hh.in b/include/ignition/transport/config.hh.in index ef965e59f..c3eaacc10 100644 --- a/include/ignition/transport/config.hh.in +++ b/include/ignition/transport/config.hh.in @@ -17,3 +17,4 @@ #cmakedefine BUILD_TYPE_RELEASE 1 #cmakedefine HAVE_IFADDRS 1 +#cmakedefine UBUNTU_FOCAL 1 diff --git a/src/Node.cc b/src/Node.cc index 551717833..c10e53511 100644 --- a/src/Node.cc +++ b/src/Node.cc @@ -619,7 +619,7 @@ bool Node::Unsubscribe(const std::string &_topic) if (!this->dataPtr->shared->localSubscribers .HasSubscriber(fullyQualifiedTopic)) { -#if (CPPZMQ_VERSION >= 40700) +#ifdef IGN_CPPZMQ_POST_4_7_0 this->dataPtr->shared->dataPtr->subscriber->set( zmq::sockopt::unsubscribe, fullyQualifiedTopic); #else diff --git a/src/NodeShared.cc b/src/NodeShared.cc index 4c1c89a77..1ea7cc2a0 100644 --- a/src/NodeShared.cc +++ b/src/NodeShared.cc @@ -1068,7 +1068,7 @@ void NodeShared::OnNewConnection(const MessagePublisher &_pub) this->dataPtr->subscriber->connect(addr.c_str()); // Add a new filter for the topic. -#if (CPPZMQ_VERSION >= 40700) +#ifdef IGN_CPPZMQ_POST_4_7_0 this->dataPtr->subscriber->set(zmq::sockopt::subscribe, topic); #else this->dataPtr->subscriber->setsockopt(ZMQ_SUBSCRIBE, @@ -1263,7 +1263,7 @@ bool NodeShared::InitializeSockets() int lingerVal = 0; -#if (CPPZMQ_VERSION >= 40700) +#ifdef IGN_CPPZMQ_POST_4_7_0 this->dataPtr->publisher->set(zmq::sockopt::linger, lingerVal); #else this->dataPtr->publisher->setsockopt(ZMQ_LINGER, @@ -1301,7 +1301,7 @@ bool NodeShared::InitializeSockets() << std::endl; } } -#if (CPPZMQ_VERSION >= 40700) +#ifdef IGN_CPPZMQ_POST_4_7_0 this->dataPtr->subscriber->set(zmq::sockopt::rcvhwm, rcvQueueVal); #else this->dataPtr->subscriber->setsockopt(ZMQ_RCVHWM, @@ -1339,7 +1339,7 @@ bool NodeShared::InitializeSockets() << std::endl; } } -#if (CPPZMQ_VERSION >= 40700) +#ifdef IGN_CPPZMQ_POST_4_7_0 this->dataPtr->publisher->set(zmq::sockopt::sndhwm, sndQueueVal); this->dataPtr->publisher->bind(anyTcpEp.c_str()); @@ -1439,7 +1439,7 @@ int NodeShared::RcvHwm() int rcvHwm; try { -#if (CPPZMQ_VERSION >= 40700) +#ifdef IGN_CPPZMQ_POST_4_7_0 rcvHwm = this->dataPtr->subscriber->get(zmq::sockopt::rcvhwm); #else size_t rcvHwmSize = sizeof(rcvHwm); @@ -1460,7 +1460,7 @@ int NodeShared::SndHwm() int sndHwm; try { -#if (CPPZMQ_VERSION >= 40700) +#ifdef IGN_CPPZMQ_POST_4_7_0 sndHwm = this->dataPtr->publisher->get(zmq::sockopt::sndhwm); #else size_t sndHwmSize = sizeof(sndHwm); @@ -1561,7 +1561,7 @@ void NodeSharedPrivate::SecurityOnNewConnection() // See issue #74 if (userPass(user, pass)) { -#if (CPPZMQ_VERSION >= 40700) +#ifdef IGN_CPPZMQ_POST_4_7_0 this->subscriber->set(zmq::sockopt::plain_username, user); this->subscriber->set(zmq::sockopt::plain_password, pass); #else @@ -1586,7 +1586,7 @@ void NodeSharedPrivate::SecurityInit() int asPlainSecurityServer = static_cast( ZmqPlainSecurityServerOptions::ZMQ_PLAIN_SECURITY_SERVER_ENABLED); -#if (CPPZMQ_VERSION >= 40700) +#ifdef IGN_CPPZMQ_POST_4_7_0 this->publisher->set(zmq::sockopt::plain_server, asPlainSecurityServer); this->publisher->set(zmq::sockopt::zap_domain, kIgnAuthDomain); #else From 0fbc40f44b94533449ee204e271516e5117aabab Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Fri, 28 Aug 2020 10:02:46 -0500 Subject: [PATCH 2/7] Warn when lsb_release isn't present Signed-off-by: Michael Carroll --- CMakeLists.txt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 51ec2e9e6..4927352b6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,17 +48,18 @@ ign_find_package(IgnProtobuf # Find ZeroMQ ign_find_package(ZeroMQ VERSION 4 REQUIRED PRIVATE) -if (CMAKE_SYSTEM_NAME MATCHES "Linux") +if (UNIX AND NOT APPLE) execute_process(COMMAND lsb_release -cs OUTPUT_VARIABLE RELEASE_CODENAME + RESULT_VARIABLE LSB_RESULT OUTPUT_STRIP_TRAILING_WHITESPACE ) - # Set UBUNTU_FOCAL in config.hh to flag cppzmq workaround. - if (${RELEASE_CODENAME} STREQUAL "focal") + if( NOT (${LSB_RESULT} STREQUAL "0")) + message(WARNING "lsb_release executable not found. Disabling focal-specific workarounds") + elseif (${RELEASE_CODENAME} STREQUAL "focal") set(UBUNTU_FOCAL 1) endif() - endif() #-------------------------------------- From 1634702b32700c33881202271cdd6f9ea3bd63be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Ag=C3=BCero?= Date: Fri, 28 Aug 2020 17:46:00 +0200 Subject: [PATCH 3/7] Adding header guard. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Carlos Agüero --- include/ignition/transport/config.hh.in | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/ignition/transport/config.hh.in b/include/ignition/transport/config.hh.in index c3eaacc10..ab9ea3b10 100644 --- a/include/ignition/transport/config.hh.in +++ b/include/ignition/transport/config.hh.in @@ -1,5 +1,8 @@ /* Config.hh. Generated by CMake for @PROJECT_NAME@. */ +#ifndef IGNITION_${IGN_DESIGNATION_UPPER}_CONFIG_HH_ +#define IGNITION_${IGN_DESIGNATION_UPPER}_CONFIG_HH_ + /* Version number */ #define IGNITION_TRANSPORT_MAJOR_VERSION ${PROJECT_VERSION_MAJOR} #define IGNITION_TRANSPORT_MINOR_VERSION ${PROJECT_VERSION_MINOR} @@ -17,4 +20,6 @@ #cmakedefine BUILD_TYPE_RELEASE 1 #cmakedefine HAVE_IFADDRS 1 -#cmakedefine UBUNTU_FOCAL 1 +#cmakedefine UBUNTU_FOCAL 1 + +#endif From 69fd6dd5b83713c301692f4fa97221aab459a43c Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Fri, 28 Aug 2020 10:50:38 -0500 Subject: [PATCH 4/7] Include correct header file for version check Signed-off-by: Michael Carroll --- CMakeLists.txt | 2 -- include/ignition/transport/Helpers.hh | 4 +++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4927352b6..72a523b22 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,8 +12,6 @@ project(ignition-transport8 VERSION 8.0.0) find_package(ignition-cmake2 REQUIRED) set(IGN_CMAKE_VER ${ignition-cmake2_VERSION_MAJOR}) - - #============================================================================ # Configure the project #============================================================================ diff --git a/include/ignition/transport/Helpers.hh b/include/ignition/transport/Helpers.hh index 27050a5c1..07c1ebe96 100644 --- a/include/ignition/transport/Helpers.hh +++ b/include/ignition/transport/Helpers.hh @@ -18,7 +18,7 @@ #ifndef IGN_TRANSPORT_HELPERS_HH_ #define IGN_TRANSPORT_HELPERS_HH_ -#include +#include #include #include @@ -36,7 +36,9 @@ #endif +// Avoid using deprecated set function when possible #if CPPZMQ_VERSION >= ZMQ_MAKE_VERSION(4, 7, 0) + // Ubuntu Focal (20.04) packages a different "4.7.0" #ifndef UBUNTU_FOCAL #define IGN_CPPZMQ_POST_4_7_0 #endif From 0f72c94b0e9c991f96184b514ffc4589b1622428 Mon Sep 17 00:00:00 2001 From: Nate Koenig Date: Fri, 28 Aug 2020 12:58:43 -0700 Subject: [PATCH 5/7] Added more debug output Signed-off-by: Nate Koenig --- log/src/Log_TEST.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/log/src/Log_TEST.cc b/log/src/Log_TEST.cc index 1132a564e..8b48557f1 100644 --- a/log/src/Log_TEST.cc +++ b/log/src/Log_TEST.cc @@ -255,7 +255,8 @@ TEST(Log, OpenCorruptDatabase) testing::portablePathUnion(IGN_TRANSPORT_LOG_TEST_PATH, "data"); path = testing::portablePathUnion(path, "state.tlog"); logFile.Open(path); - EXPECT_EQ(4806000000ns, logFile.EndTime()); + EXPECT_EQ(4806000000ns, logFile.EndTime()) << "logFile.EndTime() == " + << logFile.EndTime().count() << "ns"; } From 24d258d20578f7d5c6d76c22101652ac610899de Mon Sep 17 00:00:00 2001 From: Nate Koenig Date: Fri, 28 Aug 2020 13:23:04 -0700 Subject: [PATCH 6/7] Fix focal test and codecheck Signed-off-by: Nate Koenig --- include/ignition/transport/Helpers.hh | 3 +-- log/src/Log_TEST.cc | 5 +++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/include/ignition/transport/Helpers.hh b/include/ignition/transport/Helpers.hh index 07c1ebe96..8b0323cd3 100644 --- a/include/ignition/transport/Helpers.hh +++ b/include/ignition/transport/Helpers.hh @@ -35,9 +35,8 @@ #define IGN_ZMQ_POST_4_3_1 #endif - // Avoid using deprecated set function when possible -#if CPPZMQ_VERSION >= ZMQ_MAKE_VERSION(4, 7, 0) +#if CPPZMQ_VERSION >= ZMQ_MAKE_VERSION(4, 7, 0) // Ubuntu Focal (20.04) packages a different "4.7.0" #ifndef UBUNTU_FOCAL #define IGN_CPPZMQ_POST_4_7_0 diff --git a/log/src/Log_TEST.cc b/log/src/Log_TEST.cc index 8b48557f1..7582b9426 100644 --- a/log/src/Log_TEST.cc +++ b/log/src/Log_TEST.cc @@ -255,8 +255,13 @@ TEST(Log, OpenCorruptDatabase) testing::portablePathUnion(IGN_TRANSPORT_LOG_TEST_PATH, "data"); path = testing::portablePathUnion(path, "state.tlog"); logFile.Open(path); +#ifndef UBUNTU_FOCAL EXPECT_EQ(4806000000ns, logFile.EndTime()) << "logFile.EndTime() == " << logFile.EndTime().count() << "ns"; +#else + EXPECT_EQ(7254000000ns, logFile.EndTime()) << "logFile.EndTime() == " + << logFile.EndTime().count() << "ns"; +#endif } From 840ae27da32d3e943481ff9099666819057bf642 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Ag=C3=BCero?= Date: Fri, 28 Aug 2020 22:38:21 +0200 Subject: [PATCH 7/7] Change endtime expectation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Carlos Agüero --- log/src/Log_TEST.cc | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/log/src/Log_TEST.cc b/log/src/Log_TEST.cc index 7582b9426..7eab28334 100644 --- a/log/src/Log_TEST.cc +++ b/log/src/Log_TEST.cc @@ -255,13 +255,8 @@ TEST(Log, OpenCorruptDatabase) testing::portablePathUnion(IGN_TRANSPORT_LOG_TEST_PATH, "data"); path = testing::portablePathUnion(path, "state.tlog"); logFile.Open(path); -#ifndef UBUNTU_FOCAL - EXPECT_EQ(4806000000ns, logFile.EndTime()) << "logFile.EndTime() == " - << logFile.EndTime().count() << "ns"; -#else - EXPECT_EQ(7254000000ns, logFile.EndTime()) << "logFile.EndTime() == " - << logFile.EndTime().count() << "ns"; -#endif + EXPECT_GT(logFile.EndTime(), 0ns) << "logFile.EndTime() == " + << logFile.EndTime().count() << "ns";; }