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

This commit is contained in:
Sebastian Lackner 2015-06-07 19:18:51 +02:00 committed by Alexandre Julliard
parent d4bbcc44cb
commit 3d51b4eb9d
1 changed files with 27 additions and 11 deletions

View File

@ -3523,25 +3523,41 @@ static void test_select(void)
struct sockaddr_in address; struct sockaddr_in address;
select_thread_params thread_params; select_thread_params thread_params;
HANDLE thread_handle; HANDLE thread_handle;
DWORD id; DWORD ticks, id;
fdRead = socket(AF_INET, SOCK_STREAM, 0); fdRead = socket(AF_INET, SOCK_STREAM, 0);
ok( (fdRead != INVALID_SOCKET), "socket failed unexpectedly: %d\n", WSAGetLastError() ); ok( (fdRead != INVALID_SOCKET), "socket failed unexpectedly: %d\n", WSAGetLastError() );
fdWrite = socket(AF_INET, SOCK_STREAM, 0); fdWrite = socket(AF_INET, SOCK_STREAM, 0);
ok( (fdWrite != INVALID_SOCKET), "socket failed unexpectedly: %d\n", WSAGetLastError() ); 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=0;
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_ZERO_ALL();
FD_SET_ALL(fdRead); FD_SET_ALL(fdRead);
FD_SET_ALL(fdWrite); FD_SET_ALL(fdWrite);
select_timeout.tv_sec=0; select_timeout.tv_sec=0;
select_timeout.tv_usec=500; select_timeout.tv_usec=500;
maxfd = fdRead;
if (fdWrite > maxfd)
maxfd = fdWrite;
ret = select(maxfd+1, &readfds, &writefds, &exceptfds, &select_timeout); ret = select(maxfd+1, &readfds, &writefds, &exceptfds, &select_timeout);
ok ( (ret == 0), "select should not return any socket handles\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(fdRead, &readfds), "FD should not be set\n");
ok(!FD_ISSET(fdWrite, &writefds), "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(fdRead, &exceptfds), "FD should not be set\n");