From 656843e9a354a983e9ba7e992625b2cebb2015b8 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 11 Feb 2019 00:02:20 +0000 Subject: [PATCH] Fix issues on debian --- CMakeLists.txt | 44 ++-------- Makefile | 2 +- libutp/CMakeLists.txt | 2 +- llarp/CMakeLists.txt | 43 ++++++++-- llarp/util/logger.c | 1 - llarp/util/logger.hpp | 24 ++---- test/CMakeLists.txt | 6 -- test/crypto/test_llarp_crypto_types.cpp | 93 ++++++++++----------- test/dht/test_llarp_dht_kademlia.cpp | 2 +- test/dht/test_llarp_dht_key.cpp | 17 +++- test/dht/test_llarp_dht_txowner.cpp | 4 +- test/test_llarp_router.cpp | 2 +- test/util/test_llarp_util_aligned.cpp | 2 +- test/util/test_llarp_util_bencode.cpp | 20 +++-- test/util/test_llarp_util_bits.cpp | 2 +- test/util/test_llarp_util_queue_manager.cpp | 14 ++-- test/util/test_llarp_util_thread_pool.cpp | 4 +- vendor/CMakeLists.txt | 2 +- 18 files changed, 139 insertions(+), 145 deletions(-) delete mode 100644 llarp/util/logger.c diff --git a/CMakeLists.txt b/CMakeLists.txt index e2e50022d..b03e9a3f4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -241,6 +241,13 @@ set(ANDROID_LIB ${LIB}android) get_filename_component(TT_ROOT "vendor/libtuntap-master" ABSOLUTE) add_definitions(-D${CMAKE_SYSTEM_NAME}) +function(add_import_library libname) + add_library(libname SHARED IMPORTED) + if(NOT TARGET libname) + message(FATAL "unable to find library ${libname}") + endif() +endfunction() + if(UNIX) add_definitions(-DUNIX) add_definitions(-DPOSIX) @@ -288,10 +295,6 @@ else() set(LIBTUNTAP_SRC ${LIBTUNTAP_SRC_BASE}) endif(UNIX) -if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") - set(ISOLATE_PROC_SRC llarp/linux/netns.cpp) -endif(${CMAKE_SYSTEM_NAME} MATCHES "Linux") - if(NOT WIN32) add_subdirectory(vendor) endif(NOT WIN32) @@ -304,18 +307,7 @@ set(RC_SRC daemon/rcutil.cpp ) -set(DNS_SRC - llarp/dns.cpp - llarp/dnsc.cpp - llarp/dnsd.cpp - llarp/dns_iptracker.cpp - llarp/dns_dotlokilookup.cpp - llarp/dns_rectypes.cpp - llarp/net/net.cpp - daemon/dns.cpp -) - -set(ALL_SRC ${RC_SRC} ${EXE_SRC} ${DNS_SRC} ${LIB_PLATFORM_SRC} ${LIB_SRC}) +set(ALL_SRC ${RC_SRC} ${EXE_SRC} ${LIB_PLATFORM_SRC} ${LIB_SRC}) foreach(F ${ALL_SRC}) set_source_files_properties(${F} PROPERTIES COMPILE_FLAGS -DLOG_TAG=\\\"${F}\\\") @@ -343,14 +335,6 @@ else() install(CODE "execute_process(COMMAND setcap cap_net_admin,cap_net_bind_service=+eip ${CMAKE_INSTALL_PREFIX}/bin/lokinet)") endif(${CMAKE_SYSTEM_NAME} MATCHES "Linux") - if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") - if(NON_PC_TARGET) - target_link_libraries(${PLATFORM_LIB} -lrt) - else() - target_link_libraries(${PLATFORM_LIB} -lcap) - endif(NON_PC_TARGET) - endif(${CMAKE_SYSTEM_NAME} MATCHES "Linux") - if (WIN32) target_link_libraries(${EXE} ${STATIC_LIB} ws2_32 iphlpapi) else() @@ -362,16 +346,6 @@ else() add_library(${ANDROID_LIB} SHARED jni/lokinet_android.cpp) target_link_libraries(${ANDROID_LIB} ${STATIC_LIB} ${LIBS}) endif(ANDROID) - - if(WITH_SHARED) - add_library(${SHARED_LIB} SHARED ${LIB_SRC}) - if (WIN32) - target_link_libraries(${SHARED_LIB} ${CRYPTOGRAPHY_LIB} ${LIBS} ${UTIL_LIB} ${PLATFORM_LIB} ws2_32 iphlpapi Threads::Threads) - else (NOT WIN32) - target_link_libraries(${SHARED_LIB} ${CRYPTOGRAPHY_LIB} ${LIBS} ${UTIL_LIB} libutp ${PLATFORM_LIB} Threads::Threads) - install(TARGETS ${SHARED_LIB} LIBRARY DESTINATION lib) - endif(WIN32) - endif(WITH_SHARED) endif(SHADOW) if(USE_LIBABYSS) @@ -384,7 +358,7 @@ if(USE_LIBABYSS) ${ABYSS}/src/client.cpp ${ABYSS}/src/server.cpp ${ABYSS}/src/json.cpp) - add_library(${ABYSS_LIB} OBJECT ${ABYSS_SRC}) + add_library(${ABYSS_LIB} STATIC ${ABYSS_SRC}) target_link_libraries(${ABYSS_LIB} PUBLIC ${PLATFORM_LIB}) list(APPEND ALL_SRC ${ABYSS_SRC} ${ABYSS}/main.cpp) diff --git a/Makefile b/Makefile index ab2f320d4..3784f6ebf 100644 --- a/Makefile +++ b/Makefile @@ -91,7 +91,7 @@ COVERAGE_CONFIG_CMD = $(shell /bin/echo -n "cd '$(BUILD_ROOT)' && " ; /bin/echo TARGETS = $(REPO)/lokinet SIGS = $(TARGETS:=.sig) EXE = $(BUILD_ROOT)/lokinet -TEST_EXE = $(BUILD_ROOT)/testAll +TEST_EXE = $(BUILD_ROOT)/test/testAll ABYSS_EXE = $(BUILD_ROOT)/abyss-main LINT_FILES = $(wildcard llarp/*.cpp) diff --git a/libutp/CMakeLists.txt b/libutp/CMakeLists.txt index 29a10c615..5896a88cd 100644 --- a/libutp/CMakeLists.txt +++ b/libutp/CMakeLists.txt @@ -11,5 +11,5 @@ if(WIN32) list(APPEND UTP_SRC libutp_inet_ntop.cpp) endif(WIN32) -add_library(libutp OBJECT ${UTP_SRC}) +add_library(libutp STATIC ${UTP_SRC}) target_include_directories(libutp PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CORE_INCLUDE}) diff --git a/llarp/CMakeLists.txt b/llarp/CMakeLists.txt index 11e44ff03..4d480b6ed 100644 --- a/llarp/CMakeLists.txt +++ b/llarp/CMakeLists.txt @@ -13,7 +13,6 @@ set(LIB_UTIL_SRC util/endian.cpp util/fs.cpp util/ini.cpp - util/logger.c util/logger.cpp util/logic.cpp util/mem.cpp @@ -32,13 +31,17 @@ set(LIB_UTIL_SRC add_library(${UTIL_LIB} STATIC ${LIB_UTIL_SRC}) target_include_directories(${UTIL_LIB} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) -target_link_libraries(${UTIL_LIB} cppbackport) +target_link_libraries(${UTIL_LIB} PUBLIC cppbackport) # cut back on fluff if (NOT WIN32) - target_link_libraries(${UTIL_LIB} absl::optional) + target_link_libraries(${UTIL_LIB} PUBLIC absl::optional) endif(NOT WIN32) +if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") + set(ISOLATE_PROC_SRC linux/netns.cpp) +endif() + set(LIB_PLATFORM_SRC # for networking ev/ev.cpp @@ -52,15 +55,26 @@ set(LIB_PLATFORM_SRC # tun ${LIBTUNTAP_SRC} ${EV_SRC} -# win32 inline code - win32/win32_inet.c - win32/win32_intrnl.c - win32/win32_upoll.c ) add_library(${PLATFORM_LIB} STATIC ${LIB_PLATFORM_SRC}) target_link_libraries(${PLATFORM_LIB} PUBLIC ${CRYPTOGRAPHY_LIB} ${UTIL_LIB} libutp cppbackport Threads::Threads) +if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") + if(NON_PC_TARGET) + add_import_library(rt) + target_link_libraries(${PLATFORM_LIB} PUBLIC rt) + else() + add_import_library(rt) + target_link_libraries(${PLATFORM_LIB} PUBLIC cap) + endif() +endif() + +if(WIN32) + # win32 inline code + target_sources(${PLATFORM_LIB} PUBLIC win32/win32_inet.c win32/win32_intrnl.c win32/win32_upoll.c) +endif() + if(USE_LIBABYSS) target_link_libraries(${PLATFORM_LIB} ${ABYSS_LIB}) endif() @@ -184,8 +198,21 @@ set(LIB_SRC service/tag.cpp service/types.cpp service/vanity.cpp - testnet.c ) add_library(${STATIC_LIB} STATIC ${LIB_SRC}) target_link_libraries(${STATIC_LIB} PUBLIC ${PLATFORM_LIB} ${UTIL_LIB} ${CRYPTOGRAPHY_LIB} cppbackport libutp ${LIBS}) + +if(TESTNET) + target_sources(${STATIC_LIB} PUBLIC testnet.c) +endif() + +if(WITH_SHARED) + add_library(${SHARED_LIB} SHARED ${LIB_SRC}) + if (WIN32) + target_link_libraries(${SHARED_LIB} ${CRYPTOGRAPHY_LIB} ${LIBS} ${UTIL_LIB} ${PLATFORM_LIB} ws2_32 iphlpapi Threads::Threads) + else() + target_link_libraries(${SHARED_LIB} ${CRYPTOGRAPHY_LIB} ${LIBS} ${UTIL_LIB} libutp ${PLATFORM_LIB} Threads::Threads) + install(TARGETS ${SHARED_LIB} LIBRARY DESTINATION lib) + endif() +endif() diff --git a/llarp/util/logger.c b/llarp/util/logger.c deleted file mode 100644 index be028b093..000000000 --- a/llarp/util/logger.c +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/llarp/util/logger.hpp b/llarp/util/logger.hpp index cdb382000..45a8a0f75 100644 --- a/llarp/util/logger.hpp +++ b/llarp/util/logger.hpp @@ -259,22 +259,14 @@ namespace llarp } } // namespace llarp -#define LogDebug(x, ...) \ - _Log(llarp::eLogDebug, LOG_TAG, __LINE__, x, ##__VA_ARGS__) -#define LogInfo(x, ...) \ - _Log(llarp::eLogInfo, LOG_TAG, __LINE__, x, ##__VA_ARGS__) -#define LogWarn(x, ...) \ - _Log(llarp::eLogWarn, LOG_TAG, __LINE__, x, ##__VA_ARGS__) -#define LogError(x, ...) \ - _Log(llarp::eLogError, LOG_TAG, __LINE__, x, ##__VA_ARGS__) -#define LogDebugTag(tag, x, ...) \ - _Log(llarp::eLogDebug, tag, __LINE__, x, ##__VA_ARGS__) -#define LogInfoTag(tag, x, ...) \ - _Log(llarp::eLogInfo, tag, __LINE__, x, ##__VA_ARGS__) -#define LogWarnTag(tag, x, ...) \ - _Log(llarp::eLogWarn, tag, __LINE__, x, ##__VA_ARGS__) -#define LogErrorTag(tag, x, ...) \ - _Log(llarp::eLogError, tag, __LINE__, x, ##__VA_ARGS__) +#define LogDebug(...) _Log(llarp::eLogDebug, LOG_TAG, __LINE__, __VA_ARGS__) +#define LogInfo(...) _Log(llarp::eLogInfo, LOG_TAG, __LINE__, __VA_ARGS__) +#define LogWarn(...) _Log(llarp::eLogWarn, LOG_TAG, __LINE__, __VA_ARGS__) +#define LogError(...) _Log(llarp::eLogError, LOG_TAG, __LINE__, __VA_ARGS__) +#define LogDebugTag(tag, ...) _Log(llarp::eLogDebug, tag, __LINE__, __VA_ARGS__) +#define LogInfoTag(tag, ...) _Log(llarp::eLogInfo, tag, __LINE__, __VA_ARGS__) +#define LogWarnTag(tag, ...) _Log(llarp::eLogWarn, tag, __LINE__, __VA_ARGS__) +#define LogErrorTag(tag, ...) _Log(llarp::eLogError, tag, __LINE__, __VA_ARGS__) #ifndef LOG_TAG #define LOG_TAG "default" diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 68a2d1336..46789a472 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -48,12 +48,6 @@ add_executable(${TEST_EXE} ${TEST_SRC} ) -set(GTEST_ROOT ${INSTALL_DIR}) -# This will warn because we have googletest in-source, but this is the only way -# to import gtest_add_tests. -find_package(GTest) -gtest_add_tests(TARGET ${TEST_EXE} SOURCES ${TEST_SRC}) - target_link_libraries(${TEST_EXE} PUBLIC gmock gtest ${STATIC_LIB}) target_include_directories(${TEST_EXE} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/test/crypto/test_llarp_crypto_types.cpp b/test/crypto/test_llarp_crypto_types.cpp index 1c75863e5..3c9f067fa 100644 --- a/test/crypto/test_llarp_crypto_types.cpp +++ b/test/crypto/test_llarp_crypto_types.cpp @@ -36,9 +36,9 @@ TEST_P(PubKeyString, fromstring) llarp::PubKey::Data empty = {}; llarp::PubKey::Data full = {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}}; + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}}; // clang-format off ToStringData toStringData[] = { @@ -48,7 +48,7 @@ ToStringData toStringData[] = { // clang-format on INSTANTIATE_TEST_CASE_P(TestCryptoTypes, PubKeyString, - ::testing::ValuesIn(toStringData)); + ::testing::ValuesIn(toStringData), ); // Concerns // - file missing @@ -253,50 +253,47 @@ TEST_F(TestCryptoTypesSecret, secret_key_from_file_happy_bencode) // Win32: check for root/admin/elevation privileges #ifdef _WIN32 -BOOL IsRunAsAdmin() -{ - BOOL fIsRunAsAdmin = FALSE; - DWORD dwError = ERROR_SUCCESS; - PSID pAdministratorsGroup = NULL; - - // Allocate and initialize a SID of the administrators group. - SID_IDENTIFIER_AUTHORITY NtAuthority = SECURITY_NT_AUTHORITY; - if (!AllocateAndInitializeSid( - &NtAuthority, - 2, - SECURITY_BUILTIN_DOMAIN_RID, - DOMAIN_ALIAS_RID_ADMINS, - 0, 0, 0, 0, 0, 0, - &pAdministratorsGroup)) - { - dwError = GetLastError(); - goto Cleanup; - } - - // Determine whether the SID of administrators group is enabled in - // the primary access token of the process. - if (!CheckTokenMembership(NULL, pAdministratorsGroup, &fIsRunAsAdmin)) - { - dwError = GetLastError(); - goto Cleanup; - } - -Cleanup: - // Centralized cleanup for all allocated resources. - if (pAdministratorsGroup) - { - FreeSid(pAdministratorsGroup); - pAdministratorsGroup = NULL; - } - - // Throw the error if something failed in the function. - if (ERROR_SUCCESS != dwError) - { - throw dwError; - } - - return fIsRunAsAdmin; -} +BOOL +IsRunAsAdmin() +{ + BOOL fIsRunAsAdmin = FALSE; + DWORD dwError = ERROR_SUCCESS; + PSID pAdministratorsGroup = NULL; + + // Allocate and initialize a SID of the administrators group. + SID_IDENTIFIER_AUTHORITY NtAuthority = SECURITY_NT_AUTHORITY; + if(!AllocateAndInitializeSid(&NtAuthority, 2, SECURITY_BUILTIN_DOMAIN_RID, + DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, + &pAdministratorsGroup)) + { + dwError = GetLastError(); + goto Cleanup; + } + + // Determine whether the SID of administrators group is enabled in + // the primary access token of the process. + if(!CheckTokenMembership(NULL, pAdministratorsGroup, &fIsRunAsAdmin)) + { + dwError = GetLastError(); + goto Cleanup; + } + +Cleanup: + // Centralized cleanup for all allocated resources. + if(pAdministratorsGroup) + { + FreeSid(pAdministratorsGroup); + pAdministratorsGroup = NULL; + } + + // Throw the error if something failed in the function. + if(ERROR_SUCCESS != dwError) + { + throw dwError; + } + + return fIsRunAsAdmin; +} #endif TEST_F(TestCryptoTypesSecret, secret_key_to_missing_file) diff --git a/test/dht/test_llarp_dht_kademlia.cpp b/test/dht/test_llarp_dht_kademlia.cpp index 321bb199e..342e9ff21 100644 --- a/test/dht/test_llarp_dht_kademlia.cpp +++ b/test/dht/test_llarp_dht_kademlia.cpp @@ -85,4 +85,4 @@ makeData() } INSTANTIATE_TEST_CASE_P(TestDhtXorMetric, XorMetric, - ::testing::ValuesIn(makeData())); + ::testing::ValuesIn(makeData()), ); diff --git a/test/dht/test_llarp_dht_key.cpp b/test/dht/test_llarp_dht_key.cpp index 3ab020299..1d7868d08 100644 --- a/test/dht/test_llarp_dht_key.cpp +++ b/test/dht/test_llarp_dht_key.cpp @@ -30,15 +30,24 @@ TEST_P(DHT, constructor) } } -static constexpr Array emptyArray {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}; +static constexpr Array emptyArray{ + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}; -static constexpr Array fullArray {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}}; +static constexpr Array fullArray{ + {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}}; -static constexpr Array seqArray {{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F}}; +static constexpr Array seqArray{ + {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, + 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, + 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F}}; static const Array data[] = {emptyArray, fullArray, seqArray}; -INSTANTIATE_TEST_CASE_P(TestDhtKey, DHT, ::testing::ValuesIn(data)); +INSTANTIATE_TEST_CASE_P(TestDhtKey, DHT, ::testing::ValuesIn(data), ); TEST(TestDhtKey, eq) { diff --git a/test/dht/test_llarp_dht_txowner.cpp b/test/dht/test_llarp_dht_txowner.cpp index fbb000a45..e5a818f4c 100644 --- a/test/dht/test_llarp_dht_txowner.cpp +++ b/test/dht/test_llarp_dht_txowner.cpp @@ -117,7 +117,7 @@ namespace } // namespace INSTANTIATE_TEST_CASE_P(TestDhtTxOwner, TxOwner, - ::testing::ValuesIn(makeData())); + ::testing::ValuesIn(makeData()), ); INSTANTIATE_TEST_CASE_P(TestDhtTxOwner, TxOwnerOps, - ::testing::ValuesIn(makeCmpData())); + ::testing::ValuesIn(makeCmpData()), ); diff --git a/test/test_llarp_router.cpp b/test/test_llarp_router.cpp index 56fdbbb7d..9eb48fe09 100644 --- a/test/test_llarp_router.cpp +++ b/test/test_llarp_router.cpp @@ -81,4 +81,4 @@ FindOrCreateFunc findOrCreateFunc[] = {llarp_findOrCreateEncryption, llarp_findOrCreateIdentity}; INSTANTIATE_TEST_CASE_P(TestRouter, FindOrCreate, - ::testing::ValuesIn(findOrCreateFunc)); + ::testing::ValuesIn(findOrCreateFunc), ); diff --git a/test/util/test_llarp_util_aligned.cpp b/test/util/test_llarp_util_aligned.cpp index fb7ccbeb1..0dfd0fe0b 100644 --- a/test/util/test_llarp_util_aligned.cpp +++ b/test/util/test_llarp_util_aligned.cpp @@ -22,7 +22,7 @@ struct AlignedBufferTest : public ::testing::Test { }; -TYPED_TEST_CASE(AlignedBufferTest, TestSizes); +TYPED_TEST_CASE(AlignedBufferTest, TestSizes, ); TYPED_TEST(AlignedBufferTest, Constructor) { diff --git a/test/util/test_llarp_util_bencode.cpp b/test/util/test_llarp_util_bencode.cpp index 127c87aac..05327ec1f 100644 --- a/test/util/test_llarp_util_bencode.cpp +++ b/test/util/test_llarp_util_bencode.cpp @@ -80,7 +80,8 @@ static const TestReadInt testReadInt[] = { {{z}, false, 0}, }; -INSTANTIATE_TEST_CASE_P(TestBencode, ReadInt, ::testing::ValuesIn(testReadInt)); +INSTANTIATE_TEST_CASE_P(TestBencode, ReadInt, + ::testing::ValuesIn(testReadInt), ); struct ReadStr : public ::testing::TestWithParam< TestReadString > { @@ -117,7 +118,8 @@ static const TestReadString testReadStr[] = { {{colon, colon}, false, ""}, }; -INSTANTIATE_TEST_CASE_P(TestBencode, ReadStr, ::testing::ValuesIn(testReadStr)); +INSTANTIATE_TEST_CASE_P(TestBencode, ReadStr, + ::testing::ValuesIn(testReadStr), ); template < typename Input > struct TestWriteData @@ -164,7 +166,7 @@ static const TestWriteByteString testWriteByteString[] = { }; INSTANTIATE_TEST_CASE_P(TestBencode, WriteByteStr, - ::testing::ValuesIn(testWriteByteString)); + ::testing::ValuesIn(testWriteByteString), ); struct WriteInt : public ::testing::TestWithParam< TestWriteInt > { @@ -193,7 +195,7 @@ static const TestWriteInt testWriteInt[] = { }; INSTANTIATE_TEST_CASE_P(TestBencode, WriteInt, - ::testing::ValuesIn(testWriteInt)); + ::testing::ValuesIn(testWriteInt), ); struct WriteIntValues : public ::testing::TestWithParam< uint64_t > { @@ -227,7 +229,7 @@ INSTANTIATE_TEST_CASE_P( ::testing::Values(std::numeric_limits< uint64_t >::min(), std::numeric_limits< uint64_t >::max(), std::numeric_limits< uint64_t >::max() / 2, - std::numeric_limits< uint64_t >::max() / 3)); + std::numeric_limits< uint64_t >::max() / 3), ); TEST(TestBencode, good_version) { @@ -305,7 +307,7 @@ ListTestData listTestData[] = { }; INSTANTIATE_TEST_CASE_P(TestBencode, ListTest, - ::testing::ValuesIn(listTestData)); + ::testing::ValuesIn(listTestData), ); struct DictTestData { @@ -362,7 +364,7 @@ DictTestData dictTestData[] = { }; INSTANTIATE_TEST_CASE_P(TestBencode, DictTest, - ::testing::ValuesIn(dictTestData)); + ::testing::ValuesIn(dictTestData), ); struct ReadData { @@ -403,7 +405,7 @@ ReadData dictReadData[] = {{"de", {}}, {"d1:b2:23e", {"b", "23"}}}; INSTANTIATE_TEST_CASE_P(TestBencode, DictReadTest, - ::testing::ValuesIn(dictReadData)); + ::testing::ValuesIn(dictReadData), ); struct ListReadTest : public ::testing::TestWithParam< ReadData > { @@ -439,4 +441,4 @@ ReadData listReadData[] = { {"le", {}}, {"l1:ae", {"a"}}, {"l1:be", {"b"}}, {"l1:b2:23e", {"b", "23"}}}; INSTANTIATE_TEST_CASE_P(TestBencode, ListReadTest, - ::testing::ValuesIn(listReadData)); + ::testing::ValuesIn(listReadData), ); diff --git a/test/util/test_llarp_util_bits.cpp b/test/util/test_llarp_util_bits.cpp index ba6b08a92..5dba48927 100644 --- a/test/util/test_llarp_util_bits.cpp +++ b/test/util/test_llarp_util_bits.cpp @@ -63,4 +63,4 @@ static const InputData inputData[] = { }; // clang-format on -INSTANTIATE_TEST_CASE_P(TestBits, TestBits, ::testing::ValuesIn(inputData)); +INSTANTIATE_TEST_CASE_P(TestBits, TestBits, ::testing::ValuesIn(inputData), ); diff --git a/test/util/test_llarp_util_queue_manager.cpp b/test/util/test_llarp_util_queue_manager.cpp index 97fbeafef..e5c55dad3 100644 --- a/test/util/test_llarp_util_queue_manager.cpp +++ b/test/util/test_llarp_util_queue_manager.cpp @@ -377,7 +377,7 @@ TEST_P(BasicFunctionality, pushIndex) } INSTANTIATE_TEST_CASE_P(TestQueueManagerBasic, BasicFunctionality, - ::testing::Range(1u, 100u)); + ::testing::Range(1u, 100u), ); // Potential issues: // - That pushing an element at the max combined index will push the next @@ -557,7 +557,7 @@ CombinedIndexData PopAtMaxData[] = {7, 14, 7}}; INSTANTIATE_TEST_CASE_P(TestQueueManagerMaxCombinedIndex, PopAtMax, - ::testing::ValuesIn(PopAtMaxData)); + ::testing::ValuesIn(PopAtMaxData), ); class ReservePop : public ::testing::TestWithParam< CombinedIndexData > { @@ -632,7 +632,7 @@ CombinedIndexData ReservePopIndexForClearData[] = { }; INSTANTIATE_TEST_CASE_P(TestQueueManagerMaxCombinedIndex, ReservePop, - ::testing::ValuesIn(ReservePopIndexForClearData)); + ::testing::ValuesIn(ReservePopIndexForClearData), ); struct CircularDifferenceData { @@ -716,7 +716,7 @@ CircularDifferenceData circularDifferenceData[] = { }; INSTANTIATE_TEST_CASE_P(TestQueueManagerMaxCombinedIndex, CircularDifference, - ::testing::ValuesIn(circularDifferenceData)); + ::testing::ValuesIn(circularDifferenceData), ); class NumGenerations : public ::testing::TestWithParam< uint32_t > { @@ -750,7 +750,7 @@ uint32_t GenerationData[] = {1, QueueManager::MAX_CAPACITY}; INSTANTIATE_TEST_CASE_P(TestQueueManagerMaxCombinedIndex, NumGenerations, - ::testing::ValuesIn(GenerationData)); + ::testing::ValuesIn(GenerationData), ); TEST(TestQueueManager, abortPushIndexReservation) { @@ -880,7 +880,7 @@ AbortData abortData[] = { }; INSTANTIATE_TEST_CASE_P(TestQueueManagerMaxCombinedIndex, AbortPush, - ::testing::ValuesIn(abortData)); + ::testing::ValuesIn(abortData), ); // Testing reservePopForClear // - Failure is returned when the head of the queue is the same as the given end @@ -1056,7 +1056,7 @@ ReserveData reserveData[] = { }; INSTANTIATE_TEST_CASE_P(TestQueueManagerReserve, Reserve, - ::testing::ValuesIn(reserveData)); + ::testing::ValuesIn(reserveData), ); TEST(TestQueueManager, Enabled) { diff --git a/test/util/test_llarp_util_thread_pool.cpp b/test/util/test_llarp_util_thread_pool.cpp index f9f9c614d..a3ad28d99 100644 --- a/test/util/test_llarp_util_thread_pool.cpp +++ b/test/util/test_llarp_util_thread_pool.cpp @@ -161,7 +161,7 @@ static const AccessorsData accessorsData[] = { {10, 50}, {1, 1}, {50, 100}, {2, 22}, {100, 200}}; INSTANTIATE_TEST_CASE_P(TestThreadPool, Accessors, - ::testing::ValuesIn(accessorsData)); + ::testing::ValuesIn(accessorsData), ); struct ClosingData { @@ -340,7 +340,7 @@ ClosingData closingData[] = {{1, 1}, {2, 2}, {10, 10}, {10, 50}, {50, 75}, {25, 80}}; INSTANTIATE_TEST_CASE_P(TestThreadPool, Closing, - ::testing::ValuesIn(closingData)); + ::testing::ValuesIn(closingData), ); struct TryAddData { diff --git a/vendor/CMakeLists.txt b/vendor/CMakeLists.txt index ff40b951b..52f3133c1 100644 --- a/vendor/CMakeLists.txt +++ b/vendor/CMakeLists.txt @@ -17,5 +17,5 @@ set(CXX_COMPAT_SRC cppbackport-master/lib/fs/direntry.cpp ) -add_library(cppbackport OBJECT ${CXX_COMPAT_SRC}) +add_library(cppbackport STATIC ${CXX_COMPAT_SRC}) target_include_directories(cppbackport PUBLIC cppbackport-master/lib)