These tests call conversion functions with fixed parameter, and thus can be taken out of the adapter enumeration loop.
Signed-off-by: Jinoh Kang jinoh.kang.kr@gmail.com --- dlls/iphlpapi/tests/iphlpapi.c | 110 ++++++++++++++++++++------------- 1 file changed, 66 insertions(+), 44 deletions(-)
diff --git a/dlls/iphlpapi/tests/iphlpapi.c b/dlls/iphlpapi/tests/iphlpapi.c index f3d2e744b0f..5a174f679a2 100644 --- a/dlls/iphlpapi/tests/iphlpapi.c +++ b/dlls/iphlpapi/tests/iphlpapi.c @@ -2086,9 +2086,6 @@ static void test_interface_identifier_conversion(void) MIB_IF_ROW2 *row = table->Table + i;
/* ConvertInterfaceIndexToLuid */ - ret = ConvertInterfaceIndexToLuid( 0, NULL ); - ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret ); - memset( &luid, 0xff, sizeof(luid) ); ret = ConvertInterfaceIndexToLuid( 0, &luid ); ok( ret == ERROR_FILE_NOT_FOUND, "got %u\n", ret ); @@ -2102,12 +2099,6 @@ static void test_interface_identifier_conversion(void) ok( luid.Value == row->InterfaceLuid.Value, "mismatch\n" );
/* ConvertInterfaceLuidToIndex */ - ret = ConvertInterfaceLuidToIndex( NULL, NULL ); - ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret ); - - ret = ConvertInterfaceLuidToIndex( NULL, &index ); - ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret ); - ret = ConvertInterfaceLuidToIndex( &luid, NULL ); ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret );
@@ -2116,9 +2107,6 @@ static void test_interface_identifier_conversion(void) ok( index == row->InterfaceIndex, "mismatch\n" );
/* ConvertInterfaceLuidToGuid */ - ret = ConvertInterfaceLuidToGuid( NULL, NULL ); - ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret ); - memset( &guid, 0xff, sizeof(guid) ); ret = ConvertInterfaceLuidToGuid( NULL, &guid ); ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret ); @@ -2133,9 +2121,6 @@ static void test_interface_identifier_conversion(void) ok( IsEqualGUID( &guid, &row->InterfaceGuid ), "mismatch\n" );
/* ConvertInterfaceGuidToLuid */ - ret = ConvertInterfaceGuidToLuid( NULL, NULL ); - ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret ); - luid.Info.NetLuidIndex = 1; ret = ConvertInterfaceGuidToLuid( NULL, &luid ); ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret ); @@ -2153,15 +2138,9 @@ static void test_interface_identifier_conversion(void) if (luid.Value != row->InterfaceLuid.Value) continue;
/* ConvertInterfaceLuidToNameW */ - ret = ConvertInterfaceLuidToNameW( NULL, NULL, 0 ); - ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret ); - ret = ConvertInterfaceLuidToNameW( &luid, NULL, 0 ); ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret );
- ret = ConvertInterfaceLuidToNameW( NULL, nameW, 0 ); - ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret ); - ret = ConvertInterfaceLuidToNameW( &luid, nameW, 0 ); ok( ret == ERROR_NOT_ENOUGH_MEMORY, "got %u\n", ret );
@@ -2173,15 +2152,9 @@ static void test_interface_identifier_conversion(void) ok( !wcscmp( nameW, expect_nameW ), "got %s vs %s\n", debugstr_w( nameW ), debugstr_w( expect_nameW ) );
/* ConvertInterfaceLuidToNameA */ - ret = ConvertInterfaceLuidToNameA( NULL, NULL, 0 ); - ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret ); - ret = ConvertInterfaceLuidToNameA( &luid, NULL, 0 ); ok( ret == ERROR_NOT_ENOUGH_MEMORY, "got %u\n", ret );
- ret = ConvertInterfaceLuidToNameA( NULL, nameA, 0 ); - ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret ); - ret = ConvertInterfaceLuidToNameA( &luid, nameA, 0 ); ok( ret == ERROR_NOT_ENOUGH_MEMORY, "got %u\n", ret );
@@ -2192,9 +2165,6 @@ static void test_interface_identifier_conversion(void) ok( nameA[0], "name not set\n" );
/* ConvertInterfaceNameToLuidW */ - ret = ConvertInterfaceNameToLuidW( NULL, NULL ); - ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret ); - luid.Info.Reserved = luid.Info.NetLuidIndex = luid.Info.IfType = 0xdead; ret = ConvertInterfaceNameToLuidW( NULL, &luid ); ok( ret == ERROR_INVALID_NAME, "got %u\n", ret ); @@ -2211,9 +2181,6 @@ static void test_interface_identifier_conversion(void) ok( luid.Value == row->InterfaceLuid.Value, "mismatch\n" );
/* ConvertInterfaceNameToLuidA */ - ret = ConvertInterfaceNameToLuidA( NULL, NULL ); - ok( ret == ERROR_INVALID_NAME, "got %u\n", ret ); - luid.Info.Reserved = luid.Info.NetLuidIndex = luid.Info.IfType = 0xdead; ret = ConvertInterfaceNameToLuidA( NULL, &luid ); ok( ret == ERROR_INVALID_NAME, "got %u\n", ret ); @@ -2239,8 +2206,7 @@ static void test_interface_identifier_conversion(void) ok( !ret, "got %u\n", ret ); ok( !wcscmp( alias, row->Alias ), "got %s vs %s\n", wine_dbgstr_w( alias ), wine_dbgstr_w( row->Alias ) );
- index = if_nametoindex( NULL ); - ok( !index, "Got unexpected index %u\n", index ); + /* if_nametoindex */ index = if_nametoindex( nameA ); ok( index == row->InterfaceIndex, "Got index %u for %s, expected %u\n", index, nameA, row->InterfaceIndex ); /* Wargaming.net Game Center passes a GUID-like string. */ @@ -2249,15 +2215,7 @@ static void test_interface_identifier_conversion(void) index = if_nametoindex( wine_dbgstr_guid( &guid ) ); ok( !index, "Got unexpected index %u for input %s\n", index, wine_dbgstr_guid( &guid ) );
- name = if_indextoname( 0, NULL ); - ok( name == NULL, "got %s\n", name ); - - name = if_indextoname( 0, nameA ); - ok( name == NULL, "got %p\n", name ); - - name = if_indextoname( ~0u, nameA ); - ok( name == NULL, "got %p\n", name ); - + /* if_indextoname */ nameA[0] = 0; name = if_indextoname( row->InterfaceIndex, nameA ); ConvertInterfaceLuidToNameA( &row->InterfaceLuid, expect_nameA, ARRAY_SIZE(expect_nameA) ); @@ -2267,6 +2225,69 @@ static void test_interface_identifier_conversion(void) FreeMibTable( table ); }
+static void test_interface_identifier_conversion_failure(void) +{ + DWORD ret; + WCHAR nameW[IF_MAX_STRING_SIZE + 1]; + char nameA[IF_MAX_STRING_SIZE + 1], *name; + NET_IFINDEX index; + + /* ConvertInterfaceIndexToLuid */ + ret = ConvertInterfaceIndexToLuid( 0, NULL ); + ok( ret == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", ret ); + + /* ConvertInterfaceLuidToIndex */ + ret = ConvertInterfaceLuidToIndex( NULL, NULL ); + ok( ret == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", ret ); + + ret = ConvertInterfaceLuidToIndex( NULL, &index ); + ok( ret == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", ret ); + + /* ConvertInterfaceLuidToGuid */ + ret = ConvertInterfaceLuidToGuid( NULL, NULL ); + ok( ret == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", ret ); + + /* ConvertInterfaceGuidToLuid */ + ret = ConvertInterfaceGuidToLuid( NULL, NULL ); + ok( ret == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", ret ); + + /* ConvertInterfaceLuidToNameW */ + ret = ConvertInterfaceLuidToNameW( NULL, NULL, 0 ); + ok( ret == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", ret ); + + ret = ConvertInterfaceLuidToNameW( NULL, nameW, 0 ); + ok( ret == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", ret ); + + /* ConvertInterfaceLuidToNameA */ + ret = ConvertInterfaceLuidToNameA( NULL, NULL, 0 ); + ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret ); + + ret = ConvertInterfaceLuidToNameA( NULL, nameA, 0 ); + ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret ); + + /* ConvertInterfaceNameToLuidW */ + ret = ConvertInterfaceNameToLuidW( NULL, NULL ); + ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret ); + + /* ConvertInterfaceNameToLuidA */ + ret = ConvertInterfaceNameToLuidA( NULL, NULL ); + ok( ret == ERROR_INVALID_NAME, "got %u\n", ret ); + + /* if_nametoindex */ + index = if_nametoindex( NULL ); + ok( !index, "Got unexpected index %u\n", index ); + + /* if_indextoname */ + name = if_indextoname( 0, NULL ); + ok( name == NULL, "expected NULL, got %s\n", name ); + + name = if_indextoname( 0, nameA ); + ok( name == NULL, "expected NULL, got %p\n", name ); + + name = if_indextoname( ~0u, nameA ); + ok( name == NULL, "expected NULL, got %p\n", name ); +} + static void test_GetIfEntry2(void) { DWORD ret; @@ -2803,6 +2824,7 @@ START_TEST(iphlpapi) test_AllocateAndGetTcpExTableFromStack(); test_CreateSortedAddressPairs(); test_interface_identifier_conversion(); + test_interface_identifier_conversion_failure(); test_GetIfEntry2(); test_GetIfTable2(); test_GetIfTable2Ex();