Skip to content
This repository was archived by the owner on Apr 16, 2018. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions test/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,9 @@ testexe = executable('testexe', test_sources,
include_directories : inc, link_with : netlib,
dependencies : [gtest])

sodebugtestexe = executable('sodebugtestexe', 'socket_option_debug_test.cpp',
include_directories : inc, link_with : netlib,
dependencies : [gtest])

test('app test', testexe, args: '--gtest_color=yes')
test('app test', sodebugtestexe, args: '--gtest_color=yes')
27 changes: 27 additions & 0 deletions test/socket_option_debug_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include "socket.hpp"
#include <gtest/gtest.h>

using namespace net;

TEST(SocketOptions, Debug)
{
Socket s(Domain::IPv4, Type::UDP);

int optval;
socklen_t optlen = sizeof(optval);

SockOpt opt(1);
ASSERT_EQ(1, opt.getValue());

s.setOpt(Opt::DEBUG, opt);
ASSERT_EQ(
0, getsockopt(s.getSocket(), SOL_SOCKET, SO_DEBUG, &optval, &optlen));
ASSERT_EQ(1, optval);

optval = 0;
ASSERT_EQ(0,
setsockopt(s.getSocket(), SOL_SOCKET, SO_DEBUG, &optval, optlen));

auto s2 = s.getOpt(Opt::DEBUG);
ASSERT_EQ(0, s2.getValue());
}
24 changes: 0 additions & 24 deletions test/socket_options_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,30 +98,6 @@ TEST(SocketOptions, Linger)
}


// TEST(SocketOptions, Debug)
// {
// Socket s(Domain::IPv4, Type::UDP);

// int optval;
// socklen_t optlen = sizeof(optval);

// SockOpt opt(1);
// ASSERT_EQ(1, opt.getValue());

// s.setOpt(Opt::DEBUG, opt);
// ASSERT_EQ(
// 0, getsockopt(s.getSocket(), SOL_SOCKET, SO_DEBUG, &optval, &optlen));
// ASSERT_EQ(1, optval);

// optval = 0;
// ASSERT_EQ(0,
// setsockopt(s.getSocket(), SOL_SOCKET, SO_DEBUG, &optval, optlen));

// auto s2 = s.getOpt(Opt::DEBUG);
// ASSERT_EQ(0, s2.getValue());
// }


TEST(SocketOptions, DontRoute)
{
Socket s(Domain::IPv4, Type::UDP);
Expand Down