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

Jinoh Kang wine at gitlab.winehq.org
Fri Jun 17 11:26:36 CDT 2022


From: Jinoh Kang <jinoh.kang.kr at gmail.com>

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 21cedfbff56..c359e527a0b 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], {%lu}) = %lu\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 %lu, expected %d\n",
+        apiReturn, ERROR_INVALID_PARAMETER );
+
+    apiReturn = GetBestInterfaceEx( NULL, &bestIfIndex );
+    ok( apiReturn == ERROR_INVALID_PARAMETER,
+        "GetBestInterfaceEx(NULL, {%lu}) returned %lu, expected %d\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 %lu, expected %d\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 %lu, expected %d\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 %lu, expected %d\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], {%lu}) returned %lu, expected %d\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;
 }
-- 
GitLab


https://gitlab.winehq.org/wine/wine/-/merge_requests/266



More information about the wine-devel mailing list