Commit e5e4a7ec authored by Tomek Mrugalski's avatar Tomek Mrugalski 🛰

[1651] tests for Session::getSocketDesc() implemented.

parent 62de4b87
......@@ -259,6 +259,9 @@ int
SessionImpl::getSocketDesc() {
/// @todo boost 1.42 uses native() method, but it is deprecated
/// in 1.49 and native_handle() is recommended instead
if (!socket_.is_open()) {
isc_throw(InvalidOperation, "Can't return socket desciptor: no socket opened.");
}
return socket_.native();
}
......
......@@ -34,6 +34,9 @@ TEST(AsioSession, establish) {
asio::io_service io_service_;
Session sess(io_service_);
// can't return socket desciptor before session is established
EXPECT_THROW(sess.getSocketDesc(), isc::InvalidOperation);
EXPECT_THROW(
sess.establish("/aaaaaaaaaa/aaaaaaaaaa/aaaaaaaaaa/aaaaaaaaaa/"
"/aaaaaaaaaa/aaaaaaaaaa/aaaaaaaaaa/aaaaaaaaaa/"
......@@ -235,4 +238,14 @@ TEST_F(SessionTest, run_with_handler_timeout) {
ASSERT_THROW(my_io_service.run(), SessionTimeout);
}
TEST_F(SessionTest, get_socket_descr) {
tds->setSendLname();
sess.establish(BIND10_TEST_SOCKET_FILE);
int socket = 0;
// session is established, so getSocketDesc() should work
EXPECT_NO_THROW(socket = sess.getSocketDesc());
// expect actual socket handle to be returned, not 0
EXPECT_TRUE(0 < socket);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment