test/helpers.hpp | 6 ++++++ test/httpwserror.cpp | 23 ++++++++++++++--------- 2 files changed, 20 insertions(+), 9 deletions(-)
New commits: commit 606f85db8753e3d1f44b8fbf10be609e9bd5ccb7 Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk> Date: Tue Jan 3 17:02:53 2017 -0500 wsd: fixup max connections unittest Change-Id: I107dadb973554b21f20211c8316cec7139953f47 Reviewed-on: https://gerrit.libreoffice.org/32713 Reviewed-by: Ashod Nakashian <ashnak...@gmail.com> Tested-by: Ashod Nakashian <ashnak...@gmail.com> diff --git a/test/helpers.hpp b/test/helpers.hpp index 6c70fdd..4c9d191 100644 --- a/test/helpers.hpp +++ b/test/helpers.hpp @@ -188,6 +188,12 @@ int getErrorCode(LOOLWebSocket& ws, std::string& message) } inline +int getErrorCode(const std::shared_ptr<LOOLWebSocket>& ws, std::string& message) +{ + return getErrorCode(*ws, message); +} + +inline std::vector<char> getResponseMessage(LOOLWebSocket& ws, const std::string& prefix, std::string name = "", const size_t timeoutMs = 10000) { name = name + '[' + prefix + "] "; diff --git a/test/httpwserror.cpp b/test/httpwserror.cpp index 3db733d..c001abf 100644 --- a/test/httpwserror.cpp +++ b/test/httpwserror.cpp @@ -142,8 +142,16 @@ void HTTPWSError::testMaxDocuments() void HTTPWSError::testMaxConnections() { -#if MAX_CONNECTIONS > 0 + static_assert(MAX_CONNECTIONS >= 3, "MAX_CONNECTIONS must be at least 3"); const auto testname = "maxConnections "; + + if (MAX_CONNECTIONS > 100) + { + std::cerr << "Skipping " << testname << "test since MAX_CONNECTION (" << MAX_CONNECTIONS + << ") is too high to test. Set to a more sensible number, ideally a dozen or so." << std::endl; + return; + } + try { std::cerr << "Opening max number of connections: " << MAX_CONNECTIONS << std::endl; @@ -158,7 +166,7 @@ void HTTPWSError::testMaxConnections() std::cerr << "Opened connect #1 of " << MAX_CONNECTIONS << std::endl; std::vector<std::shared_ptr<LOOLWebSocket>> views; - for(int it = 1; it < MAX_CONNECTIONS; it++) + for (int it = 1; it < MAX_CONNECTIONS; ++it) { std::unique_ptr<Poco::Net::HTTPClientSession> session(createSession(_uri)); auto ws = std::make_shared<LOOLWebSocket>(*session, request, _response); @@ -170,24 +178,21 @@ void HTTPWSError::testMaxConnections() // try to connect MAX_CONNECTIONS + 1 std::unique_ptr<Poco::Net::HTTPClientSession> session(createSession(_uri)); - LOOLWebSocket socketN(*session, request, _response); + auto socketN = std::make_shared<LOOLWebSocket>(*session, request, _response); - // send loolclient, load and partpagerectangles - sendTextFrame(socketN, "loolclient ", testname); - sendTextFrame(socketN, "load ", testname); - sendTextFrame(socketN, "partpagerectangles ", testname); + // Send load request, which will fail. + sendTextFrame(socketN, "load url=" + docURL, testname); std::string message; const auto statusCode = getErrorCode(socketN, message); CPPUNIT_ASSERT_EQUAL(static_cast<int>(Poco::Net::WebSocket::WS_POLICY_VIOLATION), statusCode); - socketN.shutdown(); + socketN->shutdown(); } catch (const Poco::Exception& exc) { CPPUNIT_FAIL(exc.displayText()); } -#endif } CPPUNIT_TEST_SUITE_REGISTRATION(HTTPWSError); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits