Commit fabd9e1f authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

iphlpapi/tests: Add more tests for GetAdaptersInfo().

parent 1f2adbb3
...@@ -1118,53 +1118,50 @@ todo_wine_if( row.dwType == IF_TYPE_SOFTWARE_LOOPBACK) ...@@ -1118,53 +1118,50 @@ todo_wine_if( row.dwType == IF_TYPE_SOFTWARE_LOOPBACK)
static void testGetAdaptersInfo(void) static void testGetAdaptersInfo(void)
{ {
DWORD apiReturn; IP_ADAPTER_INFO *ptr, *buf;
NET_LUID luid;
GUID guid;
char name[ARRAY_SIZE(ptr->AdapterName)];
DWORD err;
ULONG len = 0; ULONG len = 0;
MIB_IFROW row;
apiReturn = GetAdaptersInfo(NULL, NULL); err = GetAdaptersInfo( NULL, NULL );
if (apiReturn == ERROR_NOT_SUPPORTED) { ok( err == ERROR_INVALID_PARAMETER, "got %d\n", err );
skip("GetAdaptersInfo is not supported\n"); err = GetAdaptersInfo( NULL, &len );
return; ok( err == ERROR_NO_DATA || err == ERROR_BUFFER_OVERFLOW, "got %d\n", err );
} if (err == ERROR_NO_DATA) return;
ok(apiReturn == ERROR_INVALID_PARAMETER,
"GetAdaptersInfo returned %d, expected ERROR_INVALID_PARAMETER\n",
apiReturn);
apiReturn = GetAdaptersInfo(NULL, &len);
ok(apiReturn == ERROR_NO_DATA || apiReturn == ERROR_BUFFER_OVERFLOW,
"GetAdaptersInfo returned %d, expected ERROR_NO_DATA or ERROR_BUFFER_OVERFLOW\n",
apiReturn);
if (apiReturn == ERROR_NO_DATA)
; /* no adapter's, that's okay */
else if (apiReturn == ERROR_BUFFER_OVERFLOW) {
PIP_ADAPTER_INFO ptr, buf = HeapAlloc(GetProcessHeap(), 0, len);
NET_LUID luid;
GUID guid;
char AdapterName[ARRAY_SIZE(ptr->AdapterName)];
apiReturn = GetAdaptersInfo(buf, &len); buf = malloc( len );
ok(apiReturn == NO_ERROR, err = GetAdaptersInfo( buf, &len );
"GetAdaptersInfo(buf, &dwSize) returned %d, expected NO_ERROR\n", ok( !err, "got %d\n", err );
apiReturn); ptr = buf;
ptr = buf; while (ptr)
while (ptr) { {
ConvertInterfaceIndexToLuid(ptr->Index, &luid); trace( "adapter '%s', address %s/%s gateway %s/%s\n", ptr->AdapterName,
ConvertInterfaceLuidToGuid(&luid, &guid); ptr->IpAddressList.IpAddress.String, ptr->IpAddressList.IpMask.String,
sprintf(AdapterName, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}", ptr->GatewayList.IpAddress.String, ptr->GatewayList.IpMask.String );
guid.Data1, guid.Data2, guid.Data3, guid.Data4[0], guid.Data4[1], row.dwIndex = ptr->Index;
guid.Data4[2], guid.Data4[3], guid.Data4[4], guid.Data4[5], GetIfEntry( &row );
guid.Data4[6], guid.Data4[7]); ConvertInterfaceIndexToLuid( ptr->Index, &luid );
ok(!strcmp(ptr->AdapterName, AdapterName), "expected '%s' got '%s'\n", ptr->AdapterName, AdapterName); ConvertInterfaceLuidToGuid( &luid, &guid );
ok(ptr->IpAddressList.IpAddress.String[0], "A valid IP address must be present\n"); sprintf( name, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
ok(ptr->IpAddressList.IpMask.String[0], "A valid mask must be present\n"); guid.Data1, guid.Data2, guid.Data3, guid.Data4[0], guid.Data4[1],
ok(ptr->GatewayList.IpAddress.String[0], "A valid IP address must be present\n"); guid.Data4[2], guid.Data4[3], guid.Data4[4], guid.Data4[5],
ok(ptr->GatewayList.IpMask.String[0], "A valid mask must be present\n"); guid.Data4[6], guid.Data4[7] );
trace("adapter '%s', address %s/%s gateway %s/%s\n", ptr->AdapterName, ok( !strcmp( ptr->AdapterName, name ), "expected '%s' got '%s'\n", ptr->AdapterName, name );
ptr->IpAddressList.IpAddress.String, ptr->IpAddressList.IpMask.String, ok( !strcmp( ptr->Description, (char *)row.bDescr ), "got %s vs %s\n", ptr->Description, (char *)row.bDescr );
ptr->GatewayList.IpAddress.String, ptr->GatewayList.IpMask.String); ok( ptr->AddressLength == row.dwPhysAddrLen, "got %d vs %d\n", ptr->AddressLength, row.dwPhysAddrLen );
ptr = ptr->Next; ok( !memcmp(ptr->Address, row.bPhysAddr, ptr->AddressLength ), "mismatch\n" );
} ok( ptr->Type == row.dwType, "got %d vs %d\n", ptr->Type, row.dwType );
HeapFree(GetProcessHeap(), 0, buf); ok( ptr->Type != MIB_IF_TYPE_LOOPBACK, "shouldn't get loopback\n" );
ok( ptr->IpAddressList.IpAddress.String[0], "A valid IP address must be present\n" );
ok( ptr->IpAddressList.IpMask.String[0], "A valid mask must be present\n" );
ok( ptr->GatewayList.IpAddress.String[0], "A valid IP address must be present\n" );
ok( ptr->GatewayList.IpMask.String[0], "A valid mask must be present\n" );
ptr = ptr->Next;
} }
free( buf );
} }
static void testGetNetworkParams(void) static void testGetNetworkParams(void)
......
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