[PATCH resend v3 1/2] iphlpapi: Add a test for GetAdaptersInfo.
Hans Leidekker
hans at codeweavers.com
Fri Mar 12 04:27:09 CST 2021
On Fri, 2021-03-12 at 16:00 +0800, Yeshun Ye wrote:
> +static void test_GetAdaptersInfo_AdapterName(void)
Please add these tests to testGetAdaptersInfo().
> +{
> + DWORD apiReturn;
> + ULONG size = 0;
> + ULONG family = AF_UNSPEC;
> + ULONG flags = GAA_FLAG_INCLUDE_PREFIX;
family and flags never change so you don't need these variables.
> + apiReturn = GetAdaptersInfo(NULL, NULL);
> + if (apiReturn == ERROR_NOT_SUPPORTED) {
> + skip("GetAdaptersInfo is not supported\n");
> + return;
> + }
> + apiReturn = GetAdaptersAddresses(0, 0, NULL, NULL, NULL);
> + if (apiReturn == ERROR_NOT_SUPPORTED) {
> + skip("GetAdaptersInfo is not supported\n");
> + return;
> + }
> + apiReturn = GetAdaptersAddresses(family, flags, 0, 0, &size);
> + ok(apiReturn == ERROR_NO_DATA || apiReturn == ERROR_BUFFER_OVERFLOW,
> + "GetAdaptersAddresses 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_ADDRESSES pAdapterAddress;
> + PIP_ADAPTER_ADDRESSES pCurrentAddress;
> +
> + pAdapterAddress = HeapAlloc(GetProcessHeap(), 0, size);
> + apiReturn = GetAdaptersAddresses(family, flags, 0, pAdapterAddress, &size);
> + ok(apiReturn == NO_ERROR,
> + "GetAdaptersAddresses(family, flags, 0, pAdapterAddress, &size) returned %d, expected NO_ERROR\n",
> + apiReturn);
> +
> + pCurrentAddress = pAdapterAddress;
> + while (pCurrentAddress)
> + {
> + if (pCurrentAddress->IfType == IF_TYPE_ETHERNET_CSMACD &&
> + ((pCurrentAddress->Flags & IP_ADAPTER_IPV4_ENABLED) || (pCurrentAddress->Flags & IP_ADAPTER_IPV6_ENABLED)))
This might be too strict. In practice these interfaces will have a
valid IP address and mask but I expect this to depend on configuration.
Note that you don't actually need this to show that your fix for
GetAdaptersInfo() is correct.
More information about the wine-devel
mailing list