mirror of
https://github.com/reactos/reactos.git
synced 2025-05-31 15:08:14 +00:00
[IPHLPAPI_WINETEST]
* Sync with Wine 1.3.29. svn path=/trunk/; revision=53964
This commit is contained in:
parent
ffdcf82397
commit
fe92ad9f84
1 changed files with 99 additions and 10 deletions
|
@ -74,6 +74,8 @@ typedef DWORD (WINAPI *GetTcpTableFunc)(PMIB_TCPTABLE,PDWORD,BOOL);
|
|||
typedef DWORD (WINAPI *GetUdpTableFunc)(PMIB_UDPTABLE,PDWORD,BOOL);
|
||||
typedef DWORD (WINAPI *GetPerAdapterInfoFunc)(ULONG,PIP_PER_ADAPTER_INFO,PULONG);
|
||||
typedef DWORD (WINAPI *GetAdaptersAddressesFunc)(ULONG,ULONG,PVOID,PIP_ADAPTER_ADDRESSES,PULONG);
|
||||
typedef DWORD (WINAPI *NotifyAddrChangeFunc)(PHANDLE,LPOVERLAPPED);
|
||||
typedef BOOL (WINAPI *CancelIPChangeNotifyFunc)(LPOVERLAPPED);
|
||||
|
||||
static GetNumberOfInterfacesFunc gGetNumberOfInterfaces = NULL;
|
||||
static GetIpAddrTableFunc gGetIpAddrTable = NULL;
|
||||
|
@ -93,6 +95,8 @@ static GetTcpTableFunc gGetTcpTable = NULL;
|
|||
static GetUdpTableFunc gGetUdpTable = NULL;
|
||||
static GetPerAdapterInfoFunc gGetPerAdapterInfo = NULL;
|
||||
static GetAdaptersAddressesFunc gGetAdaptersAddresses = NULL;
|
||||
static NotifyAddrChangeFunc gNotifyAddrChange = NULL;
|
||||
static CancelIPChangeNotifyFunc gCancelIPChangeNotify = NULL;
|
||||
|
||||
static void loadIPHlpApi(void)
|
||||
{
|
||||
|
@ -132,6 +136,10 @@ static void loadIPHlpApi(void)
|
|||
hLibrary, "GetUdpTable");
|
||||
gGetPerAdapterInfo = (GetPerAdapterInfoFunc)GetProcAddress(hLibrary, "GetPerAdapterInfo");
|
||||
gGetAdaptersAddresses = (GetAdaptersAddressesFunc)GetProcAddress(hLibrary, "GetAdaptersAddresses");
|
||||
gNotifyAddrChange = (NotifyAddrChangeFunc)GetProcAddress(
|
||||
hLibrary, "NotifyAddrChange");
|
||||
gCancelIPChangeNotify = (CancelIPChangeNotifyFunc)GetProcAddress(
|
||||
hLibrary, "CancelIPChangeNotify");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -154,6 +162,8 @@ static void freeIPHlpApi(void)
|
|||
gGetUdpStatistics = NULL;
|
||||
gGetTcpTable = NULL;
|
||||
gGetUdpTable = NULL;
|
||||
gNotifyAddrChange = NULL;
|
||||
gCancelIPChangeNotify = NULL;
|
||||
FreeLibrary(hLibrary);
|
||||
hLibrary = NULL;
|
||||
}
|
||||
|
@ -184,7 +194,7 @@ static void testGetNumberOfInterfaces(void)
|
|||
|
||||
/* Crashes on Vista */
|
||||
if (0) {
|
||||
apiReturn = gGetNumberOfInterfaces(NULL), numInterfaces;
|
||||
apiReturn = gGetNumberOfInterfaces(NULL);
|
||||
if (apiReturn == ERROR_NOT_SUPPORTED)
|
||||
return;
|
||||
ok(apiReturn == ERROR_INVALID_PARAMETER,
|
||||
|
@ -806,6 +816,78 @@ static void testGetPerAdapterInfo(void)
|
|||
HeapFree( GetProcessHeap(), 0, buffer );
|
||||
}
|
||||
|
||||
static void testNotifyAddrChange(void)
|
||||
{
|
||||
DWORD ret, bytes;
|
||||
OVERLAPPED overlapped;
|
||||
HANDLE handle;
|
||||
BOOL success;
|
||||
|
||||
if (!gNotifyAddrChange)
|
||||
{
|
||||
win_skip("NotifyAddrChange not present\n");
|
||||
return;
|
||||
}
|
||||
if (!gCancelIPChangeNotify)
|
||||
{
|
||||
win_skip("CancelIPChangeNotify not present\n");
|
||||
return;
|
||||
}
|
||||
|
||||
handle = NULL;
|
||||
ZeroMemory(&overlapped, sizeof(overlapped));
|
||||
ret = gNotifyAddrChange(&handle, &overlapped);
|
||||
if (ret == ERROR_NOT_SUPPORTED)
|
||||
{
|
||||
win_skip("NotifyAddrChange is not supported\n");
|
||||
return;
|
||||
}
|
||||
ok(ret == ERROR_IO_PENDING, "NotifyAddrChange returned %d, expected ERROR_IO_PENDING\n", ret);
|
||||
ret = GetLastError();
|
||||
todo_wine ok(ret == ERROR_IO_PENDING, "GetLastError returned %d, expected ERROR_IO_PENDING\n", ret);
|
||||
success = gCancelIPChangeNotify(&overlapped);
|
||||
todo_wine ok(success == TRUE, "CancelIPChangeNotify returned FALSE, expected TRUE\n");
|
||||
|
||||
ZeroMemory(&overlapped, sizeof(overlapped));
|
||||
success = gCancelIPChangeNotify(&overlapped);
|
||||
ok(success == FALSE, "CancelIPChangeNotify returned TRUE, expected FALSE\n");
|
||||
|
||||
handle = NULL;
|
||||
ZeroMemory(&overlapped, sizeof(overlapped));
|
||||
overlapped.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
|
||||
ret = gNotifyAddrChange(&handle, &overlapped);
|
||||
ok(ret == ERROR_IO_PENDING, "NotifyAddrChange returned %d, expected ERROR_IO_PENDING\n", ret);
|
||||
todo_wine ok(handle != INVALID_HANDLE_VALUE, "NotifyAddrChange returned invalid file handle\n");
|
||||
success = GetOverlappedResult(handle, &overlapped, &bytes, FALSE);
|
||||
ok(success == FALSE, "GetOverlappedResult returned TRUE, expected FALSE\n");
|
||||
ret = GetLastError();
|
||||
ok(ret == ERROR_IO_INCOMPLETE, "GetLastError returned %d, expected ERROR_IO_INCOMPLETE\n", ret);
|
||||
success = gCancelIPChangeNotify(&overlapped);
|
||||
todo_wine ok(success == TRUE, "CancelIPChangeNotify returned FALSE, expected TRUE\n");
|
||||
|
||||
if (winetest_interactive)
|
||||
{
|
||||
handle = NULL;
|
||||
ZeroMemory(&overlapped, sizeof(overlapped));
|
||||
overlapped.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
|
||||
trace("Testing asynchronous ipv4 address change notification. Please "
|
||||
"change the ipv4 address of one of your network interfaces\n");
|
||||
ret = gNotifyAddrChange(&handle, &overlapped);
|
||||
ok(ret == ERROR_IO_PENDING, "NotifyAddrChange returned %d, expected NO_ERROR\n", ret);
|
||||
success = GetOverlappedResult(handle, &overlapped, &bytes, TRUE);
|
||||
ok(success == TRUE, "GetOverlappedResult returned FALSE, expected TRUE\n");
|
||||
}
|
||||
|
||||
/* test synchronous functionality */
|
||||
if (winetest_interactive)
|
||||
{
|
||||
trace("Testing synchronous ipv4 address change notification. Please "
|
||||
"change the ipv4 address of one of your network interfaces\n");
|
||||
ret = gNotifyAddrChange(NULL, NULL);
|
||||
todo_wine ok(ret == NO_ERROR, "NotifyAddrChange returned %d, expected NO_ERROR\n", ret);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
still-to-be-tested 2K-onward functions:
|
||||
AddIPAddress
|
||||
|
@ -815,20 +897,20 @@ DeleteProxyArpEntry
|
|||
EnableRouter
|
||||
FlushIpNetTable
|
||||
GetAdapterIndex
|
||||
NotifyAddrChange
|
||||
NotifyRouteChange
|
||||
NotifyRouteChange + CancelIPChangeNotify
|
||||
SendARP
|
||||
UnenableRouter
|
||||
*/
|
||||
static void testWin2KFunctions(void)
|
||||
{
|
||||
testGetPerAdapterInfo();
|
||||
testNotifyAddrChange();
|
||||
}
|
||||
|
||||
static void test_GetAdaptersAddresses(void)
|
||||
{
|
||||
ULONG ret, size;
|
||||
IP_ADAPTER_ADDRESSES *aa;
|
||||
IP_ADAPTER_ADDRESSES *aa, *ptr;
|
||||
IP_ADAPTER_UNICAST_ADDRESS *ua;
|
||||
|
||||
if (!gGetAdaptersAddresses)
|
||||
|
@ -840,17 +922,25 @@ static void test_GetAdaptersAddresses(void)
|
|||
ret = gGetAdaptersAddresses(AF_UNSPEC, 0, NULL, NULL, NULL);
|
||||
ok(ret == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER got %u\n", ret);
|
||||
|
||||
size = 0;
|
||||
/* size should be ignored and overwritten if buffer is NULL */
|
||||
size = 0x7fffffff;
|
||||
ret = gGetAdaptersAddresses(AF_UNSPEC, 0, NULL, NULL, &size);
|
||||
ok(ret == ERROR_BUFFER_OVERFLOW, "expected ERROR_BUFFER_OVERFLOW, got %u\n", ret);
|
||||
if (ret != ERROR_BUFFER_OVERFLOW) return;
|
||||
|
||||
aa = HeapAlloc(GetProcessHeap(), 0, size);
|
||||
ret = gGetAdaptersAddresses(AF_UNSPEC, 0, NULL, aa, &size);
|
||||
ptr = HeapAlloc(GetProcessHeap(), 0, size);
|
||||
ret = gGetAdaptersAddresses(AF_UNSPEC, 0, NULL, ptr, &size);
|
||||
ok(!ret, "expected ERROR_SUCCESS got %u\n", ret);
|
||||
|
||||
while (!ret && winetest_debug > 1 && aa)
|
||||
for (aa = ptr; !ret && aa; aa = aa->Next)
|
||||
{
|
||||
ok(aa->DnsSuffix != NULL, "DnsSuffix is not a valid pointer\n");
|
||||
ok(aa->Description != NULL, "Description is not a valid pointer\n");
|
||||
ok(aa->FriendlyName != NULL, "FriendlyName is not a valid pointer\n");
|
||||
|
||||
if (winetest_debug <= 1)
|
||||
continue;
|
||||
|
||||
trace("Length: %u\n", S(U(*aa)).Length);
|
||||
trace("IfIndex: %u\n", S(U(*aa)).IfIndex);
|
||||
trace("Next: %p\n", aa->Next);
|
||||
|
@ -886,9 +976,8 @@ static void test_GetAdaptersAddresses(void)
|
|||
trace("IfType: %u\n", aa->IfType);
|
||||
trace("OperStatus: %u\n", aa->OperStatus);
|
||||
trace("\n");
|
||||
aa = aa->Next;
|
||||
}
|
||||
HeapFree(GetProcessHeap(), 0, aa);
|
||||
HeapFree(GetProcessHeap(), 0, ptr);
|
||||
}
|
||||
|
||||
START_TEST(iphlpapi)
|
||||
|
|
Loading…
Reference in a new issue