##// END OF EJS Templates
Randomizes the number of operations to wait between calling validation (defines min/max frequencies)
Alexandre Leroux -
r1244:7202dffeda15
parent child
Show More
@@ -1,107 +1,108
1 1 #include "FuzzingDefs.h"
2 2
3 3 const QString NB_MAX_OPERATIONS_PROPERTY = QStringLiteral("component");
4 4 const QString NB_MAX_SYNC_GROUPS_PROPERTY = QStringLiteral("nbSyncGroups");
5 5 const QString NB_MAX_VARIABLES_PROPERTY = QStringLiteral("nbMaxVariables");
6 6 const QString AVAILABLE_OPERATIONS_PROPERTY = QStringLiteral("availableOperations");
7 7 const QString CACHE_TOLERANCE_PROPERTY = QStringLiteral("cacheTolerance");
8 8 const QString INITIAL_RANGE_PROPERTY = QStringLiteral("initialRange");
9 9 const QString MAX_RANGE_PROPERTY = QStringLiteral("maxRange");
10 10 const QString METADATA_POOL_PROPERTY = QStringLiteral("metadataPool");
11 11 const QString PROVIDER_PROPERTY = QStringLiteral("provider");
12 12 const QString OPERATION_DELAY_BOUNDS_PROPERTY = QStringLiteral("operationDelays");
13 13 const QString VALIDATORS_PROPERTY = QStringLiteral("validators");
14 const QString VALIDATION_FREQUENCY_BOUNDS_PROPERTY = QStringLiteral("validationFrequencyBounds");
14 15
15 16 // //////////// //
16 17 // FuzzingState //
17 18 // //////////// //
18 19
19 20 const SyncGroup &FuzzingState::syncGroup(SyncGroupId id) const
20 21 {
21 22 return m_SyncGroupsPool.at(id);
22 23 }
23 24
24 25 SyncGroup &FuzzingState::syncGroup(SyncGroupId id)
25 26 {
26 27 return m_SyncGroupsPool.at(id);
27 28 }
28 29
29 30 const VariableState &FuzzingState::variableState(VariableId id) const
30 31 {
31 32 return m_VariablesPool.at(id);
32 33 }
33 34
34 35 VariableState &FuzzingState::variableState(VariableId id)
35 36 {
36 37 return m_VariablesPool.at(id);
37 38 }
38 39
39 40 SyncGroupId FuzzingState::syncGroupId(VariableId variableId) const
40 41 {
41 42 auto end = m_SyncGroupsPool.cend();
42 43 auto it
43 44 = std::find_if(m_SyncGroupsPool.cbegin(), end, [&variableId](const auto &syncGroupEntry) {
44 45 const auto &syncGroup = syncGroupEntry.second;
45 46 return syncGroup.m_Variables.find(variableId) != syncGroup.m_Variables.end();
46 47 });
47 48
48 49 return it != end ? it->first : SyncGroupId{};
49 50 }
50 51
51 52 std::vector<SyncGroupId> FuzzingState::syncGroupsIds() const
52 53 {
53 54 std::vector<SyncGroupId> result{};
54 55
55 56 for (const auto &entry : m_SyncGroupsPool) {
56 57 result.push_back(entry.first);
57 58 }
58 59
59 60 return result;
60 61 }
61 62
62 63 void FuzzingState::synchronizeVariable(VariableId variableId, SyncGroupId syncGroupId)
63 64 {
64 65 if (syncGroupId.isNull()) {
65 66 return;
66 67 }
67 68
68 69 // Registers variable into sync group: if it's the first variable, sets the variable range as
69 70 // the sync group range
70 71 auto &syncGroup = m_SyncGroupsPool.at(syncGroupId);
71 72 syncGroup.m_Variables.insert(variableId);
72 73 if (syncGroup.m_Variables.size() == 1) {
73 74 auto &variableState = m_VariablesPool.at(variableId);
74 75 syncGroup.m_Range = variableState.m_Range;
75 76 }
76 77 }
77 78
78 79 void FuzzingState::desynchronizeVariable(VariableId variableId, SyncGroupId syncGroupId)
79 80 {
80 81 if (syncGroupId.isNull()) {
81 82 return;
82 83 }
83 84
84 85 // Unregisters variable from sync group: if there is no more variable in the group, resets the
85 86 // range
86 87 auto &syncGroup = m_SyncGroupsPool.at(syncGroupId);
87 88 syncGroup.m_Variables.erase(variableId);
88 89 if (syncGroup.m_Variables.empty()) {
89 90 syncGroup.m_Range = INVALID_RANGE;
90 91 }
91 92 }
92 93
93 94 void FuzzingState::updateRanges(VariableId variableId, const SqpRange &newRange)
94 95 {
95 96 auto syncGroupId = this->syncGroupId(variableId);
96 97
97 98 // Retrieves the variables to update:
98 99 // - if the variable is synchronized to others, updates all synchronized variables
99 100 // - otherwise, updates only the variable
100 101 auto variablesToUpdate = syncGroupId.isNull() ? std::set<VariableId>{variableId}
101 102 : m_SyncGroupsPool.at(syncGroupId).m_Variables;
102 103
103 104 // Sets new range
104 105 for (const auto &variableId : variablesToUpdate) {
105 106 m_VariablesPool.at(variableId).m_Range = newRange;
106 107 }
107 108 }
@@ -1,122 +1,125
1 1 #ifndef SCIQLOP_FUZZINGDEFS_H
2 2 #define SCIQLOP_FUZZINGDEFS_H
3 3
4 4 #include <Data/SqpRange.h>
5 5
6 6 #include <QString>
7 7 #include <QUuid>
8 8 #include <QVariantHash>
9 9
10 10 #include <memory>
11 11 #include <set>
12 12
13 13 // /////// //
14 14 // Aliases //
15 15 // /////// //
16 16
17 17 using MetadataPool = std::vector<QVariantHash>;
18 18 Q_DECLARE_METATYPE(MetadataPool)
19 19
20 20 using Properties = QVariantHash;
21 21
22 22 // ///////// //
23 23 // Constants //
24 24 // ///////// //
25 25
26 26 /// Max number of operations to generate
27 27 extern const QString NB_MAX_OPERATIONS_PROPERTY;
28 28
29 29 /// Max number of sync groups to create through operations
30 30 extern const QString NB_MAX_SYNC_GROUPS_PROPERTY;
31 31
32 32 /// Max number of variables to manipulate through operations
33 33 extern const QString NB_MAX_VARIABLES_PROPERTY;
34 34
35 35 /// Set of operations available for the test
36 36 extern const QString AVAILABLE_OPERATIONS_PROPERTY;
37 37
38 38 /// Tolerance used for variable's cache (in ratio)
39 39 extern const QString CACHE_TOLERANCE_PROPERTY;
40 40
41 41 /// Range with which the timecontroller is initialized
42 42 extern const QString INITIAL_RANGE_PROPERTY;
43 43
44 44 /// Max range that an operation can reach
45 45 extern const QString MAX_RANGE_PROPERTY;
46 46
47 47 /// Set of metadata that can be associated to a variable
48 48 extern const QString METADATA_POOL_PROPERTY;
49 49
50 50 /// Provider used to retrieve data
51 51 extern const QString PROVIDER_PROPERTY;
52 52
53 53 /// Min/max times left for an operation to execute
54 54 extern const QString OPERATION_DELAY_BOUNDS_PROPERTY;
55 55
56 56 /// Validators used to validate an operation
57 57 extern const QString VALIDATORS_PROPERTY;
58 58
59 /// Min/max number of operations to execute before calling validation of the current test's state
60 extern const QString VALIDATION_FREQUENCY_BOUNDS_PROPERTY;
61
59 62 // /////// //
60 63 // Structs //
61 64 // /////// //
62 65
63 66 class Variable;
64 67 struct VariableState {
65 68 std::shared_ptr<Variable> m_Variable{nullptr};
66 69 SqpRange m_Range{INVALID_RANGE};
67 70 };
68 71
69 72 using VariableId = int;
70 73 using VariablesPool = std::map<VariableId, VariableState>;
71 74
72 75 /**
73 76 * Defines a synchronization group for a fuzzing state. A group reports the variables synchronized
74 77 * with each other, and the current range of the group (i.e. range of the last synchronized variable
75 78 * that has been moved)
76 79 */
77 80 struct SyncGroup {
78 81 std::set<VariableId> m_Variables{};
79 82 SqpRange m_Range{INVALID_RANGE};
80 83 };
81 84
82 85 using SyncGroupId = QUuid;
83 86 using SyncGroupsPool = std::map<SyncGroupId, SyncGroup>;
84 87
85 88 /**
86 89 * Defines a current state during a fuzzing state. It contains all the variables manipulated during
87 90 * the test, as well as the synchronization status of these variables.
88 91 */
89 92 struct FuzzingState {
90 93 const SyncGroup &syncGroup(SyncGroupId id) const;
91 94 SyncGroup &syncGroup(SyncGroupId id);
92 95
93 96 const VariableState &variableState(VariableId id) const;
94 97 VariableState &variableState(VariableId id);
95 98
96 99 /// @return the identifier of the synchronization group in which the variable passed in
97 100 /// parameter is located. If the variable is not in any group, returns an invalid identifier
98 101 SyncGroupId syncGroupId(VariableId variableId) const;
99 102
100 103 /// @return the set of synchronization group identifiers
101 104 std::vector<SyncGroupId> syncGroupsIds() const;
102 105
103 106 /// Updates fuzzing state according to a variable synchronization
104 107 /// @param variableId the variable that is synchronized
105 108 /// @param syncGroupId the synchronization group
106 109 void synchronizeVariable(VariableId variableId, SyncGroupId syncGroupId);
107 110
108 111 /// Updates fuzzing state according to a variable desynchronization
109 112 /// @param variableId the variable that is desynchronized
110 113 /// @param syncGroupId the synchronization group from which to remove the variable
111 114 void desynchronizeVariable(VariableId variableId, SyncGroupId syncGroupId);
112 115
113 116 /// Updates the range of a variable and all variables to which it is synchronized
114 117 /// @param the variable for which to affect the range
115 118 /// @param the range to affect
116 119 void updateRanges(VariableId variableId, const SqpRange &newRange);
117 120
118 121 VariablesPool m_VariablesPool;
119 122 SyncGroupsPool m_SyncGroupsPool;
120 123 };
121 124
122 125 #endif // SCIQLOP_FUZZINGDEFS_H
@@ -1,354 +1,382
1 1 #include "FuzzingDefs.h"
2 2 #include "FuzzingOperations.h"
3 3 #include "FuzzingUtils.h"
4 4 #include "FuzzingValidators.h"
5 5
6 6 #include "AmdaProvider.h"
7 7
8 8 #include <Network/NetworkController.h>
9 9 #include <Settings/SqpSettingsDefs.h>
10 10 #include <SqpApplication.h>
11 11 #include <Time/TimeController.h>
12 12 #include <Variable/Variable.h>
13 13 #include <Variable/VariableController.h>
14 14
15 15 #include <QLoggingCategory>
16 16 #include <QObject>
17 17 #include <QtTest>
18 18
19 19 #include <memory>
20 20
21 21 Q_LOGGING_CATEGORY(LOG_TestAmdaFuzzing, "TestAmdaFuzzing")
22 22
23 23 namespace {
24 24
25 25 // /////// //
26 26 // Aliases //
27 27 // /////// //
28 28
29 29 using Weight = double;
30 30 using Weights = std::vector<Weight>;
31 31
32 32 using VariableOperation = std::pair<VariableId, std::shared_ptr<IFuzzingOperation> >;
33 33 using VariablesOperations = std::vector<VariableOperation>;
34 34
35 35 using WeightedOperationsPool = std::map<std::shared_ptr<IFuzzingOperation>, Weight>;
36 36 using Validators = std::vector<std::shared_ptr<IFuzzingValidator> >;
37 37
38 38 // ///////// //
39 39 // Constants //
40 40 // ///////// //
41 41
42 42 // Defaults values used when the associated properties have not been set for the test
43 43 const auto NB_MAX_OPERATIONS_DEFAULT_VALUE = 100;
44 44 const auto NB_MAX_SYNC_GROUPS_DEFAULT_VALUE = 1;
45 45 const auto NB_MAX_VARIABLES_DEFAULT_VALUE = 1;
46 46 const auto AVAILABLE_OPERATIONS_DEFAULT_VALUE = QVariant::fromValue(WeightedOperationsTypes{
47 47 {FuzzingOperationType::CREATE, 1.},
48 48 {FuzzingOperationType::DELETE, 0.1}, // Delete operation is less frequent
49 49 {FuzzingOperationType::PAN_LEFT, 1.},
50 50 {FuzzingOperationType::PAN_RIGHT, 1.},
51 51 {FuzzingOperationType::ZOOM_IN, 1.},
52 52 {FuzzingOperationType::ZOOM_OUT, 1.},
53 53 {FuzzingOperationType::SYNCHRONIZE, 0.8},
54 54 {FuzzingOperationType::DESYNCHRONIZE, 0.4}});
55 55 const auto CACHE_TOLERANCE_DEFAULT_VALUE = 0.2;
56 56
57 57 /// Min/max delays between each operation (in ms)
58 58 const auto OPERATION_DELAY_BOUNDS_DEFAULT_VALUE = QVariant::fromValue(std::make_pair(100, 3000));
59 59
60 60 /// Validators for the tests (executed in the order in which they're defined)
61 61 const auto VALIDATORS_DEFAULT_VALUE = QVariant::fromValue(
62 62 ValidatorsTypes{{FuzzingValidatorType::RANGE, FuzzingValidatorType::DATA}});
63 63
64 /// Min/max number of operations to execute before calling validation
65 const auto VALIDATION_FREQUENCY_BOUNDS_DEFAULT_VALUE = QVariant::fromValue(std::make_pair(1, 10));
66
64 67 // /////// //
65 68 // Methods //
66 69 // /////// //
67 70
68 71 /// Goes through the variables pool and operations pool to determine the set of {variable/operation}
69 72 /// pairs that are valid (i.e. operation that can be executed on variable)
70 73 std::pair<VariablesOperations, Weights>
71 74 availableOperations(const FuzzingState &fuzzingState, const WeightedOperationsPool &operationsPool)
72 75 {
73 76 VariablesOperations result{};
74 77 Weights weights{};
75 78
76 79 for (const auto &variablesPoolEntry : fuzzingState.m_VariablesPool) {
77 80 auto variableId = variablesPoolEntry.first;
78 81
79 82 for (const auto &operationsPoolEntry : operationsPool) {
80 83 auto operation = operationsPoolEntry.first;
81 84 auto weight = operationsPoolEntry.second;
82 85
83 86 // A pair is valid if the current operation can be executed on the current variable
84 87 if (operation->canExecute(variableId, fuzzingState)) {
85 88 result.push_back({variableId, operation});
86 89 weights.push_back(weight);
87 90 }
88 91 }
89 92 }
90 93
91 94 return {result, weights};
92 95 }
93 96
94 97 WeightedOperationsPool createOperationsPool(const WeightedOperationsTypes &types)
95 98 {
96 99 WeightedOperationsPool result{};
97 100
98 101 std::transform(
99 102 types.cbegin(), types.cend(), std::inserter(result, result.end()), [](const auto &type) {
100 103 return std::make_pair(FuzzingOperationFactory::create(type.first), type.second);
101 104 });
102 105
103 106 return result;
104 107 }
105 108
106 109 Validators createValidators(const ValidatorsTypes &types)
107 110 {
108 111 Validators result{};
109 112
110 113 std::transform(types.cbegin(), types.cend(), std::inserter(result, result.end()),
111 114 [](const auto &type) { return FuzzingValidatorFactory::create(type); });
112 115
113 116 return result;
114 117 }
115 118
116 119 /**
117 120 * Validates all the variables' states passed in parameter, according to a set of validators
118 121 * @param variablesPool the variables' states
119 122 * @param validators the validators used for validation
120 123 */
121 124 void validate(const VariablesPool &variablesPool, const Validators &validators)
122 125 {
123 126 for (const auto &variablesPoolEntry : variablesPool) {
124 127 auto variableId = variablesPoolEntry.first;
125 128 const auto &variableState = variablesPoolEntry.second;
126 129
127 130 auto variableMessage = variableState.m_Variable ? variableState.m_Variable->name()
128 131 : QStringLiteral("null variable");
129 132 qCInfo(LOG_TestAmdaFuzzing()).noquote() << "Validating state of variable at index"
130 133 << variableId << "(" << variableMessage << ")...";
131 134
132 135 for (const auto &validator : validators) {
133 136 validator->validate(VariableState{variableState});
134 137 }
135 138
136 139 qCInfo(LOG_TestAmdaFuzzing()).noquote() << "Validation completed.";
137 140 }
138 141 }
139 142
140 143 /**
141 144 * Class to run random tests
142 145 */
143 146 class FuzzingTest {
144 147 public:
145 148 explicit FuzzingTest(VariableController &variableController, Properties properties)
146 149 : m_VariableController{variableController},
147 150 m_Properties{std::move(properties)},
148 151 m_FuzzingState{}
149 152 {
150 153 // Inits variables pool: at init, all variables are null
151 154 for (auto variableId = 0; variableId < nbMaxVariables(); ++variableId) {
152 155 m_FuzzingState.m_VariablesPool[variableId] = VariableState{};
153 156 }
154 157
155 158 // Inits sync groups and registers them into the variable controller
156 159 for (auto i = 0; i < nbMaxSyncGroups(); ++i) {
157 160 auto syncGroupId = SyncGroupId::createUuid();
158 161 variableController.onAddSynchronizationGroupId(syncGroupId);
159 162 m_FuzzingState.m_SyncGroupsPool[syncGroupId] = SyncGroup{};
160 163 }
161 164 }
162 165
163 166 void execute()
164 167 {
165 168 qCInfo(LOG_TestAmdaFuzzing()).noquote() << "Running" << nbMaxOperations() << "operations on"
166 169 << nbMaxVariables() << "variable(s)...";
167 170
171
172 // Inits the count of the number of operations before the next validation
173 int nextValidationCounter = 0;
174 auto updateValidationCounter = [this, &nextValidationCounter]() {
175 nextValidationCounter = RandomGenerator::instance().generateInt(
176 validationFrequencies().first, validationFrequencies().second);
177 qCInfo(LOG_TestAmdaFuzzing()).noquote()
178 << "Next validation in " << nextValidationCounter << "operations...";
179 };
180 updateValidationCounter();
181
168 182 auto canExecute = true;
169 183 for (auto i = 0; i < nbMaxOperations() && canExecute; ++i) {
170 184 // Retrieves all operations that can be executed in the current context
171 185 VariablesOperations variableOperations{};
172 186 Weights weights{};
173 187 std::tie(variableOperations, weights)
174 188 = availableOperations(m_FuzzingState, operationsPool());
175 189
176 190 canExecute = !variableOperations.empty();
177 191 if (canExecute) {
192 --nextValidationCounter;
193
178 194 // Of the operations available, chooses a random operation and executes it
179 195 auto variableOperation
180 196 = RandomGenerator::instance().randomChoice(variableOperations, weights);
181 197
182 198 auto variableId = variableOperation.first;
183 199 auto fuzzingOperation = variableOperation.second;
184 200
185 201 fuzzingOperation->execute(variableId, m_FuzzingState, m_VariableController,
186 202 m_Properties);
187 203
188 204 // Delays the next operation with a randomly generated time
189 205 auto delay = RandomGenerator::instance().generateInt(operationDelays().first,
190 206 operationDelays().second);
191 207 qCDebug(LOG_TestAmdaFuzzing())
192 208 << "Waiting " << delay << "ms before the next operation...";
193 209 QTest::qWait(delay);
194 210
195 211 // Validates variables
212 if (nextValidationCounter == 0) {
196 213 validate(m_FuzzingState.m_VariablesPool, validators());
214 updateValidationCounter();
215 }
197 216 }
198 217 else {
199 218 qCInfo(LOG_TestAmdaFuzzing()).noquote()
200 219 << "No more operations are available, the execution of the test will stop...";
201 220 }
202 221 }
203 222
204 223 qCInfo(LOG_TestAmdaFuzzing()).noquote() << "Execution of the test completed.";
205 224 }
206 225
207 226 private:
208 227 int nbMaxOperations() const
209 228 {
210 229 static auto result
211 230 = m_Properties.value(NB_MAX_OPERATIONS_PROPERTY, NB_MAX_OPERATIONS_DEFAULT_VALUE)
212 231 .toInt();
213 232 return result;
214 233 }
215 234
216 235 int nbMaxSyncGroups() const
217 236 {
218 237 static auto result
219 238 = m_Properties.value(NB_MAX_SYNC_GROUPS_PROPERTY, NB_MAX_SYNC_GROUPS_DEFAULT_VALUE)
220 239 .toInt();
221 240 return result;
222 241 }
223 242
224 243 int nbMaxVariables() const
225 244 {
226 245 static auto result
227 246 = m_Properties.value(NB_MAX_VARIABLES_PROPERTY, NB_MAX_VARIABLES_DEFAULT_VALUE).toInt();
228 247 return result;
229 248 }
230 249
231 250 std::pair<int, int> operationDelays() const
232 251 {
233 252 static auto result
234 253 = m_Properties
235 254 .value(OPERATION_DELAY_BOUNDS_PROPERTY, OPERATION_DELAY_BOUNDS_DEFAULT_VALUE)
236 255 .value<std::pair<int, int> >();
237 256 return result;
238 257 }
239 258
240 259 WeightedOperationsPool operationsPool() const
241 260 {
242 261 static auto result = createOperationsPool(
243 262 m_Properties.value(AVAILABLE_OPERATIONS_PROPERTY, AVAILABLE_OPERATIONS_DEFAULT_VALUE)
244 263 .value<WeightedOperationsTypes>());
245 264 return result;
246 265 }
247 266
248 267 Validators validators() const
249 268 {
250 269 static auto result
251 270 = createValidators(m_Properties.value(VALIDATORS_PROPERTY, VALIDATORS_DEFAULT_VALUE)
252 271 .value<ValidatorsTypes>());
253 272 return result;
254 273 }
255 274
275 std::pair<int, int> validationFrequencies() const
276 {
277 static auto result = m_Properties
278 .value(VALIDATION_FREQUENCY_BOUNDS_PROPERTY,
279 VALIDATION_FREQUENCY_BOUNDS_DEFAULT_VALUE)
280 .value<std::pair<int, int> >();
281 return result;
282 }
283
256 284 VariableController &m_VariableController;
257 285 Properties m_Properties;
258 286 FuzzingState m_FuzzingState;
259 287 };
260 288
261 289 } // namespace
262 290
263 291 class TestAmdaFuzzing : public QObject {
264 292 Q_OBJECT
265 293
266 294 private slots:
267 295 /// Input data for @sa testFuzzing()
268 296 void testFuzzing_data();
269 297 void testFuzzing();
270 298 };
271 299
272 300 void TestAmdaFuzzing::testFuzzing_data()
273 301 {
274 302 // ////////////// //
275 303 // Test structure //
276 304 // ////////////// //
277 305
278 306 QTest::addColumn<Properties>("properties"); // Properties for random test
279 307
280 308 // ////////// //
281 309 // Test cases //
282 310 // ////////// //
283 311
284 312 auto maxRange = SqpRange::fromDateTime({2017, 1, 1}, {0, 0}, {2017, 1, 5}, {0, 0});
285 313 MetadataPool metadataPool{{{"dataType", "vector"}, {"xml:id", "imf"}}};
286 314
287 315 // Note: we don't use auto here as we want to pass std::shared_ptr<IDataProvider> as is in the
288 316 // QVariant
289 317 std::shared_ptr<IDataProvider> provider = std::make_shared<AmdaProvider>();
290 318
291 319 QTest::newRow("fuzzingTest") << Properties{
292 320 {MAX_RANGE_PROPERTY, QVariant::fromValue(maxRange)},
293 321 {METADATA_POOL_PROPERTY, QVariant::fromValue(metadataPool)},
294 322 {PROVIDER_PROPERTY, QVariant::fromValue(provider)}};
295 323 }
296 324
297 325 void TestAmdaFuzzing::testFuzzing()
298 326 {
299 327 QFETCH(Properties, properties);
300 328
301 329 // Sets cache property
302 330 QSettings settings{};
303 331 auto cacheTolerance = properties.value(CACHE_TOLERANCE_PROPERTY, CACHE_TOLERANCE_DEFAULT_VALUE);
304 332 settings.setValue(GENERAL_TOLERANCE_AT_INIT_KEY, cacheTolerance);
305 333 settings.setValue(GENERAL_TOLERANCE_AT_UPDATE_KEY, cacheTolerance);
306 334
307 335 auto &variableController = sqpApp->variableController();
308 336 auto &timeController = sqpApp->timeController();
309 337
310 338 // Generates random initial range (bounded to max range)
311 339 auto maxRange = properties.value(MAX_RANGE_PROPERTY, QVariant::fromValue(INVALID_RANGE))
312 340 .value<SqpRange>();
313 341
314 342 QVERIFY(maxRange != INVALID_RANGE);
315 343
316 344 auto initialRangeStart
317 345 = RandomGenerator::instance().generateDouble(maxRange.m_TStart, maxRange.m_TEnd);
318 346 auto initialRangeEnd
319 347 = RandomGenerator::instance().generateDouble(maxRange.m_TStart, maxRange.m_TEnd);
320 348 if (initialRangeStart > initialRangeEnd) {
321 349 std::swap(initialRangeStart, initialRangeEnd);
322 350 }
323 351
324 352 // Sets initial range on time controller
325 353 SqpRange initialRange{initialRangeStart, initialRangeEnd};
326 354 qCInfo(LOG_TestAmdaFuzzing()).noquote() << "Setting initial range to" << initialRange << "...";
327 355 timeController.onTimeToUpdate(initialRange);
328 356 properties.insert(INITIAL_RANGE_PROPERTY, QVariant::fromValue(initialRange));
329 357
330 358 FuzzingTest test{variableController, properties};
331 359 test.execute();
332 360 }
333 361
334 362 int main(int argc, char *argv[])
335 363 {
336 364 QLoggingCategory::setFilterRules(
337 365 "*.warning=false\n"
338 366 "*.info=false\n"
339 367 "*.debug=false\n"
340 368 "FuzzingOperations.info=true\n"
341 369 "FuzzingValidators.info=true\n"
342 370 "TestAmdaFuzzing.info=true\n");
343 371
344 372 SqpApplication app{argc, argv};
345 373 SqpApplication::setOrganizationName("LPP");
346 374 SqpApplication::setOrganizationDomain("lpp.fr");
347 375 SqpApplication::setApplicationName("SciQLop-TestFuzzing");
348 376 app.setAttribute(Qt::AA_Use96Dpi, true);
349 377 TestAmdaFuzzing testObject{};
350 378 QTEST_SET_MAIN_SOURCE_PATH
351 379 return QTest::qExec(&testObject, argc, argv);
352 380 }
353 381
354 382 #include "TestAmdaFuzzing.moc"
General Comments 0
You need to be logged in to leave comments. Login now