include/mscvpdb.h: Use flexible array members for the rest of structures.
[wine.git] / dlls / faultrep / tests / faultrep.c
blob83acd34a6d4b8fe511c4542b19e6aaf3fa2a1a57
1 /*
2 * Unit test suite for fault reporting in XP and above
4 * Copyright 2010 Detlef Riekenberg
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include <stdarg.h>
23 #include <stdio.h>
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winerror.h"
28 #include "winreg.h"
30 #include "errorrep.h"
31 #include "wine/test.h"
33 static const char regpath_root[] = "Software\\Microsoft\\PCHealth\\ErrorReporting";
34 static const char regpath_exclude[] = "ExclusionList";
37 static BOOL is_process_limited(void)
39 HANDLE token;
40 TOKEN_ELEVATION_TYPE type = TokenElevationTypeDefault;
41 DWORD size;
43 OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token);
44 GetTokenInformation(token, TokenElevationType, &type, sizeof(type), &size);
45 CloseHandle(token);
47 return type == TokenElevationTypeLimited;
50 static BOOL is_registry_virtualization_enabled(void)
52 HANDLE token;
53 DWORD enabled = FALSE;
54 DWORD size;
56 OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token);
57 GetTokenInformation(token, TokenVirtualizationEnabled, &enabled, sizeof(enabled), &size);
58 CloseHandle(token);
60 return enabled;
64 /* ###### */
66 static void test_AddERExcludedApplicationA(void)
68 BOOL res;
69 LONG lres;
70 HKEY hroot;
71 HKEY hexclude = 0;
73 /* clean state */
74 lres = RegCreateKeyA(HKEY_LOCAL_MACHINE, regpath_root, &hroot);
76 if (!lres)
77 lres = RegOpenKeyA(hroot, regpath_exclude, &hexclude);
79 if (!lres)
80 RegDeleteValueA(hexclude, "winetest_faultrep.exe");
83 SetLastError(0xdeadbeef);
84 res = AddERExcludedApplicationA(NULL);
85 ok(!res, "got %d and 0x%lx (expected FALSE)\n", res, GetLastError());
87 SetLastError(0xdeadbeef);
88 res = AddERExcludedApplicationA("");
89 ok(!res, "got %d and 0x%lx (expected FALSE)\n", res, GetLastError());
91 SetLastError(0xdeadbeef);
92 /* existence of the path doesn't matter this function succeeded */
93 res = AddERExcludedApplicationA("winetest_faultrep.exe");
94 if (is_process_limited())
96 /* LastError is not set! */
97 ok(!res || broken(is_registry_virtualization_enabled()) /* win8 */,
98 "AddERExcludedApplicationA should have failed, got %d\n", res);
100 else
102 ok(res, "AddERExcludedApplicationA failed (le=0x%lx)\n", GetLastError());
104 /* add, when already present */
105 SetLastError(0xdeadbeef);
106 res = AddERExcludedApplicationA("winetest_faultrep.exe");
107 ok(res, "AddERExcludedApplicationA failed (le=0x%lx)\n", GetLastError());
110 /* cleanup */
111 RegDeleteValueA(hexclude, "winetest_faultrep.exe");
113 RegCloseKey(hexclude);
114 RegCloseKey(hroot);
117 /* ########################### */
119 START_TEST(faultrep)
121 test_AddERExcludedApplicationA();