- Sync wine tests with Wine 1.1.21
[reactos.git] / rostests / winetests / fusion / asmenum.c
1 /*
2 * Copyright 2008 James Hawkins
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 <stdio.h>
22
23 #include <windows.h>
24 #include <shlwapi.h>
25 #include <mscoree.h>
26 #include <fusion.h>
27 #include <corerror.h>
28
29 #include "wine/test.h"
30 #include "wine/list.h"
31
32 static HRESULT (WINAPI *pCreateAssemblyEnum)(IAssemblyEnum **pEnum,
33 IUnknown *pUnkReserved,
34 IAssemblyName *pName,
35 DWORD dwFlags, LPVOID pvReserved);
36 static HRESULT (WINAPI *pCreateAssemblyNameObject)(LPASSEMBLYNAME *ppAssemblyNameObj,
37 LPCWSTR szAssemblyName, DWORD dwFlags,
38 LPVOID pvReserved);
39 static HRESULT (WINAPI *pGetCachePath)(ASM_CACHE_FLAGS dwCacheFlags,
40 LPWSTR pwzCachePath, PDWORD pcchPath);
41 static HRESULT (WINAPI *pLoadLibraryShim)(LPCWSTR szDllName, LPCWSTR szVersion,
42 LPVOID pvReserved, HMODULE *phModDll);
43
44 static BOOL init_functionpointers(void)
45 {
46 HRESULT hr;
47 HMODULE hfusion;
48 HMODULE hmscoree;
49
50 static const WCHAR szFusion[] = {'f','u','s','i','o','n','.','d','l','l',0};
51
52 hmscoree = LoadLibraryA("mscoree.dll");
53 if (!hmscoree)
54 {
55 win_skip("mscoree.dll not available\n");
56 return FALSE;
57 }
58
59 pLoadLibraryShim = (void *)GetProcAddress(hmscoree, "LoadLibraryShim");
60 if (!pLoadLibraryShim)
61 {
62 win_skip("LoadLibraryShim not available\n");
63 FreeLibrary(hmscoree);
64 return FALSE;
65 }
66
67 hr = pLoadLibraryShim(szFusion, NULL, NULL, &hfusion);
68 if (FAILED(hr))
69 {
70 win_skip("fusion.dll not available\n");
71 FreeLibrary(hmscoree);
72 return FALSE;
73 }
74
75 pCreateAssemblyEnum = (void *)GetProcAddress(hfusion, "CreateAssemblyEnum");
76 pCreateAssemblyNameObject = (void *)GetProcAddress(hfusion, "CreateAssemblyNameObject");
77 pGetCachePath = (void *)GetProcAddress(hfusion, "GetCachePath");
78
79 if (!pCreateAssemblyEnum ||
80 !pCreateAssemblyNameObject || !pGetCachePath)
81 {
82 win_skip("fusion.dll not implemented\n");
83 return FALSE;
84 }
85
86 FreeLibrary(hmscoree);
87 return TRUE;
88 }
89
90 static inline void to_widechar(LPWSTR dest, LPCSTR src)
91 {
92 MultiByteToWideChar(CP_ACP, 0, src, -1, dest, MAX_PATH);
93 }
94
95 static inline void to_multibyte(LPSTR dest, LPWSTR src)
96 {
97 WideCharToMultiByte(CP_ACP, 0, src, -1, dest, MAX_PATH, NULL, NULL);
98 }
99
100 static BOOL create_full_path(LPCSTR path)
101 {
102 LPSTR new_path;
103 BOOL ret = TRUE;
104 int len;
105
106 new_path = HeapAlloc(GetProcessHeap(), 0, lstrlenA(path) + 1);
107 if (!new_path)
108 return FALSE;
109
110 lstrcpyA(new_path, path);
111
112 while ((len = lstrlenA(new_path)) && new_path[len - 1] == '\\')
113 new_path[len - 1] = 0;
114
115 while (!CreateDirectoryA(new_path, NULL))
116 {
117 LPSTR slash;
118 DWORD last_error = GetLastError();
119
120 if(last_error == ERROR_ALREADY_EXISTS)
121 break;
122
123 if(last_error != ERROR_PATH_NOT_FOUND)
124 {
125 ret = FALSE;
126 break;
127 }
128
129 if(!(slash = strrchr(new_path, '\\')))
130 {
131 ret = FALSE;
132 break;
133 }
134
135 len = slash - new_path;
136 new_path[len] = 0;
137 if(!create_full_path(new_path))
138 {
139 ret = FALSE;
140 break;
141 }
142
143 new_path[len] = '\\';
144 }
145
146 HeapFree(GetProcessHeap(), 0, new_path);
147 return ret;
148 }
149
150 static void create_file_data(LPCSTR name, LPCSTR data, DWORD size)
151 {
152 HANDLE file;
153 DWORD written;
154
155 file = CreateFileA(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
156 ok(file != INVALID_HANDLE_VALUE, "Failure to open file %s\n", name);
157 WriteFile(file, data, strlen(data), &written, NULL);
158
159 if (size)
160 {
161 SetFilePointer(file, size, NULL, FILE_BEGIN);
162 SetEndOfFile(file);
163 }
164
165 CloseHandle(file);
166 }
167
168 #define create_file(name, size) create_file_data(name, name, size)
169
170 static void test_CreateAssemblyEnum(void)
171 {
172 HRESULT hr;
173 WCHAR namestr[MAX_PATH];
174 IAssemblyEnum *asmenum;
175 IAssemblyName *asmname;
176
177 to_widechar(namestr, "wine");
178 asmname = NULL;
179 hr = pCreateAssemblyNameObject(&asmname, namestr, CANOF_PARSE_DISPLAY_NAME, NULL);
180 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
181 ok(asmname != NULL, "Expected non-NULL asmname\n");
182
183 /* pEnum is NULL */
184 if (0)
185 {
186 /* Crashes on .NET 1.x */
187 hr = pCreateAssemblyEnum(NULL, NULL, asmname, ASM_CACHE_GAC, NULL);
188 ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", hr);
189 }
190
191 /* pName is NULL */
192 asmenum = NULL;
193 hr = pCreateAssemblyEnum(&asmenum, NULL, NULL, ASM_CACHE_GAC, NULL);
194 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
195 ok(asmenum != NULL, "Expected non-NULL asmenum\n");
196
197 IAssemblyEnum_Release(asmenum);
198
199 /* dwFlags is ASM_CACHE_ROOT */
200 asmenum = (IAssemblyEnum *)0xdeadbeef;
201 hr = pCreateAssemblyEnum(&asmenum, NULL, NULL, ASM_CACHE_ROOT, NULL);
202 ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", hr);
203 ok(asmenum == (IAssemblyEnum *)0xdeadbeef,
204 "Expected asmenum to be unchanged, got %p\n", asmenum);
205
206 /* invalid dwFlags */
207 asmenum = (IAssemblyEnum *)0xdeadbeef;
208 hr = pCreateAssemblyEnum(&asmenum, NULL, NULL, 0, NULL);
209 ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", hr);
210 ok(asmenum == (IAssemblyEnum *)0xdeadbeef,
211 "Expected asmenum to be unchanged, got %p\n", asmenum);
212 }
213
214 typedef struct _tagASMNAME
215 {
216 struct list entry;
217 LPSTR data;
218 } ASMNAME;
219
220 static BOOL enum_gac_assemblies(struct list *assemblies, int depth, LPSTR path)
221 {
222 WIN32_FIND_DATAA ffd;
223 CHAR buf[MAX_PATH];
224 CHAR disp[MAX_PATH];
225 ASMNAME *name;
226 HANDLE hfind;
227 LPSTR ptr;
228
229 static CHAR parent[MAX_PATH];
230
231 sprintf(buf, "%s\\*", path);
232 hfind = FindFirstFileA(buf, &ffd);
233 if (hfind == INVALID_HANDLE_VALUE)
234 return FALSE;
235
236 do
237 {
238 if (!lstrcmpA(ffd.cFileName, ".") || !lstrcmpA(ffd.cFileName, ".."))
239 continue;
240
241 if (depth == 0)
242 {
243 lstrcpyA(parent, ffd.cFileName);
244 }
245 else if (depth == 1)
246 {
247 char culture[MAX_PATH];
248 char dll[MAX_PATH], exe[MAX_PATH];
249
250 /* Directories with no dll or exe will not be enumerated */
251 sprintf(dll, "%s\\%s\\%s.dll", path, ffd.cFileName, parent);
252 sprintf(exe, "%s\\%s\\%s.exe", path, ffd.cFileName, parent);
253 if (GetFileAttributesA(dll) == INVALID_FILE_ATTRIBUTES &&
254 GetFileAttributesA(exe) == INVALID_FILE_ATTRIBUTES)
255 continue;
256
257 ptr = strstr(ffd.cFileName, "_");
258 *ptr = '\0';
259 ptr++;
260
261 if (*ptr != '_')
262 {
263 lstrcpyA(culture, ptr);
264 *strstr(culture, "_") = '\0';
265 }
266 else
267 lstrcpyA(culture, "neutral");
268
269 ptr = strchr(ptr, '_');
270 ptr++;
271 sprintf(buf, ", Version=%s, Culture=%s, PublicKeyToken=%s",
272 ffd.cFileName, culture, ptr);
273 lstrcpyA(disp, parent);
274 lstrcatA(disp, buf);
275
276 name = HeapAlloc(GetProcessHeap(), 0, sizeof(ASMNAME));
277 name->data = HeapAlloc(GetProcessHeap(), 0, lstrlenA(disp) + 1);
278 lstrcpyA(name->data, disp);
279 list_add_tail(assemblies, &name->entry);
280
281 continue;
282 }
283
284 sprintf(buf, "%s\\%s", path, ffd.cFileName);
285 enum_gac_assemblies(assemblies, depth + 1, buf);
286 } while (FindNextFileA(hfind, &ffd) != 0);
287
288 FindClose(hfind);
289 return TRUE;
290 }
291
292 static void test_enumerate(void)
293 {
294 struct list assemblies = LIST_INIT(assemblies);
295 struct list *item, *cursor;
296 IAssemblyEnum *asmenum;
297 IAssemblyName *next;
298 WCHAR buf[MAX_PATH];
299 CHAR path[MAX_PATH];
300 CHAR disp[MAX_PATH];
301 HRESULT hr;
302 BOOL found;
303 DWORD size;
304
305 size = MAX_PATH;
306 hr = pGetCachePath(ASM_CACHE_GAC, buf, &size);
307 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
308
309 to_multibyte(path, buf);
310 lstrcatA(path, "_32");
311 enum_gac_assemblies(&assemblies, 0, path);
312
313 to_multibyte(path, buf);
314 lstrcatA(path, "_64");
315 enum_gac_assemblies(&assemblies, 0, path);
316
317 to_multibyte(path, buf);
318 lstrcatA(path, "_MSIL");
319 enum_gac_assemblies(&assemblies, 0, path);
320
321 to_multibyte(path, buf);
322 enum_gac_assemblies(&assemblies, 0, path);
323
324 asmenum = NULL;
325 hr = pCreateAssemblyEnum(&asmenum, NULL, NULL, ASM_CACHE_GAC, NULL);
326 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
327 ok(asmenum != NULL, "Expected non-NULL asmenum\n");
328
329 while (IAssemblyEnum_GetNextAssembly(asmenum, NULL, &next, 0) == S_OK)
330 {
331 size = MAX_PATH;
332 IAssemblyName_GetDisplayName(next, buf, &size, 0);
333 to_multibyte(disp, buf);
334
335 found = FALSE;
336 LIST_FOR_EACH_SAFE(item, cursor, &assemblies)
337 {
338 ASMNAME *asmname = LIST_ENTRY(item, ASMNAME, entry);
339
340 if (!lstrcmpA(asmname->data, disp))
341 {
342 found = TRUE;
343
344 list_remove(&asmname->entry);
345 HeapFree(GetProcessHeap(), 0, asmname->data);
346 HeapFree(GetProcessHeap(), 0, asmname);
347 break;
348 }
349 }
350
351 ok(found, "Extra assembly enumerated: %s\n", disp);
352 IAssemblyName_Release(next);
353 }
354
355 /* enumeration is exhausted */
356 next = (IAssemblyName *)0xdeadbeef;
357 hr = IAssemblyEnum_GetNextAssembly(asmenum, NULL, &next, 0);
358 ok(hr == S_FALSE, "Expected S_FALSE, got %08x\n", hr);
359 ok(next == (IAssemblyName *)0xdeadbeef,
360 "Expected next to be unchanged, got %p\n", next);
361
362 LIST_FOR_EACH_SAFE(item, cursor, &assemblies)
363 {
364 ASMNAME *asmname = LIST_ENTRY(item, ASMNAME, entry);
365
366 ok(FALSE, "Assembly not enumerated: %s\n", asmname->data);
367
368 list_remove(&asmname->entry);
369 HeapFree(GetProcessHeap(), 0, asmname->data);
370 HeapFree(GetProcessHeap(), 0, asmname);
371 }
372
373 IAssemblyEnum_Release(asmenum);
374 }
375
376 static void test_enumerate_name(void)
377 {
378 IAssemblyEnum *asmenum;
379 IAssemblyName *asmname, *next;
380 WCHAR buf[MAX_PATH];
381 CHAR gac[MAX_PATH];
382 CHAR path[MAX_PATH];
383 CHAR disp[MAX_PATH];
384 WCHAR namestr[MAX_PATH];
385 CHAR exp[6][MAX_PATH];
386 HRESULT hr;
387 DWORD size;
388
389 lstrcpyA(exp[0], "wine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=16a3fcd171e93a8d");
390 lstrcpyA(exp[1], "wine, Version=1.0.1.2, Culture=neutral, PublicKeyToken=123456789abcdef0");
391 lstrcpyA(exp[2], "wine, Version=1.0.1.2, Culture=neutral, PublicKeyToken=16a3fcd171e93a8d");
392 lstrcpyA(exp[3], "Wine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=16a3fcd171e93a8d");
393 lstrcpyA(exp[4], "Wine, Version=1.0.1.2, Culture=neutral, PublicKeyToken=123456789abcdef0");
394 lstrcpyA(exp[5], "Wine, Version=1.0.1.2, Culture=neutral, PublicKeyToken=16a3fcd171e93a8d");
395
396 size = MAX_PATH;
397 hr = pGetCachePath(ASM_CACHE_GAC, buf, &size);
398 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
399
400 to_multibyte(gac, buf);
401 create_full_path(gac);
402
403 sprintf(path, "%s\\Wine", gac);
404 CreateDirectoryA(path, NULL);
405
406 sprintf(path, "%s\\Wine\\1.0.0.0__16a3fcd171e93a8d", gac);
407 CreateDirectoryA(path, NULL);
408
409 lstrcatA(path, "\\Wine.dll");
410 create_file(path, 100);
411
412 sprintf(path, "%s\\Wine\\1.0.1.2__16a3fcd171e93a8d", gac);
413 CreateDirectoryA(path, NULL);
414
415 lstrcatA(path, "\\Wine.dll");
416 create_file(path, 100);
417
418 sprintf(path, "%s\\Wine\\1.0.1.2__123456789abcdef0", gac);
419 CreateDirectoryA(path, NULL);
420
421 lstrcatA(path, "\\Wine.dll");
422 create_file(path, 100);
423
424 /* test case sensitivity */
425 to_widechar(namestr, "wine");
426 asmname = NULL;
427 hr = pCreateAssemblyNameObject(&asmname, namestr, CANOF_PARSE_DISPLAY_NAME, NULL);
428 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
429 ok(asmname != NULL, "Expected non-NULL asmname\n");
430
431 asmenum = NULL;
432 hr = pCreateAssemblyEnum(&asmenum, NULL, asmname, ASM_CACHE_GAC, NULL);
433 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
434 ok(asmenum != NULL, "Expected non-NULL asmenum\n");
435
436 next = NULL;
437 hr = IAssemblyEnum_GetNextAssembly(asmenum, NULL, &next, 0);
438 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
439 ok(next != NULL, "Expected non-NULL next\n");
440
441 size = MAX_PATH;
442 hr = IAssemblyName_GetDisplayName(next, buf, &size, 0);
443 to_multibyte(disp, buf);
444 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
445 ok(!lstrcmpA(disp, exp[0]),
446 "Expected \"%s\" or \"%s\", got \"%s\"\n", exp[0], exp[1], disp);
447
448 IAssemblyName_Release(next);
449
450 next = NULL;
451 hr = IAssemblyEnum_GetNextAssembly(asmenum, NULL, &next, 0);
452 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
453 ok(next != NULL, "Expected non-NULL next\n");
454
455 size = MAX_PATH;
456 hr = IAssemblyName_GetDisplayName(next, buf, &size, 0);
457 to_multibyte(disp, buf);
458 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
459 ok(!lstrcmpA(disp, exp[1]) ||
460 !lstrcmpA(disp, exp[2]), /* Win98 */
461 "Expected \"%s\" or \"%s\", got \"%s\"\n", exp[1], exp[2], disp);
462
463 IAssemblyName_Release(next);
464
465 next = NULL;
466 hr = IAssemblyEnum_GetNextAssembly(asmenum, NULL, &next, 0);
467 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
468 ok(next != NULL, "Expected non-NULL next\n");
469
470 size = MAX_PATH;
471 hr = IAssemblyName_GetDisplayName(next, buf, &size, 0);
472 to_multibyte(disp, buf);
473 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
474 ok(!lstrcmpA(disp, exp[2]) ||
475 !lstrcmpA(disp, exp[1]), /* Win98 */
476 "Expected \"%s\" or \"%s\", got \"%s\"\n", exp[2], exp[1], disp);
477
478 IAssemblyName_Release(next);
479
480 next = (IAssemblyName *)0xdeadbeef;
481 hr = IAssemblyEnum_GetNextAssembly(asmenum, NULL, &next, 0);
482 ok(hr == S_FALSE, "Expected S_FALSE, got %08x\n", hr);
483 ok(next == (IAssemblyName *)0xdeadbeef,
484 "Expected next to be unchanged, got %p\n", next);
485
486 IAssemblyEnum_Release(asmenum);
487 IAssemblyName_Release(asmname);
488
489 /* only Version */
490 to_widechar(namestr, "Wine, Version=1.0.1.2");
491 asmname = NULL;
492 hr = pCreateAssemblyNameObject(&asmname, namestr, CANOF_PARSE_DISPLAY_NAME, NULL);
493 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
494 ok(asmname != NULL, "Expected non-NULL asmname\n");
495
496 asmenum = NULL;
497 hr = pCreateAssemblyEnum(&asmenum, NULL, asmname, ASM_CACHE_GAC, NULL);
498 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
499 ok(asmenum != NULL, "Expected non-NULL asmenum\n");
500
501 next = NULL;
502 hr = IAssemblyEnum_GetNextAssembly(asmenum, NULL, &next, 0);
503 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
504 ok(next != NULL, "Expected non-NULL next\n");
505
506 size = MAX_PATH;
507 hr = IAssemblyName_GetDisplayName(next, buf, &size, 0);
508 to_multibyte(disp, buf);
509 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
510 ok(!lstrcmpA(disp, exp[4]) ||
511 !lstrcmpA(disp, exp[5]), /* Win98 */
512 "Expected \"%s\" or \"%s\", got \"%s\"\n", exp[4], exp[5], disp);
513
514 IAssemblyName_Release(next);
515
516 next = NULL;
517 hr = IAssemblyEnum_GetNextAssembly(asmenum, NULL, &next, 0);
518 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
519 ok(next != NULL, "Expected non-NULL next\n");
520
521 size = MAX_PATH;
522 hr = IAssemblyName_GetDisplayName(next, buf, &size, 0);
523 to_multibyte(disp, buf);
524 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
525 ok(!lstrcmpA(disp, exp[5]) ||
526 !lstrcmpA(disp, exp[4]), /* Win98 */
527 "Expected \"%s\" or \"%s\", got \"%s\"\n", exp[5], exp[4], disp);
528
529 IAssemblyName_Release(next);
530
531 next = (IAssemblyName *)0xdeadbeef;
532 hr = IAssemblyEnum_GetNextAssembly(asmenum, NULL, &next, 0);
533 ok(hr == S_FALSE, "Expected S_FALSE, got %08x\n", hr);
534 ok(next == (IAssemblyName *)0xdeadbeef,
535 "Expected next to be unchanged, got %p\n", next);
536
537 IAssemblyEnum_Release(asmenum);
538 IAssemblyName_Release(asmname);
539
540 /* only PublicKeyToken */
541 to_widechar(namestr, "Wine, PublicKeyToken=16a3fcd171e93a8d");
542 asmname = NULL;
543 hr = pCreateAssemblyNameObject(&asmname, namestr, CANOF_PARSE_DISPLAY_NAME, NULL);
544 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
545 ok(asmname != NULL, "Expected non-NULL asmname\n");
546
547 asmenum = NULL;
548 hr = pCreateAssemblyEnum(&asmenum, NULL, asmname, ASM_CACHE_GAC, NULL);
549 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
550 ok(asmenum != NULL, "Expected non-NULL asmenum\n");
551
552 next = NULL;
553 hr = IAssemblyEnum_GetNextAssembly(asmenum, NULL, &next, 0);
554 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
555 ok(next != NULL, "Expected non-NULL next\n");
556
557 size = MAX_PATH;
558 hr = IAssemblyName_GetDisplayName(next, buf, &size, 0);
559 to_multibyte(disp, buf);
560 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
561 ok(!lstrcmpA(disp, exp[3]), "Expected \"%s\", got \"%s\"\n", exp[3], disp);
562
563 IAssemblyName_Release(next);
564
565 next = NULL;
566 hr = IAssemblyEnum_GetNextAssembly(asmenum, NULL, &next, 0);
567 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
568 ok(next != NULL, "Expected non-NULL next\n");
569
570 size = MAX_PATH;
571 hr = IAssemblyName_GetDisplayName(next, buf, &size, 0);
572 to_multibyte(disp, buf);
573 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
574 ok(!lstrcmpA(disp, exp[5]), "Expected \"%s\", got \"%s\"\n", exp[5], disp);
575
576 IAssemblyName_Release(next);
577
578 next = (IAssemblyName *)0xdeadbeef;
579 hr = IAssemblyEnum_GetNextAssembly(asmenum, NULL, &next, 0);
580 ok(hr == S_FALSE, "Expected S_FALSE, got %08x\n", hr);
581 ok(next == (IAssemblyName *)0xdeadbeef,
582 "Expected next to be unchanged, got %p\n", next);
583
584 IAssemblyEnum_Release(asmenum);
585 IAssemblyName_Release(asmname);
586
587 /* only Culture */
588 to_widechar(namestr, "wine, Culture=neutral");
589 asmname = NULL;
590 hr = pCreateAssemblyNameObject(&asmname, namestr, CANOF_PARSE_DISPLAY_NAME, NULL);
591 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
592 ok(asmname != NULL, "Expected non-NULL asmname\n");
593
594 asmenum = NULL;
595 hr = pCreateAssemblyEnum(&asmenum, NULL, asmname, ASM_CACHE_GAC, NULL);
596 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
597 ok(asmenum != NULL, "Expected non-NULL asmenum\n");
598
599 next = NULL;
600 hr = IAssemblyEnum_GetNextAssembly(asmenum, NULL, &next, 0);
601 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
602 ok(next != NULL, "Expected non-NULL next\n");
603
604 size = MAX_PATH;
605 hr = IAssemblyName_GetDisplayName(next, buf, &size, 0);
606 to_multibyte(disp, buf);
607 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
608 ok(!lstrcmpA(disp, exp[0]), "Expected \"%s\", got \"%s\"\n", exp[0], disp);
609
610 IAssemblyName_Release(next);
611
612 next = NULL;
613 hr = IAssemblyEnum_GetNextAssembly(asmenum, NULL, &next, 0);
614 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
615 ok(next != NULL, "Expected non-NULL next\n");
616
617 size = MAX_PATH;
618 hr = IAssemblyName_GetDisplayName(next, buf, &size, 0);
619 to_multibyte(disp, buf);
620 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
621 ok(!lstrcmpA(disp, exp[1]) ||
622 !lstrcmpA(disp, exp[2]), /* Win98 */
623 "Expected \"%s\" or \"%s\", got \"%s\"\n", exp[1], exp[2], disp);
624
625 IAssemblyName_Release(next);
626
627 next = NULL;
628 hr = IAssemblyEnum_GetNextAssembly(asmenum, NULL, &next, 0);
629 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
630 ok(next != NULL, "Expected non-NULL next\n");
631
632 size = MAX_PATH;
633 hr = IAssemblyName_GetDisplayName(next, buf, &size, 0);
634 to_multibyte(disp, buf);
635 ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
636 ok(!lstrcmpA(disp, exp[2]) ||
637 !lstrcmpA(disp, exp[1]), /* Win98 */
638 "Expected \"%s\" or \"%s\", got \"%s\"\n", exp[2], exp[1], disp);
639
640 IAssemblyName_Release(next);
641
642 next = (IAssemblyName *)0xdeadbeef;
643 hr = IAssemblyEnum_GetNextAssembly(asmenum, NULL, &next, 0);
644 ok(hr == S_FALSE, "Expected S_FALSE, got %08x\n", hr);
645 ok(next == (IAssemblyName *)0xdeadbeef,
646 "Expected next to be unchanged, got %p\n", next);
647
648 IAssemblyEnum_Release(asmenum);
649 IAssemblyName_Release(asmname);
650
651 sprintf(path, "%s\\Wine\\1.0.0.0__16a3fcd171e93a8d\\Wine.dll", gac);
652 DeleteFileA(path);
653 sprintf(path, "%s\\Wine\\1.0.1.2__16a3fcd171e93a8d\\Wine.dll", gac);
654 DeleteFileA(path);
655 sprintf(path, "%s\\Wine\\1.0.1.2__123456789abcdef0\\Wine.dll", gac);
656 DeleteFileA(path);
657 sprintf(path, "%s\\Wine\\1.0.0.0__16a3fcd171e93a8d", gac);
658 RemoveDirectoryA(path);
659 sprintf(path, "%s\\Wine\\1.0.1.2__16a3fcd171e93a8d", gac);
660 RemoveDirectoryA(path);
661 sprintf(path, "%s\\Wine\\1.0.1.2__123456789abcdef0", gac);
662 RemoveDirectoryA(path);
663 sprintf(path, "%s\\Wine", gac);
664 RemoveDirectoryA(path);
665 }
666
667 START_TEST(asmenum)
668 {
669 if (!init_functionpointers())
670 return;
671
672 test_CreateAssemblyEnum();
673 test_enumerate();
674 test_enumerate_name();
675 }