From 72a99c43a73b4027bf9304b3bf006124b356127f Mon Sep 17 00:00:00 2001 From: Damian Jarek Date: Sat, 8 Dec 2018 00:10:10 +0100 Subject: [PATCH] Pausation abandoning test Check if paused operations are correctly abandoned when the ExecutionContext shuts down. Signed-off-by: Damian Jarek --- CHANGELOG.md | 1 + test/beast/websocket/write.cpp | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e5ef0e0..b8226948 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ Version 223: * Add test::stream::service * Add websocket service +* Pausation abandoning test -------------------------------------------------------------------------------- diff --git a/test/beast/websocket/write.cpp b/test/beast/websocket/write.cpp index 8a14a66e..372e3979 100644 --- a/test/beast/websocket/write.cpp +++ b/test/beast/websocket/write.cpp @@ -262,6 +262,38 @@ public: }); } + void + testPausationAbandoning() + { + struct test_op + { + std::shared_ptr> s_; + + void operator()( + boost::system::error_code = {}, + std::size_t = 0) + { + BEAST_FAIL(); + } + }; + + std::weak_ptr> weak_ws; + { + echo_server es{log}; + net::io_context ioc; + auto ws = std::make_shared>(ioc); + test_op op{ws}; + ws->next_layer().connect(es.stream()); + ws->handshake("localhost", "/"); + ws->async_ping("", op); + BEAST_EXPECT(ws->impl_->wr_block.is_locked()); + ws->async_write(sbuf("*"), op); + weak_ws = ws; + ws->next_layer().close(); + } + BEAST_EXPECT(weak_ws.expired()); + } + void testWriteSuspend() { @@ -647,6 +679,7 @@ public: run() override { testWrite(); + testPausationAbandoning(); testWriteSuspend(); testAsyncWriteFrame(); testIssue300();