mscoree: Add tests for LoadLibraryShim.

This commit is contained in:
Vincent Povirk 2010-10-26 14:37:28 -05:00 committed by Alexandre Julliard
parent 5f98620c05
commit a96941a3bf
1 changed files with 129 additions and 1 deletions

View File

@ -25,6 +25,25 @@ static HMODULE hmscoree;
static HRESULT (WINAPI *pGetCORVersion)(LPWSTR, DWORD, DWORD*);
static HRESULT (WINAPI *pGetCORSystemDirectory)(LPWSTR, DWORD, DWORD*);
static HRESULT (WINAPI *pGetRequestedRuntimeInfo)(LPCWSTR, LPCWSTR, LPCWSTR, DWORD, DWORD, LPWSTR, DWORD, DWORD*, LPWSTR, DWORD, DWORD*);
static HRESULT (WINAPI *pLoadLibraryShim)(LPCWSTR, LPCWSTR, LPVOID, HMODULE*);
static WCHAR tolowerW( WCHAR ch )
{
if (ch >= 'A' && ch <= 'Z') return ch|32;
else return ch;
}
static WCHAR *strstriW( const WCHAR *str, const WCHAR *sub )
{
while (*str)
{
const WCHAR *p1 = str, *p2 = sub;
while (*p1 && *p2 && tolowerW(*p1) == tolowerW(*p2)) { p1++; p2++; }
if (!*p2) return (WCHAR *)str;
str++;
}
return NULL;
}
static BOOL init_functionpointers(void)
{
@ -39,8 +58,9 @@ static BOOL init_functionpointers(void)
pGetCORVersion = (void *)GetProcAddress(hmscoree, "GetCORVersion");
pGetCORSystemDirectory = (void *)GetProcAddress(hmscoree, "GetCORSystemDirectory");
pGetRequestedRuntimeInfo = (void *)GetProcAddress(hmscoree, "GetRequestedRuntimeInfo");
pLoadLibraryShim = (void *)GetProcAddress(hmscoree, "LoadLibraryShim");
if (!pGetCORVersion || !pGetCORSystemDirectory || !pGetRequestedRuntimeInfo)
if (!pGetCORVersion || !pGetCORSystemDirectory || !pGetRequestedRuntimeInfo || !pLoadLibraryShim)
{
win_skip("functions not available\n");
FreeLibrary(hmscoree);
@ -129,12 +149,120 @@ static void test_versioninfo(void)
ok(!lstrcmpW(version, v2_0), "version is %s , expected %s\n", wine_dbgstr_w(version), wine_dbgstr_w(v2_0));
}
static void test_loadlibraryshim(void)
{
const WCHAR v4_0[] = {'v','4','.','0','.','3','0','3','1','9',0};
const WCHAR v2_0[] = {'v','2','.','0','.','5','0','7','2','7',0};
const WCHAR v1_1[] = {'v','1','.','1','.','4','3','2','2',0};
const WCHAR vbogus[] = {'v','b','o','g','u','s',0};
const WCHAR fusion[] = {'f','u','s','i','o','n',0};
const WCHAR fusiondll[] = {'f','u','s','i','o','n','.','d','l','l',0};
const WCHAR nosuchdll[] = {'j','n','v','n','l','.','d','l','l',0};
const WCHAR gdipdll[] = {'g','d','i','p','l','u','s','.','d','l','l',0};
const WCHAR gdidll[] = {'g','d','i','3','2','.','d','l','l',0};
HRESULT hr;
const WCHAR *latest = NULL;
HMODULE hdll;
WCHAR dllpath[MAX_PATH];
hr = pLoadLibraryShim(fusion, v1_1, NULL, &hdll);
ok(hr == S_OK || hr == E_HANDLE, "LoadLibraryShim failed, hr=%x\n", hr);
if (SUCCEEDED(hr))
{
latest = v1_1;
GetModuleFileNameW(hdll, dllpath, MAX_PATH);
todo_wine ok(strstriW(dllpath, v1_1) != 0, "incorrect fusion.dll path %s\n", wine_dbgstr_w(dllpath));
ok(strstriW(dllpath, fusiondll) != 0, "incorrect fusion.dll path %s\n", wine_dbgstr_w(dllpath));
FreeLibrary(hdll);
}
hr = pLoadLibraryShim(fusion, v2_0, NULL, &hdll);
ok(hr == S_OK || hr == E_HANDLE, "LoadLibraryShim failed, hr=%x\n", hr);
if (SUCCEEDED(hr))
{
latest = v2_0;
GetModuleFileNameW(hdll, dllpath, MAX_PATH);
todo_wine ok(strstriW(dllpath, v2_0) != 0, "incorrect fusion.dll path %s\n", wine_dbgstr_w(dllpath));
ok(strstriW(dllpath, fusiondll) != 0, "incorrect fusion.dll path %s\n", wine_dbgstr_w(dllpath));
FreeLibrary(hdll);
}
hr = pLoadLibraryShim(fusion, v4_0, NULL, &hdll);
ok(hr == S_OK || hr == E_HANDLE, "LoadLibraryShim failed, hr=%x\n", hr);
if (SUCCEEDED(hr))
{
/* LoadLibraryShim with a NULL version prefers 2.0 and earlier */
if (!latest)
latest = v4_0;
GetModuleFileNameW(hdll, dllpath, MAX_PATH);
todo_wine ok(strstriW(dllpath, v4_0) != 0, "incorrect fusion.dll path %s\n", wine_dbgstr_w(dllpath));
ok(strstriW(dllpath, fusiondll) != 0, "incorrect fusion.dll path %s\n", wine_dbgstr_w(dllpath));
FreeLibrary(hdll);
}
hr = pLoadLibraryShim(fusion, vbogus, NULL, &hdll);
todo_wine ok(hr == E_HANDLE, "LoadLibraryShim failed, hr=%x\n", hr);
if (SUCCEEDED(hr))
FreeLibrary(hdll);
hr = pLoadLibraryShim(fusion, NULL, NULL, &hdll);
ok(hr == S_OK, "LoadLibraryShim failed, hr=%x\n", hr);
if (SUCCEEDED(hr))
{
GetModuleFileNameW(hdll, dllpath, MAX_PATH);
if (latest)
todo_wine ok(strstriW(dllpath, latest) != 0, "incorrect fusion.dll path %s\n", wine_dbgstr_w(dllpath));
ok(strstriW(dllpath, fusiondll) != 0, "incorrect fusion.dll path %s\n", wine_dbgstr_w(dllpath));
FreeLibrary(hdll);
}
hr = pLoadLibraryShim(fusiondll, NULL, NULL, &hdll);
ok(hr == S_OK, "LoadLibraryShim failed, hr=%x\n", hr);
if (SUCCEEDED(hr))
{
GetModuleFileNameW(hdll, dllpath, MAX_PATH);
if (latest)
todo_wine ok(strstriW(dllpath, latest) != 0, "incorrect fusion.dll path %s\n", wine_dbgstr_w(dllpath));
ok(strstriW(dllpath, fusiondll) != 0, "incorrect fusion.dll path %s\n", wine_dbgstr_w(dllpath));
FreeLibrary(hdll);
}
hr = pLoadLibraryShim(nosuchdll, latest, NULL, &hdll);
todo_wine ok(hr == E_HANDLE, "LoadLibraryShim failed, hr=%x\n", hr);
if (SUCCEEDED(hr))
FreeLibrary(hdll);
hr = pLoadLibraryShim(gdipdll, latest, NULL, &hdll);
todo_wine ok(hr == E_HANDLE, "LoadLibraryShim failed, hr=%x\n", hr);
if (SUCCEEDED(hr))
FreeLibrary(hdll);
hr = pLoadLibraryShim(gdidll, latest, NULL, &hdll);
todo_wine ok(hr == E_HANDLE, "LoadLibraryShim failed, hr=%x\n", hr);
if (SUCCEEDED(hr))
FreeLibrary(hdll);
}
START_TEST(mscoree)
{
if (!init_functionpointers())
return;
test_versioninfo();
test_loadlibraryshim();
FreeLibrary(hmscoree);
}