From c98119c27e0d9ba48e9eb8c8eab55dca993ba5b8 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Wed, 20 May 2026 11:24:05 +0200 Subject: [PATCH 1/2] update CI to use github actions --- .github/workflows/ci.yml | 114 +++++++++++++++++++++++++++++++++++++++ .gitignore | 3 -- .travis.yml | 65 ---------------------- CMakeLists.txt | 10 ++-- README.rst | 7 +-- appveyor.yml | 27 ---------- 6 files changed, 123 insertions(+), 103 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .travis.yml delete mode 100644 appveyor.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..f79a99e --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,114 @@ +name: CI + +on: + push: + branches: [ master ] + pull_request: + +concurrency: + group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }} + cancel-in-progress: true + +jobs: + + linux: + name: Linux (${{ matrix.toolset }}) + runs-on: ubuntu-24.04 + + strategy: + fail-fast: false + matrix: + include: + - toolset: gcc + - toolset: clang + + steps: + - name: checkout + uses: actions/checkout@v6 + with: + fetch-depth: 1 + + - name: update package lists + continue-on-error: true + run: sudo apt update + + - uses: Chocobo1/setup-ccache-action@v1 + with: + update_packager_index: false + override_cache_key: ccache-linux-${{ matrix.toolset }} + + - name: install boost + run: | + sudo apt install libboost-tools-dev libboost-dev libboost-system-dev + echo "using gcc ;" >>~/user-config.jam + echo "using clang ;" >>~/user-config.jam + + - name: build and run tests (b2) + run: b2 toolset=${{ matrix.toolset }} warnings-as-errors=on simulator-tests + + - name: build and run tests (cmake) + run: | + cmake -B build -DCMAKE_BUILD_TYPE=Debug -DCMAKE_POLICY_VERSION_MINIMUM=3.5 + cmake --build build --parallel + cd build && ctest --output-on-failure + + + macos: + name: macOS + runs-on: macos-latest + + steps: + - name: checkout + uses: actions/checkout@v6 + with: + fetch-depth: 1 + + - uses: Chocobo1/setup-ccache-action@v1 + with: + update_packager_index: false + override_cache_key: ccache-macos + + - name: install boost + run: | + brew install boost boost-build + echo "using darwin ;" >>~/user-config.jam + + - name: build and run tests (b2) + run: b2 warnings-as-errors=on simulator-tests + + - name: build and run tests (cmake) + run: | + cmake -B build -DCMAKE_BUILD_TYPE=Debug -DCMAKE_POLICY_VERSION_MINIMUM=3.5 + cmake --build build --parallel + cd build && ctest --output-on-failure + + + windows: + name: Windows (msvc) + runs-on: windows-latest + defaults: + run: + shell: cmd + + steps: + - name: checkout + uses: actions/checkout@v6 + with: + fetch-depth: 1 + + - name: install boost + run: | + git clone --depth=1 --recurse-submodules -j10 --branch=boost-1.91.0 https://github.com/boostorg/boost.git + cd boost + bootstrap.bat + + - name: boost headers + run: | + cd boost + .\b2 headers + + - name: build and run tests (b2) + run: | + set BOOST_ROOT=%CD%\boost + set PATH=%BOOST_ROOT%;%PATH% + b2 --hash address-model=64 warnings=all warnings-as-errors=on simulator-tests diff --git a/.gitignore b/.gitignore index b2d6672..d9397d6 100644 --- a/.gitignore +++ b/.gitignore @@ -27,6 +27,3 @@ bin *.exe *.out *.app - -# temporaries -.* diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 1c02ca3..0000000 --- a/.travis.yml +++ /dev/null @@ -1,65 +0,0 @@ -language: cpp -dist: bionic - -os: - - linux - - osx - -env: - - variant=debug - - variant=release - -branches: - only: - - master - -# container-based builds -sudo: false -cache: - directories: - - $HOME/.ccache - -# sources list: https://github.com/travis-ci/apt-source-whitelist/blob/master/ubuntu.json, -# packages list: https://github.com/travis-ci/apt-package-whitelist/blob/master/ubuntu-precise -addons: - apt: - sources: - - sourceline: ppa:mhier/libboost-latest - - ubuntu-toolchain-r-test - packages: - - libboost1.68-dev - - g++-8 - - cmake - -install: - - - 'if [[ $TRAVIS_OS_NAME != "osx" ]]; then - export B2=bjam; - else - export B2=b2; - fi' - - # on linux, pull down a recent version of boost and build boost-build - - 'if [[ $TRAVIS_OS_NAME == "linux" ]]; then - cd ..; - wget https://dl.bintray.com/boostorg/release/1.68.0/source/boost_1_68_0.zip; - unzip -qq boost_1_68_0.zip; - export BOOST_ROOT=$PWD/boost_1_68_0; - (cd boost_1_68_0/tools/build/src/engine; ./build.sh); - export BOOST_BUILD_PATH=$BOOST_ROOT/tools/build; - export PATH=$BOOST_BUILD_PATH/src/engine/bin.linuxx86_64:$PATH; - cd libsimulator; - fi' - - - 'if [ $TRAVIS_OS_NAME == "linux" ]; then echo "using gcc : : ccache g++-8 ;" > ~/user-config.jam; export CXX="g++-8" ; fi' - - 'if [ $TRAVIS_OS_NAME == "osx" ]; then echo "using darwin : : ccache clang++ : -std=c++14 -Wno-deprecated-declarations ;" > ~/user-config.jam; fi' - - if [ $TRAVIS_OS_NAME == "osx" ]; then brew update > /dev/null && brew install ccache boost-build && brew upgrade cmake ; fi - - ccache -V && ccache --show-stats && ccache --zero-stats - -script: -# until we have a version of boost-build that's new enough, disable warnings -# as errors - - ${B2} --hash -j3 variant=$variant -l900 warnings-as-errors=off - - mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=$variant .. && make -j3 && make test - - ccache --show-stats - diff --git a/CMakeLists.txt b/CMakeLists.txt index 8ce97ca..a805d25 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,10 @@ set(INCLUDE_DIR include) set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) -find_package(Boost COMPONENTS system REQUIRED) +# Boost.System is header-only (since Boost 1.69), so we only need the Boost +# headers. Requesting the "system" component fails with recent Boost releases +# that no longer ship a boost_system CMake config file. +find_package(Boost REQUIRED) find_package(Threads REQUIRED) set(SIMULATOR_SRC_FILES @@ -31,7 +34,8 @@ set(SIMULATOR_SRC_FILES ) add_library(simulator ${SIMULATOR_SRC_FILES}) -include_directories(${Boost_INCLUDE_DIR} ${INCLUDE_DIR}) +target_include_directories(simulator PUBLIC ${INCLUDE_DIR}) +target_link_libraries(simulator PUBLIC Boost::boost) if(WIN32) target_link_libraries(simulator PRIVATE ws2_32) @@ -42,7 +46,7 @@ enable_testing() function(define_test) set(NAME ${ARGV0}) add_executable(${NAME} ${TEST_SRC_DIR}/${NAME}.cpp ${TEST_SRC_DIR}/main.cpp) - target_link_libraries(${NAME} simulator ${Boost_LIBRARIES}) + target_link_libraries(${NAME} simulator) target_link_libraries(${NAME} Threads::Threads) add_test(NAME ${NAME} COMMAND ${NAME}) endfunction() diff --git a/README.rst b/README.rst index 6b9379d..8fb68fa 100644 --- a/README.rst +++ b/README.rst @@ -1,11 +1,8 @@ libsimulator ============ -.. image:: https://travis-ci.org/arvidn/libsimulator.svg?branch=master - :target: https://travis-ci.org/arvidn/libsimulator - -.. image:: https://ci.appveyor.com/api/projects/status/0857n4g3f6mui90i/branch/master - :target: https://ci.appveyor.com/project/arvidn/libsimulator/branch/master +.. image:: https://github.com/arvidn/libsimulator/actions/workflows/ci.yml/badge.svg?branch=master + :target: https://github.com/arvidn/libsimulator/actions/workflows/ci.yml *This is still in initial development, some of this README represents ambitions rather than the current state* diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index b5b1f48..0000000 --- a/appveyor.yml +++ /dev/null @@ -1,27 +0,0 @@ -version: 1.0.{build} -image: Visual Studio 2017 -branches: - only: - - master -skip_tags: true -clone_depth: 1 -install: -- set BUILD_DIR=%CD% -- set BOOST_ROOT=c:\Libraries\boost_1_67_0 -- set BOOST_BUILD_PATH=%BOOST_ROOT%\tools\build -- echo %BOOST_ROOT% -- echo %BOOST_BUILD_PATH% -- set PATH=%PATH%;%BOOST_BUILD_PATH%\src\engine\bin.ntx86 -- set PATH=c:\msys64\mingw32\bin;%PATH% -- g++ --version -- copy user-config.jam %HOMEDRIVE%%HOMEPATH%\user-config.jam -- cd %BOOST_BUILD_PATH%\src\engine -- build.bat >nul -- cd %BUILD_DIR% -environment: - matrix: - - compiler: msvc-14.1 - - compiler: gcc -build_script: -- b2.exe --hash warnings-as-errors=on -j2 address-model=32 %compiler% - From 84ae0035da6973f74810745f0a66135c99cce518 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Wed, 20 May 2026 11:39:03 +0200 Subject: [PATCH 2/2] fix warnings --- src/io_service.cpp | 15 +++++++++++++++ src/simulator.cpp | 2 +- src/socks_server.cpp | 2 +- src/tcp_socket.cpp | 4 ---- test/acceptor.cpp | 4 ++-- test/multi_homed.cpp | 2 +- test/null_buffers.cpp | 4 ++-- test/parse_request.cpp | 12 ++++++------ test/resolver.cpp | 6 +++--- test/udp_socket.cpp | 6 +++--- 10 files changed, 34 insertions(+), 23 deletions(-) diff --git a/src/io_service.cpp b/src/io_service.cpp index b48d7a5..049c957 100644 --- a/src/io_service.cpp +++ b/src/io_service.cpp @@ -49,11 +49,26 @@ namespace sim { namespace asio { m_sim.remove_io_service(this); } + // this constructor is never meant to be called (hence the assert). It only + // exists to satisfy interfaces that require a default-like constructor. The + // null reference is deliberate, so suppress the warning about it. +#if defined __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wnull-dereference" +#elif defined __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wnull-dereference" +#endif io_context::io_context(std::size_t) : m_sim(*reinterpret_cast(0)) { assert(false); } +#if defined __clang__ +#pragma clang diagnostic pop +#elif defined __GNUC__ +#pragma GCC diagnostic pop +#endif int io_context::get_path_mtu(const asio::ip::address& source, const asio::ip::address& dest) const { diff --git a/src/simulator.cpp b/src/simulator.cpp index 79cfa4e..0d004ad 100644 --- a/src/simulator.cpp +++ b/src/simulator.cpp @@ -60,7 +60,7 @@ namespace : m_ioc(ioc) {} - virtual void incoming_packet(aux::packet p) override final { assert(false); } + virtual void incoming_packet(aux::packet /* p */) override final { assert(false); } virtual std::string label() const override final { diff --git a/src/socks_server.cpp b/src/socks_server.cpp index 54513f1..cfd1771 100644 --- a/src/socks_server.cpp +++ b/src/socks_server.cpp @@ -715,7 +715,7 @@ namespace sim header[4] = static_cast(it->second.size()); int idx = 5; std::copy(it->second.begin(), it->second.end(), header.data() + idx); - idx += it->second.size(); + idx += static_cast(it->second.size()); header[idx] = (from_port >> 8) & 0xff; header[idx + 1] = from_port & 0xff; diff --git a/src/tcp_socket.cpp b/src/tcp_socket.cpp index 302fdcf..987129c 100644 --- a/src/tcp_socket.cpp +++ b/src/tcp_socket.cpp @@ -427,10 +427,6 @@ namespace ip { void tcp::socket::async_write_some_impl(std::vector const& bufs , aux::function handler) { - int buf_size = 0; - for (int i = 0; i < int(bufs.size()); ++i) - buf_size += int(bufs[i].size()); - boost::system::error_code ec; std::size_t const bytes_transferred = write_some_impl(bufs, ec); if (ec == boost::system::error_code(error::would_block)) diff --git a/test/acceptor.cpp b/test/acceptor.cpp index b308f3e..6c3c34b 100644 --- a/test/acceptor.cpp +++ b/test/acceptor.cpp @@ -49,7 +49,7 @@ void on_sent(boost::system::error_code const& ec, std::size_t bytes_transferred return; } - num_sent += bytes_transferred; + num_sent += int(bytes_transferred); std::printf("[%4d] sent %d bytes\n", millis, int(bytes_transferred)); std::printf("closing\n"); @@ -67,7 +67,7 @@ void on_receive(boost::system::error_code const& ec return; } - num_received += bytes_transferred; + num_received += int(bytes_transferred); std::printf("[%4d] received %d bytes\n", millis, int(bytes_transferred)); diff --git a/test/multi_homed.cpp b/test/multi_homed.cpp index 2522d7c..2751414 100644 --- a/test/multi_homed.cpp +++ b/test/multi_homed.cpp @@ -43,7 +43,7 @@ int num_ipv4 = 0; } -void on_receive(boost::system::error_code const& ec, std::size_t bytes_transferred +void on_receive(boost::system::error_code const& ec, std::size_t /* bytes_transferred */ , udp::socket& s) { int millis = int(duration_cast(high_resolution_clock::now() diff --git a/test/null_buffers.cpp b/test/null_buffers.cpp index f95cb3e..182f302 100644 --- a/test/null_buffers.cpp +++ b/test/null_buffers.cpp @@ -47,7 +47,7 @@ void on_sent(boost::system::error_code const& ec, std::size_t bytes_transferred return; } - num_sent += bytes_transferred; + num_sent += int(bytes_transferred); std::printf("[%4d] sent %d bytes (total: %d)\n" , millis, int(bytes_transferred), num_sent); @@ -81,7 +81,7 @@ void on_receive(boost::system::error_code const& ec, ip::tcp::socket& sock) return; } - num_received += bytes_transferred; + num_received += int(bytes_transferred); std::printf("[%4d] received %d bytes (total: %d)\n" , millis, int(bytes_transferred), num_received); diff --git a/test/parse_request.cpp b/test/parse_request.cpp index d26bf7d..5e17d48 100644 --- a/test/parse_request.cpp +++ b/test/parse_request.cpp @@ -30,7 +30,7 @@ All rights reserved. TEST_CASE("parse GET request", "[parse_request]") { auto str = "GET /foo/bar?x=4 HTTP/1.1\r\n\r\n"; - sim::http_request req = sim::parse_request(str, std::strlen(str)); + sim::http_request req = sim::parse_request(str, static_cast(std::strlen(str))); CHECK(req.method == "GET"); CHECK(req.req == "/foo/bar?x=4"); CHECK(req.path == "/foo/bar"); @@ -40,21 +40,21 @@ TEST_CASE("parse GET request", "[parse_request]") TEST_CASE("request path is normalized (no leading slash)", "[parse_request]") { auto str = "GET foo/bar HTTP/1.1\r\n\r\n"; - sim::http_request req = sim::parse_request(str, std::strlen(str)); + sim::http_request req = sim::parse_request(str, static_cast(std::strlen(str))); CHECK(req.path == "/foo/bar"); } TEST_CASE("request path is normalized (..)", "[parse_request]") { auto str = "GET /foo/../foo/bar HTTP/1.1\r\n\r\n"; - sim::http_request req = sim::parse_request(str, std::strlen(str)); + sim::http_request req = sim::parse_request(str, static_cast(std::strlen(str))); CHECK(req.path == "/foo/bar"); } TEST_CASE("parse CONNECT request", "[parse_request]") { auto str = "CONNECT 192.168.0.1:8888 HTTP/1.1\r\n\r\n"; - sim::http_request req = sim::parse_request(str, std::strlen(str)); + sim::http_request req = sim::parse_request(str, static_cast(std::strlen(str))); CHECK(req.method == "CONNECT"); CHECK(req.req == "192.168.0.1:8888"); CHECK(req.path == "192.168.0.1:8888"); @@ -64,7 +64,7 @@ TEST_CASE("parse CONNECT request", "[parse_request]") TEST_CASE("headers are parsed", "[parse_request]") { auto str = "GET / HTTP/1.1\r\nX-Foo: Bar\r\n\r\n"; - sim::http_request req = sim::parse_request(str, std::strlen(str)); + sim::http_request req = sim::parse_request(str, static_cast(std::strlen(str))); CHECK(!req.headers.empty()); CHECK(req.headers["x-foo"] == "Bar"); } @@ -72,5 +72,5 @@ TEST_CASE("headers are parsed", "[parse_request]") TEST_CASE("invalid formed request throws parse exception", "[parse_request]") { auto str = "INVALID"; - REQUIRE_THROWS_WITH(sim::parse_request(str, std::strlen(str)), Catch::Matchers::ContainsSubstring("parse failed")); + REQUIRE_THROWS_WITH(sim::parse_request(str, static_cast(std::strlen(str))), Catch::Matchers::ContainsSubstring("parse failed")); } diff --git a/test/resolver.cpp b/test/resolver.cpp index 95c1d4e..266f16c 100644 --- a/test/resolver.cpp +++ b/test/resolver.cpp @@ -37,7 +37,7 @@ using chrono::milliseconds; int num_lookups = 0; -void on_name_lookup(boost::system::error_code const& ec +void on_name_lookup(boost::system::error_code const& /* ec */ , asio::ip::tcp::resolver::results_type ips) { ++num_lookups; @@ -62,7 +62,7 @@ void on_name_lookup(boost::system::error_code const& ec } void on_failed_name_lookup(boost::system::error_code const& ec - , asio::ip::tcp::resolver::results_type ips) + , asio::ip::tcp::resolver::results_type /* ips */) { ++num_lookups; @@ -166,7 +166,7 @@ TEST_CASE("resolve an IP address", "[resolver]") { asio::ip::tcp::resolver resolver(ios); resolver.async_resolve("10.10.10.10", "8080" - , [](boost::system::error_code const& ec, asio::ip::tcp::resolver::results_type ips) + , [](boost::system::error_code const& /* ec */, asio::ip::tcp::resolver::results_type ips) { ++num_lookups; std::vector expect = { make_address_v4("10.10.10.10") }; diff --git a/test/udp_socket.cpp b/test/udp_socket.cpp index 0cdba3e..e33d267 100644 --- a/test/udp_socket.cpp +++ b/test/udp_socket.cpp @@ -53,7 +53,7 @@ void on_receive(boost::system::error_code const& ec, std::size_t bytes_transferr return; } - num_received += bytes_transferred; + num_received += int(bytes_transferred); std::printf("[%4d] received %d bytes from %s\n", millis , int(bytes_transferred) @@ -97,8 +97,8 @@ TEST_CASE("send packet to udp socket", "[udp_socket]") for (int i = 1; i < 10; ++i) { - num_sent += outgoing.send_to(asio::buffer(send_buf, 100 * i) - , udp::endpoint(make_address_v4("40.30.20.10"), 1337), 0, ec); + num_sent += int(outgoing.send_to(asio::buffer(send_buf, 100 * i) + , udp::endpoint(make_address_v4("40.30.20.10"), 1337), 0, ec)); REQUIRE(!ec); }