-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
171 lines (140 loc) · 8.59 KB
/
main.cpp
File metadata and controls
171 lines (140 loc) · 8.59 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#include "mainwindow.h"
#include "tests/test_entry.h"
#include <QApplication>
#include <QDebug>
#include <QTextStream>
namespace {
int runServiceTests(bool printStdoutSummary)
{
QTextStream testOutput(stdout);
auto reportTestGroup = [&](const QString &name, int result) {
if (printStdoutSummary) {
testOutput << name << ": " << (result == 0 ? "PASS" : "FAIL")
<< " (code=" << result << ")" << Qt::endl;
}
};
qDebug() << "=== Service Tests Start ===";
const int databaseTestResult = service_tests::runDatabaseServiceTests();
reportTestGroup(QStringLiteral("Database service tests"), databaseTestResult);
qDebug() << "Database service tests:" << (databaseTestResult == 0 ? "PASS" : "FAIL")
<< "(code=" << databaseTestResult << ")";
const int parserDispatcherTestResult = service_tests::runParserDispatcherTests();
reportTestGroup(QStringLiteral("Parser/dispatcher tests"), parserDispatcherTestResult);
qDebug() << "Parser/dispatcher tests:" << (parserDispatcherTestResult == 0 ? "PASS" : "FAIL")
<< "(code=" << parserDispatcherTestResult << ")";
const int logicTestResult = service_tests::runLogicTests();
reportTestGroup(QStringLiteral("Logic tests"), logicTestResult);
qDebug() << "Logic tests:" << (logicTestResult == 0 ? "PASS" : "FAIL")
<< "(code=" << logicTestResult << ")";
const int queryExecutorTestResult = service_tests::runQueryExecutorTests();
reportTestGroup(QStringLiteral("Query executor tests"), queryExecutorTestResult);
qDebug() << "Query executor tests:" << (queryExecutorTestResult == 0 ? "PASS" : "FAIL")
<< "(code=" << queryExecutorTestResult << ")";
const int tableTestResult = service_tests::runTableServiceTests();
reportTestGroup(QStringLiteral("Table service tests"), tableTestResult);
qDebug() << "Table service tests:" << (tableTestResult == 0 ? "PASS" : "FAIL")
<< "(code=" << tableTestResult << ")";
const int tupleTestResult = service_tests::runTupleServiceTests();
reportTestGroup(QStringLiteral("Tuple service tests"), tupleTestResult);
qDebug() << "Tuple service tests:" << (tupleTestResult == 0 ? "PASS" : "FAIL")
<< "(code=" << tupleTestResult << ")";
const int lockManagerTestResult = service_tests::runLockManagerTests();
reportTestGroup(QStringLiteral("Lock manager tests"), lockManagerTestResult);
qDebug() << "Lock manager tests:" << (lockManagerTestResult == 0 ? "PASS" : "FAIL")
<< "(code=" << lockManagerTestResult << ")";
const int threadedServiceTestResult = service_tests::runThreadedServiceTests();
reportTestGroup(QStringLiteral("Threaded service tests"), threadedServiceTestResult);
qDebug() << "Threaded service tests:" << (threadedServiceTestResult == 0 ? "PASS" : "FAIL")
<< "(code=" << threadedServiceTestResult << ")";
const int catalogCacheTestResult = service_tests::runCatalogCacheTests();
reportTestGroup(QStringLiteral("Catalog cache tests"), catalogCacheTestResult);
qDebug() << "Catalog cache tests:" << (catalogCacheTestResult == 0 ? "PASS" : "FAIL")
<< "(code=" << catalogCacheTestResult << ")";
const int serviceCommonCacheTestResult = service_tests::runServiceCommonCacheTests();
reportTestGroup(QStringLiteral("Service common cache tests"), serviceCommonCacheTestResult);
qDebug() << "Service common cache tests:" << (serviceCommonCacheTestResult == 0 ? "PASS" : "FAIL")
<< "(code=" << serviceCommonCacheTestResult << ")";
const int tableRuntimePipelineTestResult = service_tests::runTableRuntimePipelineTests();
reportTestGroup(QStringLiteral("Table runtime pipeline tests"), tableRuntimePipelineTestResult);
qDebug() << "Table runtime pipeline tests:" << (tableRuntimePipelineTestResult == 0 ? "PASS" : "FAIL")
<< "(code=" << tableRuntimePipelineTestResult << ")";
const int indexRuntimeRepairTestResult = service_tests::runIndexRuntimeRepairTests();
reportTestGroup(QStringLiteral("Index runtime repair tests"), indexRuntimeRepairTestResult);
qDebug() << "Index runtime repair tests:" << (indexRuntimeRepairTestResult == 0 ? "PASS" : "FAIL")
<< "(code=" << indexRuntimeRepairTestResult << ")";
const int clientSessionTestResult = service_tests::runClientSessionTests();
reportTestGroup(QStringLiteral("Client session tests"), clientSessionTestResult);
qDebug() << "Client session tests:" << (clientSessionTestResult == 0 ? "PASS" : "FAIL")
<< "(code=" << clientSessionTestResult << ")";
const int cliClientTestResult = service_tests::runCliClientTests();
reportTestGroup(QStringLiteral("CLI client tests"), cliClientTestResult);
qDebug() << "CLI client tests:" << (cliClientTestResult == 0 ? "PASS" : "FAIL")
<< "(code=" << cliClientTestResult << ")";
const int authClientTestResult = service_tests::runAuthClientTests();
reportTestGroup(QStringLiteral("Auth client tests"), authClientTestResult);
qDebug() << "Auth client tests:" << (authClientTestResult == 0 ? "PASS" : "FAIL")
<< "(code=" << authClientTestResult << ")";
const int guiClientRuntimeTestResult = service_tests::runGuiClientRuntimeTests();
reportTestGroup(QStringLiteral("GUI client runtime tests"), guiClientRuntimeTestResult);
qDebug() << "GUI client runtime tests:" << (guiClientRuntimeTestResult == 0 ? "PASS" : "FAIL")
<< "(code=" << guiClientRuntimeTestResult << ")";
const int integrationTestResult = service_tests::runIntegrationTests();
reportTestGroup(QStringLiteral("Integration tests"), integrationTestResult);
qDebug() << "Integration tests:" << (integrationTestResult == 0 ? "PASS" : "FAIL")
<< "(code=" << integrationTestResult << ")";
const int stressTestResult = service_tests::runStressTests();
reportTestGroup(QStringLiteral("Stress tests"), stressTestResult);
qDebug() << "Stress tests:" << (stressTestResult == 0 ? "PASS" : "FAIL")
<< "(code=" << stressTestResult << ")";
const int totalFailureCount = (databaseTestResult == 0 ? 0 : 1)
+ (parserDispatcherTestResult == 0 ? 0 : 1)
+ (logicTestResult == 0 ? 0 : 1)
+ (queryExecutorTestResult == 0 ? 0 : 1)
+ (tableTestResult == 0 ? 0 : 1)
+ (tupleTestResult == 0 ? 0 : 1)
+ (lockManagerTestResult == 0 ? 0 : 1)
+ (threadedServiceTestResult == 0 ? 0 : 1)
+ (catalogCacheTestResult == 0 ? 0 : 1)
+ (serviceCommonCacheTestResult == 0 ? 0 : 1)
+ (tableRuntimePipelineTestResult == 0 ? 0 : 1)
+ (indexRuntimeRepairTestResult == 0 ? 0 : 1)
+ (clientSessionTestResult == 0 ? 0 : 1)
+ (cliClientTestResult == 0 ? 0 : 1)
+ (authClientTestResult == 0 ? 0 : 1)
+ (guiClientRuntimeTestResult == 0 ? 0 : 1)
+ (integrationTestResult == 0 ? 0 : 1)
+ (stressTestResult == 0 ? 0 : 1);
qDebug() << "=== Service Tests End ===";
qDebug() << "Service test summary:" << (totalFailureCount == 0 ? "ALL PASS" : "SOME FAIL")
<< "(" << totalFailureCount << "failed groups)";
return totalFailureCount;
}
} // namespace
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
const QStringList arguments = app.arguments();
const bool runTestsOnly = arguments.contains(QStringLiteral("--run-tests"));
const bool skipTests = arguments.contains(QStringLiteral("--skip-tests"))
|| arguments.contains(QStringLiteral("--no-tests"));
if (arguments.contains(QStringLiteral("--skip-stress-tests"))
|| arguments.contains(QStringLiteral("--no-stress-tests"))) {
qputenv("DBMS_SKIP_STRESS_TESTS", "1");
}
#ifdef QT_NO_DEBUG
const bool debugBuild = false;
#else
const bool debugBuild = true;
#endif
if (runTestsOnly || (debugBuild && !skipTests)) {
const int totalFailureCount = runServiceTests(runTestsOnly);
if (runTestsOnly) {
return totalFailureCount == 0 ? 0 : 1;
}
} else if (skipTests) {
qDebug() << "Skipping service tests due to --skip-tests/--no-tests.";
}
MainWindow window;
window.show();
return app.exec();
}