diff --git a/plugins/amda/tests/FuzzingDefs.cpp b/plugins/amda/tests/FuzzingDefs.cpp index c3ca9b0..e6a5880 100644 --- a/plugins/amda/tests/FuzzingDefs.cpp +++ b/plugins/amda/tests/FuzzingDefs.cpp @@ -11,6 +11,7 @@ const QString METADATA_POOL_PROPERTY = QStringLiteral("metadataPool"); const QString PROVIDER_PROPERTY = QStringLiteral("provider"); const QString OPERATION_DELAY_BOUNDS_PROPERTY = QStringLiteral("operationDelays"); const QString VALIDATORS_PROPERTY = QStringLiteral("validators"); +const QString VALIDATION_FREQUENCY_BOUNDS_PROPERTY = QStringLiteral("validationFrequencyBounds"); // //////////// // // FuzzingState // diff --git a/plugins/amda/tests/FuzzingDefs.h b/plugins/amda/tests/FuzzingDefs.h index 9a2bc46..2a2b110 100644 --- a/plugins/amda/tests/FuzzingDefs.h +++ b/plugins/amda/tests/FuzzingDefs.h @@ -56,6 +56,9 @@ extern const QString OPERATION_DELAY_BOUNDS_PROPERTY; /// Validators used to validate an operation extern const QString VALIDATORS_PROPERTY; +/// Min/max number of operations to execute before calling validation of the current test's state +extern const QString VALIDATION_FREQUENCY_BOUNDS_PROPERTY; + // /////// // // Structs // // /////// // diff --git a/plugins/amda/tests/TestAmdaFuzzing.cpp b/plugins/amda/tests/TestAmdaFuzzing.cpp index 686542d..a0763d3 100644 --- a/plugins/amda/tests/TestAmdaFuzzing.cpp +++ b/plugins/amda/tests/TestAmdaFuzzing.cpp @@ -61,6 +61,9 @@ const auto OPERATION_DELAY_BOUNDS_DEFAULT_VALUE = QVariant::fromValue(std::make_ const auto VALIDATORS_DEFAULT_VALUE = QVariant::fromValue( ValidatorsTypes{{FuzzingValidatorType::RANGE, FuzzingValidatorType::DATA}}); +/// Min/max number of operations to execute before calling validation +const auto VALIDATION_FREQUENCY_BOUNDS_DEFAULT_VALUE = QVariant::fromValue(std::make_pair(1, 10)); + // /////// // // Methods // // /////// // @@ -165,6 +168,17 @@ public: qCInfo(LOG_TestAmdaFuzzing()).noquote() << "Running" << nbMaxOperations() << "operations on" << nbMaxVariables() << "variable(s)..."; + + // Inits the count of the number of operations before the next validation + int nextValidationCounter = 0; + auto updateValidationCounter = [this, &nextValidationCounter]() { + nextValidationCounter = RandomGenerator::instance().generateInt( + validationFrequencies().first, validationFrequencies().second); + qCInfo(LOG_TestAmdaFuzzing()).noquote() + << "Next validation in " << nextValidationCounter << "operations..."; + }; + updateValidationCounter(); + auto canExecute = true; for (auto i = 0; i < nbMaxOperations() && canExecute; ++i) { // Retrieves all operations that can be executed in the current context @@ -175,6 +189,8 @@ public: canExecute = !variableOperations.empty(); if (canExecute) { + --nextValidationCounter; + // Of the operations available, chooses a random operation and executes it auto variableOperation = RandomGenerator::instance().randomChoice(variableOperations, weights); @@ -193,7 +209,10 @@ public: QTest::qWait(delay); // Validates variables - validate(m_FuzzingState.m_VariablesPool, validators()); + if (nextValidationCounter == 0) { + validate(m_FuzzingState.m_VariablesPool, validators()); + updateValidationCounter(); + } } else { qCInfo(LOG_TestAmdaFuzzing()).noquote() @@ -253,6 +272,15 @@ private: return result; } + std::pair validationFrequencies() const + { + static auto result = m_Properties + .value(VALIDATION_FREQUENCY_BOUNDS_PROPERTY, + VALIDATION_FREQUENCY_BOUNDS_DEFAULT_VALUE) + .value >(); + return result; + } + VariableController &m_VariableController; Properties m_Properties; FuzzingState m_FuzzingState;