[PATCH] ws2_32/tests: Add IDN resolution test for GetAddrInfoW
Bruno Jesus
00cpxxx at gmail.com
Thu Nov 24 13:48:51 CST 2016
I'm using €.linux.it because I could not find any standard domain name for validation. Maybe winehq.org could have a IDN sub-domain name to test.
Also instead of broken'ing every test to catch Windows <= 7 I'm skipping before, so real failures are not lost due to broken covering them in Win >= 8.
Signed-off-by: Bruno Jesus <00cpxxx at gmail.com>
---
dlls/ws2_32/tests/sock.c | 38 ++++++++++++++++++++++++++++++++++++++
include/ws2tcpip.h | 2 ++
2 files changed, 40 insertions(+)
diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c
index 80425c9..c874e2f 100644
--- a/dlls/ws2_32/tests/sock.c
+++ b/dlls/ws2_32/tests/sock.c
@@ -6811,6 +6811,7 @@ static void test_GetAddrInfoW(void)
ADDRINFOW *result, *result2, *p, hint;
WCHAR name[256];
DWORD size = sizeof(name)/sizeof(WCHAR);
+ static const WCHAR idn_domain[] = {0x20AC,'.','l','i','n','u','x','.','i','t',0}; /* euro sign */
if (!pGetAddrInfoW || !pFreeAddrInfoW)
{
@@ -6993,6 +6994,43 @@ 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 */
+ if (broken(1) && LOWORD(GetVersion()) < 0x0206)
+ {
+ win_skip("IDN resolution not supported\n");
+ return;
+ }
+todo_wine {
+ result = NULL;
+ ret = pGetAddrInfoW(idn_domain, 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_domain, NULL, &hint, &result);
+ ok(!ret, "got %d expected success\n", ret);
+ ok(result != NULL, "got %p\n", result);
+ pFreeAddrInfoW(result);
+}
+ /* 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);
+ result = NULL;
+ ret = pGetAddrInfoW(idn_domain, NULL, &hint, &result);
+ 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(result == NULL, "got %p\n", result);
}
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
--
2.9.3
More information about the wine-patches
mailing list