mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 18:15:11 +00:00
[WS2_32_APITEST:WSAASYNC] Fix and improve some tests. ROSTESTS-317 (#1132)
- Add getsockname() addr_con_loc looping case. Fix intermittent failure on Windows (NT <= 6.0): "WSAAsync.c:232: Test failed: ERROR: getsockname function wrong addr, expected 100007f returned 0" ROSTESTS-317 - Improve select() ServerSocket looping case. Visible on Windows (NT >= 6.1).
This commit is contained in:
parent
62e59652a0
commit
ffd0ab39b5
1 changed files with 38 additions and 6 deletions
|
@ -10,6 +10,7 @@
|
|||
#define SVR_PORT 5000
|
||||
#define WAIT_TIMEOUT_ 10000
|
||||
#define EXIT_FLAGS (FD_ACCEPT|FD_CONNECT)
|
||||
#define MAX_LOOPCOUNT 9u
|
||||
|
||||
START_TEST(WSAAsync)
|
||||
{
|
||||
|
@ -36,6 +37,8 @@ START_TEST(WSAAsync)
|
|||
struct fd_set select_efds;
|
||||
struct timeval timeval;
|
||||
BOOL ConnectSent = FALSE;
|
||||
unsigned int Addr_con_locLoopCount = 0,
|
||||
ServerSocketLoopCount = 0;
|
||||
|
||||
if (WSAStartup(MAKEWORD(2, 2), &WsaData) != 0)
|
||||
{
|
||||
|
@ -124,7 +127,7 @@ START_TEST(WSAAsync)
|
|||
if (dwWait != WAIT_OBJECT_0 && // server socket event
|
||||
dwWait != WAIT_OBJECT_0+1) // client socket event
|
||||
{
|
||||
ok(0, "Unknown event received %ld\n", dwWait);
|
||||
ok(FALSE, "Unknown event received %lu\n", dwWait);
|
||||
skip("ERROR: Connection timeout\n");
|
||||
break;
|
||||
}
|
||||
|
@ -227,12 +230,27 @@ START_TEST(WSAAsync)
|
|||
else
|
||||
{
|
||||
if (nSockNameRes != 0)
|
||||
ok(0, "ERROR: getsockname function failed, expected %d error %d\n", 0, nSockNameRes);
|
||||
ok(FALSE, "ERROR: getsockname function failed, expected 0 error %d\n", nSockNameRes);
|
||||
if (len != sizeof(addr_con_loc))
|
||||
ok(0, "ERROR: getsockname function wrong size, expected %d returned %d\n", sizeof(addr_con_loc), len);
|
||||
// FIXME: fails on WHS testbot
|
||||
//if (addr_con_loc.sin_addr.s_addr != server_addr_in.sin_addr.s_addr)
|
||||
// ok(0, "ERROR: getsockname function wrong addr, expected %lx returned %lx\n", server_addr_in.sin_addr.s_addr, addr_con_loc.sin_addr.s_addr);
|
||||
ok(FALSE, "ERROR: getsockname function wrong size, expected %Iu returned %d\n", sizeof(addr_con_loc), len);
|
||||
|
||||
if (addr_con_loc.sin_addr.s_addr == 0ul)
|
||||
{
|
||||
if (++Addr_con_locLoopCount >= MAX_LOOPCOUNT)
|
||||
{
|
||||
ok(FALSE, "Giving up, on getsockname() (%u/%u), as addr_con_loc is not set yet\n",
|
||||
Addr_con_locLoopCount, MAX_LOOPCOUNT);
|
||||
goto done;
|
||||
}
|
||||
|
||||
trace("Looping, for getsockname() (%u/%u), as addr_con_loc is not set yet\n",
|
||||
Addr_con_locLoopCount, MAX_LOOPCOUNT);
|
||||
Sleep(1);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (addr_con_loc.sin_addr.s_addr != server_addr_in.sin_addr.s_addr)
|
||||
ok(FALSE, "ERROR: getsockname function wrong addr, expected %08lx returned %08lx\n", server_addr_in.sin_addr.s_addr, addr_con_loc.sin_addr.s_addr);
|
||||
}
|
||||
if ((dwFlags & FD_ACCEPT) != 0)
|
||||
{// client connected
|
||||
|
@ -281,6 +299,20 @@ START_TEST(WSAAsync)
|
|||
ok(sockaccept != INVALID_SOCKET, "ERROR: Connection accept function failed, error %d\n", WSAGetLastError());
|
||||
dwFlags |= FD_ACCEPT;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (++ServerSocketLoopCount >= MAX_LOOPCOUNT)
|
||||
{
|
||||
ok(FALSE, "Giving up, on select() (%u/%u), as ServerSocket is not readable yet\n",
|
||||
ServerSocketLoopCount, MAX_LOOPCOUNT);
|
||||
goto done;
|
||||
}
|
||||
|
||||
trace("Looping, for select() (%u/%u), as ServerSocket is not readable yet\n",
|
||||
ServerSocketLoopCount, MAX_LOOPCOUNT);
|
||||
Sleep(1);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue