kernel32/tests: Better check the NT path returned by QueryFullProcessImageName().
[wine] / dlls / mscoree / tests / debugging.c
1 /*
2  * Copyright 2011 Alistair Leslie-Hughes
3  *
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.
8  *
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.
13  *
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
17  */
18
19 #define COBJMACROS
20
21 #include "windows.h"
22 #include "ole2.h"
23 #include "corerror.h"
24 #include "mscoree.h"
25 #include "corhdr.h"
26
27 #include "wine/test.h"
28
29 #include "initguid.h"
30 #include "cordebug.h"
31
32 static HMODULE hmscoree;
33
34 static HRESULT (WINAPI *pCreateDebuggingInterfaceFromVersion)(int, LPCWSTR, IUnknown **);
35
36 const WCHAR v2_0[] = {'v','2','.','0','.','5','0','7','2','7',0};
37
38 static BOOL init_functionpointers(void)
39 {
40     hmscoree = LoadLibraryA("mscoree.dll");
41
42     if (!hmscoree)
43     {
44         win_skip("mscoree.dll not available\n");
45         return FALSE;
46     }
47
48     pCreateDebuggingInterfaceFromVersion = (void *)GetProcAddress(hmscoree, "CreateDebuggingInterfaceFromVersion");
49
50     if (!pCreateDebuggingInterfaceFromVersion)
51     {
52         win_skip("functions not available\n");
53         FreeLibrary(hmscoree);
54         return FALSE;
55     }
56
57     return TRUE;
58 }
59
60 static void test_createDebugger(void)
61 {
62     HRESULT hr;
63     IUnknown *pUnk;
64     ICorDebug *pCorDebug;
65
66     hr = pCreateDebuggingInterfaceFromVersion(0, v2_0, &pUnk);
67     ok(hr == E_INVALIDARG, "CreateDebuggingInterfaceFromVersion returned %08x\n", hr);
68
69     hr = pCreateDebuggingInterfaceFromVersion(1, v2_0, &pUnk);
70     ok(hr == E_INVALIDARG, "CreateDebuggingInterfaceFromVersion returned %08x\n", hr);
71
72     hr = pCreateDebuggingInterfaceFromVersion(2, v2_0, &pUnk);
73     ok(hr == E_INVALIDARG, "CreateDebuggingInterfaceFromVersion returned %08x\n", hr);
74
75     hr = pCreateDebuggingInterfaceFromVersion(4, v2_0, &pUnk);
76     ok(hr == E_INVALIDARG, "CreateDebuggingInterfaceFromVersion returned %08x\n", hr);
77
78     hr = pCreateDebuggingInterfaceFromVersion(3, v2_0, NULL);
79     ok(hr == E_INVALIDARG, "CreateDebuggingInterfaceFromVersion returned %08x\n", hr);
80
81     hr = pCreateDebuggingInterfaceFromVersion(3, v2_0, &pUnk);
82     if(hr == S_OK)
83     {
84         hr = IUnknown_QueryInterface(pUnk, &IID_ICorDebug, (void**)&pCorDebug);
85         todo_wine ok(hr == S_OK, "expected S_OK got %08x\n", hr);
86         if(hr == S_OK)
87         {
88             ICorDebug_Release(pCorDebug);
89         }
90         IUnknown_Release(pUnk);
91     }
92     else
93     {
94         skip(".NET 2.0 or mono not installed.\n");
95     }
96 }
97
98 START_TEST(debugging)
99 {
100     if (!init_functionpointers())
101         return;
102
103     test_createDebugger();
104
105     FreeLibrary(hmscoree);
106 }