diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 703e6cb..8272194 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -127,7 +127,7 @@ jobs: cd build cmake .. make tests - make test + ctest integ: runs-on: ubuntu-latest strategy: diff --git a/CMakeLists.txt b/CMakeLists.txt index 404d4cf..1db4128 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -79,7 +79,7 @@ endif(APPLE) #set_property(TARGET dublintraceroute PROPERTY CXX_STANDARD 11) #set_property(TARGET dublintraceroute PROPERTY CXX_STANDARD_REQUIRED ON) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") add_dependencies(dublin-traceroute dublintraceroute) @@ -125,30 +125,14 @@ endif() # Testing -INCLUDE(ExternalProject) -# Only include googletest if the git submodule has been fetched -IF(EXISTS "${CMAKE_SOURCE_DIR}/googletest/CMakeLists.txt") - # Enable tests and add the test directory - MESSAGE(STATUS "Tests have been enabled") - SET(GOOGLETEST_ROOT ${CMAKE_SOURCE_DIR}/googletest) - SET(GOOGLETEST_INCLUDE ${GOOGLETEST_ROOT}/googletest/include) - SET(GOOGLETEST_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/googletest) - SET(GOOGLETEST_LIBRARY ${GOOGLETEST_BINARY_DIR}/googletest) - - ExternalProject_Add( - googletest - DOWNLOAD_COMMAND "" - SOURCE_DIR ${GOOGLETEST_ROOT} - BINARY_DIR ${GOOGLETEST_BINARY_DIR} - CMAKE_CACHE_ARGS "-DBUILD_GTEST:bool=ON" "-DBUILD_GMOCK:bool=OFF" - "-Dgtest_force_shared_crt:bool=ON" - INSTALL_COMMAND "" - ) - # Make sure we build googletest before anything else - ADD_DEPENDENCIES(dublintraceroute googletest) - ENABLE_TESTING() - ADD_SUBDIRECTORY(tests) -ELSE() - MESSAGE(STATUS "googletest git submodule is absent. Run `git submodule init && git submodule update` to get it") -ENDIF() +include(FetchContent) +FetchContent_Declare( + googletest + URL https://github.com/google/googletest/archive/refs/tags/v1.15.2.zip +) +set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) +FetchContent_MakeAvailable(googletest) +# Make sure we build googletest before anything else +ENABLE_TESTING() +ADD_SUBDIRECTORY(tests) diff --git a/docs/README.md b/docs/README.md index c3d6fea..6662d83 100644 --- a/docs/README.md +++ b/docs/README.md @@ -247,10 +247,11 @@ make You need the latest XCode installed to build this project. Then run: ```bash -brew install https://raw.githubusercontent.com/insomniacslk/dublin-traceroute/master/homebrew/dublin-traceroute.rb +wget https://raw.githubusercontent.com/insomniacslk/dublin-traceroute/master/homebrew/dublin-traceroute.rb +brew install ./dublin-traceroute.rb ``` -This will be as simple as `brew install dublin-traceroute` after https://github.com/Homebrew/homebrew/pull/50000 will be merged. +Unfortunately `dublin-traceroute` is not part of Homebrew's base packages, see . Please [file an issue](https://github.com/insomniacslk/dublin-traceroute/issues/new/choose) with the necessary details if this doesn't work for you. diff --git a/googletest b/googletest index bfc0ffc..7d76a23 160000 --- a/googletest +++ b/googletest @@ -1 +1 @@ -Subproject commit bfc0ffc8a698072c794ae7299db9cb6866f4c0bc +Subproject commit 7d76a231b0e29caf86e68d1df858308cd53b2a66 diff --git a/include/dublintraceroute/icmp_messages.h b/include/dublintraceroute/icmp_messages.h index 220d8e8..2bf9ad9 100644 --- a/include/dublintraceroute/icmp_messages.h +++ b/include/dublintraceroute/icmp_messages.h @@ -24,14 +24,14 @@ typedef std::tuple icmpmessage_t; -struct icmpmessage_hash: public std::unary_function { +struct icmpmessage_hash { std::size_t operator()(const icmpmessage_t &key) const { return std::get<0>(key) ^ std::get<1>(key); } }; -struct icmpmessage_equals: public std::binary_function { +struct icmpmessage_equals { bool operator()(const icmpmessage_t &left, const icmpmessage_t &right) const { return ( std::get<0>(left) == std::get<0>(right) && diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 9cca40f..9f1b99b 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -2,4 +2,3 @@ INCLUDE_DIRECTORIES(${gtest_INCLUDE_DIRS}) ADD_SUBDIRECTORY(src) - diff --git a/tests/src/CMakeLists.txt b/tests/src/CMakeLists.txt index b0cf7dd..8063014 100644 --- a/tests/src/CMakeLists.txt +++ b/tests/src/CMakeLists.txt @@ -1,5 +1,8 @@ # SPDX-License-Identifier: BSD-2-Clause +include(GoogleTest) +enable_testing() + # This file is shamelessly copied and modified from libtins. # Use dublintraceroute's include directories + test include directories INCLUDE_DIRECTORIES( @@ -34,11 +37,15 @@ ADD_CUSTOM_TARGET( # Test executables ADD_EXECUTABLE(UDPv4Test EXCLUDE_FROM_ALL udpv4.cxx) +gtest_discover_tests(UDPv4Test) ADD_EXECUTABLE(HopTest EXCLUDE_FROM_ALL hop.cxx) +gtest_discover_tests(HopTest) ADD_EXECUTABLE(HopsTest EXCLUDE_FROM_ALL hops.cxx) +gtest_discover_tests(HopsTest) # Tests ADD_TEST(UDPv4 UDPv4Test) ADD_TEST(Hop HopTest) ADD_TEST(Hops HopsTest) +