Erich E. Hoover : ws2_32/tests: Add an interactive test for interface change notifications.
Alexandre Julliard
julliard at wine.codeweavers.com
Tue Feb 10 10:46:04 CST 2015
Module: wine
Branch: master
Commit: c15c7a4925bb095d5a3c2235aa79a5b1e411993b
URL: http://source.winehq.org/git/wine.git/?a=commit;h=c15c7a4925bb095d5a3c2235aa79a5b1e411993b
Author: Erich E. Hoover <erich.e.hoover at wine-staging.com>
Date: Thu Apr 3 09:26:45 2014 -0600
ws2_32/tests: Add an interactive test for interface change notifications.
---
dlls/ws2_32/tests/sock.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 68 insertions(+)
diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c
index 7288b5c..19663c2 100644
--- a/dlls/ws2_32/tests/sock.c
+++ b/dlls/ws2_32/tests/sock.c
@@ -7058,6 +7058,73 @@ static void test_sioRoutingInterfaceQuery(void)
closesocket(sock);
}
+static void test_sioAddressListChange(void)
+{
+ struct sockaddr_in bindAddress;
+ struct in_addr net_address;
+ WSAOVERLAPPED overlapped;
+ struct hostent *h;
+ DWORD num_bytes;
+ SOCKET sock;
+ int acount;
+ int ret;
+
+ if (!winetest_interactive)
+ {
+ skip("Cannot test SIO_ADDRESS_LIST_CHANGE, interactive tests must be enabled\n");
+ return;
+ }
+
+ /* Use gethostbyname to find the list of local network interfaces */
+ h = gethostbyname("");
+ if (!h)
+ {
+ skip("Cannot test SIO_ADDRESS_LIST_CHANGE, gethostbyname failed with %u\n",
+ WSAGetLastError());
+ return;
+ }
+ for (acount = 0; h->h_addr_list[acount]; acount++);
+ if (acount == 0)
+ {
+ skip("Cannot test SIO_ADDRESS_LIST_CHANGE, test requires a network card.\n");
+ return;
+ }
+ net_address.s_addr = *(ULONG *) h->h_addr_list[0];
+
+ /* Bind an overlapped socket to the first found network interface */
+ sock = WSASocketW(AF_INET, SOCK_STREAM, IPPROTO_TCP, NULL, 0, WSA_FLAG_OVERLAPPED);
+ ok(sock != INVALID_SOCKET, "Expected socket to return a valid socket\n");
+ if (sock == INVALID_SOCKET)
+ {
+ skip("Cannot test SIO_ADDRESS_LIST_CHANGE, socket creation failed with %u\n",
+ WSAGetLastError());
+ return;
+ }
+ memset(&bindAddress, 0, sizeof(bindAddress));
+ bindAddress.sin_family = AF_INET;
+ bindAddress.sin_addr.s_addr = net_address.s_addr;
+ ret = bind(sock, (struct sockaddr*)&bindAddress, sizeof(bindAddress));
+ if (ret != 0)
+ {
+ skip("Cannot test SIO_ADDRESS_LIST_CHANGE, failed to bind, error %u\n", WSAGetLastError());
+ goto end;
+ }
+
+ /* Wait for address changes, request that the user connect/disconnect an interface */
+ memset(&overlapped, 0, sizeof(overlapped));
+ overlapped.hEvent = CreateEventA(NULL, FALSE, FALSE, NULL);
+ ret = WSAIoctl(sock, SIO_ADDRESS_LIST_CHANGE, NULL, 0, NULL, 0, &num_bytes, &overlapped, NULL);
+ ok(ret == SOCKET_ERROR, "WSAIoctl succeeded unexpectedly\n");
+ ok(WSAGetLastError() == WSA_IO_PENDING, "Expected pending last error %d\n", WSAGetLastError());
+ trace("Testing socket-based ipv4 address list change notification. Please connect/disconnect or"
+ " change the ipv4 address of any of the local network interfaces (10 second timeout).\n");
+ ret = WaitForSingleObject(overlapped.hEvent, 10000);
+ ok(ret == WAIT_OBJECT_0, "failed to get overlapped event %u\n", ret);
+
+end:
+ closesocket(sock);
+}
+
static void test_synchronous_WSAIoctl(void)
{
HANDLE previous_port, io_port;
@@ -8204,6 +8271,7 @@ START_TEST( sock )
test_ConnectEx();
test_sioRoutingInterfaceQuery();
+ test_sioAddressListChange();
test_WSALookupService();
More information about the wine-cvs
mailing list