mscoree/tests: Comment out a couple of tests that crash on Windows.
[wine/testsucceed.git] / dlls / mscoree / tests / mscoree.c
blob0536ba1f8765fd11260536aaef59670522e0c9f2
1 /*
2 * Copyright 2010 Louis Lenders
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include "corerror.h"
20 #include "mscoree.h"
21 #include "wine/test.h"
23 static HMODULE hmscoree;
25 static HRESULT (WINAPI *pGetCORVersion)(LPWSTR, DWORD, DWORD*);
26 static HRESULT (WINAPI *pGetCORSystemDirectory)(LPWSTR, DWORD, DWORD*);
27 static HRESULT (WINAPI *pGetRequestedRuntimeInfo)(LPCWSTR, LPCWSTR, LPCWSTR, DWORD, DWORD, LPWSTR, DWORD, DWORD*, LPWSTR, DWORD, DWORD*);
29 static BOOL init_functionpointers(void)
31 hmscoree = LoadLibraryA("mscoree.dll");
33 if (!hmscoree)
35 win_skip("mscoree.dll not available\n");
36 return FALSE;
39 pGetCORVersion = (void *)GetProcAddress(hmscoree, "GetCORVersion");
40 pGetCORSystemDirectory = (void *)GetProcAddress(hmscoree, "GetCORSystemDirectory");
41 pGetRequestedRuntimeInfo = (void *)GetProcAddress(hmscoree, "GetRequestedRuntimeInfo");
43 if (!pGetCORVersion || !pGetCORSystemDirectory || !pGetRequestedRuntimeInfo)
45 win_skip("functions not available\n");
46 FreeLibrary(hmscoree);
47 return FALSE;
50 return TRUE;
53 static void test_versioninfo(void)
55 const WCHAR v2_0[] = {'v','2','.','0','.','5','0','7','2','7',0};
56 const WCHAR v1_1[] = {'v','1','.','1','.','4','3','2','2',0};
58 WCHAR version[MAX_PATH];
59 WCHAR path[MAX_PATH];
60 DWORD size, path_len;
61 HRESULT hr;
63 if (0) /* crashes on <= w2k3 */
65 hr = pGetCORVersion(NULL, MAX_PATH, &size);
66 ok(hr == E_POINTER,"GetCORVersion returned %08x\n", hr);
69 hr = pGetCORVersion(version, 1, &size);
70 ok(hr == HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER),"GetCORVersion returned %08x\n", hr);
72 hr = pGetCORVersion(version, MAX_PATH, &size);
73 ok(hr == S_OK,"GetCORVersion returned %08x\n", hr);
75 trace("latest installed .net runtime: %s\n", wine_dbgstr_w(version));
77 hr = pGetCORSystemDirectory(path, MAX_PATH , &size);
78 ok(hr == S_OK, "GetCORSystemDirectory returned %08x\n", hr);
79 /* size includes terminating null-character */
80 ok(size == (lstrlenW(path) + 1),"size is %d instead of %d\n", size, (lstrlenW(path) + 1));
82 path_len = size;
84 hr = pGetCORSystemDirectory(path, path_len-1 , &size);
85 ok(hr == HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), "GetCORSystemDirectory returned %08x\n", hr);
87 if (0) /* crashes on <= w2k3 */
89 hr = pGetCORSystemDirectory(NULL, MAX_PATH , &size);
90 ok(hr == HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), "GetCORSystemDirectory returned %08x\n", hr);
93 hr = pGetCORSystemDirectory(path, MAX_PATH , NULL);
94 ok(hr == E_POINTER,"GetCORSystemDirectory returned %08x\n", hr);
96 trace("latest installed .net installed in directory: %s\n", wine_dbgstr_w(path));
98 /* test GetRequestedRuntimeInfo, first get info about different versions of runtime */
99 hr = pGetRequestedRuntimeInfo( NULL, v2_0, NULL, 0, 0, path, MAX_PATH, &path_len, version, MAX_PATH, &size);
101 if(hr == CLR_E_SHIM_RUNTIME) return; /* skipping rest of tests on win2k as .net 2.0 not installed */
103 ok(hr == S_OK, "GetRequestedRuntimeInfo returned %08x\n", hr);
104 trace(" installed in directory %s is .net version %s \n", wine_dbgstr_w(path), wine_dbgstr_w(version));
106 hr = pGetRequestedRuntimeInfo( NULL, v1_1, NULL, 0, 0, path, MAX_PATH, &path_len, version, MAX_PATH, &size);
107 ok(hr == S_OK || CLR_E_SHIM_RUNTIME /*v1_1 not installed*/, "GetRequestedRuntimeInfo returned %08x\n", hr);
108 if(hr == S_OK)
109 trace(" installed in directory %s is .net version %s \n", wine_dbgstr_w(path), wine_dbgstr_w(version));
110 /* version number NULL not allowed without RUNTIME_INFO_UPGRADE_VERSION flag */
111 hr = pGetRequestedRuntimeInfo( NULL, NULL, NULL, 0, 0, path, MAX_PATH, &path_len, version, MAX_PATH, &size);
112 ok(hr == CLR_E_SHIM_RUNTIME, "GetRequestedRuntimeInfo returned %08x\n", hr);
113 /* with RUNTIME_INFO_UPGRADE_VERSION flag and version number NULL, latest installed version is returned */
114 hr = pGetRequestedRuntimeInfo( NULL, NULL, NULL, 0, RUNTIME_INFO_UPGRADE_VERSION, path, MAX_PATH, &path_len, version, MAX_PATH, &size);
115 ok(hr == S_OK, "GetRequestedRuntimeInfo returned %08x\n", hr);
117 hr = pGetRequestedRuntimeInfo( NULL, v2_0, NULL, 0, 0, path, 1, &path_len, version, MAX_PATH, &size);
118 ok(hr == HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), "GetRequestedRuntimeInfo returned %08x\n", hr);
120 /* if one of the buffers is NULL, the other one is still happily filled */
121 memset(version, 0, sizeof(version));
122 hr = pGetRequestedRuntimeInfo( NULL, v2_0, NULL, 0, 0, NULL, MAX_PATH, &path_len, version, MAX_PATH, &size);
123 ok(hr == S_OK, "GetRequestedRuntimeInfo returned %08x\n", hr);
124 ok(!lstrcmpW(version, v2_0), "version is %s , expected %s\n", wine_dbgstr_w(version), wine_dbgstr_w(v2_0));
125 /* With NULL-pointer for bufferlength, the buffer itsself still gets filled with correct string */
126 memset(version, 0, sizeof(version));
127 hr = pGetRequestedRuntimeInfo( NULL, v2_0, NULL, 0, 0, path, MAX_PATH, &path_len, version, MAX_PATH, NULL);
128 ok(hr == S_OK, "GetRequestedRuntimeInfo returned %08x\n", hr);
129 ok(!lstrcmpW(version, v2_0), "version is %s , expected %s\n", wine_dbgstr_w(version), wine_dbgstr_w(v2_0));
132 START_TEST(mscoree)
134 if (!init_functionpointers())
135 return;
137 test_versioninfo();
139 FreeLibrary(hmscoree);