@@ -48,3 +48,30 SyncGroupId FuzzingState::syncGroupId(VariableId variableId) const | |||||
48 | return it != end ? it->first : SyncGroupId{}; |
|
48 | return it != end ? it->first : SyncGroupId{}; | |
49 | } |
|
49 | } | |
50 |
|
50 | |||
|
51 | std::vector<SyncGroupId> FuzzingState::syncGroupsIds() const | |||
|
52 | { | |||
|
53 | std::vector<SyncGroupId> result{}; | |||
|
54 | ||||
|
55 | for (const auto &entry : m_SyncGroupsPool) { | |||
|
56 | result.push_back(entry.first); | |||
|
57 | } | |||
|
58 | ||||
|
59 | return result; | |||
|
60 | } | |||
|
61 | ||||
|
62 | void FuzzingState::synchronizeVariable(VariableId variableId, SyncGroupId syncGroupId) | |||
|
63 | { | |||
|
64 | if (syncGroupId.isNull()) { | |||
|
65 | return; | |||
|
66 | } | |||
|
67 | ||||
|
68 | // Registers variable into sync group: if it's the first variable, sets the variable range as | |||
|
69 | // the sync group range | |||
|
70 | auto &syncGroup = m_SyncGroupsPool.at(syncGroupId); | |||
|
71 | syncGroup.m_Variables.insert(variableId); | |||
|
72 | if (syncGroup.m_Variables.size() == 1) { | |||
|
73 | auto &variableState = m_VariablesPool.at(variableId); | |||
|
74 | syncGroup.m_Range = variableState.m_Range; | |||
|
75 | } | |||
|
76 | } | |||
|
77 |
@@ -97,6 +97,14 struct FuzzingState { | |||||
97 | /// parameter is located. If the variable is not in any group, returns an invalid identifier |
|
97 | /// parameter is located. If the variable is not in any group, returns an invalid identifier | |
98 | SyncGroupId syncGroupId(VariableId variableId) const; |
|
98 | SyncGroupId syncGroupId(VariableId variableId) const; | |
99 |
|
99 | |||
|
100 | /// @return the set of synchronization group identifiers | |||
|
101 | std::vector<SyncGroupId> syncGroupsIds() const; | |||
|
102 | ||||
|
103 | /// Updates fuzzing state according to a variable synchronization | |||
|
104 | /// @param variableId the variable that is synchronized | |||
|
105 | /// @param syncGroupId the synchronization group | |||
|
106 | void synchronizeVariable(VariableId variableId, SyncGroupId syncGroupId); | |||
|
107 | ||||
100 |
|
108 | |||
101 | VariablesPool m_VariablesPool; |
|
109 | VariablesPool m_VariablesPool; | |
102 | SyncGroupsPool m_SyncGroupsPool; |
|
110 | SyncGroupsPool m_SyncGroupsPool; |
@@ -160,6 +160,17 struct SynchronizeOperation : public IFuzzingOperation { | |||||
160 | void execute(VariableId variableId, FuzzingState &fuzzingState, |
|
160 | void execute(VariableId variableId, FuzzingState &fuzzingState, | |
161 | VariableController &variableController, const Properties &) const override |
|
161 | VariableController &variableController, const Properties &) const override | |
162 | { |
|
162 | { | |
|
163 | auto &variableState = fuzzingState.variableState(variableId); | |||
|
164 | ||||
|
165 | // Chooses a random synchronization group and adds the variable into sync group | |||
|
166 | auto syncGroupId = RandomGenerator::instance().randomChoice(fuzzingState.syncGroupsIds()); | |||
|
167 | qCInfo(LOG_FuzzingOperations()).noquote() | |||
|
168 | << "Adding" << variableState.m_Variable->name() << "into synchronization group" | |||
|
169 | << syncGroupId << "..."; | |||
|
170 | variableController.onAddSynchronized(variableState.m_Variable, syncGroupId); | |||
|
171 | ||||
|
172 | // Updates state | |||
|
173 | fuzzingState.synchronizeVariable(variableId, syncGroupId); | |||
163 | } |
|
174 | } | |
164 | }; |
|
175 | }; | |
165 |
|
176 |
General Comments 0
You need to be logged in to leave comments.
Login now