[PATCH 2/2] ntdll: RtlIpv4|6 tests
Donat Enikeev
donat at enikeev.net
Wed Jan 6 17:26:10 CST 2016
Tests for newly added implementations plus `test_RtlIpv4StringToAddress` rewritten as there was no such function before and therefore tests were never applied
Signed-off-by: Donat Enikeev <donat at enikeev.net>
---
dlls/ntdll/tests/rtl.c | 444 +++++++++++++++++++++++++++++++------------------
1 file changed, 281 insertions(+), 163 deletions(-)
diff --git a/dlls/ntdll/tests/rtl.c b/dlls/ntdll/tests/rtl.c
index 94a22ac..8a77bcc 100644
--- a/dlls/ntdll/tests/rtl.c
+++ b/dlls/ntdll/tests/rtl.c
@@ -25,6 +25,8 @@
#include "ntdll_test.h"
#include "inaddr.h"
+#include "in6addr.h"
+#include "winnls.h"
#ifndef __WINE_WINTERNL_H
@@ -89,6 +91,8 @@ static IMAGE_BASE_RELOCATION *(WINAPI *pLdrProcessRelocationBlock)(void*,UINT,US
static CHAR * (WINAPI *pRtlIpv4AddressToStringA)(const IN_ADDR *, LPSTR);
static NTSTATUS (WINAPI *pRtlIpv4AddressToStringExA)(const IN_ADDR *, USHORT, LPSTR, PULONG);
static NTSTATUS (WINAPI *pRtlIpv4StringToAddressA)(PCSTR, BOOLEAN, PCSTR *, IN_ADDR *);
+static CHAR * (WINAPI *pRtlIpv6AddressToStringA)(const IN6_ADDR *, LPSTR);
+static WCHAR * (WINAPI *pRtlIpv6AddressToStringW)(const IN6_ADDR *, LPWSTR);
static NTSTATUS (WINAPI *pLdrAddRefDll)(ULONG, HMODULE);
static NTSTATUS (WINAPI *pLdrLockLoaderLock)(ULONG, ULONG*, ULONG_PTR*);
static NTSTATUS (WINAPI *pLdrUnlockLoaderLock)(ULONG, ULONG_PTR);
@@ -115,24 +119,24 @@ static void InitFunctionPtrs(void)
hntdll = LoadLibraryA("ntdll.dll");
ok(hntdll != 0, "LoadLibrary failed\n");
if (hntdll) {
- pRtlCompareMemory = (void *)GetProcAddress(hntdll, "RtlCompareMemory");
- pRtlCompareMemoryUlong = (void *)GetProcAddress(hntdll, "RtlCompareMemoryUlong");
+ pRtlCompareMemory = (void *)GetProcAddress(hntdll, "RtlCompareMemory");
+ pRtlCompareMemoryUlong = (void *)GetProcAddress(hntdll, "RtlCompareMemoryUlong");
pRtlDeleteTimer = (void *)GetProcAddress(hntdll, "RtlDeleteTimer");
- pRtlMoveMemory = (void *)GetProcAddress(hntdll, "RtlMoveMemory");
- pRtlFillMemory = (void *)GetProcAddress(hntdll, "RtlFillMemory");
- pRtlFillMemoryUlong = (void *)GetProcAddress(hntdll, "RtlFillMemoryUlong");
- pRtlZeroMemory = (void *)GetProcAddress(hntdll, "RtlZeroMemory");
- pRtlUlonglongByteSwap = (void *)GetProcAddress(hntdll, "RtlUlonglongByteSwap");
- pRtlUniform = (void *)GetProcAddress(hntdll, "RtlUniform");
- pRtlRandom = (void *)GetProcAddress(hntdll, "RtlRandom");
- pRtlAreAllAccessesGranted = (void *)GetProcAddress(hntdll, "RtlAreAllAccessesGranted");
- pRtlAreAnyAccessesGranted = (void *)GetProcAddress(hntdll, "RtlAreAnyAccessesGranted");
- pRtlComputeCrc32 = (void *)GetProcAddress(hntdll, "RtlComputeCrc32");
- pRtlInitializeHandleTable = (void *)GetProcAddress(hntdll, "RtlInitializeHandleTable");
- pRtlIsValidIndexHandle = (void *)GetProcAddress(hntdll, "RtlIsValidIndexHandle");
- pRtlDestroyHandleTable = (void *)GetProcAddress(hntdll, "RtlDestroyHandleTable");
- pRtlAllocateHandle = (void *)GetProcAddress(hntdll, "RtlAllocateHandle");
- pRtlFreeHandle = (void *)GetProcAddress(hntdll, "RtlFreeHandle");
+ pRtlMoveMemory = (void *)GetProcAddress(hntdll, "RtlMoveMemory");
+ pRtlFillMemory = (void *)GetProcAddress(hntdll, "RtlFillMemory");
+ pRtlFillMemoryUlong = (void *)GetProcAddress(hntdll, "RtlFillMemoryUlong");
+ pRtlZeroMemory = (void *)GetProcAddress(hntdll, "RtlZeroMemory");
+ pRtlUlonglongByteSwap = (void *)GetProcAddress(hntdll, "RtlUlonglongByteSwap");
+ pRtlUniform = (void *)GetProcAddress(hntdll, "RtlUniform");
+ pRtlRandom = (void *)GetProcAddress(hntdll, "RtlRandom");
+ pRtlAreAllAccessesGranted = (void *)GetProcAddress(hntdll, "RtlAreAllAccessesGranted");
+ pRtlAreAnyAccessesGranted = (void *)GetProcAddress(hntdll, "RtlAreAnyAccessesGranted");
+ pRtlComputeCrc32 = (void *)GetProcAddress(hntdll, "RtlComputeCrc32");
+ pRtlInitializeHandleTable = (void *)GetProcAddress(hntdll, "RtlInitializeHandleTable");
+ pRtlIsValidIndexHandle = (void *)GetProcAddress(hntdll, "RtlIsValidIndexHandle");
+ pRtlDestroyHandleTable = (void *)GetProcAddress(hntdll, "RtlDestroyHandleTable");
+ pRtlAllocateHandle = (void *)GetProcAddress(hntdll, "RtlAllocateHandle");
+ pRtlFreeHandle = (void *)GetProcAddress(hntdll, "RtlFreeHandle");
pRtlAllocateAndInitializeSid = (void *)GetProcAddress(hntdll, "RtlAllocateAndInitializeSid");
pRtlFreeSid = (void *)GetProcAddress(hntdll, "RtlFreeSid");
pNtCurrentTeb = (void *)GetProcAddress(hntdll, "NtCurrentTeb");
@@ -141,6 +145,8 @@ static void InitFunctionPtrs(void)
pLdrProcessRelocationBlock = (void *)GetProcAddress(hntdll, "LdrProcessRelocationBlock");
pRtlIpv4AddressToStringA = (void *)GetProcAddress(hntdll, "RtlIpv4AddressToStringA");
pRtlIpv4AddressToStringExA = (void *)GetProcAddress(hntdll, "RtlIpv4AddressToStringExA");
+ pRtlIpv6AddressToStringA = (void *)GetProcAddress(hntdll, "RtlIpv6AddressToStringA");
+ pRtlIpv6AddressToStringW = (void *)GetProcAddress(hntdll, "RtlIpv6AddressToStringW");
pRtlIpv4StringToAddressA = (void *)GetProcAddress(hntdll, "RtlIpv4StringToAddressA");
pLdrAddRefDll = (void *)GetProcAddress(hntdll, "LdrAddRefDll");
pLdrLockLoaderLock = (void *)GetProcAddress(hntdll, "LdrLockLoaderLock");
@@ -1129,172 +1135,282 @@ static void test_RtlIpv4AddressToStringEx(void)
static void test_RtlIpv4StringToAddress(void)
{
NTSTATUS res;
- IN_ADDR ip, expected_ip;
- PCSTR terminator;
- CHAR dummy;
+ IN_ADDR ip;
+ LPCSTR terminator;
struct
{
PCSTR address;
NTSTATUS res;
int terminator_offset;
- int ip[4];
- BOOL strict_is_different;
- NTSTATUS res_strict;
- int terminator_offset_strict;
- int ip_strict[4];
- } tests[] =
+ ULONG ip_ulong;
+ } tests[] = /** tests data for non-strict (strict below) */
+ {
+ { "255.255.255.255:123", STATUS_SUCCESS, 15, 4294967295UL },
+ { "255.255.255.256", STATUS_INVALID_PARAMETER, 15, 1 },
+ { "255.255.255.42949672", STATUS_INVALID_PARAMETER, 22, 1 },
+ { "a", STATUS_INVALID_PARAMETER, 0, 1 },
+ { "1.1.1.0xaA", STATUS_SUCCESS, 10, 2852192513UL },
+ { "1.1.1.0XaA", STATUS_SUCCESS, 10, 2852192513UL },
+ { "1.1.1.0x", STATUS_INVALID_PARAMETER, 8, 1 },
+ { "1.1.1.0xff", STATUS_SUCCESS, 10, 4278255873UL },
+ { "1.1.1.0x100", STATUS_INVALID_PARAMETER, 11, 1 },
+ { "1.1.1.0xffffffff", STATUS_INVALID_PARAMETER, 16, 1 },
+ { "1.1.1.0x100000000", STATUS_INVALID_PARAMETER, 16, 1 },
+ { "1.1.1.010", STATUS_SUCCESS, 9, 134283521UL },
+ { "1.1.1.00", STATUS_SUCCESS, 8, 65793 },
+ { "1.1.1.007", STATUS_SUCCESS, 9, 117506305UL },
+ { "1.1.1.08", STATUS_INVALID_PARAMETER, 7, 1 },
+ { "1.1.1.008", STATUS_SUCCESS, 8, 65793 },
+ { "1.1.1.0a", STATUS_SUCCESS, 7, 65793 },
+ { "1.1.1.0o10", STATUS_SUCCESS, 7, 65793 },
+ { "1.1.1.0b10", STATUS_SUCCESS, 7, 65793 },
+ { "1.1.1.-2", STATUS_INVALID_PARAMETER, 6, 1 },
+ { "1", STATUS_SUCCESS, 1, 16777216 },
+ { "-1", STATUS_INVALID_PARAMETER, 0, 0 },
+ { "203569230", STATUS_SUCCESS, 9, 1312301580UL },
+ { "1.223756", STATUS_SUCCESS, 8, 208274177 },
+ { "3.4.756", STATUS_SUCCESS, 7, 4093772803UL },
+ { "3.4.756.1", STATUS_INVALID_PARAMETER, 9, 1 },
+ { "3.4.65536", STATUS_INVALID_PARAMETER, 9, 1 },
+ { "3.4.5.6.7", STATUS_INVALID_PARAMETER, 7, 1 },
+ { "3.4.5.+6", STATUS_INVALID_PARAMETER, 6, 1 },
+ { " 3.4.5.6", STATUS_INVALID_PARAMETER, 0, 1 },
+ { "\t3.4.5.6", STATUS_INVALID_PARAMETER, 0, 1 },
+ { "3.4.5.6 ", STATUS_SUCCESS, 7, 100992003UL },
+ { "3. 4.5.6", STATUS_INVALID_PARAMETER, 2, 1 },
+ { ".", STATUS_INVALID_PARAMETER, 1, 1 },
+ { "..", STATUS_INVALID_PARAMETER, 1, 1 },
+ { "1.", STATUS_INVALID_PARAMETER, 2, 1 },
+ { "1..", STATUS_INVALID_PARAMETER, 3, 1 },
+ { ".1", STATUS_INVALID_PARAMETER, 1, 1 },
+ { ".1.", STATUS_INVALID_PARAMETER, 1, 1 },
+ { ".1.2.3", STATUS_INVALID_PARAMETER, 1, 1 },
+ { "::1", STATUS_INVALID_PARAMETER, 0, 1 },
+ { ":1", STATUS_INVALID_PARAMETER, 0, 1 },
+ }, tests_strict[] =
{
- { "", STATUS_INVALID_PARAMETER, 0, { -1 } },
- { " ", STATUS_INVALID_PARAMETER, 0, { -1 } },
- { "1.1.1.1", STATUS_SUCCESS, 7, { 1, 1, 1, 1 } },
- { "0.0.0.0", STATUS_SUCCESS, 7, { 0, 0, 0, 0 } },
- { "255.255.255.255", STATUS_SUCCESS, 15, { 255, 255, 255, 255 } },
- { "255.255.255.255:123",
- STATUS_SUCCESS, 15, { 255, 255, 255, 255 } },
- { "255.255.255.256", STATUS_INVALID_PARAMETER, 15, { -1 } },
- { "255.255.255.4294967295",
- STATUS_INVALID_PARAMETER, 22, { -1 } },
- { "255.255.255.4294967296",
- STATUS_INVALID_PARAMETER, 21, { -1 } },
- { "255.255.255.4294967297",
- STATUS_INVALID_PARAMETER, 21, { -1 } },
- { "a", STATUS_INVALID_PARAMETER, 0, { -1 } },
- { "1.1.1.0xaA", STATUS_SUCCESS, 10, { 1, 1, 1, 170 },
- TRUE, STATUS_INVALID_PARAMETER, 8, { -1 } },
- { "1.1.1.0XaA", STATUS_SUCCESS, 10, { 1, 1, 1, 170 },
- TRUE, STATUS_INVALID_PARAMETER, 8, { -1 } },
- { "1.1.1.0x", STATUS_INVALID_PARAMETER, 8, { -1 } },
- { "1.1.1.0xff", STATUS_SUCCESS, 10, { 1, 1, 1, 255 },
- TRUE, STATUS_INVALID_PARAMETER, 8, { -1 } },
- { "1.1.1.0x100", STATUS_INVALID_PARAMETER, 11, { -1 },
- TRUE, STATUS_INVALID_PARAMETER, 8, { -1 } },
- { "1.1.1.0xffffffff",STATUS_INVALID_PARAMETER, 16, { -1 },
- TRUE, STATUS_INVALID_PARAMETER, 8, { -1 } },
- { "1.1.1.0x100000000",
- STATUS_INVALID_PARAMETER, 16, { -1, 0, 0, 0 },
- TRUE, STATUS_INVALID_PARAMETER, 8, { -1 } },
- { "1.1.1.010", STATUS_SUCCESS, 9, { 1, 1, 1, 8 },
- TRUE, STATUS_INVALID_PARAMETER, 7, { -1 } },
- { "1.1.1.00", STATUS_SUCCESS, 8, { 1, 1, 1, 0 },
- TRUE, STATUS_INVALID_PARAMETER, 7, { -1 } },
- { "1.1.1.007", STATUS_SUCCESS, 9, { 1, 1, 1, 7 },
- TRUE, STATUS_INVALID_PARAMETER, 7, { -1 } },
- { "1.1.1.08", STATUS_INVALID_PARAMETER, 7, { -1 } },
- { "1.1.1.008", STATUS_SUCCESS, 8, { 1, 1, 1, 0 },
- TRUE, STATUS_INVALID_PARAMETER, 7, { -1 } },
- { "1.1.1.0a", STATUS_SUCCESS, 7, { 1, 1, 1, 0 } },
- { "1.1.1.0o10", STATUS_SUCCESS, 7, { 1, 1, 1, 0 } },
- { "1.1.1.0b10", STATUS_SUCCESS, 7, { 1, 1, 1, 0 } },
- { "1.1.1.-2", STATUS_INVALID_PARAMETER, 6, { -1 } },
- { "1", STATUS_SUCCESS, 1, { 0, 0, 0, 1 },
- TRUE, STATUS_INVALID_PARAMETER, 1, { -1 } },
- { "-1", STATUS_INVALID_PARAMETER, 0, { -1 } },
- { "203569230", STATUS_SUCCESS, 9, { 12, 34, 56, 78 },
- TRUE, STATUS_INVALID_PARAMETER, 9, { -1 } },
- { "1.223756", STATUS_SUCCESS, 8, { 1, 3, 106, 12 },
- TRUE, STATUS_INVALID_PARAMETER, 8, { -1 } },
- { "3.4.756", STATUS_SUCCESS, 7, { 3, 4, 2, 244 },
- TRUE, STATUS_INVALID_PARAMETER, 7, { -1 } },
- { "3.4.756.1", STATUS_INVALID_PARAMETER, 9, { -1 } },
- { "3.4.65536", STATUS_INVALID_PARAMETER, 9, { -1 } },
- { "3.4.5.6.7", STATUS_INVALID_PARAMETER, 7, { -1 } },
- { "3.4.5.+6", STATUS_INVALID_PARAMETER, 6, { -1 } },
- { " 3.4.5.6", STATUS_INVALID_PARAMETER, 0, { -1 } },
- { "\t3.4.5.6", STATUS_INVALID_PARAMETER, 0, { -1 } },
- { "3.4.5.6 ", STATUS_SUCCESS, 7, { 3, 4, 5, 6 } },
- { "3. 4.5.6", STATUS_INVALID_PARAMETER, 2, { -1 } },
- { ".", STATUS_INVALID_PARAMETER, 1, { -1 } },
- { "..", STATUS_INVALID_PARAMETER, 1, { -1 } },
- { "1.", STATUS_INVALID_PARAMETER, 2, { -1 } },
- { "1..", STATUS_INVALID_PARAMETER, 3, { -1 } },
- { ".1", STATUS_INVALID_PARAMETER, 1, { -1 } },
- { ".1.", STATUS_INVALID_PARAMETER, 1, { -1 } },
- { ".1.2.3", STATUS_INVALID_PARAMETER, 1, { -1 } },
- { "0.1.2.3", STATUS_SUCCESS, 7, { 0, 1, 2, 3 } },
- { "0.1.2.3.", STATUS_INVALID_PARAMETER, 7, { -1 } },
- { "[0.1.2.3]", STATUS_INVALID_PARAMETER, 0, { -1 } },
- { "::1", STATUS_INVALID_PARAMETER, 0, { -1 } },
- { ":1", STATUS_INVALID_PARAMETER, 0, { -1 } },
+ { "", STATUS_INVALID_PARAMETER, 0, 0},
+ { " ", STATUS_INVALID_PARAMETER, 0, 0 },
+ { "1.1.1.1", STATUS_SUCCESS, 7, 16843009 },
+ { "0.0.0.0", STATUS_SUCCESS, 7, 0 },
+ { "255.255.255.255", STATUS_SUCCESS, 15, 4294967295UL },
+ { "255.255.255.256", STATUS_INVALID_PARAMETER, 15, 1 },
+ { "255.255.255.42949672", STATUS_INVALID_PARAMETER, 22, 1 },
+ { "1.1.1.010", STATUS_INVALID_PARAMETER, 9, 1 },
+ { "1.1.1.00", STATUS_INVALID_PARAMETER, 8, 1 },
+ { "1.1.1.007", STATUS_INVALID_PARAMETER, 9, 1 },
+ { "1.1.1.08", STATUS_INVALID_PARAMETER, 7, 1 },
+ { "1.1.1.008", STATUS_INVALID_PARAMETER, 8, 1 },
+ { "1.1.1.-2", STATUS_INVALID_PARAMETER, 6, 1 },
+ { "1", STATUS_INVALID_PARAMETER, 1, 1 },
+ { "-1", STATUS_INVALID_PARAMETER, 0, 1 },
+ { "203569230", STATUS_INVALID_PARAMETER, 9, 1 },
+ { "1.223756", STATUS_INVALID_PARAMETER, 8, 1 },
+ { "3.4.756", STATUS_INVALID_PARAMETER, 7, 1 },
+ { "3.4.756.1", STATUS_INVALID_PARAMETER, 9, 1 },
+ { "3.4.65536", STATUS_INVALID_PARAMETER, 9, 1 },
+ { "3.4.5.6.7", STATUS_INVALID_PARAMETER, 7, 1 },
+ { "3.4.5.+6", STATUS_INVALID_PARAMETER, 6, 1 },
+ { " 3.4.5.6", STATUS_INVALID_PARAMETER, 0, 1 },
+ { "\t3.4.5.6", STATUS_INVALID_PARAMETER, 0, 1 },
+ { "3.4.5.6", STATUS_SUCCESS, 7, 100992003 },
+ { "3. 4.5.6", STATUS_INVALID_PARAMETER, 2, 1 },
+ { ".", STATUS_INVALID_PARAMETER, 1, 1 },
+ { "..", STATUS_INVALID_PARAMETER, 1, 1 },
+ { "1.", STATUS_INVALID_PARAMETER, 2, 1 },
+ { "1..", STATUS_INVALID_PARAMETER, 3, 1 },
+ { ".1", STATUS_INVALID_PARAMETER, 1, 1 },
+ { ".1.", STATUS_INVALID_PARAMETER, 1, 1 },
+ { ".1.2.3", STATUS_INVALID_PARAMETER, 1, 1 },
+ { "0.1.2.3", STATUS_SUCCESS, 7, 50462976 },
+ { "0.1.2.3.", STATUS_INVALID_PARAMETER, 7, 1 },
+ { "[0.1.2.3]", STATUS_INVALID_PARAMETER, 0, 1 },
+ { "::1", STATUS_INVALID_PARAMETER, 0, 1 },
+ { ":1", STATUS_INVALID_PARAMETER, 0, 1 },
};
const int testcount = sizeof(tests) / sizeof(tests[0]);
+ const int testcount_strict = sizeof(tests_strict) / sizeof(tests_strict[0]);
int i;
if (!pRtlIpv4StringToAddressA)
{
- skip("RtlIpv4StringToAddress not available\n");
+ skip("RtlIpv4StringToAddressA not available\n");
return;
}
- if (0)
- {
- /* leaving either parameter NULL crashes on Windows */
- res = pRtlIpv4StringToAddressA(NULL, FALSE, &terminator, &ip);
- res = pRtlIpv4StringToAddressA("1.1.1.1", FALSE, NULL, &ip);
- res = pRtlIpv4StringToAddressA("1.1.1.1", FALSE, &terminator, NULL);
- /* same for the wide char version */
- /*
- res = pRtlIpv4StringToAddressW(NULL, FALSE, &terminatorW, &ip);
- res = pRtlIpv4StringToAddressW(L"1.1.1.1", FALSE, NULL, &ip);
- res = pRtlIpv4StringToAddressW(L"1.1.1.1", FALSE, &terminatorW, NULL);
- */
- }
-
+ /* non-strict */
for (i = 0; i < testcount; i++)
{
- /* non-strict */
- terminator = &dummy;
- ip.S_un.S_addr = 0xabababab;
+ memset(&ip, 0, sizeof(ip));
+
res = pRtlIpv4StringToAddressA(tests[i].address, FALSE, &terminator, &ip);
- ok(res == tests[i].res,
- "[%s] res = 0x%08x, expected 0x%08x\n",
- tests[i].address, res, tests[i].res);
- ok(terminator == tests[i].address + tests[i].terminator_offset,
- "[%s] terminator = %p, expected %p\n",
- tests[i].address, terminator, tests[i].address + tests[i].terminator_offset);
- if (tests[i].ip[0] == -1)
- expected_ip.S_un.S_addr = 0xabababab;
- else
- {
- expected_ip.S_un.S_un_b.s_b1 = tests[i].ip[0];
- expected_ip.S_un.S_un_b.s_b2 = tests[i].ip[1];
- expected_ip.S_un.S_un_b.s_b3 = tests[i].ip[2];
- expected_ip.S_un.S_un_b.s_b4 = tests[i].ip[3];
- }
- ok(ip.S_un.S_addr == expected_ip.S_un.S_addr,
- "[%s] ip = %08x, expected %08x\n",
- tests[i].address, ip.S_un.S_addr, expected_ip.S_un.S_addr);
+ todo_wine ok(res == tests[i].res,
+ "#%d '%s' (Strict:FALSE) res = 0x%08x, expected 0x%08x\n", i,
+ tests[i].address, res, tests[i].res);
+
+ if (res == STATUS_SUCCESS) {
+ todo_wine ok( terminator == tests[i].address + (size_t)tests[i].terminator_offset,
+ "#%d '%s' (Strict:FALSE) terminator = %p, expected %p for ptr %p\n", i,
+ tests[i].address, terminator, tests[i].address + (size_t)tests[i].terminator_offset, tests[i].address);
+
+ todo_wine ok(ip.S_un.S_addr == tests[i].ip_ulong,
+ "#%d '%s' (Strict:FALSE) ip = %llu, expected %llu\n", i,
+ tests[i].address, (long long unsigned)ip.S_un.S_addr, (long long unsigned)tests[i].ip_ulong);
- if (!tests[i].strict_is_different)
- {
- tests[i].res_strict = tests[i].res;
- tests[i].terminator_offset_strict = tests[i].terminator_offset;
- tests[i].ip_strict[0] = tests[i].ip[0];
- tests[i].ip_strict[1] = tests[i].ip[1];
- tests[i].ip_strict[2] = tests[i].ip[2];
- tests[i].ip_strict[3] = tests[i].ip[3];
}
- /* strict */
- terminator = &dummy;
- ip.S_un.S_addr = 0xabababab;
- res = pRtlIpv4StringToAddressA(tests[i].address, TRUE, &terminator, &ip);
- ok(res == tests[i].res_strict,
- "[%s] res = 0x%08x, expected 0x%08x\n",
- tests[i].address, res, tests[i].res_strict);
- ok(terminator == tests[i].address + tests[i].terminator_offset_strict,
- "[%s] terminator = %p, expected %p\n",
- tests[i].address, terminator, tests[i].address + tests[i].terminator_offset_strict);
- if (tests[i].ip_strict[0] == -1)
- expected_ip.S_un.S_addr = 0xabababab;
- else
+ }
+
+ /* strict */
+ for (i=0; i<testcount_strict; i++)
+ {
+ memset(&ip, 0, sizeof(ip));
+
+ res = pRtlIpv4StringToAddressA(tests_strict[i].address, TRUE, &terminator, &ip);
+
+ ok(res == tests_strict[i].res,
+ "#%d '%s' (Strict:TRUE) res = 0x%08x, expected 0x%08x\n", i,
+ tests_strict[i].address, res, tests_strict[i].res);
+
+ if (res == STATUS_SUCCESS)
{
- expected_ip.S_un.S_un_b.s_b1 = tests[i].ip_strict[0];
- expected_ip.S_un.S_un_b.s_b2 = tests[i].ip_strict[1];
- expected_ip.S_un.S_un_b.s_b3 = tests[i].ip_strict[2];
- expected_ip.S_un.S_un_b.s_b4 = tests[i].ip_strict[3];
+ ok(terminator == tests_strict[i].address + (size_t)tests_strict[i].terminator_offset,
+ "#%d '%s' (Strict:TRUE) terminator = %p, expected %p for ptr %p\n", i,
+ tests_strict[i].address, terminator, tests_strict[i].address + tests_strict[i].terminator_offset, tests_strict[i].address);
+
+ ok(ip.S_un.S_addr == tests_strict[i].ip_ulong,
+ "#%d '%s' (Strict:TRUE) ip = %llu, expected %llu\n", i,
+ tests_strict[i].address, (long long unsigned)ip.S_un.S_addr, (long long unsigned)tests_strict[i].ip_ulong);
}
- ok(ip.S_un.S_addr == expected_ip.S_un.S_addr,
- "[%s] ip = %08x, expected %08x\n",
- tests[i].address, ip.S_un.S_addr, expected_ip.S_un.S_addr);
+
+ }
+}
+
+struct ipv6_testing_data
+{
+ LPCSTR readable_addr;
+ UCHAR expected_representation[16];
+ LPCSTR readable_compact_addr; /** could differ from readable **/
+};
+
+static struct ipv6_testing_data ipv6_samples[] =
+{
+ { "0::", { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, "::" },
+ { "::01", { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }, "::1" },
+ { "1::2", { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2 }, "1::2" },
+ { "2002:4559:1FE2::4559:1FE2", { 32, 2, 69, 89, 31, 226, 0, 0, 0, 0, 0, 0, 69, 89, 31, 226 }, "2002:4559:1fe2::4559:1fe2" },
+ { "2a02:6b8::3", { 42, 2, 6, 184, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3 }, "2a02:6b8::3" },
+ { "::192.168.001.1", { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 192, 168, 1, 1 }, "::192.168.1.1" },
+ { "fff::190.160.10.10", { 15, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 190, 160, 10, 10 }, "FFf::bea0:a0a" },
+ { "2001:0db8:11a3:09d7:1f34:8a2e:07a0:765d", { 32, 1, 13, 184, 17, 163, 9, 215,31, 52, 138, 46, 7, 160, 118, 93 }, "2001:db8:11a3:9d7:1f34:8a2e:7a0:765d" },
+ { "2001:0db8::", { 32, 1, 13, 184, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, "2001:db8::" },
+ { "ff00::", { 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, "ff00::" }
+};
+
+
+static void test_RtlIpv6AddressToStringA(void)
+{
+ const int testcount = sizeof(ipv6_samples) / sizeof(ipv6_samples[0]);
+ int i;
+ CHAR buffer[65];
+ CHAR * res;
+
+ if ( !pRtlIpv6AddressToStringA )
+ {
+ win_skip("Method not supported\n");
+ return;
+ }
+
+ res = pRtlIpv6AddressToStringA((IN6_ADDR*) &ipv6_samples[0].expected_representation, (LPSTR)&buffer);
+ if ((void *)&buffer==(void *)res) {
+ win_skip("No conversion expected with stub without inet_ntop\n");
+ return;
+ }
+
+ for (i=0; i<testcount; i++)
+ {
+ CHAR buffer[65];
+ CHAR * res;
+ IN6_ADDR * in6;
+ int expected_len, result_len;
+
+ memset(buffer, 0, sizeof(buffer) - 1);
+
+ in6 = (IN6_ADDR*) &ipv6_samples[i].expected_representation;
+
+ res = pRtlIpv6AddressToStringA(in6, (LPSTR)&buffer);
+
+ ok( 0 == (CHAR)(*res),
+ "Pointer to 0 expected, got %c at %p\n",
+ (CHAR)(*res), res);
+
+ expected_len = strlen(ipv6_samples[i].readable_compact_addr);
+ result_len = strlen(buffer);
+
+ ok( expected_len == result_len,
+ "Unexpected resulting strlen, waited for %d, got %d\n",
+ expected_len, result_len);
+
+ ok ( strcasecmp((const char *)ipv6_samples[i].readable_compact_addr, (const char *)&buffer) == 0,
+ "Unexpected IPv6 address, waited '%s', got '%s'",
+ ipv6_samples[i].readable_compact_addr, (const char *)&buffer);
+ }
+
+}
+
+static void test_RtlIpv6AddressToStringW(void)
+{
+ const int testcount = sizeof(ipv6_samples) / sizeof(ipv6_samples[0]);
+ int i;
+ WCHAR buffer[INET6_ADDRSTRLEN];
+ WCHAR * res;
+
+ if ( !pRtlIpv6AddressToStringW )
+ {
+ win_skip("Method not supported\n");
+ return;
+ }
+
+ res = pRtlIpv6AddressToStringW((IN6_ADDR*) &ipv6_samples[0].expected_representation, (LPWSTR)&buffer);
+
+ if ((void *)&buffer==(void *)res)
+ {
+ win_skip("No conversion expected with stub without inet_ntop\n");
+ return;
+ }
+
+ for (i=0; i<testcount; i++)
+ {
+ WCHAR buffer[INET6_ADDRSTRLEN];
+ WCHAR * res;
+ WCHAR W_readable_addr[INET6_ADDRSTRLEN];
+
+ IN6_ADDR * in6;
+ int expected_len, result_len;
+
+ in6 = (IN6_ADDR*) &ipv6_samples[i].expected_representation;
+
+ expected_len = strlen(ipv6_samples[i].readable_compact_addr);
+
+ memset(&W_readable_addr,0, sizeof(W_readable_addr));
+ memset(&buffer,0, sizeof(W_readable_addr));
+
+ MultiByteToWideChar(CP_ACP,0,ipv6_samples[i].readable_compact_addr,expected_len,(LPWSTR)&W_readable_addr,expected_len);
+
+ res = pRtlIpv6AddressToStringW(in6, (LPWSTR)&buffer);
+
+ ok( '\0' == (WCHAR)(*res),
+ "Pointer to 0 expected, got %s at %p+%p, full string '%s'\n",
+ wine_dbgstr_wn(res, 1), buffer, res, wine_dbgstr_w((const WCHAR *)&buffer));
+
+ expected_len = lstrlenW((LPCWSTR)&W_readable_addr);
+ result_len = lstrlenW((LPCWSTR)&buffer);
+
+ ok( expected_len == result_len,
+ "Unexpected resulting strlen, waited for %d, got %d\n", expected_len, result_len);
+
+ ok( lstrcmpiW((LPCWSTR)&W_readable_addr, (LPCWSTR)&buffer) == 0,
+ "IPv6 address strings are not equal, '%s' expected, got '%s'",
+ wine_dbgstr_w((const WCHAR *)&W_readable_addr), wine_dbgstr_w((const WCHAR *)&buffer));
}
}
@@ -1779,8 +1895,8 @@ static void test_RtlDecompressBuffer(void)
/* regular tests for RtlDecompressBuffer */
for (i = 0; i < sizeof(test_lznt) / sizeof(test_lznt[0]); i++)
{
- trace("Running test %d (compressed_size=%u, uncompressed_size=%u, status=0x%08x)\n",
- i, test_lznt[i].compressed_size, test_lznt[i].uncompressed_size, test_lznt[i].status);
+ /* trace("Running test %d (compressed_size=%u, uncompressed_size=%u, status=0x%08x)\n",
+ i, test_lznt[i].compressed_size, test_lznt[i].uncompressed_size, test_lznt[i].status); */
/* test with very big buffer */
final_size = 0xdeadbeef;
@@ -2080,6 +2196,8 @@ START_TEST(rtl)
test_RtlIpv4AddressToString();
test_RtlIpv4AddressToStringEx();
test_RtlIpv4StringToAddress();
+ test_RtlIpv6AddressToStringA();
+ test_RtlIpv6AddressToStringW();
test_LdrAddRefDll();
test_LdrLockLoaderLock();
test_RtlCompressBuffer();
--
2.1.4
More information about the wine-patches
mailing list