main.cpp
1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//#include <iostream>
#include <stdio.h>
#include <string.h>
#include "cppunit/TestResult.h"
#include "cppunit/TestResultCollector.h"
#include "cppunit/TestRunner.h"
#include "cppunit/extensions/TestFactoryRegistry.h"
#include "cppunit/CompilerOutputter.h"
#include "Common/TREPS_kernel_config.h"
#include "Application/Application.h"
//path to TREPS application config file
#define APP_CONF_FILE "config/app.config"
using namespace std;
using namespace CppUnit;
using namespace TREPS::Application;
int main(int argc, char *argv[])
{
if ((argc == 2) && (strcmp(argv[1],"unittest") == 0))
{
cout << "Run unit tests : " << endl;
//Init Application
ApplicationClass *app = ApplicationClass::getInstance();
if (!app->init(APP_CONF_FILE))
{
app->kill();
return 1;
}
//run unit tests
TestResult testResult;
TestResultCollector collectedResults;
testResult.addListener(&collectedResults);
TestRunner testRunner;
testRunner.addTest(TestFactoryRegistry::getRegistry().makeTest());
testRunner.run(testResult);
CompilerOutputter compilerOutPutter(&collectedResults, std::cerr);
compilerOutPutter.write();
app->kill();
return collectedResults.wasSuccessful() ? 0 : 1;
}
else if ((argc == 2) && (strcmp(argv[1],"-v") == 0))
{
cout << TREPS_KERNEL_VERSION << endl;
return 0;
}
//Init Application
ApplicationClass *app = ApplicationClass::getInstance();
if (!app->init(APP_CONF_FILE))
{
app->kill();
return 1;
}
//Run the request
if (!app->run(argc,argv))
{
app->kill();
return 1;
}
app->kill();
return 0;
}