Organize source files in CMakeLists with source_group

This commit is contained in:
Mohammad Nejati
2024-11-23 06:20:00 +00:00
committed by Mohammad Nejati
parent 75e45287fb
commit 827ecf5e93
70 changed files with 285 additions and 816 deletions

View File

@ -12,6 +12,10 @@ add_executable(advanced-server-flex-awaitable
Jamfile
advanced_server_flex_awaitable.cpp)
source_group("" FILES
Jamfile
advanced_server_flex_awaitable.cpp)
target_include_directories(advanced-server-flex-awaitable
PRIVATE ${PROJECT_SOURCE_DIR})

View File

@ -12,6 +12,10 @@ add_executable(advanced-server-flex
Jamfile
advanced_server_flex.cpp)
source_group("" FILES
Jamfile
advanced_server_flex.cpp)
target_include_directories(advanced-server-flex
PRIVATE ${PROJECT_SOURCE_DIR})

View File

@ -12,6 +12,10 @@ add_executable(advanced-server
Jamfile
advanced_server.cpp)
source_group("" FILES
Jamfile
advanced_server.cpp)
target_link_libraries(advanced-server PRIVATE Boost::beast)
set_target_properties(advanced-server PROPERTIES FOLDER "example-advanced-server")

View File

@ -12,6 +12,10 @@ add_executable(echo-op
Jamfile
echo_op.cpp)
source_group("" FILES
Jamfile
echo_op.cpp)
target_link_libraries(echo-op PRIVATE Boost::beast)
set_target_properties(echo-op

View File

@ -12,6 +12,10 @@ add_executable(http-client-async-ssl-system-executor
Jamfile
http_client_async_ssl_system_executor.cpp)
source_group("" FILES
Jamfile
http_client_async_ssl_system_executor.cpp)
target_include_directories(http-client-async-ssl-system-executor
PRIVATE ${PROJECT_SOURCE_DIR})

View File

@ -12,6 +12,10 @@ add_executable(http-client-async-ssl
Jamfile
http_client_async_ssl.cpp)
source_group("" FILES
Jamfile
http_client_async_ssl.cpp)
target_include_directories(http-client-async-ssl
PRIVATE ${PROJECT_SOURCE_DIR})

View File

@ -12,6 +12,10 @@ add_executable(http-client-async
Jamfile
http_client_async.cpp)
source_group("" FILES
Jamfile
http_client_async.cpp)
target_link_libraries(http-client-async PRIVATE Boost::beast)
set_target_properties(http-client-async

View File

@ -12,6 +12,10 @@ add_executable(http-client-awaitable-ssl
Jamfile
http_client_awaitable_ssl.cpp)
source_group("" FILES
Jamfile
http_client_awaitable_ssl.cpp)
target_include_directories(http-client-awaitable-ssl
PRIVATE ${PROJECT_SOURCE_DIR})

View File

@ -12,6 +12,10 @@ add_executable(http-client-awaitable
Jamfile
http_client_awaitable.cpp)
source_group("" FILES
Jamfile
http_client_awaitable.cpp)
target_link_libraries(http-client-awaitable PRIVATE Boost::beast)
set_target_properties(http-client-awaitable

View File

@ -12,6 +12,10 @@ add_executable(http-client-json
Jamfile
json_client.cpp)
source_group("" FILES
Jamfile
json_client.cpp)
target_link_libraries(http-client-json PRIVATE Boost::beast Boost::json)
set_target_properties(http-client-json

View File

@ -12,6 +12,10 @@ add_executable(http-client-coro-ssl
Jamfile
http_client_coro_ssl.cpp)
source_group("" FILES
Jamfile
http_client_coro_ssl.cpp)
target_include_directories(http-client-coro-ssl
PRIVATE ${PROJECT_SOURCE_DIR})

View File

@ -12,6 +12,10 @@ add_executable(http-client-coro
Jamfile
http_client_coro.cpp)
source_group("" FILES
Jamfile
http_client_coro.cpp)
target_link_libraries(http-client-coro PRIVATE Boost::beast)
set_target_properties(http-client-coro

View File

@ -13,6 +13,11 @@ add_executable(http-crawl
http_crawl.cpp
urls_large_data.cpp)
source_group("" FILES
Jamfile
http_crawl.cpp
urls_large_data.cpp)
target_link_libraries(http-crawl PRIVATE Boost::beast)
set_target_properties(http-crawl

View File

@ -12,6 +12,10 @@ add_executable(http-client-methods
Jamfile
http_client_methods.cpp)
source_group("" FILES
Jamfile
http_client_methods.cpp)
target_link_libraries(http-client-methods PRIVATE Boost::beast)
set_target_properties(http-client-methods

View File

@ -12,6 +12,10 @@ add_executable(http-client-sync-ssl
Jamfile
http_client_sync_ssl.cpp)
source_group("" FILES
Jamfile
http_client_sync_ssl.cpp)
target_include_directories(http-client-sync-ssl
PRIVATE ${PROJECT_SOURCE_DIR})

View File

@ -12,6 +12,10 @@ add_executable(http-client-sync
Jamfile
http_client_sync.cpp)
source_group("" FILES
Jamfile
http_client_sync.cpp)
target_link_libraries(http-client-sync PRIVATE Boost::beast)
set_target_properties(http-client-sync

View File

@ -12,6 +12,10 @@ add_executable(http-server-async-ssl
Jamfile
http_server_async_ssl.cpp)
source_group("" FILES
Jamfile
http_server_async_ssl.cpp)
target_include_directories(http-server-async-ssl
PRIVATE ${PROJECT_SOURCE_DIR})

View File

@ -12,6 +12,10 @@ add_executable(http-server-async
Jamfile
http_server_async.cpp)
source_group("" FILES
Jamfile
http_server_async.cpp)
target_link_libraries(http-server-async PRIVATE Boost::beast)
set_target_properties(http-server-async

View File

@ -12,6 +12,10 @@ add_executable(http-server-awaitable
Jamfile
http_server_awaitable.cpp)
source_group("" FILES
Jamfile
http_server_awaitable.cpp)
target_link_libraries(http-server-awaitable PRIVATE Boost::beast)
set_target_properties(http-server-awaitable

View File

@ -12,6 +12,10 @@ add_executable(http-server-coro-ssl
Jamfile
http_server_coro_ssl.cpp)
source_group("" FILES
Jamfile
http_server_coro_ssl.cpp)
target_include_directories(http-server-coro-ssl
PRIVATE ${PROJECT_SOURCE_DIR})

View File

@ -12,6 +12,10 @@ add_executable(http-server-coro
Jamfile
http_server_coro.cpp)
source_group("" FILES
Jamfile
http_server_coro.cpp)
target_link_libraries(http-server-coro PRIVATE Boost::beast)
set_target_properties(http-server-coro

View File

@ -12,6 +12,10 @@ add_executable(http-server-fast
Jamfile
http_server_fast.cpp)
source_group("" FILES
Jamfile
http_server_fast.cpp)
target_link_libraries(http-server-fast PRIVATE Boost::beast)
set_target_properties(http-server-fast

View File

@ -12,6 +12,10 @@ add_executable(http-server-flex
Jamfile
http_server_flex.cpp)
source_group("" FILES
Jamfile
http_server_flex.cpp)
target_include_directories(http-server-flex
PRIVATE ${PROJECT_SOURCE_DIR})

View File

@ -12,6 +12,10 @@ add_executable(http-server-small
Jamfile
http_server_small.cpp)
source_group("" FILES
Jamfile
http_server_small.cpp)
target_link_libraries(http-server-small PRIVATE Boost::beast)
set_target_properties(http-server-small

View File

@ -12,6 +12,10 @@ add_executable(http-server-stackless-ssl
Jamfile
http_server_stackless_ssl.cpp)
source_group("" FILES
Jamfile
http_server_stackless_ssl.cpp)
target_include_directories(http-server-stackless-ssl
PRIVATE ${PROJECT_SOURCE_DIR})

View File

@ -12,6 +12,10 @@ add_executable(http-server-stackless
Jamfile
http_server_stackless.cpp)
source_group("" FILES
Jamfile
http_server_stackless.cpp)
target_link_libraries(http-server-stackless PRIVATE Boost::beast)
set_target_properties(http-server-stackless

View File

@ -12,6 +12,10 @@ add_executable(http-server-sync-ssl
Jamfile
http_server_sync_ssl.cpp)
source_group("" FILES
Jamfile
http_server_sync_ssl.cpp)
target_include_directories(http-server-sync-ssl
PRIVATE ${PROJECT_SOURCE_DIR})

View File

@ -12,6 +12,10 @@ add_executable(http-server-sync
Jamfile
http_server_sync.cpp)
source_group("" FILES
Jamfile
http_server_sync.cpp)
target_link_libraries(http-server-sync PRIVATE Boost::beast)
set_target_properties(http-server-sync

View File

@ -12,6 +12,10 @@ add_executable(websocket-client-async-ssl-system-executor
Jamfile
websocket_client_async_ssl_system_executor.cpp)
source_group("" FILES
Jamfile
websocket_client_async_ssl_system_executor.cpp)
target_include_directories(websocket-client-async-ssl-system-executor
PRIVATE ${PROJECT_SOURCE_DIR})

View File

@ -12,6 +12,10 @@ add_executable(websocket-client-async-ssl
Jamfile
websocket_client_async_ssl.cpp)
source_group("" FILES
Jamfile
websocket_client_async_ssl.cpp)
target_include_directories(websocket-client-async-ssl
PRIVATE ${PROJECT_SOURCE_DIR})

View File

@ -12,6 +12,10 @@ add_executable(websocket-client-async
Jamfile
websocket_client_async.cpp)
source_group("" FILES
Jamfile
websocket_client_async.cpp)
target_link_libraries(websocket-client-async PRIVATE Boost::beast)
set_target_properties(websocket-client-async

View File

@ -12,6 +12,10 @@ add_executable(websocket-client-awaitable
Jamfile
websocket_client_awaitable.cpp)
source_group("" FILES
Jamfile
websocket_client_awaitable.cpp)
target_link_libraries(websocket-client-awaitable PRIVATE Boost::beast)
set_target_properties(websocket-client-awaitable

View File

@ -12,6 +12,10 @@ add_executable(websocket-client-coro-ssl
Jamfile
websocket_client_coro_ssl.cpp)
source_group("" FILES
Jamfile
websocket_client_coro_ssl.cpp)
target_include_directories(websocket-client-coro-ssl
PRIVATE ${PROJECT_SOURCE_DIR})

View File

@ -12,6 +12,10 @@ add_executable(websocket-client-coro
Jamfile
websocket_client_coro.cpp)
source_group("" FILES
Jamfile
websocket_client_coro.cpp)
target_link_libraries(websocket-client-coro PRIVATE Boost::beast)
set_target_properties(websocket-client-coro

View File

@ -12,6 +12,10 @@ add_executable(websocket-client-sync-ssl
Jamfile
websocket_client_sync_ssl.cpp)
source_group("" FILES
Jamfile
websocket_client_sync_ssl.cpp)
target_include_directories(websocket-client-sync-ssl
PRIVATE ${PROJECT_SOURCE_DIR})

View File

@ -12,6 +12,10 @@ add_executable(websocket-client-sync
Jamfile
websocket_client_sync.cpp)
source_group("" FILES
Jamfile
websocket_client_sync.cpp)
target_link_libraries(websocket-client-sync PRIVATE Boost::beast)
set_target_properties(websocket-client-sync

View File

@ -12,6 +12,10 @@ add_executable(websocket-server-async-ssl
Jamfile
websocket_server_async_ssl.cpp)
source_group("" FILES
Jamfile
websocket_server_async_ssl.cpp)
target_include_directories(websocket-server-async-ssl
PRIVATE ${PROJECT_SOURCE_DIR})

View File

@ -12,6 +12,10 @@ add_executable(websocket-server-async
Jamfile
websocket_server_async.cpp)
source_group("" FILES
Jamfile
websocket_server_async.cpp)
target_link_libraries(websocket-server-async PRIVATE Boost::beast)
set_target_properties(websocket-server-async

View File

@ -12,6 +12,10 @@ add_executable(websocket-server-awaitable
Jamfile
websocket_server_awaitable.cpp)
source_group("" FILES
Jamfile
websocket_server_awaitable.cpp)
target_link_libraries(websocket-server-awaitable PRIVATE Boost::beast)
set_target_properties(websocket-server-awaitable

View File

@ -23,6 +23,21 @@ add_executable(websocket-chat-multi
websocket_session.cpp
websocket_session.hpp)
source_group("" FILES
beast.hpp
chat_client.html
http_session.cpp
http_session.hpp
Jamfile
listener.cpp
listener.hpp
main.cpp
net.hpp
shared_state.cpp
shared_state.hpp
websocket_session.cpp
websocket_session.hpp)
target_link_libraries(websocket-chat-multi PRIVATE Boost::beast)
set_target_properties(websocket-chat-multi

View File

@ -12,6 +12,10 @@ add_executable(websocket-server-coro-ssl
Jamfile
websocket_server_coro_ssl.cpp)
source_group("" FILES
Jamfile
websocket_server_coro_ssl.cpp)
target_include_directories(websocket-server-coro-ssl
PRIVATE ${PROJECT_SOURCE_DIR})

View File

@ -12,6 +12,10 @@ add_executable(websocket-server-coro
Jamfile
websocket_server_coro.cpp)
source_group("" FILES
Jamfile
websocket_server_coro.cpp)
target_link_libraries(websocket-server-coro PRIVATE Boost::beast)
set_target_properties(websocket-server-coro

View File

@ -12,6 +12,10 @@ add_executable(websocket-server-fast
Jamfile
websocket_server_fast.cpp)
source_group("" FILES
Jamfile
websocket_server_fast.cpp)
target_link_libraries(websocket-server-fast PRIVATE Boost::beast)
set_target_properties(websocket-server-fast

View File

@ -12,6 +12,10 @@ add_executable(websocket-server-stackless-ssl
Jamfile
websocket_server_stackless_ssl.cpp)
source_group("" FILES
Jamfile
websocket_server_stackless_ssl.cpp)
target_include_directories(websocket-server-stackless-ssl
PRIVATE ${PROJECT_SOURCE_DIR})

View File

@ -12,6 +12,10 @@ add_executable(websocket-server-stackless
Jamfile
websocket_server_stackless.cpp)
source_group("" FILES
Jamfile
websocket_server_stackless.cpp)
target_link_libraries(websocket-server-stackless PRIVATE Boost::beast)
set_target_properties(websocket-server-stackless

View File

@ -12,6 +12,10 @@ add_executable(websocket-server-sync-ssl
Jamfile
websocket_server_sync_ssl.cpp)
source_group("" FILES
Jamfile
websocket_server_sync_ssl.cpp)
target_include_directories(websocket-server-sync-ssl
PRIVATE ${PROJECT_SOURCE_DIR})

View File

@ -12,6 +12,10 @@ add_executable(websocket-server-sync
Jamfile
websocket_server_sync.cpp)
source_group("" FILES
Jamfile
websocket_server_sync.cpp)
target_link_libraries(websocket-server-sync PRIVATE Boost::beast)
set_target_properties(websocket-server-sync

View File

@ -12,6 +12,7 @@ find_package(OpenSSL)
# lib-asio
add_library(lib-asio STATIC lib_asio.cpp)
source_group("" FILES lib_asio.cpp)
target_compile_definitions(lib-asio PUBLIC
BOOST_ASIO_SEPARATE_COMPILATION
BOOST_ASIO_NO_DEPRECATED
@ -24,12 +25,14 @@ set_target_properties(lib-asio PROPERTIES FOLDER "static-libs")
# lib-asio-ssl
add_library(lib-asio-ssl STATIC lib_asio_ssl.cpp)
source_group("" FILES lib_asio_ssl.cpp)
target_link_libraries(lib-asio-ssl PUBLIC lib-asio)
target_link_libraries(lib-asio-ssl PUBLIC OpenSSL::SSL OpenSSL::Crypto)
set_target_properties(lib-asio-ssl PROPERTIES FOLDER "static-libs")
# lib-beast
add_library(lib-beast STATIC lib_beast.cpp)
source_group("" FILES lib_beast.cpp)
target_compile_definitions(lib-beast PUBLIC BOOST_BEAST_SEPARATE_COMPILATION)
target_link_libraries(lib-beast PUBLIC Boost::beast lib-asio)
set_target_properties(lib-beast PROPERTIES FOLDER "static-libs")
@ -58,6 +61,7 @@ set_target_properties(lib-zlib PROPERTIES FOLDER "static-libs")
# lib-test
add_library(lib-test STATIC lib_test.cpp)
source_group("" FILES lib_test.cpp)
target_include_directories(lib-test PUBLIC extras/include)
target_link_libraries(lib-test PUBLIC lib-beast)
set_target_properties(lib-test PROPERTIES FOLDER "static-libs")

View File

@ -27,6 +27,15 @@ add_executable(tests-beast
websocket.cpp
zlib.cpp)
source_group("" FILES
Jamfile
core.cpp
http.cpp
ssl.cpp
version.cpp
websocket.cpp
zlib.cpp)
target_link_libraries(tests-beast
lib-asio-ssl
lib-test)

View File

@ -15,7 +15,15 @@ add_executable(tests-beast-_experimental
icy_stream.cpp
stream.cpp)
source_group("" FILES
Jamfile
_test_detail_stream_state.cpp
error.cpp
icy_stream.cpp
stream.cpp)
target_link_libraries(tests-beast-_experimental
lib-asio-ssl
lib-test)
set_target_properties(tests-beast-_experimental

View File

@ -8,60 +8,11 @@
# Official repository: https://github.com/boostorg/beast
#
add_executable(tests-beast-core
Jamfile
test_buffer.hpp
file_test.hpp
stream_tests.hpp
test_handler.hpp
_detail_base64.cpp
_detail_bind_continuation.cpp
_detail_buffer.cpp
_detail_clamp.cpp
_detail_get_io_context.cpp
_detail_is_invocable.cpp
_detail_read.cpp
_detail_sha1.cpp
_detail_tuple.cpp
_detail_variant.cpp
_detail_varint.cpp
async_base.cpp
basic_stream.cpp
bind_handler.cpp
buffer_ref.cpp
buffer_traits.cpp
buffered_read_stream.cpp
buffers_adaptor.cpp
buffers_cat.cpp
buffers_generator.cpp
buffers_prefix.cpp
buffers_range.cpp
buffers_suffix.cpp
buffers_to_string.cpp
detect_ssl.cpp
error.cpp
file.cpp
file_base.cpp
file_posix.cpp
file_stdio.cpp
file_win32.cpp
filtering_cancellation_slot.cpp
flat_buffer.cpp
flat_static_buffer.cpp
flat_stream.cpp
make_printable.cpp
multi_buffer.cpp
ostream.cpp
rate_policy.cpp
read_size.cpp
role.cpp
saved_handler.cpp
span.cpp
static_buffer.cpp
static_string.cpp
stream_traits.cpp
string.cpp
tcp_stream.cpp)
file(GLOB_RECURSE PFILES CONFIGURE_DEPENDS Jamfile *.cpp *.hpp)
add_executable(tests-beast-core ${PFILES})
source_group("" FILES ${PFILES})
target_link_libraries(tests-beast-core
lib-test

View File

@ -1,44 +0,0 @@
//
// Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Official repository: https://github.com/boostorg/beast
//
// Test that header file is self-contained.
#include <boost/beast/core/detail/static_const.hpp>
#include <boost/beast/_experimental/unit_test/suite.hpp>
#include <boost/beast/core/close_socket.hpp>
namespace boost {
namespace beast {
struct foo_impl
{
void operator()() const noexcept
{
BEAST_PASS();
}
};
constexpr auto& bar =
boost::beast::detail::static_const<detail::close_socket_impl>::value;
class static_const_test : public beast::unit_test::suite
{
public:
void
run() override
{
pass();
}
};
BEAST_DEFINE_TESTSUITE(beast,core,static_const);
} // beast
} // boost

View File

@ -1,39 +0,0 @@
//
// Copyright (c) 2018 Vinnie Falco (vinnie dot falco at gmail dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Official repository: https://github.com/boostorg/beast
//
// Test that header file is self-contained.
#include <boost/beast/core/close_socket.hpp>
#include <boost/beast/_experimental/unit_test/suite.hpp>
#include <boost/beast/_experimental/test/stream.hpp>
#include <boost/beast/core/stream_traits.hpp>
#include <boost/beast/core/string.hpp>
#include <boost/asio/ip/tcp.hpp>
#include <boost/asio/write.hpp>
#include <utility>
namespace boost {
namespace beast {
class close_socket_test : public beast::unit_test::suite
{
public:
void
run() override
{
testClose();
testJavadocs();
}
};
BEAST_DEFINE_TESTSUITE(beast,core,close_socket);
} // beast
} // boost

View File

@ -1,49 +0,0 @@
//
// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Official repository: https://github.com/boostorg/beast
//
// Test that header file is self-contained.
#include <boost/beast/core/net::make_strand.hpp>
#include <boost/beast/_experimental/unit_test/suite.hpp>
#include <boost/asio/executor.hpp>
#include <boost/asio/io_context.hpp>
namespace boost {
namespace beast {
class make_strand_test : public beast::unit_test::suite
{
public:
void
testFunction()
{
net::io_context ioc;
net::make_strand(ioc);
net::make_strand(ioc.get_executor());
net::make_strand(net::make_strand(ioc));
net::any_io_executor ex(ioc.get_executor());
net::make_strand(ex);
// this *should-not* compile
//net::make_strand(ex.context());
}
void
run() override
{
testFunction();
pass();
}
};
BEAST_DEFINE_TESTSUITE(beast,core,net::make_strand);
} // beast
} // boost

View File

@ -1,12 +0,0 @@
//
// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Official repository: https://github.com/boostorg/beast
//
// Test that header file is self-contained.
#include <beast/core/prepare_buffers.hpp>

View File

@ -1,235 +0,0 @@
//
// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Official repository: https://github.com/boostorg/beast
//
// Test that header file is self-contained.
#include <beast/detail/zlib/deflate_stream.hpp>
#include <beast/detail/zlib/inflate_stream.hpp>
#include <beast/unit_test/suite.hpp>
#include <array>
#include <cassert>
#include <memory>
#include <random>
namespace boost {
namespace beast {
namespace zlib {
class zlib_test : public beast::unit_test::suite
{
public:
class buffer
{
std::size_t size_ = 0;
std::size_t capacity_ = 0;
std::unique_ptr<std::uint8_t[]> p_;
public:
buffer() = default;
buffer(buffer&&) = default;
buffer& operator=(buffer&&) = default;
explicit
buffer(std::size_t capacity)
{
reserve(capacity);
}
bool
empty() const
{
return size_ == 0;
}
std::size_t
size() const
{
return size_;
}
std::size_t
capacity() const
{
return capacity_;
}
std::uint8_t const*
data() const
{
return p_.get();
}
std::uint8_t*
data()
{
return p_.get();
}
void
reserve(std::size_t capacity)
{
if(capacity != capacity_)
{
p_.reset(new std::uint8_t[capacity]);
capacity_ = capacity;
}
}
void
resize(std::size_t size)
{
assert(size <= capacity_);
size_ = size;
}
};
buffer
make_source1(std::size_t size)
{
std::mt19937 rng;
buffer b(size);
auto p = b.data();
std::size_t n = 0;
static std::string const chars(
"01234567890{}\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
"{{{{{{{{{{}}}}}}}}}} ");
while(n < size)
{
*p++ = chars[rng()%chars.size()];
++n;
}
b.resize(n);
return b;
}
buffer
make_source2(std::size_t size)
{
std::mt19937 rng;
std::array<double, 2> const i{0, 65535};
std::array<double, 2> const w{0, 1};
std::piecewise_linear_distribution<double> d(
i.begin(), i.end(), w.begin());
buffer b(size);
auto p = b.data();
std::size_t n = 0;
while(n < size)
{
if(n == 1)
{
*p++ = rng()%256;
++n;
continue;
}
auto const v = static_cast<std::uint16_t>(d(rng));
*p++ = v>>8;
*p++ = v&0xff;
n += 2;
}
b.resize(n);
return b;
}
void
checkInflate(buffer const& input, buffer const& original)
{
for(std::size_t i = 0; i < input.size(); ++i)
{
buffer output(original.size());
inflate_stream zs;
zs.avail_in = 0;
zs.next_in = 0;
zs.next_out = output.data();
zs.avail_out = output.capacity();
if(i > 0)
{
zs.next_in = (Byte*)input.data();
zs.avail_in = i;
auto result = zs.write(Z_FULL_FLUSH);
expect(result == Z_OK);
}
zs.next_in = (Byte*)input.data() + i;
zs.avail_in = input.size() - i;
auto result = zs.write(Z_FULL_FLUSH);
output.resize(output.capacity() - zs.avail_out);
expect(result == Z_OK);
expect(output.size() == original.size());
expect(std::memcmp(
output.data(), original.data(), original.size()) == 0);
}
}
void testSpecial()
{
{
deflate_stream zs;
}
{
inflate_stream zs;
}
}
void testCompress()
{
static std::size_t constexpr N = 2048;
for(int source = 0; source <= 1; ++source)
{
buffer original;
switch(source)
{
case 0:
original = make_source1(N);
break;
case 1:
original = make_source2(N);
break;
}
for(int level = 0; level <= 9; ++level)
{
for(int strategy = 0; strategy <= 4; ++strategy)
{
for(int wbits = 15; wbits <= 15; ++wbits)
{
deflate_stream zs;
zs.avail_in = 0;
zs.next_in = 0;
expect(deflate_stream::deflateInit2(&zs,
level,
wbits,
4,
strategy) == Z_OK);
buffer output(deflate_stream::deflateBound(&zs, original.size()));
zs.next_in = (Byte*)original.data();
zs.avail_in = original.size();
zs.next_out = output.data();
zs.avail_out = output.capacity();
auto result = zs.deflate(Z_FULL_FLUSH);
expect(result == Z_OK);
output.resize(output.capacity() - zs.avail_out);
checkInflate(output, original);
}
}
}
}
}
void run() override
{
testSpecial();
testCompress();
}
};
BEAST_DEFINE_TESTSUITE(zlib,core,beast);
} // zlib
} // beast
} // boost

View File

@ -8,49 +8,11 @@
# Official repository: https://github.com/boostorg/beast
#
add_executable (tests-beast-http
Jamfile
any_completion_handler.cpp
basic_dynamic_body_fwd.cpp
basic_dynamic_body.cpp
basic_file_body_fwd.cpp
basic_file_body.cpp
basic_parser.cpp
buffer_body_fwd.cpp
buffer_body.cpp
chunk_encode.cpp
deferred.cpp
dynamic_body_fwd.cpp
dynamic_body.cpp
empty_body_fwd.cpp
empty_body.cpp
error.cpp
field_compiles.cpp
field.cpp
fields_fwd.cpp
fields.cpp
file_body_fwd.cpp
file_body.cpp
message_fwd.cpp
message_generator_fwd.cpp
message_generator.cpp
message.cpp
parser_fwd.cpp
parser.cpp
read.cpp
rfc7230.cpp
serializer_fwd.cpp
serializer.cpp
span_body_fwd.cpp
span_body.cpp
status.cpp
string_body_fwd.cpp
string_body.cpp
type_traits.cpp
vector_body_fwd.cpp
vector_body.cpp
verb.cpp
write.cpp)
file(GLOB_RECURSE PFILES CONFIGURE_DEPENDS Jamfile *.cpp *.hpp)
add_executable(tests-beast-http ${PFILES})
source_group("" FILES ${PFILES})
target_link_libraries(tests-beast-http
lib-test

View File

@ -11,6 +11,10 @@ add_executable (tests-beast-ssl
Jamfile
ssl_stream.cpp)
source_group("" FILES
Jamfile
ssl_stream.cpp)
target_link_libraries(tests-beast-ssl
lib-asio-ssl
lib-test)

View File

@ -8,36 +8,11 @@
# Official repository: https://github.com/boostorg/beast
#
add_executable (tests-beast-websocket
Jamfile
_detail_decorator.cpp
_detail_prng.cpp
_detail_impl_base.cpp
test.hpp
_detail_prng.cpp
any_completion_handler.cpp
accept.cpp
cancel.cpp
close.cpp
deferred.cpp
error.cpp
frame.cpp
handshake.cpp
option.cpp
ping.cpp
read1.cpp
read2.cpp
read3.cpp
rfc6455.cpp
ssl.cpp
stream.cpp
stream_base.cpp
stream_explicit.cpp
stream_fwd.cpp
teardown.cpp
timer.cpp
utf8_checker.cpp
write.cpp)
file(GLOB_RECURSE PFILES CONFIGURE_DEPENDS Jamfile *.cpp *.hpp)
add_executable(tests-beast-websocket ${PFILES})
source_group("" FILES ${PFILES})
target_link_libraries(tests-beast-websocket
lib-asio-ssl

View File

@ -1,285 +0,0 @@
//
// Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Official repository: https://github.com/boostorg/beast
//
#include <boost/beast/core.hpp>
#include <boost/asio.hpp>
#include <boost/asio/spawn.hpp>
#include <boost/asio/use_future.hpp>
#include <algorithm>
#include <future>
#include <iostream>
#include <thread>
//[ws_snippet_1
#include <boost/beast/websocket.hpp>
using namespace boost::beast::websocket;
//]
using namespace boost::beast;
namespace doc_ws_snippets {
void fxx() {
net::io_service ios;
net::io_service::work work{ios};
std::thread t{[&](){ ios.run(); }};
error_code ec;
net::ip::tcp::socket sock{ios};
{
//[ws_snippet_2
stream<net::ip::tcp::socket> ws{ios};
//]
}
{
//[ws_snippet_3
stream<net::ip::tcp::socket> ws{std::move(sock)};
//]
}
{
//[ws_snippet_4
stream<net::ip::tcp::socket&> ws{sock};
//]
//[ws_snippet_5
ws.next_layer().shutdown(net::ip::tcp::socket::shutdown_send);
//]
}
{
//[ws_snippet_6
std::string const host = "mywebapp.com";
net::ip::tcp::resolver r{ios};
stream<net::ip::tcp::socket> ws{ios};
net::connect(ws.next_layer(), r.resolve({host, "ws"}));
//]
}
{
//[ws_snippet_7
net::ip::tcp::acceptor acceptor{ios};
stream<net::ip::tcp::socket> ws{acceptor.get_io_service()};
acceptor.accept(ws.next_layer());
//]
}
{
stream<net::ip::tcp::socket> ws{ios};
//[ws_snippet_8
ws.handshake("localhost", "/");
//]
//[ws_snippet_9
ws.handshake_ex("localhost", "/",
[](request_type& m)
{
m.insert(http::field::sec_websocket_protocol, "xmpp;ws-chat");
});
//]
//[ws_snippet_10
response_type res;
ws.handshake(res, "localhost", "/");
if(! res.count(http::field::sec_websocket_protocol))
throw std::invalid_argument("missing subprotocols");
//]
//[ws_snippet_11
ws.accept();
//]
//[ws_snippet_12
ws.accept_ex(
[](response_type& m)
{
m.insert(http::field::server, "MyServer");
});
//]
}
{
//[ws_snippet_13]
// Buffer required for reading HTTP messages
flat_buffer buffer;
// Read the HTTP request ourselves
http::request<http::string_body> req;
http::read(sock, buffer, req);
// See if its a WebSocket upgrade request
if(websocket::is_upgrade(req))
{
// Construct the stream, transferring ownership of the socket
stream<net::ip::tcp::socket> ws{std::move(sock)};
// Accept the request from our message. Clients SHOULD NOT
// begin sending WebSocket frames until the server has
// provided a response, but just in case they did, we pass
// any leftovers in the buffer to the accept function.
//
ws.accept(req, buffer.data());
}
else
{
// Its not a WebSocket upgrade, so
// handle it like a normal HTTP request.
}
//]
}
{
stream<net::ip::tcp::socket> ws{ios};
//[ws_snippet_14
// Read into our buffer until we reach the end of the HTTP request.
// No parsing takes place here, we are just accumulating data.
net::streambuf buffer;
net::read_until(sock, buffer, "\r\n\r\n");
// Now accept the connection, using the buffered data.
ws.accept(buffer.data());
//]
}
{
stream<net::ip::tcp::socket> ws{ios};
//[ws_snippet_15
multi_buffer buffer;
ws.read(buffer);
ws.text(ws.got_text());
ws.write(buffer.data());
buffer.consume(buffer.size());
//]
}
{
stream<net::ip::tcp::socket> ws{ios};
//[ws_snippet_16
multi_buffer buffer;
for(;;)
if(ws.read_some(buffer, 0))
break;
ws.binary(ws.got_binary());
consuming_buffers<multi_buffer::const_buffers_type> cb{buffer.data()};
for(;;)
{
using net::buffer_size;
if(buffer_size(cb) > 512)
{
ws.write_some(false, buffer_prefix(512, cb));
cb.consume(512);
}
else
{
ws.write_some(true, cb);
break;
}
}
//]
}
{
stream<net::ip::tcp::socket> ws{ios};
//[ws_snippet_17
auto cb =
[](frame_type kind, string_view payload)
{
// Do something with the payload
boost::ignore_unused(kind, payload);
};
ws.control_callback(cb);
//]
//[ws_snippet_18
ws.close(close_code::normal);
//]
//[ws_snippet_19
ws.auto_fragment(true);
ws.write_buffer_size(16384);
//]
//[ws_snippet_20
multi_buffer buffer;
ws.async_read(buffer,
[](error_code, std::size_t)
{
// Do something with the buffer
});
//]
}
} // fxx()
// workaround for https://github.com/chriskohlhoff/asio/issues/112
#ifdef BOOST_MSVC
//[ws_snippet_21
void echo(stream<net::ip::tcp::socket>& ws,
multi_buffer& buffer, net::yield_context yield)
{
ws.async_read(buffer, yield);
std::future<void> fut =
ws.async_write(buffer.data(), net::use_future);
}
//]
#endif
} // doc_ws_snippets
//------------------------------------------------------------------------------
#if BOOST_BEAST_USE_OPENSSL
//[wss_snippet_1
#include <boost/beast/websocket/ssl.hpp>
#include <boost/asio/ssl.hpp>
//]
namespace doc_wss_snippets {
void fxx() {
net::io_service ios;
net::io_service::work work{ios};
std::thread t{[&](){ ios.run(); }};
error_code ec;
net::ip::tcp::socket sock{ios};
{
//[wss_snippet_2
net::ssl::context ctx{net::ssl::context::tlsv12};
stream<net::ssl::stream<net::ip::tcp::socket>> wss{ios, ctx};
//]
}
{
//[wss_snippet_3
net::ip::tcp::endpoint ep;
net::ssl::context ctx{net::ssl::context::tlsv12};
stream<net::ssl::stream<net::ip::tcp::socket>> ws{ios, ctx};
// connect the underlying TCP/IP socket
ws.next_layer().next_layer().connect(ep);
// perform SSL handshake
ws.next_layer().handshake(net::ssl::stream_base::client);
// perform WebSocket handshake
ws.handshake("localhost", "/");
//]
}
} // fxx()
} // doc_wss_snippets
#endif

View File

@ -8,7 +8,14 @@
# Official repository: https://github.com/boostorg/beast
#
add_executable (tests-beast-zlib
add_executable(tests-beast-zlib
Jamfile
error.cpp
deflate_stream.cpp
inflate_stream.cpp
zlib.cpp)
source_group("" FILES
Jamfile
error.cpp
deflate_stream.cpp

View File

@ -12,6 +12,10 @@ add_executable(bench-buffers
Jamfile
bench_buffers.cpp)
source_group("" FILES
Jamfile
bench_buffers.cpp)
target_link_libraries(bench-buffers
lib-test)

View File

@ -14,6 +14,12 @@ add_executable(bench-parser
nodejs_parser.cpp
bench_parser.cpp)
source_group("" FILES
Jamfile
nodejs_parser.hpp
nodejs_parser.cpp
bench_parser.cpp)
target_include_directories(bench-parser
PRIVATE ${PROJECT_SOURCE_DIR})

View File

@ -12,6 +12,10 @@ add_executable(bench-utf8-checker
Jamfile
bench_utf8_checker.cpp)
source_group("" FILES
Jamfile
bench_utf8_checker.cpp)
target_link_libraries(bench-utf8-checker
lib-test)

View File

@ -12,6 +12,10 @@ add_executable(bench-wsload
Jamfile
wsload.cpp)
source_group("" FILES
Jamfile
wsload.cpp)
target_link_libraries(bench-wsload
lib-beast)

View File

@ -8,7 +8,12 @@
# Official repository: https://github.com/boostorg/beast
#
add_executable (bench-zlib
add_executable(bench-zlib
Jamfile
deflate_stream.cpp
inflate_stream.cpp)
source_group("" FILES
Jamfile
deflate_stream.cpp
inflate_stream.cpp)

View File

@ -86,6 +86,7 @@ else()
endif()
add_executable(main main.cpp)
source_group("" FILES main.cpp)
target_link_libraries(main Boost::beast)
enable_testing()

View File

@ -8,28 +8,11 @@
# Official repository: https://github.com/boostorg/beast
#
add_executable (tests-doc
Jamfile
snippets.hpp
snippets.ipp
core_snippets.cpp
core_1_refresher.cpp
core_3_timeouts.cpp
core_4_layers.cpp
http_10_custom_parser.cpp
http_examples.cpp
http_snippets.cpp
websocket_common.ipp
websocket.cpp
websocket_1_connecting.cpp
websocket_2_handshaking.cpp
websocket_3_decorator.cpp
websocket_4_messages.cpp
websocket_5_control_frames.cpp
websocket_6_timeouts.cpp
websocket_7_teardown.cpp
websocket_8_notes.cpp
exemplars.cpp)
file(GLOB_RECURSE PFILES CONFIGURE_DEPENDS Jamfile *.cpp *.ipp *.hpp)
add_executable(tests-doc ${PFILES})
source_group("" FILES ${PFILES})
target_include_directories(tests-doc
PRIVATE ${PROJECT_SOURCE_DIR})

View File

@ -8,7 +8,12 @@
# Official repository: https://github.com/boostorg/beast
#
add_executable (tests-example-common
add_executable(tests-example-common
Jamfile
root_certificates.cpp
server_certificate.cpp)
source_group("" FILES
Jamfile
root_certificates.cpp
server_certificate.cpp)

View File

@ -71,6 +71,7 @@ function(add_boost_beast_fuzzer NAME)
# Fuzzer executable
set(SOURCE_FILES ${ARGN})
add_executable(fuzzer_${NAME} ${SOURCE_FILES})
source_group("" FILES ${SOURCE_FILES})
target_link_libraries(fuzzer_${NAME} PRIVATE lib-beast)
target_compile_options(fuzzer_${NAME} PRIVATE -g -O2 -fsanitize=fuzzer,address,undefined -fno-sanitize-recover=undefined)
target_link_libraries(fuzzer_${NAME} PRIVATE -fsanitize=fuzzer,address,undefined)