Release 1.5.29.
[wine] / dlls / faultrep / tests / faultrep.c
1 /*
2  * Unit test suite for fault reporting in XP and above
3  *
4  * Copyright 2010 Detlef Riekenberg
5  *
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.
10  *
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.
15  *
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
19  *
20  */
21
22 #include <stdarg.h>
23 #include <stdio.h>
24
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winerror.h"
28 #include "winreg.h"
29
30 #include "errorrep.h"
31 #include "wine/test.h"
32
33 static char regpath_root[] = "Software\\Microsoft\\PCHealth\\ErrorReporting";
34 static char regpath_exclude[] = "ExclusionList";
35
36 /* ###### */
37
38 static void test_AddERExcludedApplicationA(void)
39 {
40     BOOL res;
41     LONG lres;
42     HKEY hroot;
43     HKEY hexclude = 0;
44
45     /* clean state */
46     lres = RegOpenKeyExA(HKEY_LOCAL_MACHINE, regpath_root, 0, KEY_WRITE, &hroot);
47
48     if (!lres)
49         lres = RegOpenKeyA(hroot, regpath_exclude, &hexclude);
50
51     if (!lres)
52         RegDeleteValueA(hexclude, "winetest_faultrep.exe");
53
54
55     SetLastError(0xdeadbeef);
56     res = AddERExcludedApplicationA(NULL);
57     ok(!res, "got %d and 0x%x (expected FALSE)\n", res, GetLastError());
58
59     SetLastError(0xdeadbeef);
60     res = AddERExcludedApplicationA("");
61     ok(!res, "got %d and 0x%x (expected FALSE)\n", res, GetLastError());
62
63     SetLastError(0xdeadbeef);
64     /* access rights to HKLM or existence of the path doesn't matter
65        this function succeeded */
66     res = AddERExcludedApplicationA("winetest_faultrep.exe");
67     ok(res, "got %d and 0x%x (expected TRUE)\n", res, GetLastError());
68
69     /* add, when already present */
70     SetLastError(0xdeadbeef);
71     res = AddERExcludedApplicationA("winetest_faultrep.exe");
72     ok(res, "got %d and 0x%x (expected TRUE)\n", res, GetLastError());
73
74     /* cleanup */
75     RegDeleteValueA(hexclude, "winetest_faultrep.exe");
76
77     RegCloseKey(hexclude);
78     RegCloseKey(hroot);
79 }
80
81 /* ########################### */
82
83 START_TEST(faultrep)
84 {
85     test_AddERExcludedApplicationA();
86 }