ws2_32/tests: Add some FIONREAD tests.
This commit is contained in:
parent
4ec773a099
commit
7e4d075ec1
|
@ -3859,7 +3859,7 @@ static void test_addr_to_print(void)
|
||||||
|
|
||||||
static void test_ioctlsocket(void)
|
static void test_ioctlsocket(void)
|
||||||
{
|
{
|
||||||
SOCKET sock;
|
SOCKET sock, src, dst;
|
||||||
struct tcp_keepalive kalive;
|
struct tcp_keepalive kalive;
|
||||||
int ret, optval;
|
int ret, optval;
|
||||||
static const LONG cmds[] = {FIONBIO, FIONREAD, SIOCATMARK};
|
static const LONG cmds[] = {FIONBIO, FIONREAD, SIOCATMARK};
|
||||||
|
@ -3943,6 +3943,32 @@ static void test_ioctlsocket(void)
|
||||||
ok(ret == 0 || broken(ret == SOCKET_ERROR), "WSAIoctl failed unexpectedly\n");
|
ok(ret == 0 || broken(ret == SOCKET_ERROR), "WSAIoctl failed unexpectedly\n");
|
||||||
|
|
||||||
closesocket(sock);
|
closesocket(sock);
|
||||||
|
|
||||||
|
if (tcp_socketpair(&src, &dst) != 0)
|
||||||
|
{
|
||||||
|
ok(0, "creating socket pair failed, skipping test\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* test FIONREAD on TCP sockets */
|
||||||
|
optval = 0xdeadbeef;
|
||||||
|
ret = WSAIoctl(dst, FIONREAD, NULL, 0, &optval, sizeof(optval), &arg, NULL, NULL);
|
||||||
|
ok(ret == 0, "WSAIoctl failed unexpectedly with error %d\n", WSAGetLastError());
|
||||||
|
ok(optval == 0, "FIONREAD should have returned 0 bytes, got %d instead\n", optval);
|
||||||
|
|
||||||
|
optval = 0xdeadbeef;
|
||||||
|
ok(send(src, "TEST", 4, 0) == 4, "failed to send test data\n");
|
||||||
|
Sleep(100);
|
||||||
|
ret = WSAIoctl(dst, FIONREAD, NULL, 0, &optval, sizeof(optval), &arg, NULL, NULL);
|
||||||
|
ok(ret == 0, "WSAIoctl failed unexpectedly with error %d\n", WSAGetLastError());
|
||||||
|
ok(optval == 4, "FIONREAD should have returned 4 bytes, got %d instead\n", optval);
|
||||||
|
|
||||||
|
closesocket(dst);
|
||||||
|
optval = 0xdeadbeef;
|
||||||
|
ret = WSAIoctl(dst, FIONREAD, NULL, 0, &optval, sizeof(optval), &arg, NULL, NULL);
|
||||||
|
ok(ret == SOCKET_ERROR, "WSAIoctl succeeded unexpectedly\n");
|
||||||
|
ok(optval == 0xdeadbeef, "FIONREAD should not have changed last error, got %d instead\n", optval);
|
||||||
|
closesocket(src);
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL drain_pause = FALSE;
|
static BOOL drain_pause = FALSE;
|
||||||
|
|
Loading…
Reference in New Issue