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