From decbf30ad1f1ef0d7ef72e574d37df30589a1092 Mon Sep 17 00:00:00 2001 From: Claudio Cicconetti Date: Thu, 18 Jul 2019 17:38:07 +0200 Subject: [PATCH 1/3] Copy FindGflags.cmake in cmake Consistent with other CMake find scripts, otherwise cmake 3.10.3 does not find it. --- cmake/FindGflags.cmake | 81 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 cmake/FindGflags.cmake diff --git a/cmake/FindGflags.cmake b/cmake/FindGflags.cmake new file mode 100644 index 000000000..246ceacdd --- /dev/null +++ b/cmake/FindGflags.cmake @@ -0,0 +1,81 @@ +# Copyright (c) Facebook, Inc. and its affiliates. +# Find libgflags. +# There's a lot of compatibility cruft going on in here, both +# to deal with changes across the FB consumers of this and also +# to deal with variances in behavior of cmake itself. +# +# Since this file is named FindGflags.cmake the cmake convention +# is for the module to export both GFLAGS_FOUND and Gflags_FOUND. +# The convention expected by consumers is that we export the +# following variables, even though these do not match the cmake +# conventions: +# +# LIBGFLAGS_INCLUDE_DIR - where to find gflags/gflags.h, etc. +# LIBGFLAGS_LIBRARY - List of libraries when using libgflags. +# LIBGFLAGS_FOUND - True if libgflags found. +# +# We need to be able to locate gflags both from an installed +# cmake config file and just from the raw headers and libs, so +# test for the former and then the latter, and then stick +# the results together and export them into the variables +# listed above. +# +# For forwards compatibility, we export the following variables: +# +# gflags_INCLUDE_DIR - where to find gflags/gflags.h, etc. +# gflags_TARGET / GFLAGS_TARGET / gflags_LIBRARIES +# - List of libraries when using libgflags. +# gflags_FOUND - True if libgflags found. +# + +IF (LIBGFLAGS_INCLUDE_DIR) + # Already in cache, be silent + SET(Gflags_FIND_QUIETLY TRUE) +ENDIF () + +find_package(gflags CONFIG QUIET) +if (gflags_FOUND) + if (NOT Gflags_FIND_QUIETLY) + message(STATUS "Found gflags from package config ${gflags_CONFIG}") + endif() + # Re-export the config-specified libs with our local names + set(LIBGFLAGS_LIBRARY ${gflags_LIBRARIES}) + set(LIBGFLAGS_INCLUDE_DIR ${gflags_INCLUDE_DIR}) + set(LIBGFLAGS_FOUND ${gflags_FOUND}) + # cmake module compat + set(GFLAGS_FOUND ${gflags_FOUND}) + set(Gflags_FOUND ${gflags_FOUND}) +else() + FIND_PATH(LIBGFLAGS_INCLUDE_DIR gflags/gflags.h) + + FIND_LIBRARY(LIBGFLAGS_LIBRARY_DEBUG NAMES gflagsd gflags_staticd) + FIND_LIBRARY(LIBGFLAGS_LIBRARY_RELEASE NAMES gflags gflags_static) + + INCLUDE(SelectLibraryConfigurations) + SELECT_LIBRARY_CONFIGURATIONS(LIBGFLAGS) + + # handle the QUIETLY and REQUIRED arguments and set LIBGFLAGS_FOUND to TRUE if + # all listed variables are TRUE + INCLUDE(FindPackageHandleStandardArgs) + FIND_PACKAGE_HANDLE_STANDARD_ARGS(gflags DEFAULT_MSG LIBGFLAGS_LIBRARY LIBGFLAGS_INCLUDE_DIR) + # cmake module compat + set(Gflags_FOUND ${GFLAGS_FOUND}) + # compat with some existing FindGflags consumers + set(LIBGFLAGS_FOUND ${GFLAGS_FOUND}) + + # Compat with the gflags CONFIG based detection + set(gflags_FOUND ${GFLAGS_FOUND}) + set(gflags_INCLUDE_DIR ${LIBGFLAGS_INCLUDE_DIR}) + set(gflags_LIBRARIES ${LIBGFLAGS_LIBRARY}) + set(GFLAGS_TARGET ${LIBGFLAGS_LIBRARY}) + set(gflags_TARGET ${LIBGFLAGS_LIBRARY}) + + MARK_AS_ADVANCED(LIBGFLAGS_LIBRARY LIBGFLAGS_INCLUDE_DIR) +endif() + +# Compat with the gflags CONFIG based detection +if (LIBGFLAGS_FOUND AND NOT TARGET gflags) + add_library(gflags UNKNOWN IMPORTED) + set_target_properties(gflags PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${LIBGFLAGS_INCLUDE_DIR}") + set_target_properties(gflags PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES "C" IMPORTED_LOCATION "${LIBGFLAGS_LIBRARY}") +endif() From 8e15e7d17e12ad49e0d2d30bdc539271d0ec98b1 Mon Sep 17 00:00:00 2001 From: Claudio Cicconetti Date: Thu, 18 Jul 2019 17:39:40 +0200 Subject: [PATCH 2/3] Minor fix to QuickClientTransportTest Member function call of test class not found inside a lambda, unless this is specified explicitly with g++ 5.4.0. --- quic/client/test/QuicClientTransportTest.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/quic/client/test/QuicClientTransportTest.cpp b/quic/client/test/QuicClientTransportTest.cpp index 26b1cb1e3..99cc0cf69 100644 --- a/quic/client/test/QuicClientTransportTest.cpp +++ b/quic/client/test/QuicClientTransportTest.cpp @@ -449,7 +449,7 @@ TEST_P(QuicClientTransportIntegrationTest, TLSAlert) { EXPECT_EQ(indices.size(), 1); auto tmp = std::move(qLogger->logs[indices[0]]); auto event = dynamic_cast(tmp.get()); - checkTransportSummaryEvent(event); + this->checkTransportSummaryEvent(event); eventbase_.terminateLoopSoon(); })); @@ -480,7 +480,7 @@ TEST_P(QuicClientTransportIntegrationTest, BadServerTest) { EXPECT_EQ(indices.size(), 1); auto tmp = std::move(qLogger->logs[indices[0]]); auto event = dynamic_cast(tmp.get()); - checkTransportSummaryEvent(event); + this->checkTransportSummaryEvent(event); })); client->start(&clientConnCallback); eventbase_.loop(); From 727e4d86855db2bc70a0f155bb8147fb751be237 Mon Sep 17 00:00:00 2001 From: Claudio Cicconetti Date: Thu, 18 Jul 2019 17:40:56 +0200 Subject: [PATCH 3/3] Minor fix to FunctionLooperTest Test class must defined explicitly. EXPECT_EQ() with Boolean values transformed into EXPECT_TRUE()/EXPECT_FALSE(), preventing a compiler warning (g++ 5.4.0). --- quic/common/test/FunctionLooperTest.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/quic/common/test/FunctionLooperTest.cpp b/quic/common/test/FunctionLooperTest.cpp index 70daaeb8a..dbe645f6e 100644 --- a/quic/common/test/FunctionLooperTest.cpp +++ b/quic/common/test/FunctionLooperTest.cpp @@ -17,6 +17,8 @@ using namespace testing; namespace quic { namespace test { +class FunctionLooperTest : public ::testing::Test {}; + TEST(FunctionLooperTest, LooperNotRunning) { EventBase evb; bool called = false; @@ -175,11 +177,11 @@ TEST(FunctionLooperTest, PacingOnce) { looper->run(); evb.loopOnce(); EXPECT_EQ(1, fromTimerVec.size()); - EXPECT_EQ(false, fromTimerVec.back()); + EXPECT_FALSE(fromTimerVec.back()); EXPECT_TRUE(looper->isScheduled()); looper->timeoutExpired(); EXPECT_EQ(2, fromTimerVec.size()); - EXPECT_EQ(true, fromTimerVec.back()); + EXPECT_TRUE(fromTimerVec.back()); looper->stop(); } @@ -202,21 +204,21 @@ TEST(FunctionLooperTest, KeepPacing) { looper->run(); evb.loopOnce(); EXPECT_EQ(1, fromTimerVec.size()); - EXPECT_EQ(false, fromTimerVec.back()); + EXPECT_FALSE(fromTimerVec.back()); EXPECT_TRUE(looper->isScheduled()); looper->cancelTimeout(); EXPECT_FALSE(looper->isScheduled()); looper->timeoutExpired(); EXPECT_EQ(2, fromTimerVec.size()); - EXPECT_EQ(true, fromTimerVec.back()); + EXPECT_TRUE(fromTimerVec.back()); EXPECT_TRUE(looper->isScheduled()); looper->cancelTimeout(); EXPECT_FALSE(looper->isScheduled()); looper->timeoutExpired(); EXPECT_EQ(3, fromTimerVec.size()); - EXPECT_EQ(true, fromTimerVec.back()); + EXPECT_TRUE(fromTimerVec.back()); EXPECT_TRUE(looper->isScheduled()); stopPacing = true; @@ -224,7 +226,7 @@ TEST(FunctionLooperTest, KeepPacing) { EXPECT_FALSE(looper->isScheduled()); looper->timeoutExpired(); EXPECT_EQ(4, fromTimerVec.size()); - EXPECT_EQ(true, fromTimerVec.back()); + EXPECT_TRUE(fromTimerVec.back()); EXPECT_FALSE(looper->isScheduled()); looper->stop();