Commit 3d51b4eb authored by Sebastian Lackner's avatar Sebastian Lackner Committed by Alexandre Julliard

ws2_32/tests: Add tests for calling select with zero timeout.

parent d4bbcc44
......@@ -3523,29 +3523,45 @@ static void test_select(void)
struct sockaddr_in address;
select_thread_params thread_params;
HANDLE thread_handle;
DWORD id;
DWORD ticks, id;
fdRead = socket(AF_INET, SOCK_STREAM, 0);
ok( (fdRead != INVALID_SOCKET), "socket failed unexpectedly: %d\n", WSAGetLastError() );
fdWrite = socket(AF_INET, SOCK_STREAM, 0);
ok( (fdWrite != INVALID_SOCKET), "socket failed unexpectedly: %d\n", WSAGetLastError() );
maxfd = fdRead;
if (fdWrite > maxfd)
maxfd = fdWrite;
FD_ZERO_ALL();
FD_SET_ALL(fdRead);
FD_SET_ALL(fdWrite);
select_timeout.tv_sec=0;
select_timeout.tv_usec=500;
select_timeout.tv_usec=0;
maxfd = fdRead;
if (fdWrite > maxfd)
maxfd = fdWrite;
ticks = GetTickCount();
ret = select(maxfd+1, &readfds, &writefds, &exceptfds, &select_timeout);
ticks = GetTickCount() - ticks;
ok(ret == 0, "select should not return any socket handles\n");
ok(ticks < 10, "select was blocking for %u ms, expected < 10 ms\n", ticks);
ok(!FD_ISSET(fdRead, &readfds), "FD should not be set\n");
ok(!FD_ISSET(fdWrite, &writefds), "FD should not be set\n");
ok(!FD_ISSET(fdRead, &exceptfds), "FD should not be set\n");
ok(!FD_ISSET(fdWrite, &exceptfds), "FD should not be set\n");
FD_ZERO_ALL();
FD_SET_ALL(fdRead);
FD_SET_ALL(fdWrite);
select_timeout.tv_sec=0;
select_timeout.tv_usec=500;
ret = select(maxfd+1, &readfds, &writefds, &exceptfds, &select_timeout);
ok ( (ret == 0), "select should not return any socket handles\n");
ok ( !FD_ISSET(fdRead, &readfds), "FD should not be set\n");
ok ( !FD_ISSET(fdWrite, &writefds), "FD should not be set\n");
ok ( !FD_ISSET(fdRead, &exceptfds), "FD should not be set\n");
ok ( !FD_ISSET(fdWrite, &exceptfds), "FD should not be set\n");
ok(ret == 0, "select should not return any socket handles\n");
ok(!FD_ISSET(fdRead, &readfds), "FD should not be set\n");
ok(!FD_ISSET(fdWrite, &writefds), "FD should not be set\n");
ok(!FD_ISSET(fdRead, &exceptfds), "FD should not be set\n");
ok(!FD_ISSET(fdWrite, &exceptfds), "FD should not be set\n");
ok ((listen(fdWrite, SOMAXCONN) == SOCKET_ERROR), "listen did not fail\n");
ret = closesocket(fdWrite);
......
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