##// END OF EJS Templates
add fuzzing amda test skip
perrinel -
r1401:5ce5cfcc084a develop
parent child
Show More
@@ -1,560 +1,560
1 #include "FuzzingDefs.h"
1 #include "FuzzingDefs.h"
2 #include "FuzzingOperations.h"
2 #include "FuzzingOperations.h"
3 #include "FuzzingUtils.h"
3 #include "FuzzingUtils.h"
4 #include "FuzzingValidators.h"
4 #include "FuzzingValidators.h"
5
5
6 #include "AmdaProvider.h"
6 #include "AmdaProvider.h"
7
7
8 #include <Common/SignalWaiter.h>
8 #include <Common/SignalWaiter.h>
9 #include <Network/NetworkController.h>
9 #include <Network/NetworkController.h>
10 #include <Settings/SqpSettingsDefs.h>
10 #include <Settings/SqpSettingsDefs.h>
11 #include <SqpApplication.h>
11 #include <SqpApplication.h>
12 #include <Time/TimeController.h>
12 #include <Time/TimeController.h>
13 #include <Variable/Variable.h>
13 #include <Variable/Variable.h>
14 #include <Variable/VariableController.h>
14 #include <Variable/VariableController.h>
15
15
16 #include <QLoggingCategory>
16 #include <QLoggingCategory>
17 #include <QObject>
17 #include <QObject>
18 #include <QtTest>
18 #include <QtTest>
19
19
20 #include <memory>
20 #include <memory>
21
21
22 Q_LOGGING_CATEGORY(LOG_TestAmdaFuzzing, "TestAmdaFuzzing")
22 Q_LOGGING_CATEGORY(LOG_TestAmdaFuzzing, "TestAmdaFuzzing")
23
23
24 /**
24 /**
25 * Macro used to generate a getter for a property in @sa FuzzingTest. The macro generates a static
25 * Macro used to generate a getter for a property in @sa FuzzingTest. The macro generates a static
26 * attribute that is initialized by searching in properties the property and use a default value if
26 * attribute that is initialized by searching in properties the property and use a default value if
27 * it's not present. Macro arguments are:
27 * it's not present. Macro arguments are:
28 * - GETTER_NAME : name of the getter
28 * - GETTER_NAME : name of the getter
29 * - PROPERTY_NAME: used to generate constants for property's name ({PROPERTY_NAME}_PROPERTY) and
29 * - PROPERTY_NAME: used to generate constants for property's name ({PROPERTY_NAME}_PROPERTY) and
30 * default value ({PROPERTY_NAME}_DEFAULT_VALUE)
30 * default value ({PROPERTY_NAME}_DEFAULT_VALUE)
31 * - TYPE : return type of the getter
31 * - TYPE : return type of the getter
32 */
32 */
33 // clang-format off
33 // clang-format off
34 #define DECLARE_PROPERTY_GETTER(GETTER_NAME, PROPERTY_NAME, TYPE) \
34 #define DECLARE_PROPERTY_GETTER(GETTER_NAME, PROPERTY_NAME, TYPE) \
35 TYPE GETTER_NAME() const \
35 TYPE GETTER_NAME() const \
36 { \
36 { \
37 static auto result = m_Properties.value(PROPERTY_NAME##_PROPERTY, PROPERTY_NAME##_DEFAULT_VALUE).value<TYPE>(); \
37 static auto result = m_Properties.value(PROPERTY_NAME##_PROPERTY, PROPERTY_NAME##_DEFAULT_VALUE).value<TYPE>(); \
38 return result; \
38 return result; \
39 } \
39 } \
40 // clang-format on
40 // clang-format on
41
41
42 namespace {
42 namespace {
43
43
44 // /////// //
44 // /////// //
45 // Aliases //
45 // Aliases //
46 // /////// //
46 // /////// //
47
47
48 using IntPair = std::pair<int, int>;
48 using IntPair = std::pair<int, int>;
49 using Weight = double;
49 using Weight = double;
50 using Weights = std::vector<Weight>;
50 using Weights = std::vector<Weight>;
51
51
52 struct OperationProperty {
52 struct OperationProperty {
53 Weight m_Weight{1.};
53 Weight m_Weight{1.};
54 bool m_WaitAcquisition{false};
54 bool m_WaitAcquisition{false};
55 };
55 };
56
56
57 using VariableOperation = std::pair<VariableId, std::shared_ptr<IFuzzingOperation> >;
57 using VariableOperation = std::pair<VariableId, std::shared_ptr<IFuzzingOperation> >;
58 using VariablesOperations = std::vector<VariableOperation>;
58 using VariablesOperations = std::vector<VariableOperation>;
59
59
60 struct CustomVariableOperation {
60 struct CustomVariableOperation {
61 VariableOperation m_VariableOperation{};
61 VariableOperation m_VariableOperation{};
62 bool m_WaitAcquisition{false};
62 bool m_WaitAcquisition{false};
63 };
63 };
64 using CustomVariablesOperations = std::vector<CustomVariableOperation>;
64 using CustomVariablesOperations = std::vector<CustomVariableOperation>;
65
65
66 using OperationsTypes = std::map<FuzzingOperationType, OperationProperty>;
66 using OperationsTypes = std::map<FuzzingOperationType, OperationProperty>;
67 using OperationsPool = std::map<std::shared_ptr<IFuzzingOperation>, OperationProperty>;
67 using OperationsPool = std::map<std::shared_ptr<IFuzzingOperation>, OperationProperty>;
68
68
69 using Validators = std::vector<std::shared_ptr<IFuzzingValidator> >;
69 using Validators = std::vector<std::shared_ptr<IFuzzingValidator> >;
70
70
71 // ///////// //
71 // ///////// //
72 // Constants //
72 // Constants //
73 // ///////// //
73 // ///////// //
74
74
75 // Defaults values used when the associated properties have not been set for the test
75 // Defaults values used when the associated properties have not been set for the test
76 const auto ACQUISITION_TIMEOUT_DEFAULT_VALUE = 100000;
76 const auto ACQUISITION_TIMEOUT_DEFAULT_VALUE = 100000;
77 const auto NB_MAX_OPERATIONS_DEFAULT_VALUE = 160;
77 const auto NB_MAX_OPERATIONS_DEFAULT_VALUE = 160;
78 const auto NB_MAX_SYNC_GROUPS_DEFAULT_VALUE = 8;
78 const auto NB_MAX_SYNC_GROUPS_DEFAULT_VALUE = 8;
79 const auto NB_MAX_VARIABLES_DEFAULT_VALUE = 30;
79 const auto NB_MAX_VARIABLES_DEFAULT_VALUE = 30;
80 const auto AVAILABLE_OPERATIONS_DEFAULT_VALUE = QVariant::fromValue(
80 const auto AVAILABLE_OPERATIONS_DEFAULT_VALUE = QVariant::fromValue(
81 OperationsTypes{{FuzzingOperationType::CREATE, {40000., true}},
81 OperationsTypes{{FuzzingOperationType::CREATE, {40000., true}},
82 {FuzzingOperationType::DELETE, {0.0}}, // Delete operation is less frequent
82 {FuzzingOperationType::DELETE, {0.0}}, // Delete operation is less frequent
83 {FuzzingOperationType::PAN_LEFT, {1.}},
83 {FuzzingOperationType::PAN_LEFT, {1.}},
84 {FuzzingOperationType::PAN_RIGHT, {1.}},
84 {FuzzingOperationType::PAN_RIGHT, {1.}},
85 {FuzzingOperationType::ZOOM_IN, {1.}},
85 {FuzzingOperationType::ZOOM_IN, {1.}},
86 {FuzzingOperationType::ZOOM_OUT, {1.}},
86 {FuzzingOperationType::ZOOM_OUT, {1.}},
87 {FuzzingOperationType::SYNCHRONIZE, {500.0}},
87 {FuzzingOperationType::SYNCHRONIZE, {500.0}},
88 {FuzzingOperationType::DESYNCHRONIZE, {0.0}}});
88 {FuzzingOperationType::DESYNCHRONIZE, {0.0}}});
89 const auto CACHE_TOLERANCE_DEFAULT_VALUE = 0.2;
89 const auto CACHE_TOLERANCE_DEFAULT_VALUE = 0.2;
90
90
91 /// Min/max delays between each operation (in ms)
91 /// Min/max delays between each operation (in ms)
92 const auto OPERATION_DELAY_BOUNDS_DEFAULT_VALUE = QVariant::fromValue(std::make_pair(20, 3000));
92 const auto OPERATION_DELAY_BOUNDS_DEFAULT_VALUE = QVariant::fromValue(std::make_pair(20, 3000));
93
93
94 /// Validators for the tests (executed in the order in which they're defined)
94 /// Validators for the tests (executed in the order in which they're defined)
95 const auto VALIDATORS_DEFAULT_VALUE = QVariant::fromValue(
95 const auto VALIDATORS_DEFAULT_VALUE = QVariant::fromValue(
96 ValidatorsTypes{{FuzzingValidatorType::RANGE, FuzzingValidatorType::DATA}});
96 ValidatorsTypes{{FuzzingValidatorType::RANGE, FuzzingValidatorType::DATA}});
97
97
98 /// Min/max number of operations to execute before calling validation
98 /// Min/max number of operations to execute before calling validation
99 const auto VALIDATION_FREQUENCY_BOUNDS_DEFAULT_VALUE = QVariant::fromValue(std::make_pair(2, 10));
99 const auto VALIDATION_FREQUENCY_BOUNDS_DEFAULT_VALUE = QVariant::fromValue(std::make_pair(2, 10));
100
100
101
101
102 // /////// //////
102 // /////// //////
103 // CUSTOM CASE //
103 // CUSTOM CASE //
104 // /////// //////
104 // /////// //////
105
105
106 auto op = [](auto type){
106 auto op = [](auto type){
107 return FuzzingOperationFactory::create(type);
107 return FuzzingOperationFactory::create(type);
108 };
108 };
109
109
110
110
111 const QVariant CUSTOM_CASE_ONE =QVariant::fromValue(CustomVariablesOperations{{{0, op(FuzzingOperationType::CREATE)}, true},
111 const QVariant CUSTOM_CASE_ONE =QVariant::fromValue(CustomVariablesOperations{{{0, op(FuzzingOperationType::CREATE)}, true},
112 {{0, op(FuzzingOperationType::SYNCHRONIZE)}},
112 {{0, op(FuzzingOperationType::SYNCHRONIZE)}},
113 {{1, op(FuzzingOperationType::CREATE)}, true},
113 {{1, op(FuzzingOperationType::CREATE)}, true},
114 {{1, op(FuzzingOperationType::SYNCHRONIZE)}},
114 {{1, op(FuzzingOperationType::SYNCHRONIZE)}},
115 {{0, op(FuzzingOperationType::PAN_LEFT)}},
115 {{0, op(FuzzingOperationType::PAN_LEFT)}},
116 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
116 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
117 {{0, op(FuzzingOperationType::PAN_LEFT)}},
117 {{0, op(FuzzingOperationType::PAN_LEFT)}},
118 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
118 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
119 {{0, op(FuzzingOperationType::PAN_LEFT)}},
119 {{0, op(FuzzingOperationType::PAN_LEFT)}},
120 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
120 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
121 {{0, op(FuzzingOperationType::PAN_LEFT)}},
121 {{0, op(FuzzingOperationType::PAN_LEFT)}},
122 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
122 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
123 {{0, op(FuzzingOperationType::PAN_LEFT)}},
123 {{0, op(FuzzingOperationType::PAN_LEFT)}},
124 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
124 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
125 {{0, op(FuzzingOperationType::PAN_RIGHT)}},
125 {{0, op(FuzzingOperationType::PAN_RIGHT)}},
126 {{1, op(FuzzingOperationType::PAN_LEFT)}},
126 {{1, op(FuzzingOperationType::PAN_LEFT)}},
127 {{0, op(FuzzingOperationType::PAN_RIGHT)}},
127 {{0, op(FuzzingOperationType::PAN_RIGHT)}},
128 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
128 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
129 {{0, op(FuzzingOperationType::PAN_LEFT)}},
129 {{0, op(FuzzingOperationType::PAN_LEFT)}},
130 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
130 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
131 {{0, op(FuzzingOperationType::PAN_LEFT)}},
131 {{0, op(FuzzingOperationType::PAN_LEFT)}},
132 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
132 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
133 {{0, op(FuzzingOperationType::PAN_LEFT)}},
133 {{0, op(FuzzingOperationType::PAN_LEFT)}},
134 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
134 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
135 {{0, op(FuzzingOperationType::PAN_LEFT)}},
135 {{0, op(FuzzingOperationType::PAN_LEFT)}},
136 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
136 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
137 {{0, op(FuzzingOperationType::PAN_LEFT)}},
137 {{0, op(FuzzingOperationType::PAN_LEFT)}},
138 {{1, op(FuzzingOperationType::PAN_LEFT)}},
138 {{1, op(FuzzingOperationType::PAN_LEFT)}},
139 {{0, op(FuzzingOperationType::PAN_LEFT)}},
139 {{0, op(FuzzingOperationType::PAN_LEFT)}},
140 {{1, op(FuzzingOperationType::PAN_LEFT)}},
140 {{1, op(FuzzingOperationType::PAN_LEFT)}},
141 {{0, op(FuzzingOperationType::PAN_RIGHT)}},
141 {{0, op(FuzzingOperationType::PAN_RIGHT)}},
142 {{1, op(FuzzingOperationType::PAN_LEFT)}},
142 {{1, op(FuzzingOperationType::PAN_LEFT)}},
143 {{0, op(FuzzingOperationType::PAN_RIGHT)}},
143 {{0, op(FuzzingOperationType::PAN_RIGHT)}},
144 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
144 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
145 {{0, op(FuzzingOperationType::PAN_LEFT)}},
145 {{0, op(FuzzingOperationType::PAN_LEFT)}},
146 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
146 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
147 {{0, op(FuzzingOperationType::PAN_LEFT)}},
147 {{0, op(FuzzingOperationType::PAN_LEFT)}},
148 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
148 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
149 {{0, op(FuzzingOperationType::PAN_LEFT)}},
149 {{0, op(FuzzingOperationType::PAN_LEFT)}},
150 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
150 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
151 {{0, op(FuzzingOperationType::PAN_LEFT)}},
151 {{0, op(FuzzingOperationType::PAN_LEFT)}},
152 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
152 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
153 {{0, op(FuzzingOperationType::PAN_LEFT)}},
153 {{0, op(FuzzingOperationType::PAN_LEFT)}},
154 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
154 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
155 {{0, op(FuzzingOperationType::PAN_LEFT)}},
155 {{0, op(FuzzingOperationType::PAN_LEFT)}},
156 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
156 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
157 {{0, op(FuzzingOperationType::PAN_RIGHT)}},
157 {{0, op(FuzzingOperationType::PAN_RIGHT)}},
158 {{1, op(FuzzingOperationType::PAN_LEFT)}},
158 {{1, op(FuzzingOperationType::PAN_LEFT)}},
159 {{0, op(FuzzingOperationType::PAN_RIGHT)}},
159 {{0, op(FuzzingOperationType::PAN_RIGHT)}},
160 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
160 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
161 {{0, op(FuzzingOperationType::PAN_LEFT)}},
161 {{0, op(FuzzingOperationType::PAN_LEFT)}},
162 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
162 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
163 {{0, op(FuzzingOperationType::PAN_LEFT)}},
163 {{0, op(FuzzingOperationType::PAN_LEFT)}},
164 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
164 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
165 {{0, op(FuzzingOperationType::PAN_RIGHT)}},
165 {{0, op(FuzzingOperationType::PAN_RIGHT)}},
166 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
166 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
167 {{0, op(FuzzingOperationType::PAN_LEFT)}},
167 {{0, op(FuzzingOperationType::PAN_LEFT)}},
168 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
168 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
169 {{0, op(FuzzingOperationType::PAN_LEFT)}},
169 {{0, op(FuzzingOperationType::PAN_LEFT)}},
170 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
170 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
171 {{0, op(FuzzingOperationType::PAN_LEFT)}},
171 {{0, op(FuzzingOperationType::PAN_LEFT)}},
172 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
172 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
173 {{0, op(FuzzingOperationType::PAN_RIGHT)}},
173 {{0, op(FuzzingOperationType::PAN_RIGHT)}},
174 {{1, op(FuzzingOperationType::PAN_LEFT)}},
174 {{1, op(FuzzingOperationType::PAN_LEFT)}},
175 {{0, op(FuzzingOperationType::PAN_RIGHT)}},
175 {{0, op(FuzzingOperationType::PAN_RIGHT)}},
176 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
176 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
177 {{0, op(FuzzingOperationType::PAN_LEFT)}},
177 {{0, op(FuzzingOperationType::PAN_LEFT)}},
178 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
178 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
179 {{0, op(FuzzingOperationType::PAN_LEFT)}},
179 {{0, op(FuzzingOperationType::PAN_LEFT)}},
180 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
180 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
181 {{0, op(FuzzingOperationType::PAN_LEFT)}},
181 {{0, op(FuzzingOperationType::PAN_LEFT)}},
182 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
182 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
183 {{0, op(FuzzingOperationType::PAN_LEFT)}},
183 {{0, op(FuzzingOperationType::PAN_LEFT)}},
184 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
184 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
185 {{0, op(FuzzingOperationType::PAN_LEFT)}},
185 {{0, op(FuzzingOperationType::PAN_LEFT)}},
186 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
186 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
187 {{0, op(FuzzingOperationType::PAN_LEFT)}},
187 {{0, op(FuzzingOperationType::PAN_LEFT)}},
188 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
188 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
189 {{0, op(FuzzingOperationType::PAN_RIGHT)}},
189 {{0, op(FuzzingOperationType::PAN_RIGHT)}},
190 {{1, op(FuzzingOperationType::PAN_LEFT)}},
190 {{1, op(FuzzingOperationType::PAN_LEFT)}},
191 {{0, op(FuzzingOperationType::PAN_RIGHT)}},
191 {{0, op(FuzzingOperationType::PAN_RIGHT)}},
192 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
192 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
193 {{0, op(FuzzingOperationType::PAN_RIGHT)}},
193 {{0, op(FuzzingOperationType::PAN_RIGHT)}},
194 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
194 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
195 {{0, op(FuzzingOperationType::PAN_LEFT)}},
195 {{0, op(FuzzingOperationType::PAN_LEFT)}},
196 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
196 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
197 {{0, op(FuzzingOperationType::PAN_LEFT)}},
197 {{0, op(FuzzingOperationType::PAN_LEFT)}},
198 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
198 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
199 {{0, op(FuzzingOperationType::PAN_LEFT)}},
199 {{0, op(FuzzingOperationType::PAN_LEFT)}},
200 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
200 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
201 {{0, op(FuzzingOperationType::PAN_LEFT)}},
201 {{0, op(FuzzingOperationType::PAN_LEFT)}},
202 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
202 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
203 {{0, op(FuzzingOperationType::PAN_LEFT)}},
203 {{0, op(FuzzingOperationType::PAN_LEFT)}},
204 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
204 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
205 {{0, op(FuzzingOperationType::PAN_RIGHT)}},
205 {{0, op(FuzzingOperationType::PAN_RIGHT)}},
206 {{1, op(FuzzingOperationType::PAN_LEFT)}},
206 {{1, op(FuzzingOperationType::PAN_LEFT)}},
207 {{0, op(FuzzingOperationType::PAN_RIGHT)}},
207 {{0, op(FuzzingOperationType::PAN_RIGHT)}},
208 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
208 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
209 {{0, op(FuzzingOperationType::PAN_LEFT)}},
209 {{0, op(FuzzingOperationType::PAN_LEFT)}},
210 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
210 {{1, op(FuzzingOperationType::PAN_RIGHT)}},
211 });
211 });
212
212
213 const QVariant CUSTOM_CASE_TWO =QVariant::fromValue(CustomVariablesOperations{{{0, op(FuzzingOperationType::CREATE)}, true},
213 const QVariant CUSTOM_CASE_TWO =QVariant::fromValue(CustomVariablesOperations{{{0, op(FuzzingOperationType::CREATE)}, true},
214 {{0, op(FuzzingOperationType::SYNCHRONIZE)}},
214 {{0, op(FuzzingOperationType::SYNCHRONIZE)}},
215 {{1, op(FuzzingOperationType::CREATE)}, true},
215 {{1, op(FuzzingOperationType::CREATE)}, true},
216 {{1, op(FuzzingOperationType::SYNCHRONIZE)}},
216 {{1, op(FuzzingOperationType::SYNCHRONIZE)}},
217 {{1, op(FuzzingOperationType::ZOOM_OUT)}},
217 {{1, op(FuzzingOperationType::ZOOM_OUT)}},
218 {{1, op(FuzzingOperationType::ZOOM_IN)}},
218 {{1, op(FuzzingOperationType::ZOOM_IN)}},
219 });
219 });
220
220
221 // /////// //
221 // /////// //
222 // Methods //
222 // Methods //
223 // /////// //
223 // /////// //
224
224
225 /// Goes through the variables pool and operations pool to determine the set of {variable/operation}
225 /// Goes through the variables pool and operations pool to determine the set of {variable/operation}
226 /// pairs that are valid (i.e. operation that can be executed on variable)
226 /// pairs that are valid (i.e. operation that can be executed on variable)
227 std::pair<VariablesOperations, Weights> availableOperations(const FuzzingState &fuzzingState,
227 std::pair<VariablesOperations, Weights> availableOperations(const FuzzingState &fuzzingState,
228 const OperationsPool &operationsPool)
228 const OperationsPool &operationsPool)
229 {
229 {
230 VariablesOperations result{};
230 VariablesOperations result{};
231 Weights weights{};
231 Weights weights{};
232
232
233 for (const auto &variablesPoolEntry : fuzzingState.m_VariablesPool) {
233 for (const auto &variablesPoolEntry : fuzzingState.m_VariablesPool) {
234 auto variableId = variablesPoolEntry.first;
234 auto variableId = variablesPoolEntry.first;
235
235
236 for (const auto &operationsPoolEntry : operationsPool) {
236 for (const auto &operationsPoolEntry : operationsPool) {
237 auto operation = operationsPoolEntry.first;
237 auto operation = operationsPoolEntry.first;
238 auto operationProperty = operationsPoolEntry.second;
238 auto operationProperty = operationsPoolEntry.second;
239
239
240 // A pair is valid if the current operation can be executed on the current variable
240 // A pair is valid if the current operation can be executed on the current variable
241 if (operation->canExecute(variableId, fuzzingState)) {
241 if (operation->canExecute(variableId, fuzzingState)) {
242 result.push_back({variableId, operation});
242 result.push_back({variableId, operation});
243 weights.push_back(operationProperty.m_Weight);
243 weights.push_back(operationProperty.m_Weight);
244 }
244 }
245 }
245 }
246 }
246 }
247
247
248 return {result, weights};
248 return {result, weights};
249 }
249 }
250
250
251 OperationsPool createOperationsPool(const OperationsTypes &types)
251 OperationsPool createOperationsPool(const OperationsTypes &types)
252 {
252 {
253 OperationsPool result{};
253 OperationsPool result{};
254
254
255 std::transform(
255 std::transform(
256 types.cbegin(), types.cend(), std::inserter(result, result.end()), [](const auto &type) {
256 types.cbegin(), types.cend(), std::inserter(result, result.end()), [](const auto &type) {
257 return std::make_pair(FuzzingOperationFactory::create(type.first), type.second);
257 return std::make_pair(FuzzingOperationFactory::create(type.first), type.second);
258 });
258 });
259
259
260 return result;
260 return result;
261 }
261 }
262
262
263 Validators createValidators(const ValidatorsTypes &types)
263 Validators createValidators(const ValidatorsTypes &types)
264 {
264 {
265 Validators result{};
265 Validators result{};
266
266
267 std::transform(types.cbegin(), types.cend(), std::inserter(result, result.end()),
267 std::transform(types.cbegin(), types.cend(), std::inserter(result, result.end()),
268 [](const auto &type) { return FuzzingValidatorFactory::create(type); });
268 [](const auto &type) { return FuzzingValidatorFactory::create(type); });
269
269
270 return result;
270 return result;
271 }
271 }
272
272
273 /**
273 /**
274 * Validates all the variables' states passed in parameter, according to a set of validators
274 * Validates all the variables' states passed in parameter, according to a set of validators
275 * @param variablesPool the variables' states
275 * @param variablesPool the variables' states
276 * @param validators the validators used for validation
276 * @param validators the validators used for validation
277 */
277 */
278 void validate(const VariablesPool &variablesPool, const Validators &validators)
278 void validate(const VariablesPool &variablesPool, const Validators &validators)
279 {
279 {
280 for (const auto &variablesPoolEntry : variablesPool) {
280 for (const auto &variablesPoolEntry : variablesPool) {
281 auto variableId = variablesPoolEntry.first;
281 auto variableId = variablesPoolEntry.first;
282 const auto &variableState = variablesPoolEntry.second;
282 const auto &variableState = variablesPoolEntry.second;
283
283
284 auto variableMessage = variableState.m_Variable ? variableState.m_Variable->name()
284 auto variableMessage = variableState.m_Variable ? variableState.m_Variable->name()
285 : QStringLiteral("null variable");
285 : QStringLiteral("null variable");
286 qCInfo(LOG_TestAmdaFuzzing()).noquote() << "Validating state of variable at index"
286 qCInfo(LOG_TestAmdaFuzzing()).noquote() << "Validating state of variable at index"
287 << variableId << "(" << variableMessage << ")...";
287 << variableId << "(" << variableMessage << ")...";
288
288
289 for (const auto &validator : validators) {
289 for (const auto &validator : validators) {
290 validator->validate(VariableState{variableState});
290 validator->validate(VariableState{variableState});
291 }
291 }
292
292
293 qCInfo(LOG_TestAmdaFuzzing()).noquote() << "Validation completed.";
293 qCInfo(LOG_TestAmdaFuzzing()).noquote() << "Validation completed.";
294 }
294 }
295 }
295 }
296
296
297 /**
297 /**
298 * Class to run random tests
298 * Class to run random tests
299 */
299 */
300 class FuzzingTest {
300 class FuzzingTest {
301 public:
301 public:
302 explicit FuzzingTest(VariableController &variableController, Properties properties)
302 explicit FuzzingTest(VariableController &variableController, Properties properties)
303 : m_VariableController{variableController},
303 : m_VariableController{variableController},
304 m_Properties{std::move(properties)},
304 m_Properties{std::move(properties)},
305 m_FuzzingState{}
305 m_FuzzingState{}
306 {
306 {
307 // Inits variables pool: at init, all variables are null
307 // Inits variables pool: at init, all variables are null
308 for (auto variableId = 0; variableId < nbMaxVariables(); ++variableId) {
308 for (auto variableId = 0; variableId < nbMaxVariables(); ++variableId) {
309 m_FuzzingState.m_VariablesPool[variableId] = VariableState{};
309 m_FuzzingState.m_VariablesPool[variableId] = VariableState{};
310 }
310 }
311
311
312 // Inits sync groups and registers them into the variable controller
312 // Inits sync groups and registers them into the variable controller
313 for (auto i = 0; i < nbMaxSyncGroups(); ++i) {
313 for (auto i = 0; i < nbMaxSyncGroups(); ++i) {
314 auto syncGroupId = SyncGroupId::createUuid();
314 auto syncGroupId = SyncGroupId::createUuid();
315 variableController.onAddSynchronizationGroupId(syncGroupId);
315 variableController.onAddSynchronizationGroupId(syncGroupId);
316 m_FuzzingState.m_SyncGroupsPool[syncGroupId] = SyncGroup{};
316 m_FuzzingState.m_SyncGroupsPool[syncGroupId] = SyncGroup{};
317 }
317 }
318 }
318 }
319
319
320 void execute()
320 void execute()
321 {
321 {
322
322
323 // Inits the count of the number of operations before the next validation
323 // Inits the count of the number of operations before the next validation
324 int nextValidationCounter = 0;
324 int nextValidationCounter = 0;
325 auto updateValidationCounter = [this, &nextValidationCounter]() {
325 auto updateValidationCounter = [this, &nextValidationCounter]() {
326 nextValidationCounter = RandomGenerator::instance().generateInt(
326 nextValidationCounter = RandomGenerator::instance().generateInt(
327 validationFrequencies().first, validationFrequencies().second);
327 validationFrequencies().first, validationFrequencies().second);
328 qCInfo(LOG_TestAmdaFuzzing()).noquote()
328 qCInfo(LOG_TestAmdaFuzzing()).noquote()
329 << "Next validation in " << nextValidationCounter << "operation(s)...";
329 << "Next validation in " << nextValidationCounter << "operation(s)...";
330 };
330 };
331 updateValidationCounter();
331 updateValidationCounter();
332
332
333 // Get custom operations
333 // Get custom operations
334 auto customOperations = m_Properties.value(CUSTOM_OPERATIONS_PROPERTY).value<CustomVariablesOperations>();
334 auto customOperations = m_Properties.value(CUSTOM_OPERATIONS_PROPERTY).value<CustomVariablesOperations>();
335 auto isCustomTest = !customOperations.empty();
335 auto isCustomTest = !customOperations.empty();
336
336
337 auto nbOperations = isCustomTest ? customOperations.size() : nbMaxOperations();
337 auto nbOperations = isCustomTest ? customOperations.size() : nbMaxOperations();
338
338
339 qCInfo(LOG_TestAmdaFuzzing()).noquote() << "Running" << nbOperations << "operations on"
339 qCInfo(LOG_TestAmdaFuzzing()).noquote() << "Running" << nbOperations << "operations on"
340 << nbMaxVariables() << "variable(s)...";
340 << nbMaxVariables() << "variable(s)...";
341
341
342 auto canExecute = true;
342 auto canExecute = true;
343 for (auto i = 0; i < nbOperations && canExecute; ++i) {
343 for (auto i = 0; i < nbOperations && canExecute; ++i) {
344 VariableOperation variableOperation{};
344 VariableOperation variableOperation{};
345 auto forceWait = false;
345 auto forceWait = false;
346
346
347 if(isCustomTest){
347 if(isCustomTest){
348 auto customOperation = customOperations.front();
348 auto customOperation = customOperations.front();
349 variableOperation = customOperation.m_VariableOperation;
349 variableOperation = customOperation.m_VariableOperation;
350 customOperations.erase(customOperations.begin());
350 customOperations.erase(customOperations.begin());
351
351
352 canExecute = variableOperation.second->canExecute(variableOperation.first, m_FuzzingState);
352 canExecute = variableOperation.second->canExecute(variableOperation.first, m_FuzzingState);
353 forceWait = customOperation.m_WaitAcquisition;
353 forceWait = customOperation.m_WaitAcquisition;
354 } else {
354 } else {
355 // Retrieves all operations that can be executed in the current context
355 // Retrieves all operations that can be executed in the current context
356 VariablesOperations variableOperations{};
356 VariablesOperations variableOperations{};
357 Weights weights{};
357 Weights weights{};
358 std::tie(variableOperations, weights)
358 std::tie(variableOperations, weights)
359 = availableOperations(m_FuzzingState, operationsPool());
359 = availableOperations(m_FuzzingState, operationsPool());
360
360
361 // Of the operations available, chooses a random operation and executes it
361 // Of the operations available, chooses a random operation and executes it
362 variableOperation
362 variableOperation
363 = RandomGenerator::instance().randomChoice(variableOperations, weights);
363 = RandomGenerator::instance().randomChoice(variableOperations, weights);
364 canExecute = !variableOperations.empty();
364 canExecute = !variableOperations.empty();
365 forceWait = operationsPool().at(variableOperation.second).m_WaitAcquisition;
365 forceWait = operationsPool().at(variableOperation.second).m_WaitAcquisition;
366 }
366 }
367
367
368 if (canExecute) {
368 if (canExecute) {
369 --nextValidationCounter;
369 --nextValidationCounter;
370
370
371 auto variableId = variableOperation.first;
371 auto variableId = variableOperation.first;
372 auto fuzzingOperation = variableOperation.second;
372 auto fuzzingOperation = variableOperation.second;
373
373
374 auto waitAcquisition = nextValidationCounter == 0
374 auto waitAcquisition = nextValidationCounter == 0
375 || forceWait;
375 || forceWait;
376
376
377 qCInfo(LOG_TestAmdaFuzzing()).noquote() << "Operation :" << i +1 << " on"
377 qCInfo(LOG_TestAmdaFuzzing()).noquote() << "Operation :" << i +1 << " on"
378 << nbOperations;
378 << nbOperations;
379 fuzzingOperation->execute(variableId, m_FuzzingState, m_VariableController,
379 fuzzingOperation->execute(variableId, m_FuzzingState, m_VariableController,
380 m_Properties);
380 m_Properties);
381
381
382 if (waitAcquisition) {
382 if (waitAcquisition) {
383 qCDebug(LOG_TestAmdaFuzzing()) << "Waiting for acquisition to finish...";
383 qCDebug(LOG_TestAmdaFuzzing()) << "Waiting for acquisition to finish...";
384 SignalWaiter{m_VariableController, SIGNAL(acquisitionFinished())}.wait(
384 SignalWaiter{m_VariableController, SIGNAL(acquisitionFinished())}.wait(
385 acquisitionTimeout());
385 acquisitionTimeout());
386
386
387 // Validates variables
387 // Validates variables
388 if (nextValidationCounter == 0) {
388 if (nextValidationCounter == 0) {
389 validate(m_FuzzingState.m_VariablesPool, validators());
389 validate(m_FuzzingState.m_VariablesPool, validators());
390 updateValidationCounter();
390 updateValidationCounter();
391 }
391 }
392 }
392 }
393 else {
393 else {
394 // Delays the next operation with a randomly generated time
394 // Delays the next operation with a randomly generated time
395 auto delay = RandomGenerator::instance().generateInt(operationDelays().first,
395 auto delay = RandomGenerator::instance().generateInt(operationDelays().first,
396 operationDelays().second);
396 operationDelays().second);
397 qCDebug(LOG_TestAmdaFuzzing())
397 qCDebug(LOG_TestAmdaFuzzing())
398 << "Waiting " << delay << "ms before the next operation...";
398 << "Waiting " << delay << "ms before the next operation...";
399 QTest::qWait(delay);
399 QTest::qWait(delay);
400 }
400 }
401 }
401 }
402 else {
402 else {
403 qCInfo(LOG_TestAmdaFuzzing()).noquote()
403 qCInfo(LOG_TestAmdaFuzzing()).noquote()
404 << "No more operations are available, the execution of the test will stop...";
404 << "No more operations are available, the execution of the test will stop...";
405 }
405 }
406 }
406 }
407
407
408 qCInfo(LOG_TestAmdaFuzzing()).noquote() << "Execution of the test completed.";
408 qCInfo(LOG_TestAmdaFuzzing()).noquote() << "Execution of the test completed.";
409 }
409 }
410
410
411 private:
411 private:
412 OperationsPool operationsPool() const
412 OperationsPool operationsPool() const
413 {
413 {
414 static auto result = createOperationsPool(
414 static auto result = createOperationsPool(
415 m_Properties.value(AVAILABLE_OPERATIONS_PROPERTY, AVAILABLE_OPERATIONS_DEFAULT_VALUE)
415 m_Properties.value(AVAILABLE_OPERATIONS_PROPERTY, AVAILABLE_OPERATIONS_DEFAULT_VALUE)
416 .value<OperationsTypes>());
416 .value<OperationsTypes>());
417 return result;
417 return result;
418 }
418 }
419
419
420 Validators validators() const
420 Validators validators() const
421 {
421 {
422 static auto result
422 static auto result
423 = createValidators(m_Properties.value(VALIDATORS_PROPERTY, VALIDATORS_DEFAULT_VALUE)
423 = createValidators(m_Properties.value(VALIDATORS_PROPERTY, VALIDATORS_DEFAULT_VALUE)
424 .value<ValidatorsTypes>());
424 .value<ValidatorsTypes>());
425 return result;
425 return result;
426 }
426 }
427
427
428 DECLARE_PROPERTY_GETTER(nbMaxOperations, NB_MAX_OPERATIONS, int)
428 DECLARE_PROPERTY_GETTER(nbMaxOperations, NB_MAX_OPERATIONS, int)
429 DECLARE_PROPERTY_GETTER(nbMaxSyncGroups, NB_MAX_SYNC_GROUPS, int)
429 DECLARE_PROPERTY_GETTER(nbMaxSyncGroups, NB_MAX_SYNC_GROUPS, int)
430 DECLARE_PROPERTY_GETTER(nbMaxVariables, NB_MAX_VARIABLES, int)
430 DECLARE_PROPERTY_GETTER(nbMaxVariables, NB_MAX_VARIABLES, int)
431 DECLARE_PROPERTY_GETTER(operationDelays, OPERATION_DELAY_BOUNDS, IntPair)
431 DECLARE_PROPERTY_GETTER(operationDelays, OPERATION_DELAY_BOUNDS, IntPair)
432 DECLARE_PROPERTY_GETTER(validationFrequencies, VALIDATION_FREQUENCY_BOUNDS, IntPair)
432 DECLARE_PROPERTY_GETTER(validationFrequencies, VALIDATION_FREQUENCY_BOUNDS, IntPair)
433 DECLARE_PROPERTY_GETTER(acquisitionTimeout, ACQUISITION_TIMEOUT, int)
433 DECLARE_PROPERTY_GETTER(acquisitionTimeout, ACQUISITION_TIMEOUT, int)
434
434
435 VariableController &m_VariableController;
435 VariableController &m_VariableController;
436 Properties m_Properties;
436 Properties m_Properties;
437 FuzzingState m_FuzzingState;
437 FuzzingState m_FuzzingState;
438 };
438 };
439
439
440 } // namespace
440 } // namespace
441
441
442 Q_DECLARE_METATYPE(OperationsTypes)
442 Q_DECLARE_METATYPE(OperationsTypes)
443 Q_DECLARE_METATYPE(CustomVariablesOperations)
443 Q_DECLARE_METATYPE(CustomVariablesOperations)
444
444
445 class TestAmdaFuzzing : public QObject {
445 class TestAmdaFuzzing : public QObject {
446 Q_OBJECT
446 Q_OBJECT
447
447
448 private slots:
448 private slots:
449 /// Input data for @sa testFuzzing()
449 /// Input data for @sa testFuzzing()
450 void testFuzzing_data();
450 void testFuzzing_data();
451 void testFuzzing();
451 void testFuzzing();
452 };
452 };
453
453
454 void TestAmdaFuzzing::testFuzzing_data()
454 void TestAmdaFuzzing::testFuzzing_data()
455 {
455 {
456 // Note: Comment this line to run fuzzing tests
456 // Note: Comment this line to run fuzzing tests
457 // QSKIP("Fuzzing tests are disabled by default");
457 QSKIP("Fuzzing tests are disabled by default");
458
458
459 // ////////////// //
459 // ////////////// //
460 // Test structure //
460 // Test structure //
461 // ////////////// //
461 // ////////////// //
462
462
463 QTest::addColumn<Properties>("properties"); // Properties for random test
463 QTest::addColumn<Properties>("properties"); // Properties for random test
464
464
465 // ////////// //
465 // ////////// //
466 // Test cases //
466 // Test cases //
467 // ////////// //
467 // ////////// //
468
468
469 auto maxRange = SqpRange::fromDateTime({2017, 1, 5}, {8, 0}, {2017, 1, 5}, {16, 0});
469 auto maxRange = SqpRange::fromDateTime({2017, 1, 5}, {8, 0}, {2017, 1, 5}, {16, 0});
470 MetadataPool metadataPool{{{"dataType", "vector"}, {"xml:id", "c1_b"}}};
470 MetadataPool metadataPool{{{"dataType", "vector"}, {"xml:id", "c1_b"}}};
471
471
472 // Note: we don't use auto here as we want to pass std::shared_ptr<IDataProvider> as is in the
472 // Note: we don't use auto here as we want to pass std::shared_ptr<IDataProvider> as is in the
473 // QVariant
473 // QVariant
474 std::shared_ptr<IDataProvider> provider = std::make_shared<AmdaProvider>();
474 std::shared_ptr<IDataProvider> provider = std::make_shared<AmdaProvider>();
475
475
476
476
477 // Case Custom one : Only lot of pan on two variables synchronized
477 // Case Custom one : Only lot of pan on two variables synchronized
478 // QTest::newRow("fuzzingTestPan") << Properties{
478 // QTest::newRow("fuzzingTestPan") << Properties{
479 // {MAX_RANGE_PROPERTY, QVariant::fromValue(maxRange)},
479 // {MAX_RANGE_PROPERTY, QVariant::fromValue(maxRange)},
480 // {METADATA_POOL_PROPERTY, QVariant::fromValue(metadataPool)},
480 // {METADATA_POOL_PROPERTY, QVariant::fromValue(metadataPool)},
481 // {PROVIDER_PROPERTY, QVariant::fromValue(provider)},
481 // {PROVIDER_PROPERTY, QVariant::fromValue(provider)},
482 // {CUSTOM_OPERATIONS_PROPERTY, CUSTOM_CASE_ONE}};
482 // {CUSTOM_OPERATIONS_PROPERTY, CUSTOM_CASE_ONE}};
483
483
484 // QTest::newRow("fuzzingTestZoom") << Properties{
484 // QTest::newRow("fuzzingTestZoom") << Properties{
485 // {MAX_RANGE_PROPERTY, QVariant::fromValue(maxRange)},
485 // {MAX_RANGE_PROPERTY, QVariant::fromValue(maxRange)},
486 // {METADATA_POOL_PROPERTY, QVariant::fromValue(metadataPool)},
486 // {METADATA_POOL_PROPERTY, QVariant::fromValue(metadataPool)},
487 // {PROVIDER_PROPERTY, QVariant::fromValue(provider)},
487 // {PROVIDER_PROPERTY, QVariant::fromValue(provider)},
488 // {CUSTOM_OPERATIONS_PROPERTY, CUSTOM_CASE_TWO}};
488 // {CUSTOM_OPERATIONS_PROPERTY, CUSTOM_CASE_TWO}};
489
489
490
490
491 //// Fuzzing
491 //// Fuzzing
492 QTest::newRow("fuzzingTest") << Properties{
492 QTest::newRow("fuzzingTest") << Properties{
493 {MAX_RANGE_PROPERTY, QVariant::fromValue(maxRange)},
493 {MAX_RANGE_PROPERTY, QVariant::fromValue(maxRange)},
494 {METADATA_POOL_PROPERTY, QVariant::fromValue(metadataPool)},
494 {METADATA_POOL_PROPERTY, QVariant::fromValue(metadataPool)},
495 {PROVIDER_PROPERTY, QVariant::fromValue(provider)}};
495 {PROVIDER_PROPERTY, QVariant::fromValue(provider)}};
496
496
497 }
497 }
498
498
499 void TestAmdaFuzzing::testFuzzing()
499 void TestAmdaFuzzing::testFuzzing()
500 {
500 {
501 QFETCH(Properties, properties);
501 QFETCH(Properties, properties);
502
502
503 // Sets cache property
503 // Sets cache property
504 QSettings settings{};
504 QSettings settings{};
505 auto cacheTolerance = properties.value(CACHE_TOLERANCE_PROPERTY, CACHE_TOLERANCE_DEFAULT_VALUE);
505 auto cacheTolerance = properties.value(CACHE_TOLERANCE_PROPERTY, CACHE_TOLERANCE_DEFAULT_VALUE);
506 settings.setValue(GENERAL_TOLERANCE_AT_INIT_KEY, cacheTolerance);
506 settings.setValue(GENERAL_TOLERANCE_AT_INIT_KEY, cacheTolerance);
507 settings.setValue(GENERAL_TOLERANCE_AT_UPDATE_KEY, cacheTolerance);
507 settings.setValue(GENERAL_TOLERANCE_AT_UPDATE_KEY, cacheTolerance);
508
508
509 auto &variableController = sqpApp->variableController();
509 auto &variableController = sqpApp->variableController();
510 auto &timeController = sqpApp->timeController();
510 auto &timeController = sqpApp->timeController();
511
511
512 // Generates random initial range (bounded to max range)
512 // Generates random initial range (bounded to max range)
513 auto maxRange = properties.value(MAX_RANGE_PROPERTY, QVariant::fromValue(INVALID_RANGE))
513 auto maxRange = properties.value(MAX_RANGE_PROPERTY, QVariant::fromValue(INVALID_RANGE))
514 .value<SqpRange>();
514 .value<SqpRange>();
515
515
516 QVERIFY(maxRange != INVALID_RANGE);
516 QVERIFY(maxRange != INVALID_RANGE);
517
517
518 auto initialRangeStart
518 auto initialRangeStart
519 = RandomGenerator::instance().generateDouble(maxRange.m_TStart, maxRange.m_TEnd);
519 = RandomGenerator::instance().generateDouble(maxRange.m_TStart, maxRange.m_TEnd);
520 auto initialRangeEnd
520 auto initialRangeEnd
521 = RandomGenerator::instance().generateDouble(maxRange.m_TStart, maxRange.m_TEnd);
521 = RandomGenerator::instance().generateDouble(maxRange.m_TStart, maxRange.m_TEnd);
522 if (initialRangeStart > initialRangeEnd) {
522 if (initialRangeStart > initialRangeEnd) {
523 std::swap(initialRangeStart, initialRangeEnd);
523 std::swap(initialRangeStart, initialRangeEnd);
524 }
524 }
525
525
526 // Sets initial range on time controller
526 // Sets initial range on time controller
527 SqpRange initialRange{initialRangeStart, initialRangeEnd};
527 SqpRange initialRange{initialRangeStart, initialRangeEnd};
528 qCInfo(LOG_TestAmdaFuzzing()).noquote() << "Setting initial range to" << initialRange << "...";
528 qCInfo(LOG_TestAmdaFuzzing()).noquote() << "Setting initial range to" << initialRange << "...";
529 timeController.onTimeToUpdate(initialRange);
529 timeController.onTimeToUpdate(initialRange);
530 properties.insert(INITIAL_RANGE_PROPERTY, QVariant::fromValue(initialRange));
530 properties.insert(INITIAL_RANGE_PROPERTY, QVariant::fromValue(initialRange));
531
531
532 FuzzingTest test{variableController, properties};
532 FuzzingTest test{variableController, properties};
533 test.execute();
533 test.execute();
534 }
534 }
535
535
536 int main(int argc, char *argv[])
536 int main(int argc, char *argv[])
537 {
537 {
538 // Increases the test function timeout (which is 5 minutes by default) to 12 hours
538 // Increases the test function timeout (which is 5 minutes by default) to 12 hours
539 // https://stackoverflow.com/questions/42655932/setting-timeout-to-qt-test
539 // https://stackoverflow.com/questions/42655932/setting-timeout-to-qt-test
540 qputenv("QTEST_FUNCTION_TIMEOUT", QByteArray::number(12*60*60*1000));
540 qputenv("QTEST_FUNCTION_TIMEOUT", QByteArray::number(12*60*60*1000));
541
541
542 QLoggingCategory::setFilterRules(
542 QLoggingCategory::setFilterRules(
543 "*.warning=false\n"
543 "*.warning=false\n"
544 "*.info=false\n"
544 "*.info=false\n"
545 "*.debug=false\n"
545 "*.debug=false\n"
546 "FuzzingOperations.info=true\n"
546 "FuzzingOperations.info=true\n"
547 "FuzzingValidators.info=true\n"
547 "FuzzingValidators.info=true\n"
548 "TestAmdaFuzzing.info=true\n");
548 "TestAmdaFuzzing.info=true\n");
549
549
550 SqpApplication app{argc, argv};
550 SqpApplication app{argc, argv};
551 SqpApplication::setOrganizationName("LPP");
551 SqpApplication::setOrganizationName("LPP");
552 SqpApplication::setOrganizationDomain("lpp.fr");
552 SqpApplication::setOrganizationDomain("lpp.fr");
553 SqpApplication::setApplicationName("SciQLop-TestFuzzing");
553 SqpApplication::setApplicationName("SciQLop-TestFuzzing");
554 app.setAttribute(Qt::AA_Use96Dpi, true);
554 app.setAttribute(Qt::AA_Use96Dpi, true);
555 TestAmdaFuzzing testObject{};
555 TestAmdaFuzzing testObject{};
556 QTEST_SET_MAIN_SOURCE_PATH
556 QTEST_SET_MAIN_SOURCE_PATH
557 return QTest::qExec(&testObject, argc, argv);
557 return QTest::qExec(&testObject, argc, argv);
558 }
558 }
559
559
560 #include "TestAmdaFuzzing.moc"
560 #include "TestAmdaFuzzing.moc"
General Comments 0
You need to be logged in to leave comments. Login now