Commit 26136fda authored by Florian Will's avatar Florian Will Committed by Alexandre Julliard

ws2_32/tests: Test TCP_KEEP{ALIVE,CNT,INTVL} options.

parent 6d2a9004
......@@ -1193,6 +1193,7 @@ static void test_set_getsockopt(void)
DWORD values[3];
BOOL accepts_large_value;
BOOL bool_value;
BOOL allow_noprotoopt; /* for old windows or wine todo */
}
test_optsize[] =
{
......@@ -1210,6 +1211,9 @@ static void test_set_getsockopt(void)
{AF_INET, SOCK_STREAM, SOL_SOCKET, SO_SNDTIMEO, FALSE, {1, 2, 4}, {0}, TRUE},
{AF_INET, SOCK_STREAM, SOL_SOCKET, SO_OPENTYPE, FALSE, {1, 2, 4}, {0}, TRUE},
{AF_INET, SOCK_STREAM, IPPROTO_TCP, TCP_NODELAY, TRUE, {1, 1, 1}, {0}, TRUE},
{AF_INET, SOCK_STREAM, IPPROTO_TCP, TCP_KEEPALIVE, FALSE, {0, 0, 4}, {0}, TRUE, FALSE, TRUE}, /* wine todo */
{AF_INET, SOCK_STREAM, IPPROTO_TCP, TCP_KEEPCNT, FALSE, {0, 0, 4}, {0}, FALSE, FALSE, TRUE}, /* win10+, wine todo*/
{AF_INET, SOCK_STREAM, IPPROTO_TCP, TCP_KEEPINTVL, FALSE, {0, 0, 4}, {0}, TRUE, FALSE, TRUE}, /* win10+, wine todo */
{AF_INET, SOCK_DGRAM, IPPROTO_IP, IP_MULTICAST_LOOP, TRUE, {1, 1, 4}, {0}, TRUE, TRUE},
{AF_INET, SOCK_DGRAM, IPPROTO_IP, IP_MULTICAST_TTL, TRUE, {1, 1, 4}, {0}, FALSE},
{AF_INET, SOCK_DGRAM, IPPROTO_IP, IP_PKTINFO, FALSE, {0, 0, 4}, {0}, TRUE, TRUE},
......@@ -1453,6 +1457,36 @@ static void test_set_getsockopt(void)
ok(!err, "getsockopt TCP_NODELAY failed\n");
ok(!value, "TCP_NODELAY should be 0\n");
size = sizeof(DWORD);
value = 3600;
err = setsockopt(s, IPPROTO_TCP, TCP_KEEPALIVE, (char*)&value, 4);
todo_wine ok(!err, "setsockopt TCP_KEEPALIVE failed\n");
value = 0;
err = getsockopt(s, IPPROTO_TCP, TCP_KEEPALIVE, (char*)&value, &size);
todo_wine ok(!err, "getsockopt TCP_KEEPALIVE failed\n");
todo_wine ok(value == 3600, "TCP_KEEPALIVE should be 3600, is %ld\n", value);
/* TCP_KEEPCNT and TCP_KEEPINTVL are supported on win10 and later */
value = 5;
err = setsockopt(s, IPPROTO_TCP, TCP_KEEPCNT, (char*)&value, 4);
todo_wine ok(!err || broken(WSAGetLastError() == WSAENOPROTOOPT),
"setsockopt TCP_KEEPCNT failed: %d\n", WSAGetLastError());
if (!err)
{
value = 0;
err = getsockopt(s, IPPROTO_TCP, TCP_KEEPCNT, (char*)&value, &size);
ok(!err, "getsockopt TCP_KEEPCNT failed\n");
ok(value == 5, "TCP_KEEPCNT should be 5, is %ld\n", value);
err = setsockopt(s, IPPROTO_TCP, TCP_KEEPINTVL, (char*)&value, 4);
ok(!err, "setsockopt TCP_KEEPINTVL failed\n");
value = 0;
err = getsockopt(s, IPPROTO_TCP, TCP_KEEPINTVL, (char*)&value, &size);
ok(!err, "getsockopt TCP_KEEPINTVL failed\n");
ok(value == 5, "TCP_KEEPINTVL should be 5, is %ld\n", value);
}
/* Test for erroneously passing a value instead of a pointer as optval */
size = sizeof(char);
err = setsockopt(s, SOL_SOCKET, SO_DONTROUTE, (char *)1, size);
......@@ -1517,7 +1551,15 @@ static void test_set_getsockopt(void)
size = sizeof(save_value);
err = getsockopt(s2, test_optsize[i].level, test_optsize[i].optname, (char*)&save_value, &size);
ok(!err, "Unexpected getsockopt result %d.\n", err);
ok(!err || (test_optsize[i].allow_noprotoopt && WSAGetLastError() == WSAENOPROTOOPT),
"Unexpected getsockopt result %d.\n", err);
if (err)
{
closesocket(s2);
winetest_pop_context();
continue;
}
value64 = 0xffffffff00000001;
err = setsockopt(s2, test_optsize[i].level, test_optsize[i].optname, (char *)&value64, sizeof(value64));
......
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