##// END OF EJS Templates
Merge branch 'feature/CatalogueCatalogue' of https://hephaistos.lpp.polytechnique.fr/rhodecode/GIT_REPOSITORIES/LPP/Users/mperrinel/SciQLop-fork into feature/CatalogueCatalogue...
Merge branch 'feature/CatalogueCatalogue' of https://hephaistos.lpp.polytechnique.fr/rhodecode/GIT_REPOSITORIES/LPP/Users/mperrinel/SciQLop-fork into feature/CatalogueCatalogue # Conflicts: # core/include/Catalogue/CatalogueController.h # gui/src/Visualization/VisualizationGraphWidget.cpp

File last commit:

r1328:6015d1ab6800
r1358:3e0e1e37ac63 merge feature/Catalogue...
Show More
FuzzingDefs.cpp
118 lines | 3.9 KiB | text/x-c | CppLexer
Alexandre Leroux
Adds variable controller and properties to test structure...
r1200 #include "FuzzingDefs.h"
Alexandre Leroux
Wait for the end of an acquisition to validate an operation (3)...
r1248 const QString ACQUISITION_TIMEOUT_PROPERTY = QStringLiteral("acquisitionTimeout");
Alexandre Leroux
Adds "number of operations" and "number of variables" properties for the tests
r1201 const QString NB_MAX_OPERATIONS_PROPERTY = QStringLiteral("component");
Alexandre Leroux
Sets the number of sync groups to create for fuzzing tests
r1237 const QString NB_MAX_SYNC_GROUPS_PROPERTY = QStringLiteral("nbSyncGroups");
Alexandre Leroux
Adds "number of operations" and "number of variables" properties for the tests
r1201 const QString NB_MAX_VARIABLES_PROPERTY = QStringLiteral("nbMaxVariables");
Alexandre Leroux
Defines operations pool...
r1204 const QString AVAILABLE_OPERATIONS_PROPERTY = QStringLiteral("availableOperations");
Alexandre Leroux
Adds the ability to set cache tolerance for tests
r1224 const QString CACHE_TOLERANCE_PROPERTY = QStringLiteral("cacheTolerance");
Alexandre Leroux
Some fixes...
r1223 const QString INITIAL_RANGE_PROPERTY = QStringLiteral("initialRange");
Alexandre Leroux
Completes fuzzing test structure by setting initial range for the time controller
r1209 const QString MAX_RANGE_PROPERTY = QStringLiteral("maxRange");
Alexandre Leroux
Implements "Variable creation" operation (1)...
r1207 const QString METADATA_POOL_PROPERTY = QStringLiteral("metadataPool");
const QString PROVIDER_PROPERTY = QStringLiteral("provider");
Alexandre Leroux
Randomizes the time to wait between each operations (defines min/max delays)
r1243 const QString OPERATION_DELAY_BOUNDS_PROPERTY = QStringLiteral("operationDelays");
Alexandre Leroux
Adds validators to the fuzzing test...
r1228 const QString VALIDATORS_PROPERTY = QStringLiteral("validators");
Alexandre Leroux
Randomizes the number of operations to wait between calling validation (defines min/max frequencies)
r1244 const QString VALIDATION_FREQUENCY_BOUNDS_PROPERTY = QStringLiteral("validationFrequencyBounds");
Alexandre Leroux
Defines synchronization groups for fuzzing tests
r1235
// //////////// //
// FuzzingState //
// //////////// //
const SyncGroup &FuzzingState::syncGroup(SyncGroupId id) const
{
return m_SyncGroupsPool.at(id);
}
SyncGroup &FuzzingState::syncGroup(SyncGroupId id)
{
return m_SyncGroupsPool.at(id);
}
const VariableState &FuzzingState::variableState(VariableId id) const
{
return m_VariablesPool.at(id);
}
VariableState &FuzzingState::variableState(VariableId id)
{
return m_VariablesPool.at(id);
}
Alexandre Leroux
Implements canExecute() method of syn/desync operations
r1239 SyncGroupId FuzzingState::syncGroupId(VariableId variableId) const
{
auto end = m_SyncGroupsPool.cend();
auto it
= std::find_if(m_SyncGroupsPool.cbegin(), end, [&variableId](const auto &syncGroupEntry) {
const auto &syncGroup = syncGroupEntry.second;
return syncGroup.m_Variables.find(variableId) != syncGroup.m_Variables.end();
});
return it != end ? it->first : SyncGroupId{};
}
Alexandre Leroux
Implements execute() method of sync operation
r1240 std::vector<SyncGroupId> FuzzingState::syncGroupsIds() const
{
std::vector<SyncGroupId> result{};
for (const auto &entry : m_SyncGroupsPool) {
result.push_back(entry.first);
}
return result;
}
void FuzzingState::synchronizeVariable(VariableId variableId, SyncGroupId syncGroupId)
{
if (syncGroupId.isNull()) {
return;
}
Alexandre Leroux
Fixes on fuzzing tests
r1328 // Registers variable into sync group
Alexandre Leroux
Implements execute() method of sync operation
r1240 auto &syncGroup = m_SyncGroupsPool.at(syncGroupId);
Alexandre Leroux
Fixes on fuzzing tests
r1328 auto &variableState = m_VariablesPool.at(variableId);
Alexandre Leroux
Implements execute() method of sync operation
r1240 syncGroup.m_Variables.insert(variableId);
if (syncGroup.m_Variables.size() == 1) {
Alexandre Leroux
Fixes on fuzzing tests
r1328 // If it's the first variable, sets the variable range as the sync group range
Alexandre Leroux
Implements execute() method of sync operation
r1240 syncGroup.m_Range = variableState.m_Range;
}
Alexandre Leroux
Fixes on fuzzing tests
r1328 else {
// If a variable is added to an existing group, sets its range to the group's range
variableState.m_Range = syncGroup.m_Range;
}
Alexandre Leroux
Implements execute() method of sync operation
r1240 }
Alexandre Leroux
Implements execute() method of desync operation...
r1241 void FuzzingState::desynchronizeVariable(VariableId variableId, SyncGroupId syncGroupId)
{
if (syncGroupId.isNull()) {
return;
}
Alexandre Leroux
Updates states of synchronized variables when there is a move operation
r1242 // Unregisters variable from sync group: if there is no more variable in the group, resets the
// range
Alexandre Leroux
Implements execute() method of desync operation...
r1241 auto &syncGroup = m_SyncGroupsPool.at(syncGroupId);
syncGroup.m_Variables.erase(variableId);
if (syncGroup.m_Variables.empty()) {
syncGroup.m_Range = INVALID_RANGE;
}
}
Alexandre Leroux
Updates states of synchronized variables when there is a move operation
r1242 void FuzzingState::updateRanges(VariableId variableId, const SqpRange &newRange)
{
auto syncGroupId = this->syncGroupId(variableId);
// Retrieves the variables to update:
Alexandre Leroux
Fixes on fuzzing tests
r1328 // - if the variable is synchronized to others, updates the range of the group and of all
// synchronized variables
Alexandre Leroux
Updates states of synchronized variables when there is a move operation
r1242 // - otherwise, updates only the variable
Alexandre Leroux
Fixes on fuzzing tests
r1328 if (syncGroupId.isNull()) {
Alexandre Leroux
Updates states of synchronized variables when there is a move operation
r1242 m_VariablesPool.at(variableId).m_Range = newRange;
}
Alexandre Leroux
Fixes on fuzzing tests
r1328 else {
auto &syncGroup = m_SyncGroupsPool.at(syncGroupId);
syncGroup.m_Range = newRange;
for (const auto &variableId : syncGroup.m_Variables) {
m_VariablesPool.at(variableId).m_Range = newRange;
}
}
Alexandre Leroux
Updates states of synchronized variables when there is a move operation
r1242 }