[PATCH 3/3] wer/tests: Add initial tests for WerReportCreate + WerReportCloseHandle

Detlef Riekenberg wine.dev at web.de
Thu Oct 28 16:42:39 CDT 2010


--
By by ... Detlef
---
 dlls/wer/tests/Makefile.in |    3 +-
 dlls/wer/tests/report.c    |  137 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 139 insertions(+), 1 deletions(-)
 create mode 100644 dlls/wer/tests/report.c

diff --git a/dlls/wer/tests/Makefile.in b/dlls/wer/tests/Makefile.in
index 07ed264..a5cf79d 100644
--- a/dlls/wer/tests/Makefile.in
+++ b/dlls/wer/tests/Makefile.in
@@ -2,6 +2,7 @@ TESTDLL   = wer.dll
 IMPORTS   = wer
 
 C_SRCS = \
-	main.c
+	main.c \
+	report.c
 
 @MAKE_TEST_RULES@
diff --git a/dlls/wer/tests/report.c b/dlls/wer/tests/report.c
new file mode 100644
index 0000000..d83a4d8
--- /dev/null
+++ b/dlls/wer/tests/report.c
@@ -0,0 +1,137 @@
+/*
+ * 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 "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 WCHAR appcrash[] = {'A','P','P','C','R','A','S','H',0};
+
+/* ###### */
+
+static void  test_WerReportCloseHandle(void)
+{
+    HRESULT hr;
+    HREPORT report;
+
+    report = (void *) 0xdeadbeef;
+    hr = WerReportCreate(appcrash, WerReportCritical, NULL, &report);
+    todo_wine
+    ok(hr == S_OK, "got 0x%x and %p (expected S_OK)\n", hr, report);
+
+    if (!report) {
+        skip("Nothing left to test\n");
+        return;
+    }
+
+    /* close the handle */
+    hr = WerReportCloseHandle(report);
+    ok(hr == S_OK, "got 0x%x for %p (expected S_OK)\n", hr, report);
+
+    /* close the handle again */
+    hr = WerReportCloseHandle(report);
+    ok(hr == E_INVALIDARG, "got 0x%x for %p again (expected E_INVALIDARG)\n", hr, report);
+
+    hr = WerReportCloseHandle(NULL);
+    ok(hr == E_INVALIDARG, "got 0x%x for NULL(expected E_INVALIDARG)\n", hr);
+}
+
+
+static void  test_WerReportCreate(void)
+{
+    HRESULT hr;
+    HREPORT report;
+    HREPORT table[64];
+    int i;
+
+    report = (void *) 0xdeadbeef;
+    /* test a simple valid case */
+    hr = WerReportCreate(appcrash, WerReportCritical, NULL, &report);
+
+    todo_wine
+    ok(hr == S_OK, "got 0x%x and %p (expected S_OK)\n", hr, report);
+
+    if (!report) {
+        skip("Nothing left to test\n");
+        return;
+    }
+
+    hr = WerReportCloseHandle(report);
+    ok(hr == S_OK, "got 0x%x for %p (expected S_OK)\n", hr, report);
+
+    /* the ptr to store the created handle is always needed */
+    hr = WerReportCreate(appcrash, WerReportCritical, NULL, NULL);
+    ok(hr == E_INVALIDARG, "got 0x%x (expected E_INVALIDARG)\n", hr);
+
+    /* the event type must be a valid string */
+    report = (void *) 0xdeadbeef;
+    hr = WerReportCreate(NULL, WerReportCritical, NULL, &report);
+    ok(hr == E_INVALIDARG, "got 0x%x and %p(expected E_INVALIDARG)\n", hr, report);
+
+    report = (void *) 0xdeadbeef;
+    hr = WerReportCreate(empty, WerReportCritical, NULL, &report);
+    ok(hr == E_INVALIDARG, "got 0x%x and %p(expected E_INVALIDARG)\n", hr, report);
+
+    /* WER_REPORT_TYPE is not checked during WerReportCreate */
+    for (i = 0; i <= WerReportInvalid + 1; i++) {
+        report = (void *) 0xdeadbeef;
+        hr = WerReportCreate(appcrash, i, NULL, &report);
+        ok(hr == S_OK, "%d: got 0x%x and %p (expected S_OK)\n", i, hr, report);
+
+        hr = WerReportCloseHandle(report);
+        ok(hr == S_OK, "%d: got 0x%x for %p (expected S_OK)\n", i, hr, report);
+
+    }
+    report = (void *) 0xdeadbeef;
+    hr = WerReportCreate(appcrash, 42, NULL, &report);
+    ok(hr == S_OK, "42: got 0x%x and %p (expected S_OK)\n", hr, report);
+
+    /* multiple active reports are possible */
+    memset(table, 0, sizeof(table));
+    for (i = 0; i < (sizeof(table) / sizeof(table[0]) -1); i++) {
+        report = (void *) 0xdeadbeef;
+        hr = WerReportCreate(appcrash, WerReportCritical, NULL, &table[i]);
+        ok(hr == S_OK, "%02d: got 0x%x and %p (expected S_OK)\n", i, hr, table[i]);
+    }
+
+    while (i > 0) {
+        i--;
+        hr = WerReportCloseHandle(table[i]);
+        ok(hr == S_OK, "got 0x%x for %p (expected S_OK)\n", hr, table[i]);
+    }
+
+}
+
+/* ########################### */
+
+START_TEST(report)
+{
+    test_WerReportCloseHandle();
+    test_WerReportCreate();
+}
-- 
1.7.1




More information about the wine-patches mailing list