Dmitry Timoshkov : wevtapi/tests: Add some EvtGetChannelConfigProperty() tests.

Alexandre Julliard julliard at winehq.org
Wed Feb 3 15:39:28 CST 2021


Module: wine
Branch: master
Commit: 29eb6f51f74e896d676b96c35b6fde4c39fb49c2
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=29eb6f51f74e896d676b96c35b6fde4c39fb49c2

Author: Dmitry Timoshkov <dmitry at baikal.ru>
Date:   Wed Feb  3 11:11:35 2021 +0300

wevtapi/tests: Add some EvtGetChannelConfigProperty() tests.

Signed-off-by: Dmitry Timoshkov <dmitry at baikal.ru>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 configure                      |  1 +
 configure.ac                   |  1 +
 dlls/wevtapi/Makefile.in       |  1 +
 dlls/wevtapi/tests/Makefile.in |  5 +++
 dlls/wevtapi/tests/wevtapi.c   | 74 ++++++++++++++++++++++++++++++++++++++++++
 include/winevt.h               |  1 +
 6 files changed, 83 insertions(+)

diff --git a/configure b/configure
index fa0d6b0c15f..3fc223096ec 100755
--- a/configure
+++ b/configure
@@ -20831,6 +20831,7 @@ wine_fn_config_makefile dlls/webservices/tests enable_tests
 wine_fn_config_makefile dlls/wer enable_wer
 wine_fn_config_makefile dlls/wer/tests enable_tests
 wine_fn_config_makefile dlls/wevtapi enable_wevtapi
+wine_fn_config_makefile dlls/wevtapi/tests enable_tests
 wine_fn_config_makefile dlls/wevtsvc enable_wevtsvc
 wine_fn_config_makefile dlls/wiaservc enable_wiaservc
 wine_fn_config_makefile dlls/wiaservc/tests enable_tests
diff --git a/configure.ac b/configure.ac
index a9003523700..3a0bc6e713a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3756,6 +3756,7 @@ WINE_CONFIG_MAKEFILE(dlls/webservices/tests)
 WINE_CONFIG_MAKEFILE(dlls/wer)
 WINE_CONFIG_MAKEFILE(dlls/wer/tests)
 WINE_CONFIG_MAKEFILE(dlls/wevtapi)
+WINE_CONFIG_MAKEFILE(dlls/wevtapi/tests)
 WINE_CONFIG_MAKEFILE(dlls/wevtsvc)
 WINE_CONFIG_MAKEFILE(dlls/wiaservc)
 WINE_CONFIG_MAKEFILE(dlls/wiaservc/tests)
diff --git a/dlls/wevtapi/Makefile.in b/dlls/wevtapi/Makefile.in
index 9b742fe9aeb..c80aac26d3a 100644
--- a/dlls/wevtapi/Makefile.in
+++ b/dlls/wevtapi/Makefile.in
@@ -1,4 +1,5 @@
 MODULE    = wevtapi.dll
+IMPORTLIB = wevtapi
 
 EXTRADLLFLAGS = -mno-cygwin
 
diff --git a/dlls/wevtapi/tests/Makefile.in b/dlls/wevtapi/tests/Makefile.in
new file mode 100644
index 00000000000..47fde74b0eb
--- /dev/null
+++ b/dlls/wevtapi/tests/Makefile.in
@@ -0,0 +1,5 @@
+TESTDLL   = wevtapi.dll
+IMPORTS   = wevtapi advapi32
+
+C_SRCS = \
+	wevtapi.c
diff --git a/dlls/wevtapi/tests/wevtapi.c b/dlls/wevtapi/tests/wevtapi.c
new file mode 100644
index 00000000000..a0a21aa9971
--- /dev/null
+++ b/dlls/wevtapi/tests/wevtapi.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2021 Dmitry Timoshkov
+ *
+ * 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
+ */
+
+#define NONAMELESSUNION
+
+#include <stdarg.h>
+
+#include "windef.h"
+#include "winbase.h"
+#include "winevt.h"
+#include "wine/test.h"
+
+static void test_EvtGetChannelConfigProperty(void)
+{
+    HKEY key;
+    EVT_HANDLE config;
+    DWORD size, ret;
+    struct
+    {
+        EVT_VARIANT var;
+        WCHAR buf[MAX_PATH];
+    } path;
+
+    ret = RegCreateKeyW(HKEY_LOCAL_MACHINE, L"System\\CurrentControlSet\\Services\\EventLog\\Winetest", &key);
+    if (ret == ERROR_ACCESS_DENIED)
+    {
+        skip("Not enough privileges to modify HKLM\n");
+        return;
+    }
+    ok(ret == ERROR_SUCCESS, "RegCreateKey error %u\n", ret);
+
+    config = EvtOpenChannelConfig(NULL, L"Winetest", 0);
+    ok(config != NULL, "EvtOpenChannelConfig error %u\n", GetLastError());
+
+    ret = EvtGetChannelConfigProperty(config, EvtChannelLoggingConfigLogFilePath, 0, 0, NULL, &size);
+    ok(!ret, "EvtGetChannelConfigProperty should fail\n");
+    ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "got %u\n", GetLastError());
+    ok(size < sizeof(path), "got %u\n", size);
+
+    memset(&path, 0, sizeof(path));
+    path.var.Count = 0xdeadbeef;
+    path.var.Type = 0xdeadbeef;
+    ret = EvtGetChannelConfigProperty(config, EvtChannelLoggingConfigLogFilePath, 0, size, (EVT_VARIANT *)&path, &size);
+    ok(ret, "EvtGetChannelConfigProperty error %u\n", GetLastError());
+    ok(path.var.Count == 0xdeadbeef, "got %u\n", path.var.Count);
+    ok(path.var.Type == EvtVarTypeString, "got %u\n", path.var.Type);
+    ok(size == sizeof(EVT_VARIANT) + (wcslen(path.var.u.StringVal) + 1) * sizeof(WCHAR), "got %u\n", size);
+    ok(path.var.u.StringVal == path.buf, "path.var.u.StringVal = %p, path.buf = %p\n", path.var.u.StringVal, path.buf);
+
+    EvtClose(config);
+
+    RegDeleteKeyW(key, L"");
+    RegCloseKey(key);
+}
+
+START_TEST(wevtapi)
+{
+    test_EvtGetChannelConfigProperty();
+}
diff --git a/include/winevt.h b/include/winevt.h
index a37cdb7297f..4f0e7d52a0e 100644
--- a/include/winevt.h
+++ b/include/winevt.h
@@ -144,6 +144,7 @@ typedef struct _EVT_VARIANT {
 
 typedef DWORD (WINAPI *EVT_SUBSCRIBE_CALLBACK)(EVT_SUBSCRIBE_NOTIFY_ACTION Action,
                                                PVOID UserContext, EVT_HANDLE Event);
+BOOL WINAPI EvtClose(EVT_HANDLE);
 BOOL WINAPI EvtExportLog(EVT_HANDLE session, const WCHAR *path, const WCHAR *query,
                          const WCHAR *file, DWORD flags);
 BOOL WINAPI EvtGetChannelConfigProperty(EVT_HANDLE ChannelConfig,




More information about the wine-cvs mailing list