mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-15 07:05:08 +00:00
ntdll/tests: Move TlsIndex test to kernel32:loader.
Gets us access to a dll with tls to verify.
This commit is contained in:
parent
2203a8564c
commit
a8fa80cfb4
|
@ -2117,6 +2117,33 @@ nt4_is_broken:
|
|||
}
|
||||
}
|
||||
|
||||
static void check_tls_index(HANDLE dll, BOOL tls_initialized)
|
||||
{
|
||||
BOOL found_dll = FALSE;
|
||||
LIST_ENTRY *root = &NtCurrentTeb()->Peb->LdrData->InLoadOrderModuleList;
|
||||
for (LIST_ENTRY *entry = root->Flink; entry != root; entry = entry->Flink)
|
||||
{
|
||||
LDR_DATA_TABLE_ENTRY *mod = CONTAINING_RECORD(entry, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks);
|
||||
if (wcsicmp(L"ntdll.dll", mod->BaseDllName.Buffer) == 0)
|
||||
{
|
||||
/* Pick ntdll as a dll that definitely won't have TLS */
|
||||
ok(mod->TlsIndex == 0, "ntdll.dll TlsIndex: %d instead of 0\n", mod->TlsIndex);
|
||||
}
|
||||
else if (mod->DllBase == dll)
|
||||
{
|
||||
SHORT expected = tls_initialized ? -1 : 0;
|
||||
ok(mod->TlsIndex == expected, "Test exe TlsIndex: %d instead of %d\n", mod->TlsIndex, expected);
|
||||
found_dll = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
ok(mod->TlsIndex == 0 || mod->TlsIndex == -1, "%s TlsIndex: %d\n",
|
||||
debugstr_w(mod->BaseDllName.Buffer), mod->TlsIndex);
|
||||
}
|
||||
}
|
||||
ok(found_dll, "Couldn't find dll %p in module list\n", dll);
|
||||
}
|
||||
|
||||
static void test_import_resolution(void)
|
||||
{
|
||||
char temp_path[MAX_PATH];
|
||||
|
@ -2251,6 +2278,7 @@ static void test_import_resolution(void)
|
|||
ok( !strcmp( str, "hello world" ), "wrong tls data '%s' at %p\n", str, str );
|
||||
ok(ptr->tls_index_hi == 0, "TLS Index written as a short, high half: %d\n", ptr->tls_index_hi);
|
||||
}
|
||||
check_tls_index(mod, ptr->tls_index != 9999);
|
||||
FreeLibrary( mod );
|
||||
break;
|
||||
case 1: /* load with DONT_RESOLVE_DLL_REFERENCES doesn't resolve imports */
|
||||
|
@ -2267,6 +2295,7 @@ static void test_import_resolution(void)
|
|||
ok( ptr->thunks[0].u1.Function == 0xdeadbeef, "thunk resolved to %p for %s.%s\n",
|
||||
(void *)ptr->thunks[0].u1.Function, data.module, data.function.name );
|
||||
ok( ptr->tls_index == 9999, "wrong tls index %d\n", ptr->tls_index );
|
||||
check_tls_index(mod, ptr->tls_index != 9999);
|
||||
FreeLibrary( mod2 );
|
||||
FreeLibrary( mod );
|
||||
break;
|
||||
|
@ -2278,6 +2307,7 @@ static void test_import_resolution(void)
|
|||
ok( ptr->thunks[0].u1.Function == 0xdeadbeef, "thunk resolved to %p for %s.%s\n",
|
||||
(void *)ptr->thunks[0].u1.Function, data.module, data.function.name );
|
||||
ok( ptr->tls_index == 9999, "wrong tls index %d\n", ptr->tls_index );
|
||||
check_tls_index(mod, ptr->tls_index != 9999);
|
||||
FreeLibrary( mod );
|
||||
break;
|
||||
case 3: /* load with tls init function */
|
||||
|
@ -2293,6 +2323,7 @@ static void test_import_resolution(void)
|
|||
str = ((char **)NtCurrentTeb()->ThreadLocalStoragePointer)[ptr->tls_index];
|
||||
ok( !strcmp( str, "hello!world" ), "wrong tls data '%s' at %p\n", str, str );
|
||||
}
|
||||
check_tls_index(mod, ptr->tls_index != 9999);
|
||||
FreeLibrary( mod );
|
||||
}
|
||||
DeleteFileA( dll_name );
|
||||
|
|
|
@ -3608,31 +3608,6 @@ static void test_RtlFirstFreeAce(void)
|
|||
HeapFree(GetProcessHeap(), 0, acl);
|
||||
}
|
||||
|
||||
static void test_TlsIndex(void)
|
||||
{
|
||||
LIST_ENTRY *root = &NtCurrentTeb()->Peb->LdrData->InLoadOrderModuleList;
|
||||
for (LIST_ENTRY *entry = root->Flink; entry != root; entry = entry->Flink)
|
||||
{
|
||||
LDR_DATA_TABLE_ENTRY *mod = CONTAINING_RECORD(entry, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks);
|
||||
if (lstrcmpiW(L"ntdll.dll", mod->BaseDllName.Buffer) == 0)
|
||||
{
|
||||
/* Pick ntdll as a dll that definitely won't have TLS */
|
||||
ok(mod->TlsIndex == 0, "ntdll.dll TlsIndex: %d instead of 0\n", mod->TlsIndex);
|
||||
}
|
||||
else if (mod->DllBase == GetModuleHandleA(NULL))
|
||||
{
|
||||
/* mingw gcc doesn't support MSVC-style TLS */
|
||||
/* If we do get a way to add tls to this exe, uncomment the following test: */
|
||||
/* ok(mod->TlsIndex == -1, "Test exe TlsIndex: %d instead of -1\n", mod->TlsIndex); */
|
||||
}
|
||||
else
|
||||
{
|
||||
ok(mod->TlsIndex == 0 || mod->TlsIndex == -1, "%s TlsIndex: %d\n",
|
||||
debugstr_w(mod->BaseDllName.Buffer), mod->TlsIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
START_TEST(rtl)
|
||||
{
|
||||
InitFunctionPtrs();
|
||||
|
@ -3677,5 +3652,4 @@ START_TEST(rtl)
|
|||
test_DbgPrint();
|
||||
test_RtlDestroyHeap();
|
||||
test_RtlFirstFreeAce();
|
||||
test_TlsIndex();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue