include: Specify calling convention explicitly in idl files where needed.
[wine/hramrach.git] / dlls / mscoree / tests / mscoree.c
blob59ba58e37bfe9e26d8a0e0ac4cdc9dba96024a11
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 hr = pGetCORVersion(NULL, MAX_PATH, &size);
64 ok(hr == E_POINTER,"GetCORVersion returned %08x\n", hr);
66 hr = pGetCORVersion(version, 1, &size);
67 ok(hr == HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER),"GetCORVersion returned %08x\n", hr);
69 hr = pGetCORVersion(version, MAX_PATH, &size);
70 ok(hr == S_OK,"GetCORVersion returned %08x\n", hr);
72 trace("latest installed .net runtime: %s\n", wine_dbgstr_w(version));
74 hr = pGetCORSystemDirectory(path, MAX_PATH , &size);
75 ok(hr == S_OK, "GetCORSystemDirectory returned %08x\n", hr);
76 /* size includes terminating null-character */
77 ok(size == (lstrlenW(path) + 1),"size is %d instead of %d\n", size, (lstrlenW(path) + 1));
79 path_len = size;
81 hr = pGetCORSystemDirectory(path, path_len-1 , &size);
82 ok(hr == HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), "GetCORSystemDirectory returned %08x\n", hr);
84 hr = pGetCORSystemDirectory(NULL, MAX_PATH , &size);
85 ok(hr == HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), "GetCORSystemDirectory returned %08x\n", hr);
87 hr = pGetCORSystemDirectory(path, MAX_PATH , NULL);
88 ok(hr == E_POINTER,"GetCORSystemDirectory returned %08x\n", hr);
90 trace("latest installed .net installed in directory: %s\n", wine_dbgstr_w(path));
92 /* test GetRequestedRuntimeInfo, first get info about different versions of runtime */
93 hr = pGetRequestedRuntimeInfo( NULL, v2_0, NULL, 0, 0, path, MAX_PATH, &path_len, version, MAX_PATH, &size);
95 if(hr == CLR_E_SHIM_RUNTIME) return; /* skipping rest of tests on win2k as .net 2.0 not installed */
97 ok(hr == S_OK, "GetRequestedRuntimeInfo returned %08x\n", hr);
98 trace(" installed in directory %s is .net version %s \n", wine_dbgstr_w(path), wine_dbgstr_w(version));
100 hr = pGetRequestedRuntimeInfo( NULL, v1_1, NULL, 0, 0, path, MAX_PATH, &path_len, version, MAX_PATH, &size);
101 ok(hr == S_OK || CLR_E_SHIM_RUNTIME /*v1_1 not installed*/, "GetRequestedRuntimeInfo returned %08x\n", hr);
102 if(hr == S_OK)
103 trace(" installed in directory %s is .net version %s \n", wine_dbgstr_w(path), wine_dbgstr_w(version));
104 /* version number NULL not allowed without RUNTIME_INFO_UPGRADE_VERSION flag */
105 hr = pGetRequestedRuntimeInfo( NULL, NULL, NULL, 0, 0, path, MAX_PATH, &path_len, version, MAX_PATH, &size);
106 ok(hr == CLR_E_SHIM_RUNTIME, "GetRequestedRuntimeInfo returned %08x\n", hr);
107 /* with RUNTIME_INFO_UPGRADE_VERSION flag and version number NULL, latest installed version is returned */
108 hr = pGetRequestedRuntimeInfo( NULL, NULL, NULL, 0, RUNTIME_INFO_UPGRADE_VERSION, path, MAX_PATH, &path_len, version, MAX_PATH, &size);
109 ok(hr == S_OK, "GetRequestedRuntimeInfo returned %08x\n", hr);
111 hr = pGetRequestedRuntimeInfo( NULL, v2_0, NULL, 0, 0, path, 1, &path_len, version, MAX_PATH, &size);
112 ok(hr == HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), "GetRequestedRuntimeInfo returned %08x\n", hr);
114 /* if one of the buffers is NULL, the other one is still happily filled */
115 memset(version, 0, sizeof(version));
116 hr = pGetRequestedRuntimeInfo( NULL, v2_0, NULL, 0, 0, NULL, MAX_PATH, &path_len, version, MAX_PATH, &size);
117 ok(hr == S_OK, "GetRequestedRuntimeInfo returned %08x\n", hr);
118 ok(!lstrcmpW(version, v2_0), "version is %s , expected %s\n", wine_dbgstr_w(version), wine_dbgstr_w(v2_0));
119 /* With NULL-pointer for bufferlength, the buffer itsself still gets filled with correct string */
120 memset(version, 0, sizeof(version));
121 hr = pGetRequestedRuntimeInfo( NULL, v2_0, NULL, 0, 0, path, MAX_PATH, &path_len, version, MAX_PATH, NULL);
122 ok(hr == S_OK, "GetRequestedRuntimeInfo returned %08x\n", hr);
123 ok(!lstrcmpW(version, v2_0), "version is %s , expected %s\n", wine_dbgstr_w(version), wine_dbgstr_w(v2_0));
126 START_TEST(mscoree)
128 if (!init_functionpointers())
129 return;
131 test_versioninfo();
133 FreeLibrary(hmscoree);