[ROSAUTOTEST]
authorSylvain Petreolle <spetreolle@yahoo.fr>
Wed, 27 Aug 2014 20:19:43 +0000 (20:19 +0000)
committerSylvain Petreolle <spetreolle@yahoo.fr>
Wed, 27 Aug 2014 20:19:43 +0000 (20:19 +0000)
Report the start and end of the tests in the Application event log.
This gives data for the advapi32:eventlog tests.

svn path=/trunk/; revision=63963

rostests/rosautotest/CMakeLists.txt
rostests/rosautotest/main.cpp
rostests/rosautotest/misc.cpp [new file with mode: 0644]
rostests/rosautotest/precomp.h
rostests/rosautotest/rosautotest.rc [new file with mode: 0644]
rostests/rosautotest/rosautotestmsg.mc [new file with mode: 0644]

index d4a4b37..106d2e7 100644 (file)
@@ -15,14 +15,16 @@ list(APPEND SOURCE
     CWebService.cpp
     CWineTest.cpp
     main.cpp
+    misc.cpp
     shutdown.cpp
     tools.cpp
     precomp.h)
 
-add_executable(rosautotest ${SOURCE})
+add_executable(rosautotest ${SOURCE} ${REACTOS_BINARY_DIR}/include/reactos/rosautotestmsg.rc)
 
 set_module_type(rosautotest win32cui UNICODE)
 add_importlibs(rosautotest advapi32 shell32 user32 wininet msvcrt kernel32 ntdll)
 add_pch(rosautotest precomp.h SOURCE)
-
+add_message_headers(ANSI rosautotestmsg.mc)
+add_dependencies(rosautotest rosautotestmsg)
 add_cd_file(TARGET rosautotest DESTINATION reactos/system32 FOR all)
index d9cdb37..7165520 100644 (file)
@@ -61,6 +61,18 @@ wmain(int argc, wchar_t* argv[])
         ss << "\n\nSystem uptime " << setprecision(2) << fixed ;
         ss << ((float)GetTickCount()/1000) << " seconds\n";
         StringOut(ss.str());
+        
+        /* Report tests startup */
+        InitLogs();
+        ReportEventW(hLog,
+                      EVENTLOG_INFORMATION_TYPE,
+                      0,
+                      MSG_TESTS_STARTED,
+                      NULL,
+                      0,
+                      0,
+                      NULL,
+                      NULL);
 
         /* Run the tests */
         WineTest.Run();
@@ -94,6 +106,18 @@ wmain(int argc, wchar_t* argv[])
     if(ReturnValue == 1)
         DbgPrint("SYSREG_ROSAUTOTEST_FAILURE\n");
 
+    /* Report successful end of tests */
+    ReportEventW(hLog,
+                  EVENTLOG_SUCCESS,
+                  0,
+                  MSG_TESTS_SUCCESSFUL,
+                  NULL,
+                  0,
+                  0,
+                  NULL,
+                  NULL);
+    FreeLogs();
+
     /* Shut down the system if requested, also in case of an exception above */
     if(Configuration.DoShutdown() && !ShutdownSystem())
         ReturnValue = 1;
diff --git a/rostests/rosautotest/misc.cpp b/rostests/rosautotest/misc.cpp
new file mode 100644 (file)
index 0000000..e2e58cf
--- /dev/null
@@ -0,0 +1,109 @@
+/*
+ * PROJECT:         ReactOS Automatic Testing Utility
+ * LICENSE:         GPL - See COPYING in the top level directory
+ * FILE:            base/applications/rapps/misc.c
+ * PURPOSE:         Misc functions
+ * PROGRAMMERS:     Dmitry Chapyshev (dmitry@reactos.org)
+ */
+
+//static 
+HANDLE hLog = NULL;
+
+VOID
+InitLogs(VOID)
+{
+    WCHAR szBuf[MAX_PATH] = L"SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\RosAutotest";
+    WCHAR szPath[MAX_PATH];
+    DWORD dwCategoryNum = 1;
+    DWORD dwDisp, dwData;
+    HKEY hKey;
+
+    if (RegCreateKeyExW(HKEY_LOCAL_MACHINE,
+                        szBuf, 0, NULL,
+                        REG_OPTION_NON_VOLATILE,
+                        KEY_WRITE, NULL, &hKey, &dwDisp) != ERROR_SUCCESS)
+    {
+        return;
+    }
+
+    if (!GetModuleFileName(NULL, szPath, sizeof(szPath) / sizeof(szPath[0])))
+        return;
+
+    if (RegSetValueExW(hKey,
+                       L"EventMessageFile",
+                       0,
+                       REG_EXPAND_SZ,
+                       (LPBYTE)szPath,
+                       (DWORD)(wcslen(szPath) + 1) * sizeof(WCHAR)) != ERROR_SUCCESS)
+    {
+        RegCloseKey(hKey);
+        return;
+    }
+
+    dwData = EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE |
+             EVENTLOG_INFORMATION_TYPE;
+
+    if (RegSetValueExW(hKey,
+                       L"TypesSupported",
+                       0,
+                       REG_DWORD,
+                       (LPBYTE)&dwData,
+                       sizeof(DWORD)) != ERROR_SUCCESS)
+    {
+        RegCloseKey(hKey);
+        return;
+    }
+
+    if (RegSetValueExW(hKey,
+                       L"CategoryMessageFile",
+                       0,
+                       REG_EXPAND_SZ,
+                       (LPBYTE)szPath,
+                       (DWORD)(wcslen(szPath) + 1) * sizeof(WCHAR)) != ERROR_SUCCESS)
+    {
+        RegCloseKey(hKey);
+        return;
+    }
+
+    if (RegSetValueExW(hKey,
+                       L"CategoryCount",
+                       0,
+                       REG_DWORD,
+                       (LPBYTE)&dwCategoryNum,
+                       sizeof(DWORD)) != ERROR_SUCCESS)
+    {
+        RegCloseKey(hKey);
+        return;
+    }
+
+    RegCloseKey(hKey);
+
+    hLog = RegisterEventSourceW(NULL, L"RosAutotest");
+}
+
+
+VOID
+FreeLogs(VOID)
+{
+    if (hLog) DeregisterEventSource(hLog);
+}
+
+
+BOOL
+WriteLogMessage(WORD wType, DWORD dwEventID, LPWSTR lpMsg)
+{
+    if (!ReportEventW(hLog,
+                      wType,
+                      0,
+                      dwEventID,
+                      NULL,
+                      1,
+                      0,
+                      (LPCWSTR*)&lpMsg,
+                      NULL))
+    {
+        return FALSE;
+    }
+
+    return TRUE;
+}
index adb25fb..21e6013 100644 (file)
@@ -20,6 +20,7 @@ using namespace std;
 #include <reason.h>
 #include <shlobj.h>
 #include <wininet.h>
+#include <winreg.h>
 
 #include <ndk/rtlfuncs.h>
 #include <reactos/buildno.h>
@@ -39,6 +40,8 @@ using namespace std;
 #include "CWebService.h"
 #include "CWineTest.h"
 
+#include <rosautotestmsg.h>
+
 /* Useful macros */
 #define EXCEPTION(Message)   throw CSimpleException(Message)
 #define FATAL(Message)       throw CFatalException(__FILE__, __LINE__, Message)
@@ -47,6 +50,11 @@ using namespace std;
 /* main.c */
 extern CConfiguration Configuration;
 
+/* misc.c */
+VOID FreeLogs(VOID);
+VOID InitLogs(VOID);
+extern HANDLE hLog;
+
 /* shutdown.c */
 bool ShutdownSystem();
 
diff --git a/rostests/rosautotest/rosautotest.rc b/rostests/rosautotest/rosautotest.rc
new file mode 100644 (file)
index 0000000..bc2ee0d
--- /dev/null
@@ -0,0 +1 @@
+#include <rosautotestmsg.rc>
diff --git a/rostests/rosautotest/rosautotestmsg.mc b/rostests/rosautotest/rosautotestmsg.mc
new file mode 100644 (file)
index 0000000..f560dad
--- /dev/null
@@ -0,0 +1,27 @@
+MessageIdTypedef=ULONG
+
+SeverityNames=(Success=0x0:STATUS_SEVERITY_SUCCESS
+Informational=0x1:STATUS_SEVERITY_INFORMATIONAL
+Warning=0x2:STATUS_SEVERITY_WARNING
+Error=0x3:STATUS_SEVERITY_ERROR)
+
+FacilityNames=(System=0x0:FACILITY_SYSTEM Application=0xFFF)
+
+LanguageNames=(English=0x409:MSG00409)
+
+MessageId=1
+Severity=Informational
+Facility=Application
+SymbolicName=MSG_TESTS_STARTED
+Language=English
+ReactOS Automatic Testing Utility is started.
+.
+
+MessageId=2
+Severity=Success
+Facility=Application
+SymbolicName=MSG_TESTS_SUCCESSFUL
+Language=English
+ReactOS Automatic Testing Utility is successful.
+.
+