Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 114 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,3 @@ bin
*.exe
*.out
*.app

# temporaries
.*
65 changes: 0 additions & 65 deletions .travis.yml

This file was deleted.

10 changes: 7 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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()
Expand Down
7 changes: 2 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
@@ -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*
Expand Down
27 changes: 0 additions & 27 deletions appveyor.yml

This file was deleted.

15 changes: 15 additions & 0 deletions src/io_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<sim::simulation*>(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
{
Expand Down
2 changes: 1 addition & 1 deletion src/simulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion src/socks_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ namespace sim
header[4] = static_cast<char>(it->second.size());
int idx = 5;
std::copy(it->second.begin(), it->second.end(), header.data() + idx);
idx += it->second.size();
idx += static_cast<int>(it->second.size());
header[idx] = (from_port >> 8) & 0xff;
header[idx + 1] = from_port & 0xff;

Expand Down
4 changes: 0 additions & 4 deletions src/tcp_socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -427,10 +427,6 @@ namespace ip {
void tcp::socket::async_write_some_impl(std::vector<boost::asio::const_buffer> const& bufs
, aux::function<void(boost::system::error_code const&, std::size_t)> 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))
Expand Down
4 changes: 2 additions & 2 deletions test/acceptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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));

Expand Down
2 changes: 1 addition & 1 deletion test/multi_homed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<milliseconds>(high_resolution_clock::now()
Expand Down
4 changes: 2 additions & 2 deletions test/null_buffers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand Down
Loading
Loading