Wine-Devel
Threads by month
- ----- 2026 -----
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2003 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2002 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2001 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- 22 participants
- 84527 discussions
[PATCH] ntdll/tests: Remove Qpc(Interrupt|System)TimeIncrement(Shift) checks.
by Rémi Bernon April 29, 2021
by Rémi Bernon April 29, 2021
April 29, 2021
They are not fixed and are updated from time to time (every few secs),
randomly failing the tests on the testbot.
Signed-off-by: Rémi Bernon <rbernon(a)codeweavers.com>
---
dlls/ntdll/tests/time.c | 12 ------------
1 file changed, 12 deletions(-)
diff --git a/dlls/ntdll/tests/time.c b/dlls/ntdll/tests/time.c
index 2ed28a35d8e..90737521a4d 100644
--- a/dlls/ntdll/tests/time.c
+++ b/dlls/ntdll/tests/time.c
@@ -172,14 +172,6 @@ static void test_RtlQueryPerformanceCounter(void)
"unexpected QpcBypassEnabled %x, expected 0x83\n", usd->u3.s.QpcBypassEnabled );
ok( usd->QpcFrequency == 10000000, "unexpected QpcFrequency %I64d, expected 10000000\n", usd->QpcFrequency );
ok( !usd->u3.s.QpcShift, "unexpected QpcShift %d, expected 0\n", usd->u3.s.QpcShift );
- ok( usd->QpcInterruptTimeIncrement == ((ULONGLONG)1 << 63),
- "unexpected QpcInterruptTimeIncrement %I64x, expected 1<<63\n", usd->QpcInterruptTimeIncrement );
- ok( usd->QpcInterruptTimeIncrementShift == 1,
- "unexpected QpcInterruptTimeIncrementShift %d, expected 1\n", usd->QpcInterruptTimeIncrementShift );
- ok( usd->QpcSystemTimeIncrement == ((ULONGLONG)1 << 63),
- "unexpected QpcSystemTimeIncrement %I64x, expected 1<<63\n", usd->QpcSystemTimeIncrement );
- ok( usd->QpcSystemTimeIncrementShift == 1,
- "unexpected QpcSystemTimeIncrementShift %d, expected 1\n", usd->QpcSystemTimeIncrementShift );
hsd = NULL;
status = pNtQuerySystemInformation( SystemHypervisorSharedPageInformation, &hsd, sizeof(void *), &len );
@@ -201,10 +193,6 @@ static void test_RtlQueryPerformanceCounter(void)
else
{
ok( usd->u3.s.QpcShift == 10, "unexpected QpcShift %d, expected 10\n", usd->u3.s.QpcShift );
- ok( usd->QpcInterruptTimeIncrementShift == 2,
- "unexpected QpcInterruptTimeIncrementShift %d, expected 2\n", usd->QpcInterruptTimeIncrementShift );
- ok( usd->QpcSystemTimeIncrementShift == 2,
- "unexpected QpcSystemTimeIncrementShift %d, expected 2\n", usd->QpcSystemTimeIncrementShift );
tsc0 = __rdtsc();
ret = pRtlQueryPerformanceCounter( &counter );
--
2.31.0
1
0
April 29, 2021
Signed-off-by: Rémi Bernon <rbernon(a)codeweavers.com>
---
v2: Stop trying to be smart and just use the helper everywhere instead
of __umulh. Rename it too.
dlls/ntdll/tests/time.c | 106 ++++++++++++++++++++++++++++++++++++++++
include/winternl.h | 1 +
2 files changed, 107 insertions(+)
diff --git a/dlls/ntdll/tests/time.c b/dlls/ntdll/tests/time.c
index 51d9115b87c..f9133f276a3 100644
--- a/dlls/ntdll/tests/time.c
+++ b/dlls/ntdll/tests/time.c
@@ -19,8 +19,10 @@
*/
#define NONAMELESSUNION
+#define NONAMELESSSTRUCT
#include "ntdll_test.h"
#include "ddk/wdm.h"
+#include "intrin.h"
#define TICKSPERSEC 10000000
#define TICKSPERMSEC 10000
@@ -35,6 +37,9 @@ static NTSTATUS (WINAPI *pRtlQueryTimeZoneInformation)( RTL_TIME_ZONE_INFORMATIO
static NTSTATUS (WINAPI *pRtlQueryDynamicTimeZoneInformation)( RTL_DYNAMIC_TIME_ZONE_INFORMATION *);
static BOOL (WINAPI *pRtlQueryUnbiasedInterruptTime)( ULONGLONG *time );
+static BOOL (WINAPI *pRtlQueryPerformanceCounter)(LARGE_INTEGER*);
+static BOOL (WINAPI *pRtlQueryPerformanceFrequency)(LARGE_INTEGER*);
+
static const int MonthLengths[2][12] =
{
{ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },
@@ -122,6 +127,104 @@ static void test_NtQueryPerformanceCounter(void)
ok(status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %08x\n", status);
}
+struct hypervisor_shared_data
+{
+ UINT64 unknown;
+ UINT64 QpcMultiplier;
+ UINT64 QpcBias;
+};
+
+/* 128-bit multiply a by b and return the high 64 bits, same as __umulh */
+static UINT64 multiply_tsc(UINT64 a, UINT64 b)
+{
+ UINT64 ah = a >> 32, al = (UINT32)a, bh = b >> 32, bl = (UINT32)b, m;
+ m = (ah * bl) + (bh * al) + ((al * bl) >> 32);
+ return (ah * bh) + (m >> 32);
+}
+
+static void test_RtlQueryPerformanceCounter(void)
+{
+ struct hypervisor_shared_data *hsd;
+ KSHARED_USER_DATA *usd = (void *)0x7ffe0000;
+ LARGE_INTEGER frequency, counter;
+ NTSTATUS status;
+ UINT64 tsc0, tsc1;
+ ULONG len;
+ BOOL ret;
+
+ if (!pRtlQueryPerformanceCounter || !pRtlQueryPerformanceFrequency)
+ {
+ win_skip( "RtlQueryPerformanceCounter/Frequency not available, skipping tests\n" );
+ return;
+ }
+
+ if (!(usd->u3.s.QpcBypassEnabled & SHARED_GLOBAL_FLAGS_QPC_BYPASS_ENABLED))
+ {
+ todo_wine win_skip("QpcBypassEnabled is not set, skipping tests\n");
+ return;
+ }
+
+ if ((usd->u3.s.QpcBypassEnabled & SHARED_GLOBAL_FLAGS_QPC_BYPASS_USE_HV_PAGE))
+ {
+ ok( usd->u3.s.QpcBypassEnabled == (SHARED_GLOBAL_FLAGS_QPC_BYPASS_ENABLED|SHARED_GLOBAL_FLAGS_QPC_BYPASS_USE_HV_PAGE|SHARED_GLOBAL_FLAGS_QPC_BYPASS_USE_RDTSCP),
+ "unexpected QpcBypassEnabled %x, expected 0x83\n", usd->u3.s.QpcBypassEnabled );
+ ok( usd->QpcFrequency == 10000000, "unexpected QpcFrequency %I64d, expected 10000000\n", usd->QpcFrequency );
+ ok( !usd->u3.s.QpcShift, "unexpected QpcShift %d, expected 0\n", usd->u3.s.QpcShift );
+ ok( usd->QpcInterruptTimeIncrement == ((ULONGLONG)1 << 63),
+ "unexpected QpcInterruptTimeIncrement %I64x, expected 1<<63\n", usd->QpcInterruptTimeIncrement );
+ ok( usd->QpcInterruptTimeIncrementShift == 1,
+ "unexpected QpcInterruptTimeIncrementShift %d, expected 1\n", usd->QpcInterruptTimeIncrementShift );
+ ok( usd->QpcSystemTimeIncrement == ((ULONGLONG)1 << 63),
+ "unexpected QpcSystemTimeIncrement %I64x, expected 1<<63\n", usd->QpcSystemTimeIncrement );
+ ok( usd->QpcSystemTimeIncrementShift == 1,
+ "unexpected QpcSystemTimeIncrementShift %d, expected 1\n", usd->QpcSystemTimeIncrementShift );
+
+ hsd = NULL;
+ status = pNtQuerySystemInformation( SystemHypervisorSharedPageInformation, &hsd, sizeof(void *), &len );
+ ok( !status, "NtQuerySystemInformation returned %x\n", status );
+ ok( len == sizeof(void *), "unexpected SystemHypervisorSharedPageInformation length %u\n", len );
+ ok( !!hsd, "unexpected SystemHypervisorSharedPageInformation address %p\n", hsd );
+
+ tsc0 = __rdtsc();
+ ret = pRtlQueryPerformanceCounter( &counter );
+ tsc1 = __rdtsc();
+ ok( ret, "RtlQueryPerformanceCounter failed\n" );
+
+ tsc0 = multiply_tsc(tsc0, hsd->QpcMultiplier) + hsd->QpcBias + usd->QpcBias;
+ tsc1 = multiply_tsc(tsc1, hsd->QpcMultiplier) + hsd->QpcBias + usd->QpcBias;
+
+ ok( tsc0 <= counter.QuadPart, "rdtscp %I64d and RtlQueryPerformanceCounter %I64d are out of order\n", tsc0, counter.QuadPart );
+ ok( counter.QuadPart <= tsc1, "RtlQueryPerformanceCounter %I64d and rdtscp %I64d are out of order\n", counter.QuadPart, tsc1 );
+ }
+ else
+ {
+ ok( usd->u3.s.QpcShift == 10, "unexpected QpcShift %d, expected 10\n", usd->u3.s.QpcShift );
+ ok( usd->QpcInterruptTimeIncrementShift == 2,
+ "unexpected QpcInterruptTimeIncrementShift %d, expected 2\n", usd->QpcInterruptTimeIncrementShift );
+ ok( usd->QpcSystemTimeIncrementShift == 2,
+ "unexpected QpcSystemTimeIncrementShift %d, expected 2\n", usd->QpcSystemTimeIncrementShift );
+
+ tsc0 = __rdtsc();
+ ret = pRtlQueryPerformanceCounter( &counter );
+ tsc1 = __rdtsc();
+ ok( ret, "RtlQueryPerformanceCounter failed\n" );
+
+ tsc0 += usd->QpcBias;
+ tsc0 >>= usd->u3.s.QpcShift;
+ tsc1 += usd->QpcBias;
+ tsc1 >>= usd->u3.s.QpcShift;
+
+ ok( tsc0 <= counter.QuadPart, "rdtscp %I64d and RtlQueryPerformanceCounter %I64d are out of order\n", tsc0, counter.QuadPart );
+ ok( counter.QuadPart <= tsc1, "RtlQueryPerformanceCounter %I64d and rdtscp %I64d are out of order\n", counter.QuadPart, tsc1 );
+ }
+
+ ret = pRtlQueryPerformanceFrequency( &frequency );
+ ok( ret, "RtlQueryPerformanceFrequency failed\n" );
+ ok( frequency.QuadPart == usd->QpcFrequency,
+ "RtlQueryPerformanceFrequency returned %I64d, expected USD QpcFrequency %I64d\n",
+ frequency.QuadPart, usd->QpcFrequency );
+}
+
static void test_RtlQueryTimeZoneInformation(void)
{
RTL_DYNAMIC_TIME_ZONE_INFORMATION tzinfo, tzinfo2;
@@ -266,6 +369,8 @@ START_TEST(time)
pRtlQueryDynamicTimeZoneInformation =
(void *)GetProcAddress(mod, "RtlQueryDynamicTimeZoneInformation");
pRtlQueryUnbiasedInterruptTime = (void *)GetProcAddress(mod, "RtlQueryUnbiasedInterruptTime");
+ pRtlQueryPerformanceCounter = (void *)GetProcAddress(mod, "RtlQueryPerformanceCounter");
+ pRtlQueryPerformanceFrequency = (void *)GetProcAddress(mod, "RtlQueryPerformanceFrequency");
if (pRtlTimeToTimeFields && pRtlTimeFieldsToTime)
test_pRtlTimeToTimeFields();
@@ -274,4 +379,5 @@ START_TEST(time)
test_NtQueryPerformanceCounter();
test_RtlQueryTimeZoneInformation();
test_user_shared_data_time();
+ test_RtlQueryPerformanceCounter();
}
diff --git a/include/winternl.h b/include/winternl.h
index d35d509eb41..fcdedaec8aa 100644
--- a/include/winternl.h
+++ b/include/winternl.h
@@ -1551,6 +1551,7 @@ typedef enum _SYSTEM_INFORMATION_CLASS {
SystemFileCacheInformationEx = 81,
SystemDynamicTimeZoneInformation = 102,
SystemLogicalProcessorInformationEx = 107,
+ SystemHypervisorSharedPageInformation = 197,
SystemInformationClassMax
} SYSTEM_INFORMATION_CLASS, *PSYSTEM_INFORMATION_CLASS;
--
2.30.2
3
3
[PATCH v3 1/3] user32: Move ToUnicodeEx from wineandroid.drv to user32.
by Rémi Bernon April 29, 2021
by Rémi Bernon April 29, 2021
April 29, 2021
As a fallback implementation, using English keyboard layout.
Signed-off-by: Rémi Bernon <rbernon(a)codeweavers.com>
---
v3: Call driver first and return early if it implements the call.
dlls/user32/driver.c | 2 +-
dlls/user32/input.c | 80 ++++++++++++++++++-
dlls/wineandroid.drv/keyboard.c | 94 -----------------------
dlls/wineandroid.drv/wineandroid.drv.spec | 1 -
4 files changed, 77 insertions(+), 100 deletions(-)
diff --git a/dlls/user32/driver.c b/dlls/user32/driver.c
index 7ac77141696..e5855e1c51b 100644
--- a/dlls/user32/driver.c
+++ b/dlls/user32/driver.c
@@ -286,7 +286,7 @@ static BOOL CDECL nulldrv_RegisterHotKey( HWND hwnd, UINT modifiers, UINT vk )
static INT CDECL nulldrv_ToUnicodeEx( UINT virt, UINT scan, const BYTE *state, LPWSTR str,
int size, UINT flags, HKL layout )
{
- return 0;
+ return -2; /* use default implementation */
}
static BOOL CDECL nulldrv_UnloadKeyboardLayout( HKL layout )
diff --git a/dlls/user32/input.c b/dlls/user32/input.c
index 805bfe3e9de..24942f72aa1 100644
--- a/dlls/user32/input.c
+++ b/dlls/user32/input.c
@@ -877,11 +877,83 @@ INT WINAPI ToUnicode(UINT virtKey, UINT scanCode, const BYTE *lpKeyState,
/****************************************************************************
* ToUnicodeEx (USER32.@)
*/
-INT WINAPI ToUnicodeEx(UINT virtKey, UINT scanCode, const BYTE *lpKeyState,
- LPWSTR lpwStr, int size, UINT flags, HKL hkl)
+INT WINAPI ToUnicodeEx( UINT virt, UINT scan, const BYTE *state,
+ WCHAR *str, int size, UINT flags, HKL layout )
{
- if (!lpKeyState) return 0;
- return USER_Driver->pToUnicodeEx(virtKey, scanCode, lpKeyState, lpwStr, size, flags, hkl);
+ BOOL shift, ctrl, numlock;
+ WCHAR buffer[2];
+ INT len;
+
+ TRACE_(keyboard)( "virt %u, scan %u, state %p, str %p, size %d, flags %x, layout %p.\n",
+ virt, scan, state, str, size, flags, layout );
+
+ if (!state) return 0;
+ if ((len = USER_Driver->pToUnicodeEx( virt, scan, state, str, size, flags, layout )) >= -1) return len;
+
+ shift = state[VK_SHIFT] & 0x80;
+ ctrl = state[VK_CONTROL] & 0x80;
+ numlock = state[VK_NUMLOCK] & 0x01;
+
+ /* FIXME: English keyboard layout specific */
+
+ if (scan & 0x8000) buffer[0] = 0; /* key up */
+ else if (!ctrl)
+ {
+ switch (virt)
+ {
+ case VK_BACK: buffer[0] = '\b'; break;
+ case VK_OEM_1: buffer[0] = shift ? ':' : ';'; break;
+ case VK_OEM_2: buffer[0] = shift ? '?' : '/'; break;
+ case VK_OEM_3: buffer[0] = shift ? '~' : '`'; break;
+ case VK_OEM_4: buffer[0] = shift ? '{' : '['; break;
+ case VK_OEM_5: buffer[0] = shift ? '|' : '\\'; break;
+ case VK_OEM_6: buffer[0] = shift ? '}' : ']'; break;
+ case VK_OEM_7: buffer[0] = shift ? '"' : '\''; break;
+ case VK_OEM_COMMA: buffer[0] = shift ? '<' : ','; break;
+ case VK_OEM_MINUS: buffer[0] = shift ? '_' : '-'; break;
+ case VK_OEM_PERIOD: buffer[0] = shift ? '>' : '.'; break;
+ case VK_OEM_PLUS: buffer[0] = shift ? '+' : '='; break;
+ case VK_RETURN: buffer[0] = '\r'; break;
+ case VK_SPACE: buffer[0] = ' '; break;
+ case VK_TAB: buffer[0] = '\t'; break;
+ case VK_MULTIPLY: buffer[0] = '*'; break;
+ case VK_ADD: buffer[0] = '+'; break;
+ case VK_SUBTRACT: buffer[0] = '-'; break;
+ case VK_DIVIDE: buffer[0] = '/'; break;
+ default:
+ if (virt >= '0' && virt <= '9')
+ buffer[0] = shift ? ")!@#$%^&*("[virt - '0'] : virt;
+ else if (virt >= 'A' && virt <= 'Z')
+ buffer[0] = shift || (state[VK_CAPITAL] & 0x01) ? virt : virt + 'a' - 'A';
+ else if (virt >= VK_NUMPAD0 && virt <= VK_NUMPAD9 && numlock && !shift)
+ buffer[0] = '0' + virt - VK_NUMPAD0;
+ else if (virt == VK_DECIMAL && numlock && !shift)
+ buffer[0] = '.';
+ else
+ buffer[0] = 0;
+ break;
+ }
+ }
+ else /* Control codes */
+ {
+ switch (virt)
+ {
+ case VK_OEM_4: buffer[0] = 0x1b; break;
+ case VK_OEM_5: buffer[0] = 0x1c; break;
+ case VK_OEM_6: buffer[0] = 0x1d; break;
+ case VK_SUBTRACT: buffer[0] = 0x1e; break;
+ default:
+ if (virt >= 'A' && virt <= 'Z') buffer[0] = virt - 'A' + 1;
+ else buffer[0] = 0;
+ break;
+ }
+ }
+ buffer[1] = 0;
+ len = wcslen( buffer );
+ lstrcpynW( str, buffer, size );
+
+ TRACE_(keyboard)( "ret %d, str %s.\n", len, debugstr_w(str) );
+ return len;
}
/****************************************************************************
diff --git a/dlls/wineandroid.drv/keyboard.c b/dlls/wineandroid.drv/keyboard.c
index 0a6ede0ec5f..04565c3fad8 100644
--- a/dlls/wineandroid.drv/keyboard.c
+++ b/dlls/wineandroid.drv/keyboard.c
@@ -750,100 +750,6 @@ jboolean keyboard_event( JNIEnv *env, jobject obj, jint win, jint action, jint k
}
-/***********************************************************************
- * ANDROID_ToUnicodeEx
- */
-INT CDECL ANDROID_ToUnicodeEx( UINT virt, UINT scan, const BYTE *state,
- LPWSTR buf, int size, UINT flags, HKL hkl )
-{
- WCHAR buffer[2];
- BOOL shift = state[VK_SHIFT] & 0x80;
- BOOL ctrl = state[VK_CONTROL] & 0x80;
- BOOL numlock = state[VK_NUMLOCK] & 0x01;
-
- buffer[0] = buffer[1] = 0;
-
- if (scan & 0x8000) return 0; /* key up */
-
- /* FIXME: hardcoded layout */
-
- if (!ctrl)
- {
- switch (virt)
- {
- case VK_BACK: buffer[0] = '\b'; break;
- case VK_OEM_1: buffer[0] = shift ? ':' : ';'; break;
- case VK_OEM_2: buffer[0] = shift ? '?' : '/'; break;
- case VK_OEM_3: buffer[0] = shift ? '~' : '`'; break;
- case VK_OEM_4: buffer[0] = shift ? '{' : '['; break;
- case VK_OEM_5: buffer[0] = shift ? '|' : '\\'; break;
- case VK_OEM_6: buffer[0] = shift ? '}' : ']'; break;
- case VK_OEM_7: buffer[0] = shift ? '"' : '\''; break;
- case VK_OEM_COMMA: buffer[0] = shift ? '<' : ','; break;
- case VK_OEM_MINUS: buffer[0] = shift ? '_' : '-'; break;
- case VK_OEM_PERIOD: buffer[0] = shift ? '>' : '.'; break;
- case VK_OEM_PLUS: buffer[0] = shift ? '+' : '='; break;
- case VK_RETURN: buffer[0] = '\r'; break;
- case VK_SPACE: buffer[0] = ' '; break;
- case VK_TAB: buffer[0] = '\t'; break;
- case VK_MULTIPLY: buffer[0] = '*'; break;
- case VK_ADD: buffer[0] = '+'; break;
- case VK_SUBTRACT: buffer[0] = '-'; break;
- case VK_DIVIDE: buffer[0] = '/'; break;
- default:
- if (virt >= '0' && virt <= '9')
- {
- buffer[0] = shift ? ")!@#$%^&*("[virt - '0'] : virt;
- break;
- }
- if (virt >= 'A' && virt <= 'Z')
- {
- buffer[0] = shift || (state[VK_CAPITAL] & 0x01) ? virt : virt + 'a' - 'A';
- break;
- }
- if (virt >= VK_NUMPAD0 && virt <= VK_NUMPAD9 && numlock && !shift)
- {
- buffer[0] = '0' + virt - VK_NUMPAD0;
- break;
- }
- if (virt == VK_DECIMAL && numlock && !shift)
- {
- buffer[0] = '.';
- break;
- }
- break;
- }
- }
- else /* Control codes */
- {
- if (virt >= 'A' && virt <= 'Z')
- buffer[0] = virt - 'A' + 1;
- else
- {
- switch (virt)
- {
- case VK_OEM_4:
- buffer[0] = 0x1b;
- break;
- case VK_OEM_5:
- buffer[0] = 0x1c;
- break;
- case VK_OEM_6:
- buffer[0] = 0x1d;
- break;
- case VK_SUBTRACT:
- buffer[0] = 0x1e;
- break;
- }
- }
- }
-
- lstrcpynW( buf, buffer, size );
- TRACE( "returning %d / %s\n", strlenW( buffer ), debugstr_wn(buf, strlenW( buffer )));
- return strlenW( buffer );
-}
-
-
/***********************************************************************
* ANDROID_GetKeyNameText
*/
diff --git a/dlls/wineandroid.drv/wineandroid.drv.spec b/dlls/wineandroid.drv/wineandroid.drv.spec
index 00de23de27e..6f27c1586b3 100644
--- a/dlls/wineandroid.drv/wineandroid.drv.spec
+++ b/dlls/wineandroid.drv/wineandroid.drv.spec
@@ -7,7 +7,6 @@
@ cdecl GetKeyNameText(long ptr long) ANDROID_GetKeyNameText
@ cdecl GetKeyboardLayout(long) ANDROID_GetKeyboardLayout
@ cdecl MapVirtualKeyEx(long long long) ANDROID_MapVirtualKeyEx
-@ cdecl ToUnicodeEx(long long ptr ptr long long long) ANDROID_ToUnicodeEx
@ cdecl VkKeyScanEx(long long) ANDROID_VkKeyScanEx
@ cdecl SetCursor(long) ANDROID_SetCursor
@ cdecl ChangeDisplaySettingsEx(ptr ptr long long long) ANDROID_ChangeDisplaySettingsEx
--
2.31.0
2
4
[tools] winetest/build-patterns: Identify patterns with new and possibly fixed failures.
by Francois Gouget April 29, 2021
by Francois Gouget April 29, 2021
April 29, 2021
Show the patterns with new failures first, then those that always
failed, and finally those that do not have any recent failure and thus
may be fixed.
This should help catch new failures while they are fresh.
Signed-off-by: Francois Gouget <fgouget(a)codeweavers.com>
---
winetest/build-patterns | 113 ++++++++++++++++++++++++++++++++++------
winetest/winetest.conf | 3 ++
2 files changed, 100 insertions(+), 16 deletions(-)
diff --git a/winetest/build-patterns b/winetest/build-patterns
index e87fabc2f..32bae6b31 100755
--- a/winetest/build-patterns
+++ b/winetest/build-patterns
@@ -31,7 +31,7 @@ sub BEGIN
}
unshift @INC, $1 if ($0 =~ m=^(/.*)/[^/]+$=);
}
-use vars qw/$workdir $gitdir/;
+use vars qw/$workdir $gitdir $patternbuilds/;
require "winetest.conf";
my $name0=$0;
@@ -262,9 +262,19 @@ my %reports;
# should be included in that test's failure pattern.
#
# - failtype
-# The type of the most recent failure (see fail_type()).
+# The type of the most recent failure (see fail_type(), last).
# In particular this distinguishes random failures from non-random ones.
#
+# - first
+# The @sortedbuilds index of the oldest build with a failure matching
+# failtype. So if failtype is 'random' this ignores any 'missing dll'
+# failures that may have occurred before.
+# scalar(@sortedbuilds) if there is no failure.
+#
+# - last
+# The @sortedbuilds index of the most recent build with a failure.
+# -1 if there is none.
+#
# - status
# A hashtable of test results indexed by the build name.
my %tests;
@@ -388,11 +398,16 @@ foreach my $testname (keys %tests)
next if (!$testreport);
# Record information about the failures for this report:
+ # - The index of the first (oldest) and last (most recent) failures.
+ # Initialized for easy min / max calculations.
+ $testreport->{first} = @sortedbuilds;
+ $testreport->{last} = -1;
# - Type of failure: random or not (missing dll, etc.)
$testreport->{failtype} = "";
- foreach my $build (@sortedbuilds)
+ for my $i (0..(a)sortedbuilds-1)
{
+ my $build = $sortedbuilds[$i];
my $status = $testreport->{status}->{$build->{name}};
if (!defined $status)
{
@@ -419,7 +434,13 @@ foreach my $testname (keys %tests)
# missing dll to the test running and crashing.
# Either way the relevant round of failures starts now.
$testreport->{failed} = 1;
- last;
+ $testreport->{first} = $i;
+ $testreport->{last} = $i;
+ $testreport->{failtype} = $failtype;
+ }
+ else
+ {
+ $testreport->{last} = $i;
}
}
}
@@ -525,8 +546,9 @@ sub get_status_html($$)
sub write_patterns_list($$$$)
{
- my ($html, $pagereports, $mainpage, $testnames) = @_;
+ my ($html, $pagereports, $mainpage, $list) = @_;
+ my $testnames = $list->{testnames};
for my $i (0..@$testnames-1)
{
my $testname = $testnames->[$i];
@@ -537,9 +559,9 @@ sub write_patterns_list($$$$)
print $html " <small>(<a href='$mainpage#$testname'>see all results</a></small>)" if ($mainpage);
print $html "<div class='ralign'>";
- my $href = $i ? $testnames->[$i-1] : "";
- print $html "<a href='#$href'>↑</a>";
- $href = $i+1 < @$testnames ? $testnames->[$i+1] : undef;
+ my $href = $i ? $testnames->[$i-1] : $list->{prevunit};
+ print $html "<a href='#$href'>↑</a>" if (defined $href);
+ $href = $i+1 < @$testnames ? $testnames->[$i+1] : $list->{nextunit};
print $html "<a href='#$href'>↓</a>" if (defined $href);
print $html "</div></div>\n";
@@ -669,18 +691,37 @@ sub write_patterns_page($$$)
<div class="main">
EOF
- # Build a list of test units that will appear on this page so we can
- # link them to each other.
- my $testnames = [];
+ # Show the test units with recent failures first.
+ # Also use these lists to link the test units to each other.
+ my %lists = (
+ recent => {title => "Recent failures",
+ desc => "have recent failures (that is failures that did not happen for the $patternbuilds oldest builds).",
+ testnames => []},
+ regular => {title => "Regular failures",
+ desc => "had failures.",
+ testnames => []},
+ old => {title => "Old failures",
+ desc => "had no failure in the most recent $patternbuilds builds. Fixed or just rare failures?",
+ testnames => []},
+ );
foreach my $testname (sort keys %tests)
{
my $test = $tests{$testname};
- my $addtest;
+
+ my $first = @sortedbuilds;
+ my $last = -1;
foreach my $reportdir (keys %$pagereports)
{
my $testreport = $test->{testreports}->{$reportdir};
next if (!$testreport->{failed});
- $addtest = 1;
+
+ $first = $testreport->{first} if ($testreport->{first} < $first);
+ # For non-random failures we only care about the transition to
+ # the failure state, which is recorded in 'first'.
+ my $replast = $testreport->{failtype} eq "random" ? $testreport->{last} :
+ $testreport->{first} == @sortedbuilds ? -1 :
+ $testreport->{first};
+ $last = $replast if ($replast > $last);
foreach my $status (values %{$testreport->{status}})
{
@@ -689,12 +730,52 @@ EOF
$test->{colors}->{$status} = undef;
}
}
- push @$testnames, $testname if ($addtest);
+ next if ($last == -1); # no report had a pattern of interest
+
+ my $listid = ($last < @sortedbuilds - $patternbuilds) ? "old" :
+ ($first > $patternbuilds) ? "recent" :
+ "regular";
+ push @{$lists{$listid}->{testnames}}, $testname;
+ }
+
+ # Generate the lists index (and up test unit links)
+ print $html "<h1>$title</h1>\n";
+ print $html "<ul>\n";
+ my @listids = ("recent", "regular", "old");
+ my $prevunit = "";
+ foreach my $listid (@listids)
+ {
+ my $list = $lists{$listid};
+ my $count = @{$list->{testnames}};
+ next if (!$count);
+ print $html "<li><a href='#$listid'>$count test units</a> $list->{desc}</li>\n";
+ $list->{prevunit} = $prevunit;
+ $prevunit = $list->{testnames}->[-1];
+ }
+ print $html "</ul>\n";
+
+ # Link the last test unit of each list to the first one of the next list
+ my $nextunit;
+ foreach my $listid (reverse @listids)
+ {
+ my $list = $lists{$listid};
+ my $count = @{$list->{testnames}};
+ next if (!$count);
+ $list->{nextunit} = $nextunit;
+ $nextunit = $list->{testnames}->[0];
}
+ # Generate the test unit lists themselves
my $mainpage = $subpage ? "patterns.html" : "";
- print $html "<h2>$title</h2>\n";
- write_patterns_list($html, $pagereports, $mainpage, $testnames);
+ foreach my $listid (@listids)
+ {
+ my $list = $lists{$listid};
+ my $count = @{$list->{testnames}};
+ next if (!$count);
+ print $html "<h2 id='$listid'>$list->{title}</h2>\n";
+ write_patterns_list($html, $pagereports, $mainpage, $list);
+ }
+
print $html "</div></body></html>\n";
close($html);
diff --git a/winetest/winetest.conf b/winetest/winetest.conf
index 84824a2b3..f193f8eed 100644
--- a/winetest/winetest.conf
+++ b/winetest/winetest.conf
@@ -24,4 +24,7 @@ $maxunitsize = 32 * 1024;
# This should be in line with programs\winetest\send.c
$maxfilesize = 1.5 * 1024 * 1024;
+# The number of builds after which a failure is considered old / new
+$patternbuilds = 10;
+
1; # keep require happy
--
2.20.1
1
0
[PATCH] ws2_32/sock: WSARecv/WSASend checks async pendings of the socket.
by dongwan_kim@tmax.co.kr April 29, 2021
by dongwan_kim@tmax.co.kr April 29, 2021
April 29, 2021
Hi, My name is Dongwan Kim.
I found the misbehavior of WSARecv/WSASend when they are called multiple
times for overlapped I/O to the same socket .
Specifically, the problem occurs if WSARecv is called when overlapped
I/O gets ready. WSARecv intercepts the message from the socket.
for example,
Alice Bob
WSARecv( SOCKET_A, buffer1 ) ; <----- X
... <----- Y
WSARecv(SOCKET_A, buffer2) ;
Bob sent messages( X , Y ) to Alice. Alice should get X to buffer1, Y to
buffer 2 respectively.
But, In the current version of wine , Alice could get Y to buffer 1
because WSARecv always tries to get message from the socket without
checking if there are waiting syncs.
I attached my solution and the programs for testing.
The test server program receives messages from client with WSARecv. you
can run it as : test_server.exe 9088
9088 is port number which is hard-coded in test client program...
The test client program sends fragments of a file to server. you can run
it as : test_client.exe localhost [file_to_send]
I tested with a 96MB file.
The programs are not clean...
If you need, I can send the source code.
Thanks.
Best Regards.
1
0
April 28, 2021
Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com>
---
dlls/d3d8/tests/visual.c | 88 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 88 insertions(+)
diff --git a/dlls/d3d8/tests/visual.c b/dlls/d3d8/tests/visual.c
index fc8a05a3c40..f25549388d0 100644
--- a/dlls/d3d8/tests/visual.c
+++ b/dlls/d3d8/tests/visual.c
@@ -11070,6 +11070,93 @@ static void test_desktop_window(void)
IDirect3D8_Release(d3d);
}
+static void test_sample_mask(void)
+{
+ IDirect3DSurface8 *rt, *ms_rt;
+ struct surface_readback rb;
+ IDirect3DDevice8 *device;
+ IDirect3D8 *d3d;
+ ULONG refcount;
+ DWORD colour;
+ HWND window;
+ HRESULT hr;
+
+ static const struct
+ {
+ struct vec3 position;
+ DWORD diffuse;
+ }
+ quad[] =
+ {
+ {{-1.0f, -1.0f, 0.1f}, 0xffffffff},
+ {{-1.0f, 1.0f, 0.1f}, 0xffffffff},
+ {{ 1.0f, -1.0f, 0.1f}, 0xffffffff},
+ {{ 1.0f, 1.0f, 0.1f}, 0xffffffff},
+ };
+
+ window = create_window();
+ d3d = Direct3DCreate8(D3D_SDK_VERSION);
+ ok(!!d3d, "Failed to create a D3D object.\n");
+
+ if (FAILED(IDirect3D8_CheckDeviceMultiSampleType(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
+ D3DFMT_A8R8G8B8, TRUE, D3DMULTISAMPLE_2_SAMPLES)))
+ {
+ skip("Multisampling not supported for D3DFMT_A8R8G8B8.\n");
+ IDirect3D8_Release(d3d);
+ DestroyWindow(window);
+ return;
+ }
+
+ if (!(device = create_device(d3d, window, window, TRUE)))
+ {
+ skip("Failed to create a 3D device.\n");
+ IDirect3D8_Release(d3d);
+ DestroyWindow(window);
+ return;
+ }
+
+ hr = IDirect3DDevice8_CreateRenderTarget(device, 128, 128, D3DFMT_A8R8G8B8, D3DMULTISAMPLE_NONE, FALSE, &rt);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+ hr = IDirect3DDevice8_CreateRenderTarget(device, 128, 128,
+ D3DFMT_A8R8G8B8, D3DMULTISAMPLE_2_SAMPLES, FALSE, &ms_rt);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+
+ hr = IDirect3DDevice8_SetRenderTarget(device, ms_rt, NULL);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+
+ hr = IDirect3DDevice8_BeginScene(device);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+
+ hr = IDirect3DDevice8_SetRenderState(device, D3DRS_LIGHTING, FALSE);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+ hr = IDirect3DDevice8_SetRenderState(device, D3DRS_MULTISAMPLEMASK, 0x5);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+
+ hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffff0000, 0.0f, 0);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+ hr = IDirect3DDevice8_SetVertexShader(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+ hr = IDirect3DDevice8_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(quad[0]));
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+
+ hr = IDirect3DDevice8_CopyRects(device, ms_rt, NULL, 0, rt, NULL);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+ get_rt_readback(rt, &rb);
+ colour = get_readback_color(&rb, 64, 64);
+ ok(color_match(colour, 0xffff8080, 1), "Got unexpected colour %08x.\n", colour);
+ release_surface_readback(&rb);
+
+ hr = IDirect3DDevice8_EndScene(device);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+
+ IDirect3DSurface8_Release(ms_rt);
+ IDirect3DSurface8_Release(rt);
+ refcount = IDirect3DDevice8_Release(device);
+ ok(!refcount, "Device has %u references left.\n", refcount);
+ IDirect3D8_Release(d3d);
+ DestroyWindow(window);
+}
+
START_TEST(visual)
{
D3DADAPTER_IDENTIFIER8 identifier;
@@ -11147,4 +11234,5 @@ START_TEST(visual)
test_sysmem_draw();
test_alphatest();
test_desktop_window();
+ test_sample_mask();
}
--
2.30.2
2
9
[PATCH 1/5] ws2_32/tests: Move address lookup tests to protocol.c.
by Zebediah Figura April 28, 2021
by Zebediah Figura April 28, 2021
April 28, 2021
sock.c is huge. This doesn't bother some people, but I find that it can be
harder to navigate and slower to compile. Splitting it is tricky, but I think
there's a pretty natural divide between functions that operate on sockets
(e.g. bind, listen, recv, getsockname) and functions that don't (e.g.
get*info, inet_*, get*by*, WSC*).
Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com>
---
dlls/ws2_32/tests/protocol.c | 809 ++++++++++++++++++++++++++++++++++-
dlls/ws2_32/tests/sock.c | 805 ----------------------------------
2 files changed, 808 insertions(+), 806 deletions(-)
diff --git a/dlls/ws2_32/tests/protocol.c b/dlls/ws2_32/tests/protocol.c
index d6e454a5fbd..21b26d12aec 100644
--- a/dlls/ws2_32/tests/protocol.c
+++ b/dlls/ws2_32/tests/protocol.c
@@ -23,9 +23,18 @@
#include <windef.h>
#include <winbase.h>
#include <winsock2.h>
+#include <ws2tcpip.h>
#include "wine/test.h"
+static void (WINAPI *pFreeAddrInfoExW)(ADDRINFOEXW *ai);
+static int (WINAPI *pGetAddrInfoExW)(const WCHAR *name, const WCHAR *servname, DWORD namespace,
+ GUID *namespace_id, const ADDRINFOEXW *hints, ADDRINFOEXW **result,
+ struct timeval *timeout, OVERLAPPED *overlapped,
+ LPLOOKUPSERVICE_COMPLETION_ROUTINE completion_routine, HANDLE *handle);
+static int (WINAPI *pGetAddrInfoExOverlappedResult)(OVERLAPPED *overlapped);
+static const char *(WINAPI *p_inet_ntop)(int family, void *addr, char *string, ULONG size);
+
/* TCP and UDP over IP fixed set of service flags */
#define TCPIP_SERVICE_FLAGS (XP1_GUARANTEED_DELIVERY \
| XP1_GUARANTEED_ORDER \
@@ -290,15 +299,813 @@ static void test_getprotobynumber(void)
}
}
+/* Tests used in both getaddrinfo and GetAddrInfoW */
+static const struct addr_hint_tests
+{
+ int family, socktype, protocol;
+ DWORD error;
+}
+hinttests[] =
+{
+ {AF_UNSPEC, SOCK_STREAM, IPPROTO_TCP, 0},
+ {AF_UNSPEC, SOCK_STREAM, IPPROTO_UDP, 0},
+ {AF_UNSPEC, SOCK_STREAM, IPPROTO_IPV6,0},
+ {AF_UNSPEC, SOCK_DGRAM, IPPROTO_TCP, 0},
+ {AF_UNSPEC, SOCK_DGRAM, IPPROTO_UDP, 0},
+ {AF_UNSPEC, SOCK_DGRAM, IPPROTO_IPV6,0},
+ {AF_INET, SOCK_STREAM, IPPROTO_TCP, 0},
+ {AF_INET, SOCK_STREAM, IPPROTO_UDP, 0},
+ {AF_INET, SOCK_STREAM, IPPROTO_IPV6,0},
+ {AF_INET, SOCK_DGRAM, IPPROTO_TCP, 0},
+ {AF_INET, SOCK_DGRAM, IPPROTO_UDP, 0},
+ {AF_INET, SOCK_DGRAM, IPPROTO_IPV6,0},
+ {AF_UNSPEC, 0, IPPROTO_TCP, 0},
+ {AF_UNSPEC, 0, IPPROTO_UDP, 0},
+ {AF_UNSPEC, 0, IPPROTO_IPV6,0},
+ {AF_UNSPEC, SOCK_STREAM, 0, 0},
+ {AF_UNSPEC, SOCK_DGRAM, 0, 0},
+ {AF_INET, 0, IPPROTO_TCP, 0},
+ {AF_INET, 0, IPPROTO_UDP, 0},
+ {AF_INET, 0, IPPROTO_IPV6,0},
+ {AF_INET, SOCK_STREAM, 0, 0},
+ {AF_INET, SOCK_DGRAM, 0, 0},
+ {AF_UNSPEC, 999, IPPROTO_TCP, WSAESOCKTNOSUPPORT},
+ {AF_UNSPEC, 999, IPPROTO_UDP, WSAESOCKTNOSUPPORT},
+ {AF_UNSPEC, 999, IPPROTO_IPV6,WSAESOCKTNOSUPPORT},
+ {AF_INET, 999, IPPROTO_TCP, WSAESOCKTNOSUPPORT},
+ {AF_INET, 999, IPPROTO_UDP, WSAESOCKTNOSUPPORT},
+ {AF_INET, 999, IPPROTO_IPV6,WSAESOCKTNOSUPPORT},
+ {AF_UNSPEC, SOCK_STREAM, 999, 0},
+ {AF_UNSPEC, SOCK_STREAM, 999, 0},
+ {AF_INET, SOCK_DGRAM, 999, 0},
+ {AF_INET, SOCK_DGRAM, 999, 0},
+};
+
+static void compare_addrinfow(ADDRINFOW *a, ADDRINFOW *b)
+{
+ for (; a && b; a = a->ai_next, b = b->ai_next)
+ {
+ ok(a->ai_flags == b->ai_flags,
+ "Wrong flags %d != %d\n", a->ai_flags, b->ai_flags);
+ ok(a->ai_family == b->ai_family,
+ "Wrong family %d != %d\n", a->ai_family, b->ai_family);
+ ok(a->ai_socktype == b->ai_socktype,
+ "Wrong socktype %d != %d\n", a->ai_socktype, b->ai_socktype);
+ ok(a->ai_protocol == b->ai_protocol,
+ "Wrong protocol %d != %d\n", a->ai_protocol, b->ai_protocol);
+ ok(a->ai_addrlen == b->ai_addrlen,
+ "Wrong addrlen %lu != %lu\n", a->ai_addrlen, b->ai_addrlen);
+ ok(!memcmp(a->ai_addr, b->ai_addr, min(a->ai_addrlen, b->ai_addrlen)),
+ "Wrong address data\n");
+ if (a->ai_canonname && b->ai_canonname)
+ {
+ ok(!lstrcmpW(a->ai_canonname, b->ai_canonname), "Wrong canonical name '%s' != '%s'\n",
+ wine_dbgstr_w(a->ai_canonname), wine_dbgstr_w(b->ai_canonname));
+ }
+ else
+ ok(!a->ai_canonname && !b->ai_canonname, "Expected both names absent (%p != %p)\n",
+ a->ai_canonname, b->ai_canonname);
+ }
+ ok(!a && !b, "Expected both addresses null (%p != %p)\n", a, b);
+}
+
+static void test_GetAddrInfoW(void)
+{
+ static const WCHAR port[] = {'8','0',0};
+ static const WCHAR empty[] = {0};
+ static const WCHAR localhost[] = {'l','o','c','a','l','h','o','s','t',0};
+ static const WCHAR nxdomain[] =
+ {'n','x','d','o','m','a','i','n','.','c','o','d','e','w','e','a','v','e','r','s','.','c','o','m',0};
+ static const WCHAR zero[] = {'0',0};
+ int i, ret;
+ ADDRINFOW *result, *result2, *p, hint;
+ WCHAR name[256];
+ DWORD size = ARRAY_SIZE(name);
+ /* 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};
+
+ memset(&hint, 0, sizeof(ADDRINFOW));
+ name[0] = 0;
+ GetComputerNameExW( ComputerNamePhysicalDnsHostname, name, &size );
+
+ result = (ADDRINFOW *)0xdeadbeef;
+ WSASetLastError(0xdeadbeef);
+ ret = GetAddrInfoW(NULL, NULL, NULL, &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);
+
+ result = NULL;
+ WSASetLastError(0xdeadbeef);
+ ret = GetAddrInfoW(empty, NULL, NULL, &result);
+ ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError());
+ ok(result != NULL, "GetAddrInfoW failed\n");
+ ok(WSAGetLastError() == 0, "expected 0, got %d\n", WSAGetLastError());
+ FreeAddrInfoW(result);
+
+ result = NULL;
+ ret = GetAddrInfoW(NULL, zero, NULL, &result);
+ ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError());
+ ok(result != NULL, "GetAddrInfoW failed\n");
+
+ result2 = NULL;
+ ret = GetAddrInfoW(NULL, empty, NULL, &result2);
+ ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError());
+ ok(result2 != NULL, "GetAddrInfoW failed\n");
+ compare_addrinfow(result, result2);
+ FreeAddrInfoW(result);
+ FreeAddrInfoW(result2);
+
+ result = NULL;
+ ret = GetAddrInfoW(empty, zero, NULL, &result);
+ ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError());
+ ok(WSAGetLastError() == 0, "expected 0, got %d\n", WSAGetLastError());
+ ok(result != NULL, "GetAddrInfoW failed\n");
+
+ result2 = NULL;
+ ret = GetAddrInfoW(empty, empty, NULL, &result2);
+ ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError());
+ ok(result2 != NULL, "GetAddrInfoW failed\n");
+ compare_addrinfow(result, result2);
+ FreeAddrInfoW(result);
+ FreeAddrInfoW(result2);
+
+ result = NULL;
+ ret = GetAddrInfoW(localhost, NULL, NULL, &result);
+ ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError());
+ FreeAddrInfoW(result);
+
+ result = NULL;
+ ret = GetAddrInfoW(localhost, empty, NULL, &result);
+ ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError());
+ FreeAddrInfoW(result);
+
+ result = NULL;
+ ret = GetAddrInfoW(localhost, zero, NULL, &result);
+ ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError());
+ FreeAddrInfoW(result);
+
+ result = NULL;
+ ret = GetAddrInfoW(localhost, port, NULL, &result);
+ ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError());
+ FreeAddrInfoW(result);
+
+ result = NULL;
+ ret = GetAddrInfoW(localhost, NULL, &hint, &result);
+ ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError());
+ FreeAddrInfoW(result);
+
+ result = NULL;
+ SetLastError(0xdeadbeef);
+ ret = GetAddrInfoW(localhost, port, &hint, &result);
+ ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError());
+ ok(WSAGetLastError() == 0, "expected 0, got %d\n", WSAGetLastError());
+ FreeAddrInfoW(result);
+
+ /* try to get information from the computer name, result is the same
+ * as if requesting with an empty host name. */
+ ret = GetAddrInfoW(name, NULL, NULL, &result);
+ ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError());
+ ok(result != NULL, "GetAddrInfoW failed\n");
+
+ ret = GetAddrInfoW(empty, NULL, NULL, &result2);
+ ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError());
+ ok(result != NULL, "GetAddrInfoW failed\n");
+ compare_addrinfow(result, result2);
+ FreeAddrInfoW(result);
+ FreeAddrInfoW(result2);
+
+ ret = GetAddrInfoW(name, empty, NULL, &result);
+ ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError());
+ ok(result != NULL, "GetAddrInfoW failed\n");
+
+ ret = GetAddrInfoW(empty, empty, NULL, &result2);
+ ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError());
+ ok(result != NULL, "GetAddrInfoW failed\n");
+ compare_addrinfow(result, result2);
+ FreeAddrInfoW(result);
+ FreeAddrInfoW(result2);
+
+ result = (ADDRINFOW *)0xdeadbeef;
+ WSASetLastError(0xdeadbeef);
+ ret = GetAddrInfoW(NULL, NULL, NULL, &result);
+ if (ret == 0)
+ {
+ skip("nxdomain returned success. Broken ISP redirects?\n");
+ return;
+ }
+ 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);
+
+ result = (ADDRINFOW *)0xdeadbeef;
+ WSASetLastError(0xdeadbeef);
+ ret = GetAddrInfoW(nxdomain, NULL, NULL, &result);
+ if (ret == 0)
+ {
+ skip("nxdomain returned success. Broken ISP redirects?\n");
+ return;
+ }
+ 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);
+
+ for (i = 0; i < ARRAY_SIZE(hinttests); i++)
+ {
+ hint.ai_family = hinttests[i].family;
+ hint.ai_socktype = hinttests[i].socktype;
+ hint.ai_protocol = hinttests[i].protocol;
+
+ result = NULL;
+ SetLastError(0xdeadbeef);
+ ret = GetAddrInfoW(localhost, NULL, &hint, &result);
+ todo_wine_if (hinttests[i].error) ok(ret == hinttests[i].error, "test %d: wrong ret %d\n", i, ret);
+ if (!ret)
+ {
+ for (p = result; p; p = p->ai_next)
+ {
+ /* when AF_UNSPEC is used the return will be either AF_INET or AF_INET6 */
+ if (hinttests[i].family == AF_UNSPEC)
+ ok(p->ai_family == AF_INET || p->ai_family == AF_INET6,
+ "test %d: expected AF_INET or AF_INET6, got %d\n",
+ i, p->ai_family);
+ else
+ ok(p->ai_family == hinttests[i].family,
+ "test %d: expected family %d, got %d\n",
+ i, hinttests[i].family, p->ai_family);
+
+ ok(p->ai_socktype == hinttests[i].socktype,
+ "test %d: expected type %d, got %d\n",
+ i, hinttests[i].socktype, p->ai_socktype);
+ ok(p->ai_protocol == hinttests[i].protocol,
+ "test %d: expected protocol %d, got %d\n",
+ i, hinttests[i].protocol, p->ai_protocol);
+ }
+ FreeAddrInfoW(result);
+ }
+ else
+ {
+ ok(WSAGetLastError() == hinttests[i].error, "test %d: wrong error %d\n", i, WSAGetLastError());
+ }
+ }
+
+ /* Test IDN resolution (Internationalized Domain Names) present since Windows 8 */
+ result = NULL;
+ ret = GetAddrInfoW(idn_punycode, NULL, NULL, &result);
+ ok(!ret, "got %d expected success\n", ret);
+ ok(result != NULL, "got %p\n", result);
+ FreeAddrInfoW(result);
+
+ hint.ai_family = AF_INET;
+ hint.ai_socktype = 0;
+ hint.ai_protocol = 0;
+ hint.ai_flags = 0;
+
+ result = NULL;
+ ret = GetAddrInfoW(idn_punycode, NULL, &hint, &result);
+ ok(!ret, "got %d expected success\n", ret);
+ ok(result != NULL, "got %p\n", result);
+
+ result2 = NULL;
+ ret = GetAddrInfoW(idn_domain, NULL, NULL, &result2);
+ if (broken(ret == WSAHOST_NOT_FOUND))
+ {
+ FreeAddrInfoW(result);
+ win_skip("IDN resolution not supported in Win <= 7\n");
+ return;
+ }
+
+ ok(!ret, "got %d expected success\n", ret);
+ ok(result2 != NULL, "got %p\n", result2);
+ FreeAddrInfoW(result2);
+
+ hint.ai_family = AF_INET;
+ hint.ai_socktype = 0;
+ hint.ai_protocol = 0;
+ hint.ai_flags = 0;
+
+ result2 = NULL;
+ ret = GetAddrInfoW(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);
+
+ FreeAddrInfoW(result);
+ FreeAddrInfoW(result2);
+
+ hint.ai_family = AF_INET;
+ hint.ai_socktype = 0;
+ hint.ai_protocol = 0;
+ hint.ai_flags = 0;
+
+ result2 = NULL;
+ ret = GetAddrInfoW(idn_domain, NULL, &hint, &result2);
+ ok(!ret, "got %d expected success\n", ret);
+ ok(result2 != NULL, "got %p\n", result2);
+ FreeAddrInfoW(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 = GetAddrInfoW(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 struct completion_routine_test
+{
+ WSAOVERLAPPED *overlapped;
+ DWORD error;
+ ADDRINFOEXW **result;
+ HANDLE event;
+ DWORD called;
+} completion_routine_test;
+
+static void CALLBACK completion_routine(DWORD error, DWORD byte_count, WSAOVERLAPPED *overlapped)
+{
+ struct completion_routine_test *test = &completion_routine_test;
+
+ ok(error == test->error, "got %u\n", error);
+ ok(!byte_count, "got %u\n", byte_count);
+ ok(overlapped == test->overlapped, "got %p\n", overlapped);
+ ok(overlapped->Internal == test->error, "got %lu\n", overlapped->Internal);
+ ok(overlapped->Pointer == test->result, "got %p\n", overlapped->Pointer);
+ ok(overlapped->hEvent == NULL, "got %p\n", overlapped->hEvent);
+
+ test->called++;
+ SetEvent(test->event);
+}
+
+static void test_GetAddrInfoExW(void)
+{
+ static const WCHAR empty[] = {0};
+ static const WCHAR localhost[] = {'l','o','c','a','l','h','o','s','t',0};
+ static const WCHAR winehq[] = {'t','e','s','t','.','w','i','n','e','h','q','.','o','r','g',0};
+ static const WCHAR nxdomain[] = {'n','x','d','o','m','a','i','n','.','w','i','n','e','h','q','.','o','r','g',0};
+ ADDRINFOEXW *result;
+ OVERLAPPED overlapped;
+ HANDLE event;
+ int ret;
+
+ if (!pGetAddrInfoExW || !pGetAddrInfoExOverlappedResult)
+ {
+ win_skip("GetAddrInfoExW and/or GetAddrInfoExOverlappedResult not present\n");
+ return;
+ }
+
+ event = WSACreateEvent();
+
+ result = (ADDRINFOEXW *)0xdeadbeef;
+ WSASetLastError(0xdeadbeef);
+ ret = pGetAddrInfoExW(NULL, NULL, NS_DNS, NULL, NULL, &result, NULL, NULL, NULL, NULL);
+ 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);
+
+ result = NULL;
+ WSASetLastError(0xdeadbeef);
+ ret = pGetAddrInfoExW(empty, NULL, NS_DNS, NULL, NULL, &result, NULL, NULL, NULL, NULL);
+ ok(!ret, "GetAddrInfoExW failed with %d\n", WSAGetLastError());
+ ok(result != NULL, "GetAddrInfoW failed\n");
+ ok(WSAGetLastError() == 0, "expected 0, got %d\n", WSAGetLastError());
+ pFreeAddrInfoExW(result);
+
+ result = NULL;
+ ret = pGetAddrInfoExW(localhost, NULL, NS_DNS, NULL, NULL, &result, NULL, NULL, NULL, NULL);
+ ok(!ret, "GetAddrInfoExW failed with %d\n", WSAGetLastError());
+ pFreeAddrInfoExW(result);
+
+ result = (void *)0xdeadbeef;
+ memset(&overlapped, 0xcc, sizeof(overlapped));
+ overlapped.hEvent = event;
+ ResetEvent(event);
+ ret = pGetAddrInfoExW(localhost, NULL, NS_DNS, NULL, NULL, &result, NULL, &overlapped, NULL, NULL);
+ ok(ret == ERROR_IO_PENDING, "GetAddrInfoExW failed with %d\n", WSAGetLastError());
+ ok(!result, "result != NULL\n");
+ ok(WaitForSingleObject(event, 1000) == WAIT_OBJECT_0, "wait failed\n");
+ ret = pGetAddrInfoExOverlappedResult(&overlapped);
+ ok(!ret, "overlapped result is %d\n", ret);
+ pFreeAddrInfoExW(result);
+
+ result = (void *)0xdeadbeef;
+ memset(&overlapped, 0xcc, sizeof(overlapped));
+ ResetEvent(event);
+ overlapped.hEvent = event;
+ WSASetLastError(0xdeadbeef);
+ ret = pGetAddrInfoExW(winehq, NULL, NS_DNS, NULL, NULL, &result, NULL, &overlapped, NULL, NULL);
+ ok(ret == ERROR_IO_PENDING, "GetAddrInfoExW failed with %d\n", WSAGetLastError());
+ ok(WSAGetLastError() == ERROR_IO_PENDING, "expected 11001, got %d\n", WSAGetLastError());
+ ret = overlapped.Internal;
+ ok(ret == WSAEINPROGRESS || ret == ERROR_SUCCESS, "overlapped.Internal = %u\n", ret);
+ ok(WaitForSingleObject(event, 1000) == WAIT_OBJECT_0, "wait failed\n");
+ ret = pGetAddrInfoExOverlappedResult(&overlapped);
+ ok(!ret, "overlapped result is %d\n", ret);
+ ok(overlapped.hEvent == event, "hEvent changed %p\n", overlapped.hEvent);
+ ok(overlapped.Internal == ERROR_SUCCESS, "overlapped.Internal = %lx\n", overlapped.Internal);
+ ok(overlapped.Pointer == &result, "overlapped.Pointer != &result\n");
+ ok(result != NULL, "result == NULL\n");
+ ok(!result->ai_blob, "ai_blob != NULL\n");
+ ok(!result->ai_bloblen, "ai_bloblen != 0\n");
+ ok(!result->ai_provider, "ai_provider = %s\n", wine_dbgstr_guid(result->ai_provider));
+ pFreeAddrInfoExW(result);
+
+ result = (void *)0xdeadbeef;
+ memset(&overlapped, 0xcc, sizeof(overlapped));
+ ResetEvent(event);
+ overlapped.hEvent = event;
+ ret = pGetAddrInfoExW(NULL, NULL, NS_DNS, NULL, NULL, &result, NULL, &overlapped, NULL, NULL);
+ todo_wine
+ ok(ret == WSAHOST_NOT_FOUND, "got %d expected WSAHOST_NOT_FOUND\n", ret);
+ todo_wine
+ ok(WSAGetLastError() == WSAHOST_NOT_FOUND, "expected 11001, got %d\n", WSAGetLastError());
+ ok(result == NULL, "got %p\n", result);
+ ret = WaitForSingleObject(event, 0);
+ todo_wine_if(ret != WAIT_TIMEOUT) /* Remove when abowe todo_wines are fixed */
+ ok(ret == WAIT_TIMEOUT, "wait failed\n");
+
+ /* event + completion routine */
+ result = (void *)0xdeadbeef;
+ memset(&overlapped, 0xcc, sizeof(overlapped));
+ overlapped.hEvent = event;
+ ResetEvent(event);
+ ret = pGetAddrInfoExW(localhost, NULL, NS_DNS, NULL, NULL, &result, NULL, &overlapped, completion_routine, NULL);
+ ok(ret == WSAEINVAL, "GetAddrInfoExW failed with %d\n", WSAGetLastError());
+
+ /* completion routine, existing domain */
+ result = (void *)0xdeadbeef;
+ overlapped.hEvent = NULL;
+ completion_routine_test.overlapped = &overlapped;
+ completion_routine_test.error = ERROR_SUCCESS;
+ completion_routine_test.result = &result;
+ completion_routine_test.event = event;
+ completion_routine_test.called = 0;
+ ResetEvent(event);
+ ret = pGetAddrInfoExW(winehq, NULL, NS_DNS, NULL, NULL, &result, NULL, &overlapped, completion_routine, NULL);
+ ok(ret == ERROR_IO_PENDING, "GetAddrInfoExW failed with %d\n", WSAGetLastError());
+ ok(!result, "result != NULL\n");
+ ok(WaitForSingleObject(event, 1000) == WAIT_OBJECT_0, "wait failed\n");
+ ret = pGetAddrInfoExOverlappedResult(&overlapped);
+ ok(!ret, "overlapped result is %d\n", ret);
+ ok(overlapped.hEvent == NULL, "hEvent changed %p\n", overlapped.hEvent);
+ ok(overlapped.Internal == ERROR_SUCCESS, "overlapped.Internal = %lx\n", overlapped.Internal);
+ ok(overlapped.Pointer == &result, "overlapped.Pointer != &result\n");
+ ok(completion_routine_test.called == 1, "got %u\n", completion_routine_test.called);
+ pFreeAddrInfoExW(result);
+
+ /* completion routine, non-existing domain */
+ result = (void *)0xdeadbeef;
+ completion_routine_test.overlapped = &overlapped;
+ completion_routine_test.error = WSAHOST_NOT_FOUND;
+ completion_routine_test.called = 0;
+ ResetEvent(event);
+ ret = pGetAddrInfoExW(nxdomain, NULL, NS_DNS, NULL, NULL, &result, NULL, &overlapped, completion_routine, NULL);
+ ok(ret == ERROR_IO_PENDING, "GetAddrInfoExW failed with %d\n", WSAGetLastError());
+ ok(!result, "result != NULL\n");
+ ok(WaitForSingleObject(event, 1000) == WAIT_OBJECT_0, "wait failed\n");
+ ret = pGetAddrInfoExOverlappedResult(&overlapped);
+ ok(ret == WSAHOST_NOT_FOUND, "overlapped result is %d\n", ret);
+ ok(overlapped.hEvent == NULL, "hEvent changed %p\n", overlapped.hEvent);
+ ok(overlapped.Internal == WSAHOST_NOT_FOUND, "overlapped.Internal = %lx\n", overlapped.Internal);
+ ok(overlapped.Pointer == &result, "overlapped.Pointer != &result\n");
+ ok(completion_routine_test.called == 1, "got %u\n", completion_routine_test.called);
+ ok(result == NULL, "got %p\n", result);
+
+ WSACloseEvent(event);
+}
+
+static void verify_ipv6_addrinfo(ADDRINFOA *result, const char *expect)
+{
+ SOCKADDR_IN6 *sockaddr6;
+ char buffer[256];
+ const char *ret;
+
+ ok(result->ai_family == AF_INET6, "ai_family == %d\n", result->ai_family);
+ ok(result->ai_addrlen >= sizeof(struct sockaddr_in6), "ai_addrlen == %d\n", (int)result->ai_addrlen);
+ ok(result->ai_addr != NULL, "ai_addr == NULL\n");
+
+ sockaddr6 = (SOCKADDR_IN6 *)result->ai_addr;
+ ok(sockaddr6->sin6_family == AF_INET6, "ai_addr->sin6_family == %d\n", sockaddr6->sin6_family);
+ ok(sockaddr6->sin6_port == 0, "ai_addr->sin6_port == %d\n", sockaddr6->sin6_port);
+
+ memset(buffer, 0, sizeof(buffer));
+ ret = p_inet_ntop(AF_INET6, &sockaddr6->sin6_addr, buffer, sizeof(buffer));
+ ok(ret != NULL, "inet_ntop failed (%d)\n", WSAGetLastError());
+ ok(!strcmp(buffer, expect), "ai_addr->sin6_addr == '%s' (expected '%s')\n", buffer, expect);
+}
+
+static void compare_addrinfo(ADDRINFO *a, ADDRINFO *b)
+{
+ for (; a && b ; a = a->ai_next, b = b->ai_next)
+ {
+ ok(a->ai_flags == b->ai_flags,
+ "Wrong flags %d != %d\n", a->ai_flags, b->ai_flags);
+ ok(a->ai_family == b->ai_family,
+ "Wrong family %d != %d\n", a->ai_family, b->ai_family);
+ ok(a->ai_socktype == b->ai_socktype,
+ "Wrong socktype %d != %d\n", a->ai_socktype, b->ai_socktype);
+ ok(a->ai_protocol == b->ai_protocol,
+ "Wrong protocol %d != %d\n", a->ai_protocol, b->ai_protocol);
+ ok(a->ai_addrlen == b->ai_addrlen,
+ "Wrong addrlen %lu != %lu\n", a->ai_addrlen, b->ai_addrlen);
+ ok(!memcmp(a->ai_addr, b->ai_addr, min(a->ai_addrlen, b->ai_addrlen)),
+ "Wrong address data\n");
+ if (a->ai_canonname && b->ai_canonname)
+ {
+ ok(!strcmp(a->ai_canonname, b->ai_canonname), "Wrong canonical name '%s' != '%s'\n",
+ a->ai_canonname, b->ai_canonname);
+ }
+ else
+ ok(!a->ai_canonname && !b->ai_canonname, "Expected both names absent (%p != %p)\n",
+ a->ai_canonname, b->ai_canonname);
+ }
+ ok(!a && !b, "Expected both addresses null (%p != %p)\n", a, b);
+}
+
+static void test_getaddrinfo(void)
+{
+ int i, ret;
+ ADDRINFOA *result, *result2, *p, hint;
+ SOCKADDR_IN *sockaddr;
+ CHAR name[256], *ip;
+ DWORD size = sizeof(name);
+
+ memset(&hint, 0, sizeof(ADDRINFOA));
+ GetComputerNameExA( ComputerNamePhysicalDnsHostname, name, &size );
+
+ result = (ADDRINFOA *)0xdeadbeef;
+ WSASetLastError(0xdeadbeef);
+ ret = getaddrinfo(NULL, NULL, NULL, &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);
+
+ result = NULL;
+ WSASetLastError(0xdeadbeef);
+ ret = getaddrinfo("", NULL, NULL, &result);
+ ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError());
+ ok(result != NULL, "getaddrinfo failed\n");
+ ok(WSAGetLastError() == 0, "expected 0, got %d\n", WSAGetLastError());
+ freeaddrinfo(result);
+
+ result = NULL;
+ ret = getaddrinfo(NULL, "0", NULL, &result);
+ ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError());
+ ok(result != NULL, "getaddrinfo failed\n");
+
+ result2 = NULL;
+ ret = getaddrinfo(NULL, "", NULL, &result2);
+ ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError());
+ ok(result2 != NULL, "getaddrinfo failed\n");
+ compare_addrinfo(result, result2);
+ freeaddrinfo(result);
+ freeaddrinfo(result2);
+
+ result = NULL;
+ WSASetLastError(0xdeadbeef);
+ ret = getaddrinfo("", "0", NULL, &result);
+ ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError());
+ ok(WSAGetLastError() == 0, "expected 0, got %d\n", WSAGetLastError());
+ ok(result != NULL, "getaddrinfo failed\n");
+
+ result2 = NULL;
+ ret = getaddrinfo("", "", NULL, &result2);
+ ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError());
+ ok(result2 != NULL, "getaddrinfo failed\n");
+ compare_addrinfo(result, result2);
+ freeaddrinfo(result);
+ freeaddrinfo(result2);
+
+ result = NULL;
+ ret = getaddrinfo("localhost", NULL, NULL, &result);
+ ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError());
+ freeaddrinfo(result);
+
+ result = NULL;
+ ret = getaddrinfo("localhost", "", NULL, &result);
+ ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError());
+ freeaddrinfo(result);
+
+ result = NULL;
+ ret = getaddrinfo("localhost", "0", NULL, &result);
+ ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError());
+ freeaddrinfo(result);
+
+ result = NULL;
+ ret = getaddrinfo("localhost", "80", NULL, &result);
+ ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError());
+ freeaddrinfo(result);
+
+ result = NULL;
+ ret = getaddrinfo("localhost", NULL, &hint, &result);
+ ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError());
+ freeaddrinfo(result);
+
+ result = NULL;
+ WSASetLastError(0xdeadbeef);
+ ret = getaddrinfo("localhost", "80", &hint, &result);
+ ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError());
+ ok(WSAGetLastError() == 0, "expected 0, got %d\n", WSAGetLastError());
+ freeaddrinfo(result);
+
+ hint.ai_flags = AI_NUMERICHOST;
+ result = (void *)0xdeadbeef;
+ ret = getaddrinfo("localhost", "80", &hint, &result);
+ ok(ret == WSAHOST_NOT_FOUND, "getaddrinfo failed with %d\n", WSAGetLastError());
+ ok(WSAGetLastError() == WSAHOST_NOT_FOUND, "expected WSAHOST_NOT_FOUND, got %d\n", WSAGetLastError());
+ ok(!result, "result = %p\n", result);
+ hint.ai_flags = 0;
+
+ /* try to get information from the computer name, result is the same
+ * as if requesting with an empty host name. */
+ ret = getaddrinfo(name, NULL, NULL, &result);
+ ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError());
+ ok(result != NULL, "GetAddrInfoW failed\n");
+
+ ret = getaddrinfo("", NULL, NULL, &result2);
+ ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError());
+ ok(result != NULL, "GetAddrInfoW failed\n");
+ compare_addrinfo(result, result2);
+ freeaddrinfo(result);
+ freeaddrinfo(result2);
+
+ ret = getaddrinfo(name, "", NULL, &result);
+ ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError());
+ ok(result != NULL, "GetAddrInfoW failed\n");
+
+ ret = getaddrinfo("", "", NULL, &result2);
+ ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError());
+ ok(result != NULL, "GetAddrInfoW failed\n");
+ compare_addrinfo(result, result2);
+ freeaddrinfo(result);
+ freeaddrinfo(result2);
+
+ result = (ADDRINFOA *)0xdeadbeef;
+ WSASetLastError(0xdeadbeef);
+ ret = getaddrinfo("nxdomain.codeweavers.com", NULL, NULL, &result);
+ if (ret == 0)
+ {
+ skip("nxdomain returned success. Broken ISP redirects?\n");
+ return;
+ }
+ 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);
+
+ /* Test IPv4 address conversion */
+ result = NULL;
+ ret = getaddrinfo("192.168.1.253", NULL, NULL, &result);
+ ok(!ret, "getaddrinfo failed with %d\n", ret);
+ ok(result->ai_family == AF_INET, "ai_family == %d\n", result->ai_family);
+ ok(result->ai_addrlen >= sizeof(struct sockaddr_in), "ai_addrlen == %d\n", (int)result->ai_addrlen);
+ ok(result->ai_addr != NULL, "ai_addr == NULL\n");
+ sockaddr = (SOCKADDR_IN *)result->ai_addr;
+ ok(sockaddr->sin_family == AF_INET, "ai_addr->sin_family == %d\n", sockaddr->sin_family);
+ ok(sockaddr->sin_port == 0, "ai_addr->sin_port == %d\n", sockaddr->sin_port);
+
+ ip = inet_ntoa(sockaddr->sin_addr);
+ ok(strcmp(ip, "192.168.1.253") == 0, "sockaddr->ai_addr == '%s'\n", ip);
+ freeaddrinfo(result);
+
+ /* Test IPv4 address conversion with port */
+ result = NULL;
+ hint.ai_flags = AI_NUMERICHOST;
+ ret = getaddrinfo("192.168.1.253:1024", NULL, &hint, &result);
+ hint.ai_flags = 0;
+ ok(ret == WSAHOST_NOT_FOUND, "getaddrinfo returned unexpected result: %d\n", ret);
+ ok(result == NULL, "expected NULL, got %p\n", result);
+
+ /* Test IPv6 address conversion */
+ result = NULL;
+ SetLastError(0xdeadbeef);
+ ret = getaddrinfo("2a00:2039:dead:beef:cafe::6666", NULL, NULL, &result);
+
+ if (result != NULL)
+ {
+ ok(!ret, "getaddrinfo failed with %d\n", ret);
+ verify_ipv6_addrinfo(result, "2a00:2039:dead:beef:cafe::6666");
+ freeaddrinfo(result);
+
+ /* Test IPv6 address conversion with brackets */
+ result = NULL;
+ ret = getaddrinfo("[beef::cafe]", NULL, NULL, &result);
+ ok(!ret, "getaddrinfo failed with %d\n", ret);
+ verify_ipv6_addrinfo(result, "beef::cafe");
+ freeaddrinfo(result);
+
+ /* Test IPv6 address conversion with brackets and hints */
+ memset(&hint, 0, sizeof(ADDRINFOA));
+ hint.ai_flags = AI_NUMERICHOST;
+ hint.ai_family = AF_INET6;
+ result = NULL;
+ ret = getaddrinfo("[beef::cafe]", NULL, &hint, &result);
+ ok(!ret, "getaddrinfo failed with %d\n", ret);
+ verify_ipv6_addrinfo(result, "beef::cafe");
+ freeaddrinfo(result);
+
+ memset(&hint, 0, sizeof(ADDRINFOA));
+ hint.ai_flags = AI_NUMERICHOST;
+ hint.ai_family = AF_INET;
+ result = NULL;
+ ret = getaddrinfo("[beef::cafe]", NULL, &hint, &result);
+ ok(ret == WSAHOST_NOT_FOUND, "getaddrinfo failed with %d\n", ret);
+
+ /* Test IPv6 address conversion with brackets and port */
+ result = NULL;
+ ret = getaddrinfo("[beef::cafe]:10239", NULL, NULL, &result);
+ ok(!ret, "getaddrinfo failed with %d\n", ret);
+ verify_ipv6_addrinfo(result, "beef::cafe");
+ freeaddrinfo(result);
+
+ /* Test IPv6 address conversion with unmatched brackets */
+ result = NULL;
+ hint.ai_flags = AI_NUMERICHOST;
+ ret = getaddrinfo("[beef::cafe", NULL, &hint, &result);
+ ok(ret == WSAHOST_NOT_FOUND, "getaddrinfo failed with %d\n", ret);
+
+ ret = getaddrinfo("beef::cafe]", NULL, &hint, &result);
+ ok(ret == WSAHOST_NOT_FOUND, "getaddrinfo failed with %d\n", ret);
+ }
+ else
+ {
+ ok(ret == WSAHOST_NOT_FOUND, "getaddrinfo failed with %d\n", ret);
+ win_skip("getaddrinfo does not support IPV6\n");
+ }
+
+ hint.ai_flags = 0;
+
+ for (i = 0; i < ARRAY_SIZE(hinttests); i++)
+ {
+ hint.ai_family = hinttests[i].family;
+ hint.ai_socktype = hinttests[i].socktype;
+ hint.ai_protocol = hinttests[i].protocol;
+
+ result = NULL;
+ SetLastError(0xdeadbeef);
+ ret = getaddrinfo("localhost", NULL, &hint, &result);
+ todo_wine_if (hinttests[i].error) ok(ret == hinttests[i].error, "test %d: wrong ret %d\n", i, ret);
+ if (!ret)
+ {
+ for (p = result; p; p = p->ai_next)
+ {
+ /* when AF_UNSPEC is used the return will be either AF_INET or AF_INET6 */
+ if (hinttests[i].family == AF_UNSPEC)
+ ok(p->ai_family == AF_INET || p->ai_family == AF_INET6,
+ "test %d: expected AF_INET or AF_INET6, got %d\n",
+ i, p->ai_family);
+ else
+ ok(p->ai_family == hinttests[i].family,
+ "test %d: expected family %d, got %d\n",
+ i, hinttests[i].family, p->ai_family);
+
+ ok(p->ai_socktype == hinttests[i].socktype,
+ "test %d: expected type %d, got %d\n",
+ i, hinttests[i].socktype, p->ai_socktype);
+ ok(p->ai_protocol == hinttests[i].protocol,
+ "test %d: expected protocol %d, got %d\n",
+ i, hinttests[i].protocol, p->ai_protocol);
+ }
+ freeaddrinfo(result);
+ }
+ else
+ {
+ ok(WSAGetLastError() == hinttests[i].error, "test %d: wrong error %d\n", i, WSAGetLastError());
+ }
+ }
+
+ memset(&hint, 0, sizeof(hint));
+ ret = getaddrinfo(NULL, "nonexistentservice", &hint, &result);
+ ok(ret == WSATYPE_NOT_FOUND, "got %d\n", ret);
+}
+
START_TEST( protocol )
{
WSADATA data;
WORD version = MAKEWORD( 2, 2 );
-
+
+ pFreeAddrInfoExW = (void *)GetProcAddress(GetModuleHandleA("ws2_32"), "FreeAddrInfoExW");
+ pGetAddrInfoExOverlappedResult = (void *)GetProcAddress(GetModuleHandleA("ws2_32"), "GetAddrInfoExOverlappedResult");
+ pGetAddrInfoExW = (void *)GetProcAddress(GetModuleHandleA("ws2_32"), "GetAddrInfoExW");
+ p_inet_ntop = (void *)GetProcAddress(GetModuleHandleA("ws2_32"), "inet_ntop");
+
if (WSAStartup( version, &data )) return;
test_WSAEnumProtocolsA();
test_WSAEnumProtocolsW();
test_getprotobyname();
test_getprotobynumber();
+
+ test_GetAddrInfoW();
+ test_GetAddrInfoExW();
+ test_getaddrinfo();
}
diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c
index 61af5b0183a..877c21377aa 100644
--- a/dlls/ws2_32/tests/sock.c
+++ b/dlls/ws2_32/tests/sock.c
@@ -65,12 +65,6 @@
k.keepaliveinterval = interval;
/* Function pointers */
-static void (WINAPI *pFreeAddrInfoExW)(ADDRINFOEXW *ai);
-static int (WINAPI *pGetAddrInfoExW)(const WCHAR *name, const WCHAR *servname, DWORD namespace,
- GUID *namespace_id, const ADDRINFOEXW *hints, ADDRINFOEXW **result,
- struct timeval *timeout, OVERLAPPED *overlapped,
- LPLOOKUPSERVICE_COMPLETION_ROUTINE completion_routine, HANDLE *handle);
-static int (WINAPI *pGetAddrInfoExOverlappedResult)(OVERLAPPED *overlapped);
static int (WINAPI *pGetHostNameW)(WCHAR *, int);
static PCSTR (WINAPI *pInetNtop)(INT,LPVOID,LPSTR,ULONG);
static PCWSTR(WINAPI *pInetNtopW)(INT,LPVOID,LPWSTR,ULONG);
@@ -163,46 +157,6 @@ typedef struct select_thread_params
BOOL ReadKilled;
} select_thread_params;
-/* Tests used in both getaddrinfo and GetAddrInfoW */
-static const struct addr_hint_tests
-{
- int family, socktype, protocol;
- DWORD error;
-} hinttests[] = {
- {AF_UNSPEC, SOCK_STREAM, IPPROTO_TCP, 0 },
- {AF_UNSPEC, SOCK_STREAM, IPPROTO_UDP, 0 },
- {AF_UNSPEC, SOCK_STREAM, IPPROTO_IPV6,0 },
- {AF_UNSPEC, SOCK_DGRAM, IPPROTO_TCP, 0 },
- {AF_UNSPEC, SOCK_DGRAM, IPPROTO_UDP, 0 },
- {AF_UNSPEC, SOCK_DGRAM, IPPROTO_IPV6,0 },
- {AF_INET, SOCK_STREAM, IPPROTO_TCP, 0 },
- {AF_INET, SOCK_STREAM, IPPROTO_UDP, 0 },
- {AF_INET, SOCK_STREAM, IPPROTO_IPV6,0 },
- {AF_INET, SOCK_DGRAM, IPPROTO_TCP, 0 },
- {AF_INET, SOCK_DGRAM, IPPROTO_UDP, 0 },
- {AF_INET, SOCK_DGRAM, IPPROTO_IPV6,0 },
- {AF_UNSPEC, 0, IPPROTO_TCP, 0 },
- {AF_UNSPEC, 0, IPPROTO_UDP, 0 },
- {AF_UNSPEC, 0, IPPROTO_IPV6,0 },
- {AF_UNSPEC, SOCK_STREAM, 0, 0 },
- {AF_UNSPEC, SOCK_DGRAM, 0, 0 },
- {AF_INET, 0, IPPROTO_TCP, 0 },
- {AF_INET, 0, IPPROTO_UDP, 0 },
- {AF_INET, 0, IPPROTO_IPV6,0 },
- {AF_INET, SOCK_STREAM, 0, 0 },
- {AF_INET, SOCK_DGRAM, 0, 0 },
- {AF_UNSPEC, 999, IPPROTO_TCP, WSAESOCKTNOSUPPORT },
- {AF_UNSPEC, 999, IPPROTO_UDP, WSAESOCKTNOSUPPORT },
- {AF_UNSPEC, 999, IPPROTO_IPV6,WSAESOCKTNOSUPPORT },
- {AF_INET, 999, IPPROTO_TCP, WSAESOCKTNOSUPPORT },
- {AF_INET, 999, IPPROTO_UDP, WSAESOCKTNOSUPPORT },
- {AF_INET, 999, IPPROTO_IPV6,WSAESOCKTNOSUPPORT },
- {AF_UNSPEC, SOCK_STREAM, 999, 0 },
- {AF_UNSPEC, SOCK_STREAM, 999, 0 },
- {AF_INET, SOCK_DGRAM, 999, 0 },
- {AF_INET, SOCK_DGRAM, 999, 0 },
-};
-
/**************** Static variables ***************/
static DWORD tls; /* Thread local storage index */
@@ -390,62 +344,6 @@ static void check_so_opentype (void)
ok ( tmp == 0, "check_so_opentype: wrong startup value of SO_OPENTYPE: %d\n", tmp );
}
-static void compare_addrinfo (ADDRINFO *a, ADDRINFO *b)
-{
- for (; a && b ; a = a->ai_next, b = b->ai_next)
- {
- ok(a->ai_flags == b->ai_flags,
- "Wrong flags %d != %d\n", a->ai_flags, b->ai_flags);
- ok(a->ai_family == b->ai_family,
- "Wrong family %d != %d\n", a->ai_family, b->ai_family);
- ok(a->ai_socktype == b->ai_socktype,
- "Wrong socktype %d != %d\n", a->ai_socktype, b->ai_socktype);
- ok(a->ai_protocol == b->ai_protocol,
- "Wrong protocol %d != %d\n", a->ai_protocol, b->ai_protocol);
- ok(a->ai_addrlen == b->ai_addrlen,
- "Wrong addrlen %lu != %lu\n", a->ai_addrlen, b->ai_addrlen);
- ok(!memcmp(a->ai_addr, b->ai_addr, min(a->ai_addrlen, b->ai_addrlen)),
- "Wrong address data\n");
- if (a->ai_canonname && b->ai_canonname)
- {
- ok(!strcmp(a->ai_canonname, b->ai_canonname), "Wrong canonical name '%s' != '%s'\n",
- a->ai_canonname, b->ai_canonname);
- }
- else
- ok(!a->ai_canonname && !b->ai_canonname, "Expected both names absent (%p != %p)\n",
- a->ai_canonname, b->ai_canonname);
- }
- ok(!a && !b, "Expected both addresses null (%p != %p)\n", a, b);
-}
-
-static void compare_addrinfow (ADDRINFOW *a, ADDRINFOW *b)
-{
- for (; a && b ; a = a->ai_next, b = b->ai_next)
- {
- ok(a->ai_flags == b->ai_flags,
- "Wrong flags %d != %d\n", a->ai_flags, b->ai_flags);
- ok(a->ai_family == b->ai_family,
- "Wrong family %d != %d\n", a->ai_family, b->ai_family);
- ok(a->ai_socktype == b->ai_socktype,
- "Wrong socktype %d != %d\n", a->ai_socktype, b->ai_socktype);
- ok(a->ai_protocol == b->ai_protocol,
- "Wrong protocol %d != %d\n", a->ai_protocol, b->ai_protocol);
- ok(a->ai_addrlen == b->ai_addrlen,
- "Wrong addrlen %lu != %lu\n", a->ai_addrlen, b->ai_addrlen);
- ok(!memcmp(a->ai_addr, b->ai_addr, min(a->ai_addrlen, b->ai_addrlen)),
- "Wrong address data\n");
- if (a->ai_canonname && b->ai_canonname)
- {
- ok(!lstrcmpW(a->ai_canonname, b->ai_canonname), "Wrong canonical name '%s' != '%s'\n",
- wine_dbgstr_w(a->ai_canonname), wine_dbgstr_w(b->ai_canonname));
- }
- else
- ok(!a->ai_canonname && !b->ai_canonname, "Expected both names absent (%p != %p)\n",
- a->ai_canonname, b->ai_canonname);
- }
- ok(!a && !b, "Expected both addresses null (%p != %p)\n", a, b);
-}
-
/**************** Server utility functions ***************/
/*
@@ -1201,9 +1099,6 @@ static void Init (void)
WSADATA data;
HMODULE hws2_32 = GetModuleHandleA("ws2_32.dll"), ntdll;
- pFreeAddrInfoExW = (void *)GetProcAddress(hws2_32, "FreeAddrInfoExW");
- pGetAddrInfoExW = (void *)GetProcAddress(hws2_32, "GetAddrInfoExW");
- pGetAddrInfoExOverlappedResult = (void *)GetProcAddress(hws2_32, "GetAddrInfoExOverlappedResult");
pGetHostNameW = (void *)GetProcAddress(hws2_32, "GetHostNameW");
pInetNtop = (void *)GetProcAddress(hws2_32, "inet_ntop");
pInetNtopW = (void *)GetProcAddress(hws2_32, "InetNtopW");
@@ -6537,703 +6432,6 @@ todo_wine
#undef POLL_ISSET
#undef POLL_CLEAR
-static void test_GetAddrInfoW(void)
-{
- static const WCHAR port[] = {'8','0',0};
- static const WCHAR empty[] = {0};
- static const WCHAR localhost[] = {'l','o','c','a','l','h','o','s','t',0};
- static const WCHAR nxdomain[] =
- {'n','x','d','o','m','a','i','n','.','c','o','d','e','w','e','a','v','e','r','s','.','c','o','m',0};
- static const WCHAR zero[] = {'0',0};
- int i, ret;
- ADDRINFOW *result, *result2, *p, hint;
- WCHAR name[256];
- DWORD size = ARRAY_SIZE(name);
- /* 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};
-
- memset(&hint, 0, sizeof(ADDRINFOW));
- name[0] = 0;
- GetComputerNameExW( ComputerNamePhysicalDnsHostname, name, &size );
-
- result = (ADDRINFOW *)0xdeadbeef;
- WSASetLastError(0xdeadbeef);
- ret = GetAddrInfoW(NULL, NULL, NULL, &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);
-
- result = NULL;
- WSASetLastError(0xdeadbeef);
- ret = GetAddrInfoW(empty, NULL, NULL, &result);
- ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError());
- ok(result != NULL, "GetAddrInfoW failed\n");
- ok(WSAGetLastError() == 0, "expected 0, got %d\n", WSAGetLastError());
- FreeAddrInfoW(result);
-
- result = NULL;
- ret = GetAddrInfoW(NULL, zero, NULL, &result);
- ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError());
- ok(result != NULL, "GetAddrInfoW failed\n");
-
- result2 = NULL;
- ret = GetAddrInfoW(NULL, empty, NULL, &result2);
- ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError());
- ok(result2 != NULL, "GetAddrInfoW failed\n");
- compare_addrinfow(result, result2);
- FreeAddrInfoW(result);
- FreeAddrInfoW(result2);
-
- result = NULL;
- ret = GetAddrInfoW(empty, zero, NULL, &result);
- ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError());
- ok(WSAGetLastError() == 0, "expected 0, got %d\n", WSAGetLastError());
- ok(result != NULL, "GetAddrInfoW failed\n");
-
- result2 = NULL;
- ret = GetAddrInfoW(empty, empty, NULL, &result2);
- ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError());
- ok(result2 != NULL, "GetAddrInfoW failed\n");
- compare_addrinfow(result, result2);
- FreeAddrInfoW(result);
- FreeAddrInfoW(result2);
-
- result = NULL;
- ret = GetAddrInfoW(localhost, NULL, NULL, &result);
- ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError());
- FreeAddrInfoW(result);
-
- result = NULL;
- ret = GetAddrInfoW(localhost, empty, NULL, &result);
- ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError());
- FreeAddrInfoW(result);
-
- result = NULL;
- ret = GetAddrInfoW(localhost, zero, NULL, &result);
- ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError());
- FreeAddrInfoW(result);
-
- result = NULL;
- ret = GetAddrInfoW(localhost, port, NULL, &result);
- ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError());
- FreeAddrInfoW(result);
-
- result = NULL;
- ret = GetAddrInfoW(localhost, NULL, &hint, &result);
- ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError());
- FreeAddrInfoW(result);
-
- result = NULL;
- SetLastError(0xdeadbeef);
- ret = GetAddrInfoW(localhost, port, &hint, &result);
- ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError());
- ok(WSAGetLastError() == 0, "expected 0, got %d\n", WSAGetLastError());
- FreeAddrInfoW(result);
-
- /* try to get information from the computer name, result is the same
- * as if requesting with an empty host name. */
- ret = GetAddrInfoW(name, NULL, NULL, &result);
- ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError());
- ok(result != NULL, "GetAddrInfoW failed\n");
-
- ret = GetAddrInfoW(empty, NULL, NULL, &result2);
- ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError());
- ok(result != NULL, "GetAddrInfoW failed\n");
- compare_addrinfow(result, result2);
- FreeAddrInfoW(result);
- FreeAddrInfoW(result2);
-
- ret = GetAddrInfoW(name, empty, NULL, &result);
- ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError());
- ok(result != NULL, "GetAddrInfoW failed\n");
-
- ret = GetAddrInfoW(empty, empty, NULL, &result2);
- ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError());
- ok(result != NULL, "GetAddrInfoW failed\n");
- compare_addrinfow(result, result2);
- FreeAddrInfoW(result);
- FreeAddrInfoW(result2);
-
- result = (ADDRINFOW *)0xdeadbeef;
- WSASetLastError(0xdeadbeef);
- ret = GetAddrInfoW(NULL, NULL, NULL, &result);
- if(ret == 0)
- {
- skip("nxdomain returned success. Broken ISP redirects?\n");
- return;
- }
- 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);
-
- result = (ADDRINFOW *)0xdeadbeef;
- WSASetLastError(0xdeadbeef);
- ret = GetAddrInfoW(nxdomain, NULL, NULL, &result);
- if(ret == 0)
- {
- skip("nxdomain returned success. Broken ISP redirects?\n");
- return;
- }
- 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);
-
- for (i = 0;i < (ARRAY_SIZE(hinttests));i++)
- {
- hint.ai_family = hinttests[i].family;
- hint.ai_socktype = hinttests[i].socktype;
- hint.ai_protocol = hinttests[i].protocol;
-
- result = NULL;
- SetLastError(0xdeadbeef);
- ret = GetAddrInfoW(localhost, NULL, &hint, &result);
- todo_wine_if(hinttests[i].error) ok(ret == hinttests[i].error, "test %d: wrong ret %d\n", i, ret);
- if(!ret)
- {
- for (p = result; p; p = p->ai_next)
- {
- /* when AF_UNSPEC is used the return will be either AF_INET or AF_INET6 */
- if (hinttests[i].family == AF_UNSPEC)
- ok(p->ai_family == AF_INET || p->ai_family == AF_INET6,
- "test %d: expected AF_INET or AF_INET6, got %d\n",
- i, p->ai_family);
- else
- ok(p->ai_family == hinttests[i].family,
- "test %d: expected family %d, got %d\n",
- i, hinttests[i].family, p->ai_family);
-
- ok(p->ai_socktype == hinttests[i].socktype,
- "test %d: expected type %d, got %d\n",
- i, hinttests[i].socktype, p->ai_socktype);
- ok(p->ai_protocol == hinttests[i].protocol,
- "test %d: expected protocol %d, got %d\n",
- i, hinttests[i].protocol, p->ai_protocol);
- }
- FreeAddrInfoW(result);
- }
- else
- {
- ok(WSAGetLastError() == hinttests[i].error, "test %d: wrong error %d\n", i, WSAGetLastError());
- }
- }
-
- /* Test IDN resolution (Internationalized Domain Names) present since Windows 8 */
- result = NULL;
- ret = GetAddrInfoW(idn_punycode, NULL, NULL, &result);
- ok(!ret, "got %d expected success\n", ret);
- ok(result != NULL, "got %p\n", result);
- FreeAddrInfoW(result);
-
- hint.ai_family = AF_INET;
- hint.ai_socktype = 0;
- hint.ai_protocol = 0;
- hint.ai_flags = 0;
-
- result = NULL;
- ret = GetAddrInfoW(idn_punycode, NULL, &hint, &result);
- ok(!ret, "got %d expected success\n", ret);
- ok(result != NULL, "got %p\n", result);
-
- result2 = NULL;
- ret = GetAddrInfoW(idn_domain, NULL, NULL, &result2);
- if (broken(ret == WSAHOST_NOT_FOUND))
- {
- FreeAddrInfoW(result);
- win_skip("IDN resolution not supported in Win <= 7\n");
- return;
- }
-
- ok(!ret, "got %d expected success\n", ret);
- ok(result2 != NULL, "got %p\n", result2);
- FreeAddrInfoW(result2);
-
- hint.ai_family = AF_INET;
- hint.ai_socktype = 0;
- hint.ai_protocol = 0;
- hint.ai_flags = 0;
-
- result2 = NULL;
- ret = GetAddrInfoW(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);
-
- FreeAddrInfoW(result);
- FreeAddrInfoW(result2);
-
- hint.ai_family = AF_INET;
- hint.ai_socktype = 0;
- hint.ai_protocol = 0;
- hint.ai_flags = 0;
-
- result2 = NULL;
- ret = GetAddrInfoW(idn_domain, NULL, &hint, &result2);
- ok(!ret, "got %d expected success\n", ret);
- ok(result2 != NULL, "got %p\n", result2);
- FreeAddrInfoW(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 = GetAddrInfoW(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 struct completion_routine_test
-{
- WSAOVERLAPPED *overlapped;
- DWORD error;
- ADDRINFOEXW **result;
- HANDLE event;
- DWORD called;
-} completion_routine_test;
-
-static void CALLBACK completion_routine(DWORD error, DWORD byte_count, WSAOVERLAPPED *overlapped)
-{
- struct completion_routine_test *test = &completion_routine_test;
-
- ok(error == test->error, "got %u\n", error);
- ok(!byte_count, "got %u\n", byte_count);
- ok(overlapped == test->overlapped, "got %p\n", overlapped);
- ok(overlapped->Internal == test->error, "got %lu\n", overlapped->Internal);
- ok(overlapped->Pointer == test->result, "got %p\n", overlapped->Pointer);
- ok(overlapped->hEvent == NULL, "got %p\n", overlapped->hEvent);
-
- test->called++;
- SetEvent(test->event);
-}
-
-static void test_GetAddrInfoExW(void)
-{
- static const WCHAR empty[] = {0};
- static const WCHAR localhost[] = {'l','o','c','a','l','h','o','s','t',0};
- static const WCHAR winehq[] = {'t','e','s','t','.','w','i','n','e','h','q','.','o','r','g',0};
- static const WCHAR nxdomain[] = {'n','x','d','o','m','a','i','n','.','w','i','n','e','h','q','.','o','r','g',0};
- ADDRINFOEXW *result;
- OVERLAPPED overlapped;
- HANDLE event;
- int ret;
-
- if (!pGetAddrInfoExW || !pGetAddrInfoExOverlappedResult)
- {
- win_skip("GetAddrInfoExW and/or GetAddrInfoExOverlappedResult not present\n");
- return;
- }
-
- event = WSACreateEvent();
-
- result = (ADDRINFOEXW *)0xdeadbeef;
- WSASetLastError(0xdeadbeef);
- ret = pGetAddrInfoExW(NULL, NULL, NS_DNS, NULL, NULL, &result, NULL, NULL, NULL, NULL);
- 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);
-
- result = NULL;
- WSASetLastError(0xdeadbeef);
- ret = pGetAddrInfoExW(empty, NULL, NS_DNS, NULL, NULL, &result, NULL, NULL, NULL, NULL);
- ok(!ret, "GetAddrInfoExW failed with %d\n", WSAGetLastError());
- ok(result != NULL, "GetAddrInfoW failed\n");
- ok(WSAGetLastError() == 0, "expected 0, got %d\n", WSAGetLastError());
- pFreeAddrInfoExW(result);
-
- result = NULL;
- ret = pGetAddrInfoExW(localhost, NULL, NS_DNS, NULL, NULL, &result, NULL, NULL, NULL, NULL);
- ok(!ret, "GetAddrInfoExW failed with %d\n", WSAGetLastError());
- pFreeAddrInfoExW(result);
-
- result = (void*)0xdeadbeef;
- memset(&overlapped, 0xcc, sizeof(overlapped));
- overlapped.hEvent = event;
- ResetEvent(event);
- ret = pGetAddrInfoExW(localhost, NULL, NS_DNS, NULL, NULL, &result, NULL, &overlapped, NULL, NULL);
- ok(ret == ERROR_IO_PENDING, "GetAddrInfoExW failed with %d\n", WSAGetLastError());
- ok(!result, "result != NULL\n");
- ok(WaitForSingleObject(event, 1000) == WAIT_OBJECT_0, "wait failed\n");
- ret = pGetAddrInfoExOverlappedResult(&overlapped);
- ok(!ret, "overlapped result is %d\n", ret);
- pFreeAddrInfoExW(result);
-
- result = (void*)0xdeadbeef;
- memset(&overlapped, 0xcc, sizeof(overlapped));
- ResetEvent(event);
- overlapped.hEvent = event;
- WSASetLastError(0xdeadbeef);
- ret = pGetAddrInfoExW(winehq, NULL, NS_DNS, NULL, NULL, &result, NULL, &overlapped, NULL, NULL);
- ok(ret == ERROR_IO_PENDING, "GetAddrInfoExW failed with %d\n", WSAGetLastError());
- ok(WSAGetLastError() == ERROR_IO_PENDING, "expected 11001, got %d\n", WSAGetLastError());
- ret = overlapped.Internal;
- ok(ret == WSAEINPROGRESS || ret == ERROR_SUCCESS, "overlapped.Internal = %u\n", ret);
- ok(WaitForSingleObject(event, 1000) == WAIT_OBJECT_0, "wait failed\n");
- ret = pGetAddrInfoExOverlappedResult(&overlapped);
- ok(!ret, "overlapped result is %d\n", ret);
- ok(overlapped.hEvent == event, "hEvent changed %p\n", overlapped.hEvent);
- ok(overlapped.Internal == ERROR_SUCCESS, "overlapped.Internal = %lx\n", overlapped.Internal);
- ok(overlapped.Pointer == &result, "overlapped.Pointer != &result\n");
- ok(result != NULL, "result == NULL\n");
- if (result != NULL)
- {
- ok(!result->ai_blob, "ai_blob != NULL\n");
- ok(!result->ai_bloblen, "ai_bloblen != 0\n");
- ok(!result->ai_provider, "ai_provider = %s\n", wine_dbgstr_guid(result->ai_provider));
- pFreeAddrInfoExW(result);
- }
-
- result = (void*)0xdeadbeef;
- memset(&overlapped, 0xcc, sizeof(overlapped));
- ResetEvent(event);
- overlapped.hEvent = event;
- ret = pGetAddrInfoExW(NULL, NULL, NS_DNS, NULL, NULL, &result, NULL, &overlapped, NULL, NULL);
- todo_wine
- ok(ret == WSAHOST_NOT_FOUND, "got %d expected WSAHOST_NOT_FOUND\n", ret);
- todo_wine
- ok(WSAGetLastError() == WSAHOST_NOT_FOUND, "expected 11001, got %d\n", WSAGetLastError());
- ok(result == NULL, "got %p\n", result);
- ret = WaitForSingleObject(event, 0);
- todo_wine_if(ret != WAIT_TIMEOUT) /* Remove when abowe todo_wines are fixed */
- ok(ret == WAIT_TIMEOUT, "wait failed\n");
-
- /* event + completion routine */
- result = (void*)0xdeadbeef;
- memset(&overlapped, 0xcc, sizeof(overlapped));
- overlapped.hEvent = event;
- ResetEvent(event);
- ret = pGetAddrInfoExW(localhost, NULL, NS_DNS, NULL, NULL, &result, NULL, &overlapped, completion_routine, NULL);
- ok(ret == WSAEINVAL, "GetAddrInfoExW failed with %d\n", WSAGetLastError());
-
- /* completion routine, existing domain */
- result = (void *)0xdeadbeef;
- overlapped.hEvent = NULL;
- completion_routine_test.overlapped = &overlapped;
- completion_routine_test.error = ERROR_SUCCESS;
- completion_routine_test.result = &result;
- completion_routine_test.event = event;
- completion_routine_test.called = 0;
- ResetEvent(event);
- ret = pGetAddrInfoExW(winehq, NULL, NS_DNS, NULL, NULL, &result, NULL, &overlapped, completion_routine, NULL);
- ok(ret == ERROR_IO_PENDING, "GetAddrInfoExW failed with %d\n", WSAGetLastError());
- ok(!result, "result != NULL\n");
- ok(WaitForSingleObject(event, 1000) == WAIT_OBJECT_0, "wait failed\n");
- ret = pGetAddrInfoExOverlappedResult(&overlapped);
- ok(!ret, "overlapped result is %d\n", ret);
- ok(overlapped.hEvent == NULL, "hEvent changed %p\n", overlapped.hEvent);
- ok(overlapped.Internal == ERROR_SUCCESS, "overlapped.Internal = %lx\n", overlapped.Internal);
- ok(overlapped.Pointer == &result, "overlapped.Pointer != &result\n");
- ok(completion_routine_test.called == 1, "got %u\n", completion_routine_test.called);
- pFreeAddrInfoExW(result);
-
- /* completion routine, non-existing domain */
- result = (void *)0xdeadbeef;
- completion_routine_test.overlapped = &overlapped;
- completion_routine_test.error = WSAHOST_NOT_FOUND;
- completion_routine_test.called = 0;
- ResetEvent(event);
- ret = pGetAddrInfoExW(nxdomain, NULL, NS_DNS, NULL, NULL, &result, NULL, &overlapped, completion_routine, NULL);
- ok(ret == ERROR_IO_PENDING, "GetAddrInfoExW failed with %d\n", WSAGetLastError());
- ok(!result, "result != NULL\n");
- ok(WaitForSingleObject(event, 1000) == WAIT_OBJECT_0, "wait failed\n");
- ret = pGetAddrInfoExOverlappedResult(&overlapped);
- ok(ret == WSAHOST_NOT_FOUND, "overlapped result is %d\n", ret);
- ok(overlapped.hEvent == NULL, "hEvent changed %p\n", overlapped.hEvent);
- ok(overlapped.Internal == WSAHOST_NOT_FOUND, "overlapped.Internal = %lx\n", overlapped.Internal);
- ok(overlapped.Pointer == &result, "overlapped.Pointer != &result\n");
- ok(completion_routine_test.called == 1, "got %u\n", completion_routine_test.called);
- ok(result == NULL, "got %p\n", result);
-
- WSACloseEvent(event);
-}
-
-static void verify_ipv6_addrinfo(ADDRINFOA *result, const char *expectedIp)
-{
- SOCKADDR_IN6 *sockaddr6;
- char ipBuffer[256];
- const char *ret;
-
- ok(result->ai_family == AF_INET6, "ai_family == %d\n", result->ai_family);
- ok(result->ai_addrlen >= sizeof(struct sockaddr_in6), "ai_addrlen == %d\n", (int)result->ai_addrlen);
- ok(result->ai_addr != NULL, "ai_addr == NULL\n");
-
- if (result->ai_addr != NULL)
- {
- sockaddr6 = (SOCKADDR_IN6 *)result->ai_addr;
- ok(sockaddr6->sin6_family == AF_INET6, "ai_addr->sin6_family == %d\n", sockaddr6->sin6_family);
- ok(sockaddr6->sin6_port == 0, "ai_addr->sin6_port == %d\n", sockaddr6->sin6_port);
-
- ZeroMemory(ipBuffer, sizeof(ipBuffer));
- ret = pInetNtop(AF_INET6, &sockaddr6->sin6_addr, ipBuffer, sizeof(ipBuffer));
- ok(ret != NULL, "inet_ntop failed (%d)\n", WSAGetLastError());
- ok(strcmp(ipBuffer, expectedIp) == 0, "ai_addr->sin6_addr == '%s' (expected '%s')\n", ipBuffer, expectedIp);
- }
-}
-
-static void test_getaddrinfo(void)
-{
- int i, ret;
- ADDRINFOA *result, *result2, *p, hint;
- SOCKADDR_IN *sockaddr;
- CHAR name[256], *ip;
- DWORD size = sizeof(name);
-
- memset(&hint, 0, sizeof(ADDRINFOA));
- GetComputerNameExA( ComputerNamePhysicalDnsHostname, name, &size );
-
- result = (ADDRINFOA *)0xdeadbeef;
- WSASetLastError(0xdeadbeef);
- ret = getaddrinfo(NULL, NULL, NULL, &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);
-
- result = NULL;
- WSASetLastError(0xdeadbeef);
- ret = getaddrinfo("", NULL, NULL, &result);
- ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError());
- ok(result != NULL, "getaddrinfo failed\n");
- ok(WSAGetLastError() == 0, "expected 0, got %d\n", WSAGetLastError());
- freeaddrinfo(result);
-
- result = NULL;
- ret = getaddrinfo(NULL, "0", NULL, &result);
- ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError());
- ok(result != NULL, "getaddrinfo failed\n");
-
- result2 = NULL;
- ret = getaddrinfo(NULL, "", NULL, &result2);
- ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError());
- ok(result2 != NULL, "getaddrinfo failed\n");
- compare_addrinfo(result, result2);
- freeaddrinfo(result);
- freeaddrinfo(result2);
-
- result = NULL;
- WSASetLastError(0xdeadbeef);
- ret = getaddrinfo("", "0", NULL, &result);
- ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError());
- ok(WSAGetLastError() == 0, "expected 0, got %d\n", WSAGetLastError());
- ok(result != NULL, "getaddrinfo failed\n");
-
- result2 = NULL;
- ret = getaddrinfo("", "", NULL, &result2);
- ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError());
- ok(result2 != NULL, "getaddrinfo failed\n");
- compare_addrinfo(result, result2);
- freeaddrinfo(result);
- freeaddrinfo(result2);
-
- result = NULL;
- ret = getaddrinfo("localhost", NULL, NULL, &result);
- ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError());
- freeaddrinfo(result);
-
- result = NULL;
- ret = getaddrinfo("localhost", "", NULL, &result);
- ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError());
- freeaddrinfo(result);
-
- result = NULL;
- ret = getaddrinfo("localhost", "0", NULL, &result);
- ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError());
- freeaddrinfo(result);
-
- result = NULL;
- ret = getaddrinfo("localhost", "80", NULL, &result);
- ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError());
- freeaddrinfo(result);
-
- result = NULL;
- ret = getaddrinfo("localhost", NULL, &hint, &result);
- ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError());
- freeaddrinfo(result);
-
- result = NULL;
- WSASetLastError(0xdeadbeef);
- ret = getaddrinfo("localhost", "80", &hint, &result);
- ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError());
- ok(WSAGetLastError() == 0, "expected 0, got %d\n", WSAGetLastError());
- freeaddrinfo(result);
-
- hint.ai_flags = AI_NUMERICHOST;
- result = (void*)0xdeadbeef;
- ret = getaddrinfo("localhost", "80", &hint, &result);
- ok(ret == WSAHOST_NOT_FOUND, "getaddrinfo failed with %d\n", WSAGetLastError());
- ok(WSAGetLastError() == WSAHOST_NOT_FOUND, "expected WSAHOST_NOT_FOUND, got %d\n", WSAGetLastError());
- ok(!result, "result = %p\n", result);
- hint.ai_flags = 0;
-
- /* try to get information from the computer name, result is the same
- * as if requesting with an empty host name. */
- ret = getaddrinfo(name, NULL, NULL, &result);
- ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError());
- ok(result != NULL, "GetAddrInfoW failed\n");
-
- ret = getaddrinfo("", NULL, NULL, &result2);
- ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError());
- ok(result != NULL, "GetAddrInfoW failed\n");
- compare_addrinfo(result, result2);
- freeaddrinfo(result);
- freeaddrinfo(result2);
-
- ret = getaddrinfo(name, "", NULL, &result);
- ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError());
- ok(result != NULL, "GetAddrInfoW failed\n");
-
- ret = getaddrinfo("", "", NULL, &result2);
- ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError());
- ok(result != NULL, "GetAddrInfoW failed\n");
- compare_addrinfo(result, result2);
- freeaddrinfo(result);
- freeaddrinfo(result2);
-
- result = (ADDRINFOA *)0xdeadbeef;
- WSASetLastError(0xdeadbeef);
- ret = getaddrinfo("nxdomain.codeweavers.com", NULL, NULL, &result);
- if(ret == 0)
- {
- skip("nxdomain returned success. Broken ISP redirects?\n");
- return;
- }
- 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);
-
- /* Test IPv4 address conversion */
- result = NULL;
- ret = getaddrinfo("192.168.1.253", NULL, NULL, &result);
- ok(!ret, "getaddrinfo failed with %d\n", ret);
- ok(result->ai_family == AF_INET, "ai_family == %d\n", result->ai_family);
- ok(result->ai_addrlen >= sizeof(struct sockaddr_in), "ai_addrlen == %d\n", (int)result->ai_addrlen);
- ok(result->ai_addr != NULL, "ai_addr == NULL\n");
- sockaddr = (SOCKADDR_IN *)result->ai_addr;
- ok(sockaddr->sin_family == AF_INET, "ai_addr->sin_family == %d\n", sockaddr->sin_family);
- ok(sockaddr->sin_port == 0, "ai_addr->sin_port == %d\n", sockaddr->sin_port);
-
- ip = inet_ntoa(sockaddr->sin_addr);
- ok(strcmp(ip, "192.168.1.253") == 0, "sockaddr->ai_addr == '%s'\n", ip);
- freeaddrinfo(result);
-
- /* Test IPv4 address conversion with port */
- result = NULL;
- hint.ai_flags = AI_NUMERICHOST;
- ret = getaddrinfo("192.168.1.253:1024", NULL, &hint, &result);
- hint.ai_flags = 0;
- ok(ret == WSAHOST_NOT_FOUND, "getaddrinfo returned unexpected result: %d\n", ret);
- ok(result == NULL, "expected NULL, got %p\n", result);
-
- /* Test IPv6 address conversion */
- result = NULL;
- SetLastError(0xdeadbeef);
- ret = getaddrinfo("2a00:2039:dead:beef:cafe::6666", NULL, NULL, &result);
-
- if (result != NULL)
- {
- ok(!ret, "getaddrinfo failed with %d\n", ret);
- verify_ipv6_addrinfo(result, "2a00:2039:dead:beef:cafe::6666");
- freeaddrinfo(result);
-
- /* Test IPv6 address conversion with brackets */
- result = NULL;
- ret = getaddrinfo("[beef::cafe]", NULL, NULL, &result);
- ok(!ret, "getaddrinfo failed with %d\n", ret);
- verify_ipv6_addrinfo(result, "beef::cafe");
- freeaddrinfo(result);
-
- /* Test IPv6 address conversion with brackets and hints */
- memset(&hint, 0, sizeof(ADDRINFOA));
- hint.ai_flags = AI_NUMERICHOST;
- hint.ai_family = AF_INET6;
- result = NULL;
- ret = getaddrinfo("[beef::cafe]", NULL, &hint, &result);
- ok(!ret, "getaddrinfo failed with %d\n", ret);
- verify_ipv6_addrinfo(result, "beef::cafe");
- freeaddrinfo(result);
-
- memset(&hint, 0, sizeof(ADDRINFOA));
- hint.ai_flags = AI_NUMERICHOST;
- hint.ai_family = AF_INET;
- result = NULL;
- ret = getaddrinfo("[beef::cafe]", NULL, &hint, &result);
- ok(ret == WSAHOST_NOT_FOUND, "getaddrinfo failed with %d\n", ret);
-
- /* Test IPv6 address conversion with brackets and port */
- result = NULL;
- ret = getaddrinfo("[beef::cafe]:10239", NULL, NULL, &result);
- ok(!ret, "getaddrinfo failed with %d\n", ret);
- verify_ipv6_addrinfo(result, "beef::cafe");
- freeaddrinfo(result);
-
- /* Test IPv6 address conversion with unmatched brackets */
- result = NULL;
- hint.ai_flags = AI_NUMERICHOST;
- ret = getaddrinfo("[beef::cafe", NULL, &hint, &result);
- ok(ret == WSAHOST_NOT_FOUND, "getaddrinfo failed with %d\n", ret);
-
- ret = getaddrinfo("beef::cafe]", NULL, &hint, &result);
- ok(ret == WSAHOST_NOT_FOUND, "getaddrinfo failed with %d\n", ret);
- }
- else
- {
- ok(ret == WSAHOST_NOT_FOUND, "getaddrinfo failed with %d\n", ret);
- win_skip("getaddrinfo does not support IPV6\n");
- }
-
- hint.ai_flags = 0;
-
- for (i = 0;i < (ARRAY_SIZE(hinttests));i++)
- {
- hint.ai_family = hinttests[i].family;
- hint.ai_socktype = hinttests[i].socktype;
- hint.ai_protocol = hinttests[i].protocol;
-
- result = NULL;
- SetLastError(0xdeadbeef);
- ret = getaddrinfo("localhost", NULL, &hint, &result);
- todo_wine_if(hinttests[i].error) ok(ret == hinttests[i].error, "test %d: wrong ret %d\n", i, ret);
- if(!ret)
- {
- for (p = result; p; p = p->ai_next)
- {
- /* when AF_UNSPEC is used the return will be either AF_INET or AF_INET6 */
- if (hinttests[i].family == AF_UNSPEC)
- ok(p->ai_family == AF_INET || p->ai_family == AF_INET6,
- "test %d: expected AF_INET or AF_INET6, got %d\n",
- i, p->ai_family);
- else
- ok(p->ai_family == hinttests[i].family,
- "test %d: expected family %d, got %d\n",
- i, hinttests[i].family, p->ai_family);
-
- ok(p->ai_socktype == hinttests[i].socktype,
- "test %d: expected type %d, got %d\n",
- i, hinttests[i].socktype, p->ai_socktype);
- ok(p->ai_protocol == hinttests[i].protocol,
- "test %d: expected protocol %d, got %d\n",
- i, hinttests[i].protocol, p->ai_protocol);
- }
- freeaddrinfo(result);
- }
- else
- {
- ok(WSAGetLastError() == hinttests[i].error, "test %d: wrong error %d\n", i, WSAGetLastError());
- }
- }
-
- memset(&hint, 0, sizeof(hint));
- ret = getaddrinfo(NULL, "nonexistentservice", &hint, &result);
- ok(ret == WSATYPE_NOT_FOUND, "got %d\n", ret);
-}
-
static void test_ConnectEx(void)
{
SOCKET listener = INVALID_SOCKET;
@@ -10680,9 +9878,6 @@ START_TEST( sock )
test_ipv6only();
test_TransmitFile();
- test_GetAddrInfoW();
- test_GetAddrInfoExW();
- test_getaddrinfo();
test_AcceptEx();
test_ConnectEx();
test_DisconnectEx();
--
2.30.2
2
7
April 28, 2021
Patch by Robert Wilhelm from bug
https://bugs.winehq.org/show_bug.cgi?id=49905
1
0
April 28, 2021
Signed-off-by: Piotr Caban <piotr(a)codeweavers.com>
---
configure.ac | 1 -
dlls/msvcrt/math.c | 54 ++++++++++++++++++++++++++++++++++---------
dlls/msvcrt/unixlib.c | 14 -----------
dlls/msvcrt/unixlib.h | 1 -
4 files changed, 43 insertions(+), 27 deletions(-)
1
0
April 28, 2021
Signed-off-by: Piotr Caban <piotr(a)codeweavers.com>
---
configure.ac | 1 -
dlls/msvcrt/math.c | 238 +++++++++++++++++++++++++++++++++++++++++-
dlls/msvcrt/unixlib.c | 14 ---
dlls/msvcrt/unixlib.h | 1 -
4 files changed, 235 insertions(+), 19 deletions(-)
1
0