Big testing system commit
[reactos.git] / rostests / rosautotest / main.cpp
1 /*
2 * PROJECT: ReactOS Automatic Testing Utility
3 * LICENSE: GNU GPLv2 or any later version as published by the Free Software Foundation
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
11 CConfiguration Configuration;
12
13 /**
14 * Prints the application usage.
15 */
16 static void
17 IntPrintUsage()
18 {
19 cout << "rosautotest - ReactOS Automatic Testing Utility" << endl
20 << "Usage: rosautotest [options] [module] [test]" << endl
21 << " options:" << endl
22 << " /? - Shows this help." << endl
23 << " /c <comment> - Specifies the comment to be submitted to the Web Service." << endl
24 << " Skips the comment set in the configuration file (if any)." << endl
25 << " Only has an effect when /w is also used." << endl
26 << " /r - Maintain information to resume from ReactOS crashes" << endl
27 << " Can only be run under ReactOS and relies on sysreg2," << endl
28 << " so incompatible with /w" << endl
29 << " /s - Shut down the system after finishing the tests." << endl
30 << " /w - Submit the results to the webservice." << endl
31 << " Requires a \"rosautotest.ini\" with valid login data." << endl
32 << " Incompatible with the /r option." << endl
33 << endl
34 << " module:" << endl
35 << " The module to be tested (i.e. \"advapi32\")" << endl
36 << " If this parameter is specified without any test parameter," << endl
37 << " all tests of the specified module are run." << endl
38 << endl
39 << " test:" << endl
40 << " The test to be run. Needs to be a test of the specified module." << endl;
41 }
42
43 /**
44 * Main entry point
45 */
46 extern "C" int
47 wmain(int argc, wchar_t* argv[])
48 {
49 CWineTest WineTest;
50 int ReturnValue = 1;
51
52 try
53 {
54 /* Set up the configuration */
55 Configuration.ParseParameters(argc, argv);
56 Configuration.GetSystemInformation();
57 Configuration.GetConfigurationFromFile();
58
59 /* Run the tests */
60 WineTest.Run();
61
62 /* For sysreg */
63 DbgPrint("SYSREG_CHECKPOINT:THIRDBOOT_COMPLETE\n");
64
65 ReturnValue = 0;
66 }
67 catch(CInvalidParameterException)
68 {
69 IntPrintUsage();
70 }
71 catch(CSimpleException& e)
72 {
73 StringOut(e.GetMessage());
74 }
75 catch(CFatalException& e)
76 {
77 stringstream ss;
78
79 ss << "An exception occured in rosautotest." << endl
80 << "Message: " << e.GetMessage() << endl
81 << "File: " << e.GetFile() << endl
82 << "Line: " << e.GetLine() << endl
83 << "Last Win32 Error: " << GetLastError() << endl;
84 StringOut(ss.str());
85 }
86
87 /* Shut down the system if requested, also in case of an exception above */
88 if(Configuration.DoShutdown() && !ShutdownSystem())
89 ReturnValue = 1;
90
91 return ReturnValue;
92 }