Skip to content

Commit

Permalink
Bump to C++14 and remove deprecated unary_function, binary_function
Browse files Browse the repository at this point in the history
Signed-off-by: Andrea Barberio <[email protected]>
  • Loading branch information
insomniacslk committed Jan 2, 2025
1 parent af52c54 commit d81c77e
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ jobs:
cd build
cmake ..
make tests
make test
ctest
integ:
runs-on: ubuntu-latest
strategy:
Expand Down
38 changes: 11 additions & 27 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)
5 changes: 3 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://github.com/Homebrew/homebrew/pull/50000>.

Please [file an issue](https://github.com/insomniacslk/dublin-traceroute/issues/new/choose) with the necessary details if this doesn't work for you.

Expand Down
2 changes: 1 addition & 1 deletion googletest
Submodule googletest updated 381 files
4 changes: 2 additions & 2 deletions include/dublintraceroute/icmp_messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
typedef std::tuple<uint8_t, uint8_t> icmpmessage_t;


struct icmpmessage_hash: public std::unary_function<icmpmessage_t, std::size_t> {
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<icmpmessage_t, icmpmessage_t, bool> {
struct icmpmessage_equals {
bool operator()(const icmpmessage_t &left, const icmpmessage_t &right) const {
return (
std::get<0>(left) == std::get<0>(right) &&
Expand Down
1 change: 0 additions & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@

INCLUDE_DIRECTORIES(${gtest_INCLUDE_DIRS})
ADD_SUBDIRECTORY(src)

7 changes: 7 additions & 0 deletions tests/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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(
Expand Down Expand Up @@ -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)

0 comments on commit d81c77e

Please sign in to comment.