|
@@
-1,133
+1,153
|
|
1
|
#include "FuzzingDefs.h"
|
|
1
|
#include "FuzzingDefs.h"
|
|
2
|
#include "FuzzingOperations.h"
|
|
2
|
#include "FuzzingOperations.h"
|
|
3
|
#include <Network/NetworkController.h>
|
|
3
|
#include <Network/NetworkController.h>
|
|
4
|
#include <SqpApplication.h>
|
|
4
|
#include <SqpApplication.h>
|
|
5
|
#include <Time/TimeController.h>
|
|
5
|
#include <Time/TimeController.h>
|
|
6
|
#include <Variable/VariableController.h>
|
|
6
|
#include <Variable/VariableController.h>
|
|
7
|
|
|
7
|
|
|
8
|
#include <QLoggingCategory>
|
|
8
|
#include <QLoggingCategory>
|
|
9
|
#include <QObject>
|
|
9
|
#include <QObject>
|
|
10
|
#include <QtTest>
|
|
10
|
#include <QtTest>
|
|
11
|
|
|
11
|
|
|
12
|
#include <memory>
|
|
12
|
#include <memory>
|
|
13
|
|
|
13
|
|
|
14
|
Q_LOGGING_CATEGORY(LOG_TestAmdaFuzzing, "TestAmdaFuzzing")
|
|
14
|
Q_LOGGING_CATEGORY(LOG_TestAmdaFuzzing, "TestAmdaFuzzing")
|
|
15
|
|
|
15
|
|
|
16
|
namespace {
|
|
16
|
namespace {
|
|
17
|
|
|
17
|
|
|
18
|
// /////// //
|
|
18
|
// /////// //
|
|
19
|
// Aliases //
|
|
19
|
// Aliases //
|
|
20
|
// /////// //
|
|
20
|
// /////// //
|
|
21
|
|
|
21
|
|
|
22
|
using VariableId = int;
|
|
22
|
using VariableId = int;
|
|
23
|
|
|
23
|
|
|
24
|
using OperationsPool = std::set<std::shared_ptr<IFuzzingOperation> >;
|
|
24
|
using OperationsPool = std::set<std::shared_ptr<IFuzzingOperation> >;
|
|
25
|
using VariablesPool = std::map<VariableId, std::shared_ptr<Variable> >;
|
|
25
|
using VariablesPool = std::map<VariableId, std::shared_ptr<Variable> >;
|
|
26
|
|
|
26
|
|
|
27
|
// ///////// //
|
|
27
|
// ///////// //
|
|
28
|
// Constants //
|
|
28
|
// Constants //
|
|
29
|
// ///////// //
|
|
29
|
// ///////// //
|
|
30
|
|
|
30
|
|
|
31
|
// Defaults values used when the associated properties have not been set for the test
|
|
31
|
// Defaults values used when the associated properties have not been set for the test
|
|
32
|
const auto NB_MAX_OPERATIONS_DEFAULT_VALUE = 100;
|
|
32
|
const auto NB_MAX_OPERATIONS_DEFAULT_VALUE = 100;
|
|
33
|
const auto NB_MAX_VARIABLES_DEFAULT_VALUE = 1;
|
|
33
|
const auto NB_MAX_VARIABLES_DEFAULT_VALUE = 1;
|
|
|
|
|
34
|
const auto AVAILABLE_OPERATIONS_DEFAULT_VALUE
|
|
|
|
|
35
|
= QVariant::fromValue(OperationsTypes{FuzzingOperationType::CREATE});
|
|
|
|
|
36
|
OperationsPool createOperationsPool(const OperationsTypes &types)
|
|
|
|
|
37
|
{
|
|
|
|
|
38
|
OperationsPool result{};
|
|
|
|
|
39
|
|
|
|
|
|
40
|
std::transform(types.cbegin(), types.cend(), std::inserter(result, result.end()),
|
|
|
|
|
41
|
[](const auto &type) { return FuzzingOperationFactory::create(type); });
|
|
|
|
|
42
|
|
|
|
|
|
43
|
return result;
|
|
|
|
|
44
|
}
|
|
|
|
|
45
|
|
|
34
|
/**
|
|
46
|
/**
|
|
35
|
* Class to run random tests
|
|
47
|
* Class to run random tests
|
|
36
|
*/
|
|
48
|
*/
|
|
37
|
class FuzzingTest {
|
|
49
|
class FuzzingTest {
|
|
38
|
public:
|
|
50
|
public:
|
|
39
|
explicit FuzzingTest(VariableController &variableController, Properties properties)
|
|
51
|
explicit FuzzingTest(VariableController &variableController, Properties properties)
|
|
40
|
: m_VariableController{variableController},
|
|
52
|
: m_VariableController{variableController},
|
|
41
|
m_Properties{std::move(properties)},
|
|
53
|
m_Properties{std::move(properties)},
|
|
42
|
m_VariablesPool{}
|
|
54
|
m_VariablesPool{}
|
|
43
|
{
|
|
55
|
{
|
|
44
|
// Inits variables pool: at init, all variables are null
|
|
56
|
// Inits variables pool: at init, all variables are null
|
|
45
|
for (auto variableId = 0; variableId < nbMaxVariables(); ++variableId) {
|
|
57
|
for (auto variableId = 0; variableId < nbMaxVariables(); ++variableId) {
|
|
46
|
m_VariablesPool[variableId] = nullptr;
|
|
58
|
m_VariablesPool[variableId] = nullptr;
|
|
47
|
}
|
|
59
|
}
|
|
48
|
}
|
|
60
|
}
|
|
49
|
|
|
61
|
|
|
50
|
void execute()
|
|
62
|
void execute()
|
|
51
|
{
|
|
63
|
{
|
|
52
|
/// @todo: complete
|
|
64
|
/// @todo: complete
|
|
53
|
qCInfo(LOG_TestAmdaFuzzing()) << "Running" << nbMaxOperations() << "operations on"
|
|
65
|
qCInfo(LOG_TestAmdaFuzzing()) << "Running" << nbMaxOperations() << "operations on"
|
|
54
|
<< nbMaxVariables() << "variables...";
|
|
66
|
<< nbMaxVariables() << "variables...";
|
|
55
|
|
|
67
|
|
|
56
|
qCInfo(LOG_TestAmdaFuzzing()) << "Execution of the test completed.";
|
|
68
|
qCInfo(LOG_TestAmdaFuzzing()) << "Execution of the test completed.";
|
|
57
|
}
|
|
69
|
}
|
|
58
|
|
|
70
|
|
|
59
|
private:
|
|
71
|
private:
|
|
60
|
int nbMaxOperations() const
|
|
72
|
int nbMaxOperations() const
|
|
61
|
{
|
|
73
|
{
|
|
62
|
static auto result
|
|
74
|
static auto result
|
|
63
|
= m_Properties.value(NB_MAX_OPERATIONS_PROPERTY, NB_MAX_OPERATIONS_DEFAULT_VALUE)
|
|
75
|
= m_Properties.value(NB_MAX_OPERATIONS_PROPERTY, NB_MAX_OPERATIONS_DEFAULT_VALUE)
|
|
64
|
.toInt();
|
|
76
|
.toInt();
|
|
65
|
return result;
|
|
77
|
return result;
|
|
66
|
}
|
|
78
|
}
|
|
67
|
|
|
79
|
|
|
68
|
int nbMaxVariables() const
|
|
80
|
int nbMaxVariables() const
|
|
69
|
{
|
|
81
|
{
|
|
70
|
static auto result
|
|
82
|
static auto result
|
|
71
|
= m_Properties.value(NB_MAX_VARIABLES_PROPERTY, NB_MAX_VARIABLES_DEFAULT_VALUE).toInt();
|
|
83
|
= m_Properties.value(NB_MAX_VARIABLES_PROPERTY, NB_MAX_VARIABLES_DEFAULT_VALUE).toInt();
|
|
72
|
return result;
|
|
84
|
return result;
|
|
73
|
}
|
|
85
|
}
|
|
74
|
|
|
86
|
|
|
|
|
|
87
|
OperationsPool operationsPool() const
|
|
|
|
|
88
|
{
|
|
|
|
|
89
|
static auto result = createOperationsPool(
|
|
|
|
|
90
|
m_Properties.value(AVAILABLE_OPERATIONS_PROPERTY, AVAILABLE_OPERATIONS_DEFAULT_VALUE)
|
|
|
|
|
91
|
.value<OperationsTypes>());
|
|
|
|
|
92
|
return result;
|
|
|
|
|
93
|
}
|
|
|
|
|
94
|
|
|
75
|
VariableController &m_VariableController;
|
|
95
|
VariableController &m_VariableController;
|
|
76
|
Properties m_Properties;
|
|
96
|
Properties m_Properties;
|
|
77
|
VariablesPool m_VariablesPool;
|
|
97
|
VariablesPool m_VariablesPool;
|
|
78
|
};
|
|
98
|
};
|
|
79
|
|
|
99
|
|
|
80
|
} // namespace
|
|
100
|
} // namespace
|
|
81
|
|
|
101
|
|
|
82
|
class TestAmdaFuzzing : public QObject {
|
|
102
|
class TestAmdaFuzzing : public QObject {
|
|
83
|
Q_OBJECT
|
|
103
|
Q_OBJECT
|
|
84
|
|
|
104
|
|
|
85
|
private slots:
|
|
105
|
private slots:
|
|
86
|
/// Input data for @sa testFuzzing()
|
|
106
|
/// Input data for @sa testFuzzing()
|
|
87
|
void testFuzzing_data();
|
|
107
|
void testFuzzing_data();
|
|
88
|
void testFuzzing();
|
|
108
|
void testFuzzing();
|
|
89
|
};
|
|
109
|
};
|
|
90
|
|
|
110
|
|
|
91
|
void TestAmdaFuzzing::testFuzzing_data()
|
|
111
|
void TestAmdaFuzzing::testFuzzing_data()
|
|
92
|
{
|
|
112
|
{
|
|
93
|
// ////////////// //
|
|
113
|
// ////////////// //
|
|
94
|
// Test structure //
|
|
114
|
// Test structure //
|
|
95
|
// ////////////// //
|
|
115
|
// ////////////// //
|
|
96
|
|
|
116
|
|
|
97
|
QTest::addColumn<Properties>("properties"); // Properties for random test
|
|
117
|
QTest::addColumn<Properties>("properties"); // Properties for random test
|
|
98
|
|
|
118
|
|
|
99
|
// ////////// //
|
|
119
|
// ////////// //
|
|
100
|
// Test cases //
|
|
120
|
// Test cases //
|
|
101
|
// ////////// //
|
|
121
|
// ////////// //
|
|
102
|
|
|
122
|
|
|
103
|
///@todo: complete
|
|
123
|
///@todo: complete
|
|
104
|
}
|
|
124
|
}
|
|
105
|
|
|
125
|
|
|
106
|
void TestAmdaFuzzing::testFuzzing()
|
|
126
|
void TestAmdaFuzzing::testFuzzing()
|
|
107
|
{
|
|
127
|
{
|
|
108
|
QFETCH(Properties, properties);
|
|
128
|
QFETCH(Properties, properties);
|
|
109
|
|
|
129
|
|
|
110
|
auto &variableController = sqpApp->variableController();
|
|
130
|
auto &variableController = sqpApp->variableController();
|
|
111
|
auto &timeController = sqpApp->timeController();
|
|
131
|
auto &timeController = sqpApp->timeController();
|
|
112
|
|
|
132
|
|
|
113
|
FuzzingTest test{variableController, properties};
|
|
133
|
FuzzingTest test{variableController, properties};
|
|
114
|
test.execute();
|
|
134
|
test.execute();
|
|
115
|
}
|
|
135
|
}
|
|
116
|
|
|
136
|
|
|
117
|
int main(int argc, char *argv[])
|
|
137
|
int main(int argc, char *argv[])
|
|
118
|
{
|
|
138
|
{
|
|
119
|
QLoggingCategory::setFilterRules(
|
|
139
|
QLoggingCategory::setFilterRules(
|
|
120
|
"*.warning=false\n"
|
|
140
|
"*.warning=false\n"
|
|
121
|
"*.info=false\n"
|
|
141
|
"*.info=false\n"
|
|
122
|
"*.debug=false\n"
|
|
142
|
"*.debug=false\n"
|
|
123
|
"FuzzingOperations.info=true\n"
|
|
143
|
"FuzzingOperations.info=true\n"
|
|
124
|
"TestAmdaFuzzing.info=true\n");
|
|
144
|
"TestAmdaFuzzing.info=true\n");
|
|
125
|
|
|
145
|
|
|
126
|
SqpApplication app{argc, argv};
|
|
146
|
SqpApplication app{argc, argv};
|
|
127
|
app.setAttribute(Qt::AA_Use96Dpi, true);
|
|
147
|
app.setAttribute(Qt::AA_Use96Dpi, true);
|
|
128
|
TestAmdaFuzzing testObject{};
|
|
148
|
TestAmdaFuzzing testObject{};
|
|
129
|
QTEST_SET_MAIN_SOURCE_PATH
|
|
149
|
QTEST_SET_MAIN_SOURCE_PATH
|
|
130
|
return QTest::qExec(&testObject, argc, argv);
|
|
150
|
return QTest::qExec(&testObject, argc, argv);
|
|
131
|
}
|
|
151
|
}
|
|
132
|
|
|
152
|
|
|
133
|
#include "TestAmdaFuzzing.moc"
|
|
153
|
#include "TestAmdaFuzzing.moc"
|