Commit 13b66d3d authored by Akihiro Sagawa's avatar Akihiro Sagawa Committed by Alexandre Julliard

ws2_32/tests: Add ioctlsocket(FIONREAD) tests with listening socket.

parent 0c87c1c4
...@@ -5120,6 +5120,7 @@ static void test_ioctlsocket(void) ...@@ -5120,6 +5120,7 @@ static void test_ioctlsocket(void)
{ {
SOCKET sock, src, dst; SOCKET sock, src, dst;
struct tcp_keepalive kalive; struct tcp_keepalive kalive;
struct sockaddr_in address;
int ret, optval; int ret, optval;
static const LONG cmds[] = {FIONBIO, FIONREAD, SIOCATMARK}; static const LONG cmds[] = {FIONBIO, FIONREAD, SIOCATMARK};
UINT i, bytes_rec; UINT i, bytes_rec;
...@@ -5205,6 +5206,38 @@ static void test_ioctlsocket(void) ...@@ -5205,6 +5206,38 @@ static void test_ioctlsocket(void)
closesocket(sock); closesocket(sock);
sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
ok(sock != INVALID_SOCKET, "Creating the socket failed: %d\n", WSAGetLastError());
if(sock == INVALID_SOCKET)
{
skip("Can't continue without a socket.\n");
return;
}
/* test FIONREAD with a fresh and non-connected socket */
arg = 0xdeadbeef;
ret = ioctlsocket(sock, FIONREAD, &arg);
ok(ret == 0, "ioctlsocket failed unexpectedly with error %d\n", WSAGetLastError());
ok(arg == 0, "expected 0, got %u\n", arg);
memset(&address, 0, sizeof(address));
address.sin_family = AF_INET;
address.sin_addr.s_addr = inet_addr( SERVERIP );
address.sin_port = htons( SERVERPORT );
ret = bind(sock, (struct sockaddr *)&address, sizeof(address));
ok(ret == 0, "bind failed unexpectedly with error %d\n", WSAGetLastError());
ret = listen(sock, SOMAXCONN);
ok(ret == 0, "listen failed unexpectedly with error %d\n", WSAGetLastError());
/* test FIONREAD with listening socket */
arg = 0xdeadbeef;
ret = ioctlsocket(sock, FIONREAD, &arg);
todo_wine ok(ret == 0, "ioctlsocket failed unexpectedly with error %d\n", WSAGetLastError());
todo_wine ok(arg == 0, "expected 0, got %u\n", arg);
closesocket(sock);
if (tcp_socketpair(&src, &dst) != 0) if (tcp_socketpair(&src, &dst) != 0)
{ {
ok(0, "creating socket pair failed, skipping test\n"); ok(0, "creating socket pair failed, skipping test\n");
......
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