@@ -11,6 +11,7 const QString METADATA_POOL_PROPERTY = QStringLiteral("metadataPool"); | |||||
11 | const QString PROVIDER_PROPERTY = QStringLiteral("provider"); |
|
11 | const QString PROVIDER_PROPERTY = QStringLiteral("provider"); | |
12 | const QString OPERATION_DELAY_BOUNDS_PROPERTY = QStringLiteral("operationDelays"); |
|
12 | const QString OPERATION_DELAY_BOUNDS_PROPERTY = QStringLiteral("operationDelays"); | |
13 | const QString VALIDATORS_PROPERTY = QStringLiteral("validators"); |
|
13 | const QString VALIDATORS_PROPERTY = QStringLiteral("validators"); | |
|
14 | const QString VALIDATION_FREQUENCY_BOUNDS_PROPERTY = QStringLiteral("validationFrequencyBounds"); | |||
14 |
|
15 | |||
15 | // //////////// // |
|
16 | // //////////// // | |
16 | // FuzzingState // |
|
17 | // FuzzingState // |
@@ -56,6 +56,9 extern const QString OPERATION_DELAY_BOUNDS_PROPERTY; | |||||
56 | /// Validators used to validate an operation |
|
56 | /// Validators used to validate an operation | |
57 | extern const QString VALIDATORS_PROPERTY; |
|
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 | // Structs // |
|
63 | // Structs // | |
61 | // /////// // |
|
64 | // /////// // |
@@ -61,6 +61,9 const auto OPERATION_DELAY_BOUNDS_DEFAULT_VALUE = QVariant::fromValue(std::make_ | |||||
61 | const auto VALIDATORS_DEFAULT_VALUE = QVariant::fromValue( |
|
61 | const auto VALIDATORS_DEFAULT_VALUE = QVariant::fromValue( | |
62 | ValidatorsTypes{{FuzzingValidatorType::RANGE, FuzzingValidatorType::DATA}}); |
|
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 | // Methods // |
|
68 | // Methods // | |
66 | // /////// // |
|
69 | // /////// // | |
@@ -165,6 +168,17 public: | |||||
165 | qCInfo(LOG_TestAmdaFuzzing()).noquote() << "Running" << nbMaxOperations() << "operations on" |
|
168 | qCInfo(LOG_TestAmdaFuzzing()).noquote() << "Running" << nbMaxOperations() << "operations on" | |
166 | << nbMaxVariables() << "variable(s)..."; |
|
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 | auto canExecute = true; |
|
182 | auto canExecute = true; | |
169 | for (auto i = 0; i < nbMaxOperations() && canExecute; ++i) { |
|
183 | for (auto i = 0; i < nbMaxOperations() && canExecute; ++i) { | |
170 | // Retrieves all operations that can be executed in the current context |
|
184 | // Retrieves all operations that can be executed in the current context | |
@@ -175,6 +189,8 public: | |||||
175 |
|
189 | |||
176 | canExecute = !variableOperations.empty(); |
|
190 | canExecute = !variableOperations.empty(); | |
177 | if (canExecute) { |
|
191 | if (canExecute) { | |
|
192 | --nextValidationCounter; | |||
|
193 | ||||
178 | // Of the operations available, chooses a random operation and executes it |
|
194 | // Of the operations available, chooses a random operation and executes it | |
179 | auto variableOperation |
|
195 | auto variableOperation | |
180 | = RandomGenerator::instance().randomChoice(variableOperations, weights); |
|
196 | = RandomGenerator::instance().randomChoice(variableOperations, weights); | |
@@ -193,7 +209,10 public: | |||||
193 | QTest::qWait(delay); |
|
209 | QTest::qWait(delay); | |
194 |
|
210 | |||
195 | // Validates variables |
|
211 | // Validates variables | |
196 | validate(m_FuzzingState.m_VariablesPool, validators()); |
|
212 | if (nextValidationCounter == 0) { | |
|
213 | validate(m_FuzzingState.m_VariablesPool, validators()); | |||
|
214 | updateValidationCounter(); | |||
|
215 | } | |||
197 | } |
|
216 | } | |
198 | else { |
|
217 | else { | |
199 | qCInfo(LOG_TestAmdaFuzzing()).noquote() |
|
218 | qCInfo(LOG_TestAmdaFuzzing()).noquote() | |
@@ -253,6 +272,15 private: | |||||
253 | return result; |
|
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 | VariableController &m_VariableController; |
|
284 | VariableController &m_VariableController; | |
257 | Properties m_Properties; |
|
285 | Properties m_Properties; | |
258 | FuzzingState m_FuzzingState; |
|
286 | FuzzingState m_FuzzingState; |
General Comments 0
You need to be logged in to leave comments.
Login now