Commit de48f96d authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

ws2_32/tests: Add more tests for SIO_GET_EXTENSION_FUNCTION_ADDRESS.

parent e969cf09
......@@ -4187,6 +4187,98 @@ static void test_unsupported_ioctls(void)
}
}
static void test_get_extension_func(void)
{
OVERLAPPED overlapped = {0}, *overlapped_ptr;
GUID acceptex_guid = WSAID_ACCEPTEX;
GUID bogus_guid = {0xdeadbeef};
ULONG_PTR key;
HANDLE port;
DWORD size;
void *func;
SOCKET s;
int ret;
s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
port = CreateIoCompletionPort((HANDLE)s, NULL, 123, 0);
WSASetLastError(0xdeadbeef);
ret = WSAIoctl(s, SIO_GET_EXTENSION_FUNCTION_POINTER, &acceptex_guid, sizeof(GUID),
&func, sizeof(func), NULL, &overlapped, NULL);
todo_wine ok(ret == -1, "expected failure\n");
todo_wine ok(WSAGetLastError() == WSAEFAULT, "got error %u\n", WSAGetLastError());
WSASetLastError(0xdeadbeef);
size = 0xdeadbeef;
ret = WSAIoctl(s, SIO_GET_EXTENSION_FUNCTION_POINTER, &acceptex_guid, sizeof(GUID),
&func, sizeof(func), &size, NULL, NULL);
ok(!ret, "expected success\n");
todo_wine ok(!WSAGetLastError(), "got error %u\n", WSAGetLastError());
ok(size == sizeof(func), "got size %u\n", size);
WSASetLastError(0xdeadbeef);
size = 0xdeadbeef;
overlapped.Internal = 0xdeadbeef;
overlapped.InternalHigh = 0xdeadbeef;
ret = WSAIoctl(s, SIO_GET_EXTENSION_FUNCTION_POINTER, &acceptex_guid, sizeof(GUID),
&func, sizeof(func), &size, &overlapped, NULL);
ok(!ret, "expected success\n");
todo_wine ok(!WSAGetLastError(), "got error %u\n", WSAGetLastError());
ok(size == sizeof(func), "got size %u\n", size);
ret = GetQueuedCompletionStatus(port, &size, &key, &overlapped_ptr, 0);
ok(ret, "got error %u\n", GetLastError());
todo_wine ok(!size, "got size %u\n", size);
ok(key == 123, "got key %Iu\n", key);
ok(overlapped_ptr == &overlapped, "got overlapped %p\n", overlapped_ptr);
ok(!overlapped.Internal, "got status %#x\n", (NTSTATUS)overlapped.Internal);
todo_wine ok(!overlapped.InternalHigh, "got size %Iu\n", overlapped.InternalHigh);
size = 0xdeadbeef;
overlapped.Internal = 0xdeadbeef;
overlapped.InternalHigh = 0xdeadbeef;
ret = WSAIoctl(s, SIO_GET_EXTENSION_FUNCTION_POINTER, &bogus_guid, sizeof(GUID),
&func, sizeof(func), &size, &overlapped, NULL);
ok(ret == -1, "expected failure\n");
todo_wine ok(WSAGetLastError() == WSAEINVAL, "got error %u\n", WSAGetLastError());
ok(size == 0xdeadbeef, "got size %u\n", size);
todo_wine ok(overlapped.Internal == 0xdeadbeef, "got status %#x\n", (NTSTATUS)overlapped.Internal);
todo_wine ok(overlapped.InternalHigh == 0xdeadbeef, "got size %Iu\n", overlapped.InternalHigh);
ret = GetQueuedCompletionStatus(port, &size, &key, &overlapped_ptr, 0);
todo_wine ok(!ret, "expected failure\n");
todo_wine ok(GetLastError() == WAIT_TIMEOUT, "got error %u\n", WSAGetLastError());
CloseHandle(port);
closesocket(s);
s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
ret = WSAIoctl(s, SIO_GET_EXTENSION_FUNCTION_POINTER, &acceptex_guid, sizeof(GUID),
&func, sizeof(func), NULL, &overlapped, socket_apc);
todo_wine ok(ret == -1, "expected failure\n");
todo_wine ok(WSAGetLastError() == WSAEFAULT, "got error %u\n", WSAGetLastError());
apc_count = 0;
size = 0xdeadbeef;
ret = WSAIoctl(s, SIO_GET_EXTENSION_FUNCTION_POINTER, &acceptex_guid, sizeof(GUID),
&func, sizeof(func), &size, &overlapped, socket_apc);
ok(!ret, "got error %u\n", WSAGetLastError());
ok(size == sizeof(func), "got size %u\n", size);
ret = SleepEx(0, TRUE);
todo_wine ok(ret == WAIT_IO_COMPLETION, "got %d\n", ret);
if (ret == WAIT_IO_COMPLETION)
{
ok(apc_count == 1, "APC was called %u times\n", apc_count);
ok(!apc_error, "got APC error %u\n", apc_error);
ok(!apc_size, "got APC size %u\n", apc_size);
ok(apc_overlapped == &overlapped, "got APC overlapped %p\n", apc_overlapped);
}
closesocket(s);
}
static BOOL drain_pause = FALSE;
static DWORD WINAPI drain_socket_thread(LPVOID arg)
{
......@@ -10406,6 +10498,7 @@ START_TEST( sock )
test_address_list_query();
test_fionbio();
test_fionread_siocatmark();
test_get_extension_func();
test_keepalive_vals();
test_sioRoutingInterfaceQuery();
test_sioAddressListChange();
......
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