added invocation to test list
-- v5: Split out test for ERROR_INVALID_PARAMETER return
From: "John H. Freeman" john@freemania.pro
added invocation to test list
split tests between focus of the test
in compliance with c90 declaration moved --- dlls/iphlpapi/tests/iphlpapi.c | 60 ++++++++++++++++++++++++---------- 1 file changed, 42 insertions(+), 18 deletions(-)
diff --git a/dlls/iphlpapi/tests/iphlpapi.c b/dlls/iphlpapi/tests/iphlpapi.c index cd192003345..5a2d6ab3de1 100644 --- a/dlls/iphlpapi/tests/iphlpapi.c +++ b/dlls/iphlpapi/tests/iphlpapi.c @@ -50,6 +50,7 @@ #include <stdlib.h>
#define ICMP_MINLEN 8 /* copied from dlls/iphlpapi/ip_icmp.h file */ +static ULONG sizeForOverflowTest = 0x7fffffff;
static HMODULE hLibrary = NULL;
@@ -1737,34 +1738,53 @@ static void testWin2KFunctions(void) testNotifyAddrChange(); }
-static void test_GetAdaptersAddresses(void) +/* + * Tests GetAdaptersAddresses for Invalid Parameters NULL size and return value of ERROR_INVALID_PARAMETER + */ +static void test_GetAdaptersAddressesInvalidParameterNULLsize(void) { - BOOL dns_eligible_found = FALSE; - ULONG ret, size, osize, i; - IP_ADAPTER_ADDRESSES *aa, *ptr; - IP_ADAPTER_UNICAST_ADDRESS *ua; - + ULONG ret; ret = GetAdaptersAddresses(AF_UNSPEC, 0, NULL, NULL, NULL); ok(ret == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER got %lu\n", ret); +}
- /* size should be ignored and overwritten if buffer is NULL */ - size = 0x7fffffff; - ret = GetAdaptersAddresses(AF_UNSPEC, 0, NULL, NULL, &size); +/* size should be ignored and overwritten if buffer is NULL */ +static void test_GetAdaptersAddressesBufferOverflowZeroFlags(void) +{ + ULONG ret; + ret = GetAdaptersAddresses(AF_UNSPEC, 0, NULL, NULL, &sizeForOverflowTest); ok(ret == ERROR_BUFFER_OVERFLOW, "expected ERROR_BUFFER_OVERFLOW, got %lu\n", ret); - if (ret != ERROR_BUFFER_OVERFLOW) return; +}
- /* GAA_FLAG_SKIP_FRIENDLY_NAME is ignored */ +static void test_GetAdaptersAddressesErrorSuccess(void) +{ + ULONG ret; + IP_ADAPTER_ADDRESSES *ptr; + ptr = malloc(sizeForOverflowTest); + ret = GetAdaptersAddresses(AF_UNSPEC, 0, NULL, ptr, &sizeForOverflowTest); + ok(!ret, "expected ERROR_SUCCESS got %lu\n", ret); + free(ptr); +} + +/* GAA_FLAG_SKIP_FRIENDLY_NAME is ignored */ +static void test_GetAdaptersAddressesBufferOverflow(void) +{ + ULONG ret, osize; osize = 0x7fffffff; ret = GetAdaptersAddresses(AF_UNSPEC, GAA_FLAG_SKIP_FRIENDLY_NAME, NULL, NULL, &osize); ok(ret == ERROR_BUFFER_OVERFLOW, "expected ERROR_BUFFER_OVERFLOW, got %lu\n", ret); - ok(osize == size, "expected %ld, got %ld\n", size, osize); + ok(osize == sizeForOverflowTest, "expected %ld, got %ld\n", sizeForOverflowTest, osize); +}
- ptr = malloc(size); - ret = GetAdaptersAddresses(AF_UNSPEC, 0, NULL, ptr, &size); - ok(!ret, "expected ERROR_SUCCESS got %lu\n", ret); - free(ptr); +/* higher size must not be changed to lower size */ +static void test_GetAdaptersAddressesDoublingBufferOverlow(void) +{ + BOOL dns_eligible_found = FALSE; + ULONG ret, size, osize, i; + IP_ADAPTER_ADDRESSES *aa, *ptr; + IP_ADAPTER_UNICAST_ADDRESS *ua; + size = sizeForOverflowTest;
- /* higher size must not be changed to lower size */ size *= 2; osize = size; ptr = malloc(osize); @@ -2930,7 +2950,11 @@ START_TEST(iphlpapi) WaitForSingleObject(thread, INFINITE);
testWin2KFunctions(); - test_GetAdaptersAddresses(); + test_GetAdaptersAddressesInvalidParameterNULLsize(); + test_GetAdaptersAddressesBufferOverflowZeroFlags(); + test_GetAdaptersAddressesBufferOverflow(); + test_GetAdaptersAddressesErrorSuccess(); + test_GetAdaptersAddressesDoublingBufferOverlow(); test_GetExtendedTcpTable(); test_GetExtendedUdpTable(); test_AllocateAndGetTcpExTableFromStack();
Test phase failure in Linux 32 bit on unrelated test
This merge request was closed by Huw Davies.
Why? The current test function isn't particularly long or confusing.