[CRT_APITEST]

- Fix dll loading in static_construct test
CORE-10562

svn path=/trunk/; revision=70022
This commit is contained in:
Thomas Faber 2015-11-22 13:51:19 +00:00
parent 37c4fd4f08
commit 3aee20e0d8

View file

@ -6,6 +6,7 @@
*/ */
#include <apitest.h> #include <apitest.h>
#include <strsafe.h>
#include "dll_startup.h" #include "dll_startup.h"
extern "C" extern "C"
@ -35,7 +36,9 @@ static struct init_static
} }
} init_static; } init_static;
START_TEST(static_construct) static
VOID
TestInitStatic(VOID)
{ {
ok(static_init_counter_at_startup == 123, "static_init_counter at startup: %d\n", static_init_counter_at_startup); ok(static_init_counter_at_startup == 123, "static_init_counter at startup: %d\n", static_init_counter_at_startup);
ok(static_construct_counter_at_startup == 789, "static_construct_counter at startup: %d\n", static_construct_counter_at_startup); ok(static_construct_counter_at_startup == 789, "static_construct_counter at startup: %d\n", static_construct_counter_at_startup);
@ -46,15 +49,25 @@ START_TEST(static_construct)
ok(static_construct_counter == 790, "static_construct_counter: %d\n", static_construct_counter); ok(static_construct_counter == 790, "static_construct_counter: %d\n", static_construct_counter);
ok(init_static.m_counter == 2, "init_static.m_counter: %d\n", init_static.m_counter); ok(init_static.m_counter == 2, "init_static.m_counter: %d\n", init_static.m_counter);
ok(init_static.m_uninit == 1, "init_static.m_uninit: %d\n", init_static.m_uninit); ok(init_static.m_uninit == 1, "init_static.m_uninit: %d\n", init_static.m_uninit);
}
counter_values values; static
VOID
TestDllStartup(VOID)
{
#if defined(TEST_MSVCRT) #if defined(TEST_MSVCRT)
HMODULE hDll = LoadLibraryW(L"msvcrt_crt_dll_startup.dll"); const PCWSTR DllName = L"msvcrt_crt_dll_startup.dll";
#elif defined(TEST_STATIC_CRT) #elif defined(TEST_STATIC_CRT)
HMODULE hDll = LoadLibraryW(L"static_crt_dll_startup.dll"); const PCWSTR DllName = L"static_crt_dll_startup.dll";
#else #else
#error This test only makes sense for static CRT and msvcrt.dll #error This test only makes sense for static CRT and msvcrt.dll
#endif #endif
WCHAR DllPath[MAX_PATH];
GetModuleFileNameW(NULL, DllPath, _countof(DllPath));
wcsrchr(DllPath, L'\\')[1] = UNICODE_NULL;
StringCchCatW(DllPath, _countof(DllPath), DllName);
HMODULE hDll = LoadLibraryW(DllPath);
if (hDll == NULL) if (hDll == NULL)
{ {
skip("Helper dll not found\n"); skip("Helper dll not found\n");
@ -67,6 +80,7 @@ START_TEST(static_construct)
FreeLibrary(hDll); FreeLibrary(hDll);
return; return;
} }
counter_values values;
pSetCounterValuesPointer(&values); pSetCounterValuesPointer(&values);
ok(values.m_uninit_at_startup == 0, "m_uninit_at_startup = %d\n", values.m_uninit_at_startup); ok(values.m_uninit_at_startup == 0, "m_uninit_at_startup = %d\n", values.m_uninit_at_startup);
ok(values.m_uninit == 1, "m_uninit = %d\n", values.m_uninit); ok(values.m_uninit == 1, "m_uninit = %d\n", values.m_uninit);
@ -86,3 +100,9 @@ START_TEST(static_construct)
ok(values.dtor_counter_at_detach == 7878, "dtor_counter_at_detach = %d\n", values.dtor_counter_at_detach); ok(values.dtor_counter_at_detach == 7878, "dtor_counter_at_detach = %d\n", values.dtor_counter_at_detach);
ok(values.dtor_counter == 7879, "dtor_counter = %d\n", values.dtor_counter); ok(values.dtor_counter == 7879, "dtor_counter = %d\n", values.dtor_counter);
} }
START_TEST(static_construct)
{
TestInitStatic();
TestDllStartup();
}