ReactOS 0.4.16-dev-340-g0540c21
main.cpp
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS Automatic Testing Utility
3 * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4 * PURPOSE: Main implementation file
5 * COPYRIGHT: Copyright 2008-2009 Colin Finck (colin@reactos.org)
6 */
7
8#include "precomp.h"
9#include <cstdio>
10#include <ndk/setypes.h>
11#include <ndk/exfuncs.h>
12
14
18static void
20{
21 cout << "rosautotest - ReactOS Automatic Testing Utility" << endl
22 << "Usage: rosautotest [options] [module] [test]" << endl
23 << " options:" << endl
24 << " /? - Shows this help." << endl
25 << " /c <comment> - Specifies the comment to be submitted to the Web Service." << endl
26 << " Skips the comment set in the configuration file (if any)." << endl
27 << " Only has an effect when /w is also used." << endl
28 << " /n - Do not print test output to console" << endl
29 << " /r - Maintain information to resume from ReactOS crashes" << endl
30 << " Can only be run under ReactOS and relies on sysreg2," << endl
31 << " so incompatible with /w" << endl
32 << " /s - Shut down the system after finishing the tests." << endl
33 << " /t <num> - Repeat the test <num> times (1-10000)" << endl
34 << " /w - Submit the results to the webservice." << endl
35 << " Requires a \"rosautotest.ini\" with valid login data." << endl
36 << " Incompatible with the /r option." << endl
37 << " /l - List all modules that would run." << endl
38 << endl
39 << " module:" << endl
40 << " The module to be tested (i.e. \"advapi32\")" << endl
41 << " If this parameter is specified without any test parameter," << endl
42 << " all tests of the specified module are run." << endl
43 << endl
44 << " test:" << endl
45 << " The test to be run. Needs to be a test of the specified module." << endl;
46}
47
48static
49VOID
51{
52 ULONG NtGlobalFlags = 0;
53 BOOLEAN PrivilegeEnabled;
55
56 /* Enable SeDebugPrivilege */
58 if (!NT_SUCCESS(Status))
59 {
60 DbgPrint("Failed to enable SeDebugPrivilege: 0x%08lx\n", Status);
61 return;
62 }
63
64 /* Get current NtGlobalFlags */
65 Status = NtQuerySystemInformation(SystemFlagsInformation, &NtGlobalFlags, sizeof(NtGlobalFlags), NULL);
66 if (!NT_SUCCESS(Status))
67 {
68 DbgPrint("Failed to get NtGlobalFlags: 0x%08lx\n", Status);
69 return;
70 }
71
72 /* Disable debug prompts */
73 NtGlobalFlags |= FLG_DISABLE_DEBUG_PROMPTS;
74
75 /* Set new NtGlobalFlags */
76 Status = NtSetSystemInformation(SystemFlagsInformation, &NtGlobalFlags, sizeof(NtGlobalFlags));
77 if (!NT_SUCCESS(Status))
78 {
79 DbgPrint("Failed to set NtGlobalFlags: 0x%08lx\n", Status);
80 }
81}
82
86extern "C" int
87wmain(int argc, wchar_t* argv[])
88{
89 int ReturnValue = 1;
90
92
93 try
94 {
96
97 /* Set up the configuration */
98 Configuration.ParseParameters(argc, argv);
99 Configuration.GetSystemInformation();
100 Configuration.GetConfigurationFromFile();
101
102 ss << endl
103 << endl
104 << "[ROSAUTOTEST] System uptime " << setprecision(2) << fixed;
105 ss << ((float)GetTickCount()/1000) << " seconds" << endl;
106 StringOut(ss.str());
107
108 /* Report tests startup */
109 InitLogs();
112 0,
113 MSG_TESTS_STARTED,
114 NULL,
115 0,
116 0,
117 NULL,
118 NULL);
119
120 if (Configuration.GetRepeatCount() > 1)
121 {
122 stringstream ss1;
123
124 ss1 << "[ROSAUTOTEST] The test will be repeated " << Configuration.GetRepeatCount() << " times" << endl;
125 StringOut(ss1.str());
126 }
127
128 /* Run the tests */
129 for (unsigned long i = 0; i < Configuration.GetRepeatCount(); i++)
130 {
131 CWineTest WineTest;
132
133 if (Configuration.GetRepeatCount() > 1)
134 {
136 ss << "[ROSAUTOTEST] Running attempt #" << i+1 << endl;
137 StringOut(ss.str());
138 }
139 WineTest.Run();
140 }
141
142 /* For sysreg2 */
143 DbgPrint("SYSREG_CHECKPOINT:THIRDBOOT_COMPLETE\n");
144
145 ReturnValue = 0;
146 }
148 {
150 }
151 catch(CSimpleException& e)
152 {
154
155 // e.GetMessage() must include ending '\n'.
156 ss << "[ROSAUTOTEST] " << e.GetMessage();
157 StringOut(ss.str());
158 }
159 catch(CFatalException& e)
160 {
162
163 // e.GetMessage() must include ending '\n'.
164 ss << "An exception occured in rosautotest." << endl
165 << "Message: " << e.GetMessage()
166 << "File: " << e.GetFile() << endl
167 << "Line: " << e.GetLine() << endl
168 << "Last Win32 Error: " << GetLastError() << endl;
169 StringOut(ss.str());
170 }
171
172 /* For sysreg2 to notice if rosautotest itself failed */
173 if(ReturnValue == 1)
174 DbgPrint("SYSREG_ROSAUTOTEST_FAILURE\n");
175
176 /* Report successful end of tests */
179 0,
180 MSG_TESTS_SUCCESSFUL,
181 NULL,
182 0,
183 0,
184 NULL,
185 NULL);
186 FreeLogs();
187
188 /* Shut down the system if requested, also in case of an exception above */
189 if(Configuration.DoShutdown() && !ShutdownSystem())
190 ReturnValue = 1;
191
192 return ReturnValue;
193}
NTSYSAPI NTSTATUS NTAPI NtSetSystemInformation(IN INT SystemInformationClass, IN PVOID SystemInformation, IN ULONG SystemInformationLength)
unsigned char BOOLEAN
static int argc
Definition: ServiceArgs.c:12
_STLP_PRIV _Ios_Manip_1< streamsize > _STLP_CALL setprecision(int __n)
Definition: _iomanip.h:119
ios_base &_STLP_CALL fixed(ios_base &__s)
Definition: _ios_base.h:332
basic_ostream< _CharT, _Traits > &_STLP_CALL endl(basic_ostream< _CharT, _Traits > &__os)
Definition: _ostream.h:357
UINT32 void void ** ReturnValue
Definition: acevents.h:216
LONG NTSTATUS
Definition: precomp.h:26
VOID InitLogs()
Definition: misc.cpp:205
VOID FreeLogs()
Definition: misc.cpp:243
static HANDLE hLog
Definition: misc.cpp:13
void Run()
Definition: CWineTest.cpp:364
_String str() const
Definition: _sstream.h:230
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
BOOL WINAPI ReportEventW(IN HANDLE hEventLog, IN WORD wType, IN WORD wCategory, IN DWORD dwEventID, IN PSID lpUserSid, IN WORD wNumStrings, IN DWORD dwDataSize, IN LPCWSTR *lpStrings, IN LPVOID lpRawData)
Definition: eventlog.c:1516
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:455
@ SystemFlagsInformation
Definition: ntddk_ex.h:20
Status
Definition: gdiplustypes.h:25
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define DbgPrint
Definition: hal.h:12
#define ss
Definition: i386-dis.c:441
#define FLG_DISABLE_DEBUG_PROMPTS
Definition: pstypes.h:86
#define cout
Definition: iostream.cpp:38
#define e
Definition: ke_i.h:82
static void IntPrintUsage()
Definition: main.cpp:19
CConfiguration Configuration
Definition: main.cpp:13
static VOID SetNtGlobalFlags()
Definition: main.cpp:50
string StringOut(const string &String, bool forcePrint=true)
Definition: tools.cpp:96
bool ShutdownSystem()
Definition: shutdown.cpp:16
#define SE_DEBUG_PRIVILEGE
Definition: security.c:674
static float(__cdecl *square_half_float)(float x
#define argv
Definition: mplay32.c:18
NTSYSAPI NTSTATUS NTAPI RtlAdjustPrivilege(_In_ ULONG Privilege, _In_ BOOLEAN NewValue, _In_ BOOLEAN ForThread, _Out_ PBOOLEAN OldValue)
int wmain()
NTSYSAPI NTSTATUS NTAPI NtQuerySystemInformation(IN SYSTEM_INFORMATION_CLASS SystemInfoClass, OUT PVOID SystemInfoBuffer, IN ULONG SystemInfoBufferSize, OUT PULONG BytesReturned OPTIONAL)
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_INTERRUPT_CONFIG Configuration
Definition: wdfinterrupt.h:374
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define EVENTLOG_INFORMATION_TYPE
Definition: winnt_old.h:2865
#define EVENTLOG_SUCCESS
Definition: winnt_old.h:2862