[PATCH 3/5] iphlpapi/tests: Add tests for GetBestInterfaceEx.

Jinoh Kang jinoh.kang.kr at gmail.com
Sat Jan 15 10:33:35 CST 2022


Signed-off-by: Jinoh Kang <jinoh.kang.kr at gmail.com>
---
 dlls/iphlpapi/tests/iphlpapi.c | 57 ++++++++++++++++++++++++++++++++++
 1 file changed, 57 insertions(+)

diff --git a/dlls/iphlpapi/tests/iphlpapi.c b/dlls/iphlpapi/tests/iphlpapi.c
index 6f93d751ac7..f3d2e744b0f 100644
--- a/dlls/iphlpapi/tests/iphlpapi.c
+++ b/dlls/iphlpapi/tests/iphlpapi.c
@@ -1480,6 +1480,62 @@ static void testGetBestInterface(void)
         bestIfIndex, apiReturn, NO_ERROR );
 }
 
+static void testGetBestInterfaceEx(void)
+{
+    DWORD apiReturn;
+    DWORD bestIfIndex = 0;
+    struct sockaddr_in destAddr;
+
+    memset(&destAddr, 0, sizeof(struct sockaddr_in));
+    destAddr.sin_family = AF_INET;
+    destAddr.sin_addr.S_un.S_addr = INADDR_ANY;
+    apiReturn = GetBestInterfaceEx( (struct sockaddr *)&destAddr, &bestIfIndex );
+    trace( "GetBestInterfaceEx([0.0.0.0], {%u}) = %u\n", bestIfIndex, apiReturn );
+    if (apiReturn == ERROR_NOT_SUPPORTED)
+    {
+        skip( "GetBestInterfaceEx not supported\n" );
+        return;
+    }
+
+    apiReturn = GetBestInterfaceEx( NULL, NULL );
+    ok( apiReturn == ERROR_INVALID_PARAMETER,
+        "GetBestInterfaceEx(NULL, NULL) returned %u, expected %u\n",
+        apiReturn, ERROR_INVALID_PARAMETER );
+
+    apiReturn = GetBestInterfaceEx( NULL, &bestIfIndex );
+    ok( apiReturn == ERROR_INVALID_PARAMETER,
+        "GetBestInterfaceEx(NULL, {%u}) returned %u, expected %u\n",
+        bestIfIndex, apiReturn, ERROR_INVALID_PARAMETER );
+
+    memset(&destAddr, 0, sizeof(struct sockaddr_in));
+    apiReturn = GetBestInterfaceEx( (struct sockaddr *)&destAddr, NULL );
+    ok( apiReturn == ERROR_INVALID_PARAMETER,
+        "GetBestInterfaceEx(<AF_UNSPEC>, NULL) returned %u, expected %u\n",
+        apiReturn, ERROR_INVALID_PARAMETER );
+
+    memset(&destAddr, -1, sizeof(struct sockaddr_in));
+    apiReturn = GetBestInterfaceEx( (struct sockaddr *)&destAddr, NULL );
+    ok( apiReturn == ERROR_INVALID_PARAMETER,
+        "GetBestInterfaceEx(<INVALID>, NULL) returned %u, expected %u\n",
+        apiReturn, ERROR_INVALID_PARAMETER );
+
+    memset(&destAddr, 0, sizeof(struct sockaddr_in));
+    destAddr.sin_family = AF_INET;
+    destAddr.sin_addr.S_un.S_addr = INADDR_LOOPBACK;
+    apiReturn = GetBestInterfaceEx( (struct sockaddr *)&destAddr, NULL );
+    ok( apiReturn == ERROR_INVALID_PARAMETER,
+        "GetBestInterfaceEx([127.0.0.1], NULL) returned %u, expected %u\n",
+        apiReturn, ERROR_INVALID_PARAMETER );
+
+    memset(&destAddr, 0, sizeof(struct sockaddr_in));
+    destAddr.sin_family = AF_INET;
+    destAddr.sin_addr.S_un.S_addr = INADDR_LOOPBACK;
+    apiReturn = GetBestInterfaceEx( (struct sockaddr *)&destAddr, &bestIfIndex );
+    ok( apiReturn == NO_ERROR,
+        "GetBestInterfaceEx([127.0.0.1], {%u}) returned %u, expected %u\n",
+        bestIfIndex, apiReturn, ERROR_INVALID_PARAMETER );
+}
+
 static void testGetBestRoute(void)
 {
     DWORD apiReturn;
@@ -1515,6 +1571,7 @@ static DWORD CALLBACK testWin98Functions(void *p)
   testGetAdaptersInfo();
   testGetNetworkParams();
   testGetBestInterface();
+  testGetBestInterfaceEx();
   testGetBestRoute();
   return 0;
 }
-- 
2.31.1




More information about the wine-devel mailing list