Tidy up warnings and deprecated usage:

fix #1290

* BOOST_ASIO_NO_DEPRECATED=1 is now set
* Fix various warnings from the Boost regression test matrix
* Fix a bug in advanced servers when checking for a timeout
This commit is contained in:
Vinnie Falco
2018-11-22 20:49:30 -08:00
parent c0e5d1bd76
commit 5bff4ed8ab
23 changed files with 103 additions and 60 deletions

View File

@ -1,6 +1,7 @@
Version 192:
* Use mp11::integer_sequence
* Tidy up warnings and deprecated usage
--------------------------------------------------------------------------------

View File

@ -18,9 +18,13 @@ option (Beast_BUILD_TESTS "Build tests" ON)
if (MSVC)
set (CMAKE_VERBOSE_MAKEFILE FALSE)
add_definitions (-D_WIN32_WINNT=0x0601)
add_definitions (-D_SCL_SECURE_NO_WARNINGS=1)
add_definitions (-D_CRT_SECURE_NO_WARNINGS=1)
add_definitions (
-D_WIN32_WINNT=0x0601
-D_SCL_SECURE_NO_WARNINGS=1
-D_CRT_SECURE_NO_WARNINGS=1
-D_SILENCE_CXX17_ALLOCATOR_VOID_DEPRECATION_WARNING
-D_SILENCE_CXX17_ADAPTOR_TYPEDEFS_DEPRECATION_WARNING
)
add_compile_options(
/bigobj # large object file format
@ -74,9 +78,7 @@ get_filename_component (BOOST_ROOT ../../ ABSOLUTE)
# VFALCO I want static but "b2 stage" builds a minimal set which excludes static
add_definitions (-DBOOST_ALL_STATIC_LINK=1)
# Some of the tests use deprecated APIs
#add_definitions (-DBOOST_ASIO_NO_DEPRECATED=1)
add_definitions (-DBOOST_ASIO_NO_DEPRECATED=1)
add_definitions (-DBOOST_ASIO_DISABLE_BOOST_ARRAY=1)
add_definitions (-DBOOST_ASIO_DISABLE_BOOST_BIND=1)
add_definitions (-DBOOST_ASIO_DISABLE_BOOST_DATE_TIME=1)

View File

@ -97,15 +97,17 @@ project /boost/beast
<runtime-link>shared
<debug-symbols>on
<define>BOOST_ALL_NO_LIB=1
<define>BOOST_ASIO_NO_DEPRECATED=1
<define>BOOST_ASIO_DISABLE_BOOST_ARRAY=1
<define>BOOST_ASIO_DISABLE_BOOST_BIND=1
<define>BOOST_ASIO_DISABLE_BOOST_DATE_TIME=1
<define>BOOST_ASIO_DISABLE_BOOST_REGEX=1
#<define>BOOST_ASIO_NO_DEPRECATED=1 # some tests use deprecated strand
<define>BOOST_COROUTINES_NO_DEPRECATION_WARNING=1
<toolset>msvc:<cxxflags>"/bigobj /permissive-"
<toolset>msvc:<define>_SCL_SECURE_NO_WARNINGS=1
<toolset>msvc:<define>_CRT_SECURE_NO_WARNINGS=1
<toolset>msvc:<define>_SILENCE_CXX17_ALLOCATOR_VOID_DEPRECATION_WARNING
<toolset>msvc:<define>_SILENCE_CXX17_ADAPTOR_TYPEDEFS_DEPRECATION_WARNING
<toolset>msvc,<variant>release:<cxxflags>"/Ob2 /Oi /Ot"
<os>SOLARIS:<library>socket
<os>SOLARIS:<library>nsl

View File

@ -809,7 +809,7 @@ public:
return fail(ec, "timer");
// Check if this has been upgraded to Websocket
if(timer_.expires_at() == (std::chrono::steady_clock::time_point::min)())
if(timer_.expiry() == (std::chrono::steady_clock::time_point::min)())
return;
// Verify that the timer really expired since the deadline may have moved.

View File

@ -622,7 +622,7 @@ public:
return fail(ec, "timer");
// Check if this has been upgraded to Websocket
if(timer_.expires_at() == (std::chrono::steady_clock::time_point::min)())
if(timer_.expiry() == (std::chrono::steady_clock::time_point::min)())
return;
// Verify that the timer really expired since the deadline may have moved.

View File

@ -20,15 +20,12 @@ namespace unit_test {
/** A test runner that stores the results. */
class recorder : public runner
{
private:
results m_results;
suite_results m_suite;
case_results m_case;
public:
recorder() = default;
recorder(recorder const&) = default;
recorder& operator=(recorder const&) = default;
/** Returns a report with the results of all completed suites. */
results const&

View File

@ -13,7 +13,7 @@
#include <boost/beast/core/detail/type_traits.hpp>
#include <boost/beast/_experimental/test/stream.hpp>
#include <boost/beast/_experimental/unit_test/suite.hpp>
#include <boost/asio/io_service.hpp>
#include <boost/asio/io_context.hpp>
#include <boost/asio/strand.hpp>
#include <string>

View File

@ -15,7 +15,7 @@
#include <boost/beast/test/yield_to.hpp>
#include <boost/beast/_experimental/unit_test/suite.hpp>
#include <boost/asio/buffer.hpp>
#include <boost/asio/io_service.hpp>
#include <boost/asio/io_context.hpp>
#include <boost/asio/read.hpp>
#include <boost/asio/spawn.hpp>
#include <boost/asio/strand.hpp>
@ -224,12 +224,15 @@ public:
// breakpoint in asio_handler_invoke to make sure
// it is instantiated.
boost::asio::io_context ioc;
boost::asio::io_service::strand s{ioc};
boost::asio::strand<
boost::asio::io_context::executor_type> s(
ioc.get_executor());
test::stream ts{ioc};
buffered_read_stream<
test::stream&, multi_buffer> brs(ts);
brs.async_read_some(boost::asio::mutable_buffer{},
s.wrap(copyable_handler{}));
boost::asio::bind_executor(
s, copyable_handler{}));
}
void run() override

View File

@ -130,8 +130,8 @@ public:
decltype(bs)::const_iterator copy;
copy = it;
BEAST_EXPECT(copy == it);
copy = copy;
BEAST_EXPECT(copy == it);
auto copy2 = copy;
BEAST_EXPECT(copy2 == it);
}
}

View File

@ -9,7 +9,7 @@
GroupSources (include/boost/beast beast)
GroupSources (test/extras/include/boost/beast extras)
GroupSources (test/beast/_experimental "/")
GroupSources (test/beast/experimental "/")
add_executable (tests-beast-experimental
${BOOST_BEAST_FILES}

View File

@ -88,7 +88,7 @@ public:
ba.commit(n);
});
ioc.run();
ioc.reset();
ioc.restart();
if(ec)
break;
}

View File

@ -98,14 +98,12 @@ public:
: public std::enable_shared_from_this<session>
{
boost::asio::ip::tcp::socket socket_;
std::ostream& log_;
public:
session(
boost::asio::ip::tcp::socket sock,
std::ostream& log)
std::ostream&)
: socket_(std::move(sock))
, log_(log)
{
}

View File

@ -19,9 +19,9 @@
#include <boost/beast/http/parser.hpp>
#include <boost/beast/http/string_body.hpp>
#include <boost/beast/_experimental/test/stream.hpp>
#include <boost/beast/test/yield_to.hpp>
#include <boost/beast/_experimental/unit_test/suite.hpp>
#include <boost/asio/io_service.hpp>
#include <boost/beast/test/yield_to.hpp>
#include <boost/asio/io_context.hpp>
#include <boost/asio/strand.hpp>
#include <atomic>
@ -493,32 +493,41 @@ public:
void
testAsioHandlerInvoke()
{
using strand = boost::asio::strand<
boost::asio::io_context::executor_type>;
// make sure things compile, also can set a
// breakpoint in asio_handler_invoke to make sure
// it is instantiated.
{
boost::asio::io_context ioc;
boost::asio::io_service::strand s{ioc};
strand s{ioc.get_executor()};
test::stream ts{ioc};
flat_buffer b;
request_parser<dynamic_body> p;
async_read_some(ts, b, p, s.wrap(copyable_handler{}));
async_read_some(ts, b, p,
boost::asio::bind_executor(
s, copyable_handler{}));
}
{
boost::asio::io_context ioc;
boost::asio::io_service::strand s{ioc};
strand s{ioc.get_executor()};
test::stream ts{ioc};
flat_buffer b;
request_parser<dynamic_body> p;
async_read(ts, b, p, s.wrap(copyable_handler{}));
async_read(ts, b, p,
boost::asio::bind_executor(
s, copyable_handler{}));
}
{
boost::asio::io_context ioc;
boost::asio::io_service::strand s{ioc};
strand s{ioc.get_executor()};
test::stream ts{ioc};
flat_buffer b;
request<dynamic_body> m;
async_read(ts, b, m, s.wrap(copyable_handler{}));
async_read(ts, b, m,
boost::asio::bind_executor(
s, copyable_handler{}));
}
}

View File

@ -23,7 +23,7 @@
#include <boost/beast/test/yield_to.hpp>
#include <boost/beast/_experimental/unit_test/suite.hpp>
#include <boost/asio/error.hpp>
#include <boost/asio/io_service.hpp>
#include <boost/asio/io_context.hpp>
#include <boost/asio/strand.hpp>
#include <sstream>
#include <string>
@ -857,34 +857,43 @@ public:
void
testAsioHandlerInvoke()
{
using strand = boost::asio::strand<
boost::asio::io_context::executor_type>;
// make sure things compile, also can set a
// breakpoint in asio_handler_invoke to make sure
// it is instantiated.
{
boost::asio::io_context ioc;
boost::asio::io_service::strand s{ioc};
strand s{ioc.get_executor()};
test::stream ts{ioc};
flat_buffer b;
request<empty_body> m;
request_serializer<empty_body, fields> sr{m};
async_write_some(ts, sr, s.wrap(copyable_handler{}));
async_write_some(ts, sr,
boost::asio::bind_executor(
s, copyable_handler{}));
}
{
boost::asio::io_context ioc;
boost::asio::io_service::strand s{ioc};
strand s{ioc.get_executor()};
test::stream ts{ioc};
flat_buffer b;
request<empty_body> m;
request_serializer<empty_body, fields> sr{m};
async_write(ts, sr, s.wrap(copyable_handler{}));
async_write(ts, sr,
boost::asio::bind_executor(
s, copyable_handler{}));
}
{
boost::asio::io_context ioc;
boost::asio::io_service::strand s{ioc};
strand s{ioc.get_executor()};
test::stream ts{ioc};
flat_buffer b;
request<empty_body> m;
async_write(ts, m, s.wrap(copyable_handler{}));
async_write(ts, m,
boost::asio::bind_executor(
s, copyable_handler{}));
}
}

View File

@ -12,7 +12,7 @@
#include "test.hpp"
#include <boost/asio/io_service.hpp>
#include <boost/asio/io_context.hpp>
#include <boost/asio/strand.hpp>
namespace boost {
@ -637,9 +637,12 @@ public:
// breakpoint in asio_handler_invoke to make sure
// it is instantiated.
boost::asio::io_context ioc;
boost::asio::io_service::strand s{ioc};
boost::asio::strand<
boost::asio::io_context::executor_type> s(
ioc.get_executor());
stream<test::stream> ws{ioc};
ws.async_accept(s.wrap(copyable_handler{}));
ws.async_accept(boost::asio::bind_executor(
s, copyable_handler{}));
}
void

View File

@ -12,7 +12,7 @@
#include "test.hpp"
#include <boost/asio/io_service.hpp>
#include <boost/asio/io_context.hpp>
#include <boost/asio/strand.hpp>
namespace boost {
@ -649,9 +649,12 @@ public:
// breakpoint in asio_handler_invoke to make sure
// it is instantiated.
boost::asio::io_context ioc;
boost::asio::io_service::strand s{ioc};
boost::asio::strand<
boost::asio::io_context::executor_type> s(
ioc.get_executor());
stream<test::stream> ws{ioc};
ws.async_close({}, s.wrap(copyable_handler{}));
ws.async_close({}, boost::asio::bind_executor(
s, copyable_handler{}));
}
void

View File

@ -12,7 +12,7 @@
#include "test.hpp"
#include <boost/asio/io_service.hpp>
#include <boost/asio/io_context.hpp>
#include <boost/asio/strand.hpp>
namespace boost {
@ -511,9 +511,13 @@ public:
// breakpoint in asio_handler_invoke to make sure
// it is instantiated.
boost::asio::io_context ioc;
boost::asio::io_service::strand s{ioc};
boost::asio::strand<
boost::asio::io_context::executor_type> s(
ioc.get_executor());
stream<test::stream> ws{ioc};
ws.async_handshake("localhost", "/", s.wrap(copyable_handler{}));
ws.async_handshake("localhost", "/",
boost::asio::bind_executor(
s, copyable_handler{}));
}
void

View File

@ -12,7 +12,7 @@
#include "test.hpp"
#include <boost/asio/io_service.hpp>
#include <boost/asio/io_context.hpp>
#include <boost/asio/strand.hpp>
namespace boost {
@ -462,9 +462,12 @@ public:
// breakpoint in asio_handler_invoke to make sure
// it is instantiated.
boost::asio::io_context ioc;
boost::asio::io_service::strand s{ioc};
boost::asio::strand<
boost::asio::io_context::executor_type> s(
ioc.get_executor());
stream<test::stream> ws{ioc};
ws.async_ping({}, s.wrap(copyable_handler{}));
ws.async_ping({}, boost::asio::bind_executor(
s, copyable_handler{}));
}
void

View File

@ -12,7 +12,7 @@
#include "test.hpp"
#include <boost/asio/io_service.hpp>
#include <boost/asio/io_context.hpp>
#include <boost/asio/strand.hpp>
#include <boost/asio/write.hpp>
@ -666,10 +666,13 @@ public:
// it is instantiated.
{
boost::asio::io_context ioc;
boost::asio::io_service::strand s{ioc};
boost::asio::strand<
boost::asio::io_context::executor_type> s(
ioc.get_executor());
stream<test::stream> ws{ioc};
flat_buffer b;
ws.async_read(b, s.wrap(copyable_handler{}));
ws.async_read(b, boost::asio::bind_executor(
s, copyable_handler{}));
}
}

View File

@ -10,7 +10,7 @@
// Test that header file is self-contained.
#include <boost/beast/websocket/stream.hpp>
#include <boost/asio/io_service.hpp>
#include <boost/asio/io_context.hpp>
#include <boost/asio/strand.hpp>
#include "test.hpp"
@ -659,11 +659,14 @@ public:
// it is instantiated.
{
boost::asio::io_context ioc;
boost::asio::io_service::strand s{ioc};
boost::asio::strand<
boost::asio::io_context::executor_type> s(
ioc.get_executor());
stream<test::stream> ws{ioc};
flat_buffer b;
ws.async_write(boost::asio::const_buffer{},
s.wrap(copyable_handler{}));
boost::asio::bind_executor(s,
copyable_handler{}));
}
}

View File

@ -22,7 +22,6 @@ namespace doc_core_snippets {
void fxx()
{
//[snippet_core_1b
//
using namespace boost::beast;
@ -35,8 +34,9 @@ error_code ec;
boost::asio::ip::tcp::socket sock{ioc};
//]
boost::ignore_unused(ec);
{
{
//[snippet_core_2
char const* const host = "www.example.com";
@ -49,10 +49,12 @@ boost::asio::connect(stream, results.begin(), results.end());
// host and may be used to perform stream operations.
//]
}
}
} // fxx()
//------------------------------------------------------------------------------
//[snippet_core_3
template<class SyncWriteStream>

View File

@ -32,6 +32,7 @@ auto work = boost::asio::make_work_guard(ioc);
std::thread t{[&](){ ioc.run(); }};
error_code ec;
boost::asio::ip::tcp::socket sock{ioc};
boost::ignore_unused(ec);
{
//[ws_snippet_2

View File

@ -51,7 +51,7 @@ struct test_allocator_base<T, Equal, Assign, Move, Swap, true>
static
test_allocator<T, Equal, Assign, Move, Swap, true>
select_on_container_copy_construction(test_allocator<
T, Equal, Assign, Move, Swap, true> const& a)
T, Equal, Assign, Move, Swap, true> const&)
{
return test_allocator<T, Equal, Assign, Move, Swap, true>{};
}