From 5f4e5de2ac362e126469b6d6683b96a922e31688 2017-12-19 14:14:49 From: Alexandre Leroux Date: 2017-12-19 14:14:49 Subject: [PATCH] Implements execute() method of desync operation desync is also made for the delete operation --- diff --git a/plugins/amda/tests/FuzzingDefs.cpp b/plugins/amda/tests/FuzzingDefs.cpp index e2ea040..cf0add9 100644 --- a/plugins/amda/tests/FuzzingDefs.cpp +++ b/plugins/amda/tests/FuzzingDefs.cpp @@ -75,3 +75,17 @@ void FuzzingState::synchronizeVariable(VariableId variableId, SyncGroupId syncGr } } +void FuzzingState::desynchronizeVariable(VariableId variableId, SyncGroupId syncGroupId) +{ + if (syncGroupId.isNull()) { + return; + } + + // Unregisters variable from sync group: if there is no more variable in the group, resets the range + auto &syncGroup = m_SyncGroupsPool.at(syncGroupId); + syncGroup.m_Variables.erase(variableId); + if (syncGroup.m_Variables.empty()) { + syncGroup.m_Range = INVALID_RANGE; + } +} + diff --git a/plugins/amda/tests/FuzzingDefs.h b/plugins/amda/tests/FuzzingDefs.h index a93857d..0afef83 100644 --- a/plugins/amda/tests/FuzzingDefs.h +++ b/plugins/amda/tests/FuzzingDefs.h @@ -105,6 +105,11 @@ struct FuzzingState { /// @param syncGroupId the synchronization group void synchronizeVariable(VariableId variableId, SyncGroupId syncGroupId); + /// Updates fuzzing state according to a variable desynchronization + /// @param variableId the variable that is desynchronized + /// @param syncGroupId the synchronization group from which to remove the variable + void desynchronizeVariable(VariableId variableId, SyncGroupId syncGroupId); + VariablesPool m_VariablesPool; SyncGroupsPool m_SyncGroupsPool; diff --git a/plugins/amda/tests/FuzzingOperations.cpp b/plugins/amda/tests/FuzzingOperations.cpp index 8565513..a61dfa6 100644 --- a/plugins/amda/tests/FuzzingOperations.cpp +++ b/plugins/amda/tests/FuzzingOperations.cpp @@ -67,6 +67,10 @@ struct DeleteOperation : public IFuzzingOperation { // Updates variable's state variableState.m_Range = INVALID_RANGE; variableState.m_Variable = nullptr; + + // Desynchronizes the variable if it was in a sync group + auto syncGroupId = fuzzingState.syncGroupId(variableId); + fuzzingState.desynchronizeVariable(variableId, syncGroupId); } }; @@ -184,6 +188,21 @@ struct DesynchronizeOperation : public IFuzzingOperation { void execute(VariableId variableId, FuzzingState &fuzzingState, VariableController &variableController, const Properties &) const override { + auto &variableState = fuzzingState.variableState(variableId); + + // Gets the sync group of the variable + auto syncGroupId = fuzzingState.syncGroupId(variableId); + + qCInfo(LOG_FuzzingOperations()).noquote() + << "Removing" << variableState.m_Variable->name() << "from synchronization group" + << syncGroupId << "..."; + variableController.onAddSynchronized(variableState.m_Variable, syncGroupId); + + // Updates state + fuzzingState.desynchronizeVariable(variableId, syncGroupId); + } +}; + struct UnknownOperation : public IFuzzingOperation { bool canExecute(VariableId, const FuzzingState &) const override { return false; }