Commit 9d330d81 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

ws2_32/tests: Make sure that WSARecv() completes synchronously in test_WSARecv().

parent d9ad68a1
......@@ -7626,24 +7626,29 @@ static void test_WSARecv(void)
memset(&ov, 0, sizeof(ov));
flags = 0;
bufs[0].len = 2;
bufs[0].len = 1;
bufs[0].buf = buf;
/* Send 4 bytes and receive in two calls of 2 */
/* Send 2 bytes and receive in two calls of 1 */
SetLastError(0xdeadbeef);
iret = send(src, "test", 4, 0);
ok(iret == 4, "Expected 4, got %d\n", iret);
iret = send(src, "ab", 2, 0);
ok(iret == 2, "got %d\n", iret);
ok(GetLastError() == ERROR_SUCCESS, "Expected 0, got %ld\n", GetLastError());
SetLastError(0xdeadbeef);
bytesReturned = 0xdeadbeef;
/* Non-overlapped WSARecv() performs an alertable wait (tested below), but
* not if it completes synchronously. Make sure it completes synchronously
* by polling for input. */
check_poll_mask(dest, POLLRDNORM, POLLRDNORM);
apc_count = 0;
dwret = QueueUserAPC(apc_func, GetCurrentThread(), (ULONG_PTR)&apc_count);
ok(dwret, "QueueUserAPC returned %lu\n", dwret);
iret = WSARecv(dest, bufs, 1, &bytesReturned, &flags, NULL, NULL);
ok(!iret, "Expected 0, got %d\n", iret);
ok(bytesReturned == 2, "Expected 2, got %ld\n", bytesReturned);
ok(bytesReturned == 1, "got %ld\n", bytesReturned);
ok(GetLastError() == ERROR_SUCCESS, "Expected 0, got %ld\n", GetLastError());
ok(!apc_count, "got apc_count %u.\n", apc_count);
......@@ -7654,7 +7659,7 @@ static void test_WSARecv(void)
bytesReturned = 0xdeadbeef;
iret = WSARecv(dest, bufs, 1, &bytesReturned, &flags, NULL, NULL);
ok(!iret, "Expected 0, got %d\n", iret);
ok(bytesReturned == 2, "Expected 2, got %ld\n", bytesReturned);
ok(bytesReturned == 1, "got %ld\n", bytesReturned);
ok(GetLastError() == ERROR_SUCCESS, "Expected 0, got %ld\n", GetLastError());
bufs[0].len = 4;
......
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