@@ -9,3 +9,4 const QString MAX_RANGE_PROPERTY = QStringLiteral("maxRange"); | |||
|
9 | 9 | const QString METADATA_POOL_PROPERTY = QStringLiteral("metadataPool"); |
|
10 | 10 | const QString PROVIDER_PROPERTY = QStringLiteral("provider"); |
|
11 | 11 | const QString OPERATION_DELAY_PROPERTY = QStringLiteral("operationDelay"); |
|
12 | const QString VALIDATORS_PROPERTY = QStringLiteral("validators"); |
@@ -48,6 +48,8 extern const QString PROVIDER_PROPERTY; | |||
|
48 | 48 | /// Time left for an operation to execute |
|
49 | 49 | extern const QString OPERATION_DELAY_PROPERTY; |
|
50 | 50 | |
|
51 | /// Validators used to validate an operation | |
|
52 | extern const QString VALIDATORS_PROPERTY; | |
|
51 | 53 | |
|
52 | 54 | // /////// // |
|
53 | 55 | // Structs // |
@@ -1,7 +1,11 | |||
|
1 | 1 | #ifndef SCIQLOP_FUZZINGVALIDATORS_H |
|
2 | 2 | #define SCIQLOP_FUZZINGVALIDATORS_H |
|
3 | 3 | |
|
4 | #include <memory> | |
|
5 | #include <set> | |
|
6 | ||
|
4 | 7 | #include <QLoggingCategory> |
|
8 | #include <QMetaType> | |
|
5 | 9 | |
|
6 | 10 | Q_DECLARE_LOGGING_CATEGORY(LOG_FuzzingValidators) |
|
7 | 11 | |
@@ -30,4 +34,7 struct FuzzingValidatorFactory { | |||
|
30 | 34 | static std::unique_ptr<IFuzzingValidator> create(FuzzingValidatorType type); |
|
31 | 35 | }; |
|
32 | 36 | |
|
37 | using ValidatorsTypes = std::vector<FuzzingValidatorType>; | |
|
38 | Q_DECLARE_METATYPE(ValidatorsTypes) | |
|
39 | ||
|
33 | 40 | #endif // SCIQLOP_FUZZINGVALIDATORS_H |
@@ -1,6 +1,7 | |||
|
1 | 1 | #include "FuzzingDefs.h" |
|
2 | 2 | #include "FuzzingOperations.h" |
|
3 | 3 | #include "FuzzingUtils.h" |
|
4 | #include "FuzzingValidators.h" | |
|
4 | 5 | |
|
5 | 6 | #include "AmdaProvider.h" |
|
6 | 7 | |
@@ -34,6 +35,7 using VariablesOperations = std::vector<VariableOperation>; | |||
|
34 | 35 | |
|
35 | 36 | using WeightedOperationsPool = std::map<std::shared_ptr<IFuzzingOperation>, Weight>; |
|
36 | 37 | using VariablesPool = std::map<VariableId, VariableState>; |
|
38 | using Validators = std::vector<std::shared_ptr<IFuzzingValidator> >; | |
|
37 | 39 | |
|
38 | 40 | // ///////// // |
|
39 | 41 | // Constants // |
@@ -54,6 +56,10 const auto CACHE_TOLERANCE_DEFAULT_VALUE = 0.2; | |||
|
54 | 56 | /// Delay between each operation (in ms) |
|
55 | 57 | const auto OPERATION_DELAY_DEFAULT_VALUE = 3000; |
|
56 | 58 | |
|
59 | /// Validators for the tests (executed in the order in which they're defined) | |
|
60 | const auto VALIDATORS_DEFAULT_VALUE = QVariant::fromValue( | |
|
61 | ValidatorsTypes{{FuzzingValidatorType::RANGE, FuzzingValidatorType::DATA}}); | |
|
62 | ||
|
57 | 63 | // /////// // |
|
58 | 64 | // Methods // |
|
59 | 65 | // /////// // |
@@ -98,6 +104,16 WeightedOperationsPool createOperationsPool(const WeightedOperationsTypes &types | |||
|
98 | 104 | return result; |
|
99 | 105 | } |
|
100 | 106 | |
|
107 | Validators createValidators(const ValidatorsTypes &types) | |
|
108 | { | |
|
109 | Validators result{}; | |
|
110 | ||
|
111 | std::transform(types.cbegin(), types.cend(), std::inserter(result, result.end()), | |
|
112 | [](const auto &type) { return FuzzingValidatorFactory::create(type); }); | |
|
113 | ||
|
114 | return result; | |
|
115 | } | |
|
116 | ||
|
101 | 117 | /** |
|
102 | 118 | * Class to run random tests |
|
103 | 119 | */ |
@@ -180,6 +196,14 private: | |||
|
180 | 196 | return result; |
|
181 | 197 | } |
|
182 | 198 | |
|
199 | Validators validators() const | |
|
200 | { | |
|
201 | static auto result | |
|
202 | = createValidators(m_Properties.value(VALIDATORS_PROPERTY, VALIDATORS_DEFAULT_VALUE) | |
|
203 | .value<ValidatorsTypes>()); | |
|
204 | return result; | |
|
205 | } | |
|
206 | ||
|
183 | 207 | VariableController &m_VariableController; |
|
184 | 208 | Properties m_Properties; |
|
185 | 209 | VariablesPool m_VariablesPool; |
@@ -265,6 +289,7 int main(int argc, char *argv[]) | |||
|
265 | 289 | "*.info=false\n" |
|
266 | 290 | "*.debug=false\n" |
|
267 | 291 | "FuzzingOperations.info=true\n" |
|
292 | "FuzzingValidators.info=true\n" | |
|
268 | 293 | "TestAmdaFuzzing.info=true\n"); |
|
269 | 294 | |
|
270 | 295 | SqpApplication app{argc, argv}; |
General Comments 0
You need to be logged in to leave comments.
Login now