From: Marcin Siodelski Date: Mon, 24 Apr 2017 12:55:24 +0000 (+0200) Subject: [master] Multiple small improvements in the unit tests. X-Git-Tag: trac5243x_base~2 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=c6522aa9c377521d88b63283494a4fd5976993e5;p=thirdparty%2Fkea.git [master] Multiple small improvements in the unit tests. Also, the read buffer for unix socket client is extended to 64k. --- diff --git a/src/bin/agent/ca_command_mgr.h b/src/bin/agent/ca_command_mgr.h index 17b59a0666..d1c24fde7f 100644 --- a/src/bin/agent/ca_command_mgr.h +++ b/src/bin/agent/ca_command_mgr.h @@ -110,7 +110,7 @@ private: CtrlAgentCommandMgr(); /// @brief Buffer into which responses to forwarded commands are stored. - std::array receive_buf_; + std::array receive_buf_; }; diff --git a/src/bin/agent/tests/ca_command_mgr_unittests.cc b/src/bin/agent/tests/ca_command_mgr_unittests.cc index c70e76e09e..ef8c577dd8 100644 --- a/src/bin/agent/tests/ca_command_mgr_unittests.cc +++ b/src/bin/agent/tests/ca_command_mgr_unittests.cc @@ -230,14 +230,16 @@ public: // to this we need to run the server side socket at the same time. // Running IO service in a thread guarantees that the server responds // as soon as it receives the control command. - isc::util::thread::Thread(boost::bind(&CtrlAgentCommandMgrTest::runIO, - getIOService(), server_socket_, - expected_responses)); + isc::util::thread::Thread th(boost::bind(&CtrlAgentCommandMgrTest::runIO, + getIOService(), server_socket_, + expected_responses)); ConstElementPtr command = createCommand("foo", service); ConstElementPtr answer = mgr_.handleCommand("foo", ConstElementPtr(), command); + th.wait(); + checkAnswer(answer, expected_result0, expected_result1, expected_result2); } @@ -364,13 +366,15 @@ TEST_F(CtrlAgentCommandMgrTest, forwardListCommands) { // to this we need to run the server side socket at the same time. // Running IO service in a thread guarantees that the server responds // as soon as it receives the control command. - isc::util::thread::Thread(boost::bind(&CtrlAgentCommandMgrTest::runIO, - getIOService(), server_socket_, 1)); + isc::util::thread::Thread th(boost::bind(&CtrlAgentCommandMgrTest::runIO, + getIOService(), server_socket_, 1)); ConstElementPtr command = createCommand("list-commands", "dhcp4"); ConstElementPtr answer = mgr_.handleCommand("list-commands", ConstElementPtr(), command); + th.wait(); + // Answer of 3 is specific to the stub response we send when the // command is forwarded. So having this value returned means that // the command was forwarded as expected. diff --git a/src/lib/asiolink/testutils/test_server_unix_socket.cc b/src/lib/asiolink/testutils/test_server_unix_socket.cc index ab374cc062..63261a29f1 100644 --- a/src/lib/asiolink/testutils/test_server_unix_socket.cc +++ b/src/lib/asiolink/testutils/test_server_unix_socket.cc @@ -225,7 +225,11 @@ TestServerUnixSocket::bindServerSocket() { } void -TestServerUnixSocket::acceptHandler(const boost::system::error_code&) { +TestServerUnixSocket::acceptHandler(const boost::system::error_code& ec) { + if (ec) { + return; + } + connection_pool_->start(custom_response_); accept(); }