[PATCH 2/2] wer/tests: Add initial tests

Detlef Riekenberg wine.dev at web.de
Tue Oct 26 04:37:17 CDT 2010


---
 dlls/wer/Makefile.in       |    1 +
 dlls/wer/tests/Makefile.in |    7 +++
 dlls/wer/tests/main.c      |  110 ++++++++++++++++++++++++++++++++++++++++++++
 include/werapi.h           |    2 +
 4 files changed, 120 insertions(+), 0 deletions(-)
 create mode 100644 dlls/wer/tests/Makefile.in
 create mode 100644 dlls/wer/tests/main.c

diff --git a/dlls/wer/Makefile.in b/dlls/wer/Makefile.in
index 772182f..e90dcc0 100644
--- a/dlls/wer/Makefile.in
+++ b/dlls/wer/Makefile.in
@@ -1,4 +1,5 @@
 MODULE    = wer.dll
+IMPORTLIB = wer
 
 C_SRCS = \
 	main.c
diff --git a/dlls/wer/tests/Makefile.in b/dlls/wer/tests/Makefile.in
new file mode 100644
index 0000000..07ed264
--- /dev/null
+++ b/dlls/wer/tests/Makefile.in
@@ -0,0 +1,7 @@
+TESTDLL   = wer.dll
+IMPORTS   = wer
+
+C_SRCS = \
+	main.c
+
+ at MAKE_TEST_RULES@
diff --git a/dlls/wer/tests/main.c b/dlls/wer/tests/main.c
new file mode 100644
index 0000000..183974f
--- /dev/null
+++ b/dlls/wer/tests/main.c
@@ -0,0 +1,110 @@
+/*
+ * Unit test suite for windows error reporting in Vista and above
+ *
+ * Copyright 2010 Detlef Riekenberg
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ *
+ */
+
+#include <stdarg.h>
+#include <stdio.h>
+
+#include "windef.h"
+#include "winbase.h"
+#include "winerror.h"
+#include "winreg.h"
+
+#include "werapi.h"
+#include "wine/test.h"
+
+static const WCHAR empty[] = {0};
+static const WCHAR winetest_wer[] = {'w','i','n','e','t','e','s','t','_','w','e','r','.','e','x','e',0};
+
+/* ###### */
+
+static void test_WerAddExcludedApplication(void)
+{
+    HRESULT hr;
+
+    /* clean state */
+    hr = WerRemoveExcludedApplication(winetest_wer, FALSE);
+    if (hr == E_NOTIMPL) {
+        skip("Wer*ExcludedApplication not implemented\n");
+        return;
+    }
+    ok((hr == S_OK) || (hr == E_FAIL) || __HRESULT_FROM_WIN32(ERROR_ENVVAR_NOT_FOUND),
+        "got 0x%x (expected S_OK, E_FAIL or HRESULT_FROM_WIN32(ERROR_ENVVAR_NOT_FOUND))\n", hr);
+
+    hr = WerAddExcludedApplication(NULL, FALSE);
+    ok(hr == E_INVALIDARG, "got 0x%x (expected E_INVALIDARG)\n", hr);
+
+    hr = WerAddExcludedApplication(empty, FALSE);
+    ok(hr == E_INVALIDARG, "got 0x%x (expected E_INVALIDARG)\n", hr);
+
+    hr = WerAddExcludedApplication(winetest_wer, FALSE);
+    ok(hr == S_OK, "got 0x%x (expected S_OK)\n", hr);
+    /* app already in the list */
+    hr = WerAddExcludedApplication(winetest_wer, FALSE);
+    ok(hr == S_OK, "got 0x%x (expected S_OK)\n", hr);
+
+
+    /* cleanup */
+    hr = WerRemoveExcludedApplication(winetest_wer, FALSE);
+    ok(hr == S_OK, "got 0x%x (expected S_OK)\n", hr);
+}
+
+/* #### */
+
+static void test_WerRemoveExcludedApplication(void)
+{
+    HRESULT hr;
+
+    /* clean state */
+    hr = WerRemoveExcludedApplication(winetest_wer, FALSE);
+    if (hr == E_NOTIMPL) {
+        skip("Wer*ExcludedApplication not implemented\n");
+        return;
+    }
+
+    ok((hr == S_OK) || (hr == E_FAIL) || __HRESULT_FROM_WIN32(ERROR_ENVVAR_NOT_FOUND),
+        "got 0x%x (expected S_OK, E_FAIL or HRESULT_FROM_WIN32(ERROR_ENVVAR_NOT_FOUND))\n", hr);
+
+    hr = WerAddExcludedApplication(winetest_wer, FALSE);
+    ok(hr == S_OK, "got 0x%x (expected S_OK)\n", hr);
+
+    hr = WerRemoveExcludedApplication(NULL, FALSE);
+    ok(hr == E_INVALIDARG, "got 0x%x (expected E_INVALIDARG)\n", hr);
+
+    hr = WerRemoveExcludedApplication(empty, FALSE);
+    ok(hr == E_INVALIDARG, "got 0x%x (expected E_INVALIDARG)\n", hr);
+
+    hr = WerRemoveExcludedApplication(winetest_wer, FALSE);
+    ok(hr == S_OK, "got 0x%x (expected S_OK)\n", hr);
+
+    /* app not in the list */
+    hr = WerRemoveExcludedApplication(winetest_wer, FALSE);
+    ok((hr == E_FAIL) || __HRESULT_FROM_WIN32(ERROR_ENVVAR_NOT_FOUND),
+        "got 0x%x (expected E_FAIL or HRESULT_FROM_WIN32(ERROR_ENVVAR_NOT_FOUND))\n", hr);
+
+}
+
+/* ########################### */
+
+START_TEST(main)
+{
+    test_WerAddExcludedApplication();
+    test_WerRemoveExcludedApplication();
+}
diff --git a/include/werapi.h b/include/werapi.h
index 7ac03f3..54616db 100644
--- a/include/werapi.h
+++ b/include/werapi.h
@@ -32,7 +32,9 @@ typedef enum _WER_REGISTER_FILE_TYPE
     WerRegFileTypeMax
 } WER_REGISTER_FILE_TYPE;
 
+HRESULT WINAPI WerAddExcludedApplication(PCWSTR, BOOL);
 HRESULT WINAPI WerRegisterFile(PCWSTR file, WER_REGISTER_FILE_TYPE regfiletype, DWORD flags);
+HRESULT WINAPI WerRemoveExcludedApplication(PCWSTR, BOOL);
 
 #ifdef __cplusplus
 }
-- 
1.7.1




More information about the wine-patches mailing list