Bruno Jesus : ws2_32/tests: Ensure we have more than one IP to test gethostbyname.

Alexandre Julliard julliard at wine.codeweavers.com
Thu Nov 26 11:03:57 CST 2015


Module: wine
Branch: master
Commit: a787321d622c4920e362310d825726c67d66a217
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=a787321d622c4920e362310d825726c67d66a217

Author: Bruno Jesus <00cpxxx at gmail.com>
Date:   Thu Nov 26 13:22:12 2015 +0800

ws2_32/tests: Ensure we have more than one IP to test gethostbyname.

Sebastian called my attention about his machine that has a single IP and
make test fails. In such cases it is safe to assume that the IP returned
is the default route so the test is meaningless in this situation.

Signed-off-by: Bruno Jesus <00cpxxx at gmail.com>
Signed-off-by: Sebastian Lackner <sebastian at fds-team.de>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ws2_32/tests/sock.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c
index 3c66f7d..f483197 100644
--- a/dlls/ws2_32/tests/sock.c
+++ b/dlls/ws2_32/tests/sock.c
@@ -4468,7 +4468,7 @@ static void test_gethostbyname(void)
     struct hostent *he;
     struct in_addr **addr_list;
     char name[256], first_ip[16];
-    int ret, i;
+    int ret, i, count;
     PMIB_IPFORWARDTABLE routes = NULL;
     PIP_ADAPTER_INFO adapters = NULL, k;
     DWORD adap_size = 0, route_size = 0;
@@ -4484,9 +4484,9 @@ static void test_gethostbyname(void)
     strcpy(first_ip, inet_ntoa(*addr_list[0]));
 
     trace("List of local IPs:\n");
-    for(i = 0; addr_list[i] != NULL; i++)
+    for(count = 0; addr_list[count] != NULL; count++)
     {
-        char *ip = inet_ntoa(*addr_list[i]);
+        char *ip = inet_ntoa(*addr_list[count]);
         if (!strcmp(ip, "127.0.0.1"))
             local_ip = TRUE;
         trace("%s\n", ip);
@@ -4494,7 +4494,7 @@ static void test_gethostbyname(void)
 
     if (local_ip)
     {
-        ok (i == 1, "expected 127.0.0.1 to be the only IP returned\n");
+        ok (count == 1, "expected 127.0.0.1 to be the only IP returned\n");
         skip("Only the loopback address is present, skipping tests\n");
         return;
     }
@@ -4518,6 +4518,13 @@ static void test_gethostbyname(void)
     ret = pGetIpForwardTable(routes, &route_size, FALSE);
     ok (ret == NO_ERROR, "GetIpForwardTable failed, error: %d\n", ret);
 
+    /* This test only has meaning if there is more than one IP configured */
+    if (adapters->Next == NULL && count == 1)
+    {
+        skip("Only one IP is present, skipping tests\n");
+        goto cleanup;
+    }
+
     for (i = 0; !found_default && i < routes->dwNumEntries; i++)
     {
         /* default route (ip 0.0.0.0) ? */
@@ -4541,6 +4548,7 @@ static void test_gethostbyname(void)
 todo_wine
     ok (found_default, "failed to find the first IP from gethostbyname!\n");
 
+cleanup:
     HeapFree(GetProcessHeap(), 0, adapters);
     HeapFree(GetProcessHeap(), 0, routes);
 }




More information about the wine-cvs mailing list