##// END OF EJS Templates
Defines VariableState struct (3)...
Alexandre Leroux -
r1222:70ee007bcdd0
parent child
Show More
@@ -7,6 +7,7
7 7 #include <Network/NetworkController.h>
8 8 #include <SqpApplication.h>
9 9 #include <Time/TimeController.h>
10 #include <Variable/Variable.h>
10 11 #include <Variable/VariableController.h>
11 12
12 13 #include <QLoggingCategory>
@@ -31,7 +32,7 using VariableOperation = std::pair<VariableId, std::shared_ptr<IFuzzingOperatio
31 32 using VariablesOperations = std::vector<VariableOperation>;
32 33
33 34 using WeightedOperationsPool = std::map<std::shared_ptr<IFuzzingOperation>, Weight>;
34 using VariablesPool = std::map<VariableId, std::shared_ptr<Variable> >;
35 using VariablesPool = std::map<VariableId, VariableState>;
35 36
36 37 // ///////// //
37 38 // Constants //
@@ -65,14 +66,14 availableOperations(const VariablesPool &variablesPool,
65 66
66 67 for (const auto &variablesPoolEntry : variablesPool) {
67 68 auto variableId = variablesPoolEntry.first;
68 auto variable = variablesPoolEntry.second;
69 const auto &variableState = variablesPoolEntry.second;
69 70
70 71 for (const auto &operationsPoolEntry : operationsPool) {
71 72 auto operation = operationsPoolEntry.first;
72 73 auto weight = operationsPoolEntry.second;
73 74
74 75 // A pair is valid if the current operation can be executed on the current variable
75 if (operation->canExecute(variable)) {
76 if (operation->canExecute(variableState)) {
76 77 result.push_back({variableId, operation});
77 78 weights.push_back(weight);
78 79 }
@@ -106,7 +107,7 public:
106 107 {
107 108 // Inits variables pool: at init, all variables are null
108 109 for (auto variableId = 0; variableId < nbMaxVariables(); ++variableId) {
109 m_VariablesPool[variableId] = nullptr;
110 m_VariablesPool[variableId] = VariableState{};
110 111 }
111 112 }
112 113
@@ -130,14 +131,12 public:
130 131 = RandomGenerator::instance().randomChoice(variableOperations, weights);
131 132
132 133 auto variableId = variableOperation.first;
133 auto variable = m_VariablesPool.at(variableId);
134 auto &variableState = m_VariablesPool.at(variableId);
134 135 auto fuzzingOperation = variableOperation.second;
135 136
136 fuzzingOperation->execute(variable, m_VariableController, m_Properties);
137 fuzzingOperation->execute(variableState, m_VariableController, m_Properties);
137 138 QTest::qWait(operationDelay());
138 139
139 // Updates variable pool with the new state of the variable after operation
140 m_VariablesPool[variableId] = variable;
141 140 }
142 141 else {
143 142 qCInfo(LOG_TestAmdaFuzzing())
General Comments 0
You need to be logged in to leave comments. Login now