Bruno Jesus : ws2_32/tests: Add IDN resolution tests for GetAddrInfoW.

Alexandre Julliard julliard at winehq.org
Tue Nov 29 16:01:39 CST 2016


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

Author: Bruno Jesus <00cpxxx at gmail.com>
Date:   Tue Nov 29 15:23:14 2016 -0200

ws2_32/tests: Add IDN resolution tests for GetAddrInfoW.

Signed-off-by: Bruno Jesus <00cpxxx at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ws2_32/tests/sock.c | 77 ++++++++++++++++++++++++++++++++++++++++++++++++
 include/ws2tcpip.h       |  2 ++
 2 files changed, 79 insertions(+)

diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c
index 80425c9..049213a 100644
--- a/dlls/ws2_32/tests/sock.c
+++ b/dlls/ws2_32/tests/sock.c
@@ -6811,6 +6811,11 @@ static void test_GetAddrInfoW(void)
     ADDRINFOW *result, *result2, *p, hint;
     WCHAR name[256];
     DWORD size = sizeof(name)/sizeof(WCHAR);
+    /* te su to.winehq.org written in katakana */
+    static const WCHAR idn_domain[] =
+        {0x30C6,0x30B9,0x30C8,'.','w','i','n','e','h','q','.','o','r','g',0};
+    static const WCHAR idn_punycode[] =
+        {'x','n','-','-','z','c','k','z','a','h','.','w','i','n','e','h','q','.','o','r','g',0};
 
     if (!pGetAddrInfoW || !pFreeAddrInfoW)
     {
@@ -6993,6 +6998,78 @@ static void test_GetAddrInfoW(void)
                 ok(0, "test %d: GetAddrInfoW failed with %d (err %d)\n", i, ret, err);
         }
     }
+
+    /* Test IDN resolution (Internationalized Domain Names) present since Windows 8 */
+    trace("Testing punycode IDN %s\n", wine_dbgstr_w(idn_punycode));
+    result = NULL;
+    ret = pGetAddrInfoW(idn_punycode, NULL, NULL, &result);
+    ok(!ret, "got %d expected success\n", ret);
+    ok(result != NULL, "got %p\n", result);
+    pFreeAddrInfoW(result);
+
+    hint.ai_family = AF_INET;
+    hint.ai_socktype = 0;
+    hint.ai_protocol = 0;
+    hint.ai_flags = 0;
+
+    result = NULL;
+    ret = pGetAddrInfoW(idn_punycode, NULL, &hint, &result);
+    ok(!ret, "got %d expected success\n", ret);
+    ok(result != NULL, "got %p\n", result);
+
+    trace("Testing unicode IDN %s\n", wine_dbgstr_w(idn_domain));
+    result2 = NULL;
+    ret = pGetAddrInfoW(idn_domain, NULL, NULL, &result2);
+    if (ret == WSAHOST_NOT_FOUND && broken(1))
+    {
+        pFreeAddrInfoW(result);
+        win_skip("IDN resolution not supported in Win <= 7\n");
+        return;
+    }
+todo_wine {
+    ok(!ret, "got %d expected success\n", ret);
+    ok(result2 != NULL, "got %p\n", result2);
+    pFreeAddrInfoW(result2);
+
+    hint.ai_family = AF_INET;
+    hint.ai_socktype = 0;
+    hint.ai_protocol = 0;
+    hint.ai_flags = 0;
+
+    result2 = NULL;
+    ret = pGetAddrInfoW(idn_domain, NULL, &hint, &result2);
+    ok(!ret, "got %d expected success\n", ret);
+    ok(result2 != NULL, "got %p\n", result2);
+
+    /* ensure manually resolved punycode and unicode hosts result in same data */
+    compare_addrinfow(result, result2);
+
+    pFreeAddrInfoW(result);
+    pFreeAddrInfoW(result2);
+
+    hint.ai_family = AF_INET;
+    hint.ai_socktype = 0;
+    hint.ai_protocol = 0;
+    hint.ai_flags = 0;
+
+    result2 = NULL;
+    ret = pGetAddrInfoW(idn_domain, NULL, &hint, &result2);
+    ok(!ret, "got %d expected success\n", ret);
+    ok(result2 != NULL, "got %p\n", result2);
+    pFreeAddrInfoW(result2);
+}
+    /* Disable IDN resolution and test again*/
+    hint.ai_family = AF_INET;
+    hint.ai_socktype = 0;
+    hint.ai_protocol = 0;
+    hint.ai_flags = AI_DISABLE_IDN_ENCODING;
+
+    SetLastError(0xdeadbeef);
+    result2 = NULL;
+    ret = pGetAddrInfoW(idn_domain, NULL, &hint, &result2);
+    ok(ret == WSAHOST_NOT_FOUND, "got %d expected WSAHOST_NOT_FOUND\n", ret);
+    ok(WSAGetLastError() == WSAHOST_NOT_FOUND, "expected 11001, got %d\n", WSAGetLastError());
+    ok(result2 == NULL, "got %p\n", result2);
 }
 
 static void test_getaddrinfo(void)
diff --git a/include/ws2tcpip.h b/include/ws2tcpip.h
index ef460a8..e14a660 100644
--- a/include/ws2tcpip.h
+++ b/include/ws2tcpip.h
@@ -69,6 +69,7 @@ typedef ADDRINFOA ADDRINFO, *LPADDRINFO;
 # define AI_NON_AUTHORITATIVE      0x00004000
 # define AI_SECURE                 0x00008000
 # define AI_RETURN_PREFERRED_NAMES 0x00010000
+# define AI_DISABLE_IDN_ENCODING   0x00080000
 /* getaddrinfo error codes */
 # define EAI_AGAIN	WSATRY_AGAIN
 # define EAI_BADFLAGS	WSAEINVAL
@@ -89,6 +90,7 @@ typedef ADDRINFOA ADDRINFO, *LPADDRINFO;
 # define WS_AI_NON_AUTHORITATIVE      0x00004000
 # define WS_AI_SECURE                 0x00008000
 # define WS_AI_RETURN_PREFERRED_NAMES 0x00010000
+# define WS_AI_DISABLE_IDN_ENCODING   0x00080000
 /* getaddrinfo error codes */
 # define WS_EAI_AGAIN	WSATRY_AGAIN
 # define WS_EAI_BADFLAGS	WSAEINVAL




More information about the wine-cvs mailing list