From 6015d1ab680086f07ca476ac7034fc70ea9f3d25 2017-12-21 14:49:39 From: Alexandre Leroux Date: 2017-12-21 14:49:39 Subject: [PATCH] Fixes on fuzzing tests --- diff --git a/plugins/amda/tests/FuzzingDefs.cpp b/plugins/amda/tests/FuzzingDefs.cpp index d47bbd8..5d2502e 100644 --- a/plugins/amda/tests/FuzzingDefs.cpp +++ b/plugins/amda/tests/FuzzingDefs.cpp @@ -67,14 +67,18 @@ void FuzzingState::synchronizeVariable(VariableId variableId, SyncGroupId syncGr return; } - // Registers variable into sync group: if it's the first variable, sets the variable range as - // the sync group range + // Registers variable into sync group auto &syncGroup = m_SyncGroupsPool.at(syncGroupId); + auto &variableState = m_VariablesPool.at(variableId); syncGroup.m_Variables.insert(variableId); if (syncGroup.m_Variables.size() == 1) { - auto &variableState = m_VariablesPool.at(variableId); + // If it's the first variable, sets the variable range as the sync group range syncGroup.m_Range = variableState.m_Range; } + else { + // If a variable is added to an existing group, sets its range to the group's range + variableState.m_Range = syncGroup.m_Range; + } } void FuzzingState::desynchronizeVariable(VariableId variableId, SyncGroupId syncGroupId) @@ -97,13 +101,18 @@ void FuzzingState::updateRanges(VariableId variableId, const SqpRange &newRange) auto syncGroupId = this->syncGroupId(variableId); // Retrieves the variables to update: - // - if the variable is synchronized to others, updates all synchronized variables + // - if the variable is synchronized to others, updates the range of the group and of all + // synchronized variables // - otherwise, updates only the variable - auto variablesToUpdate = syncGroupId.isNull() ? std::set{variableId} - : m_SyncGroupsPool.at(syncGroupId).m_Variables; - - // Sets new range - for (const auto &variableId : variablesToUpdate) { + if (syncGroupId.isNull()) { m_VariablesPool.at(variableId).m_Range = newRange; } + 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; + } + } } diff --git a/plugins/amda/tests/FuzzingOperations.cpp b/plugins/amda/tests/FuzzingOperations.cpp index b947424..059c233 100644 --- a/plugins/amda/tests/FuzzingOperations.cpp +++ b/plugins/amda/tests/FuzzingOperations.cpp @@ -176,6 +176,9 @@ struct SynchronizeOperation : public IFuzzingOperation { // Updates state fuzzingState.synchronizeVariable(variableId, syncGroupId); + + variableController.onRequestDataLoading({variableState.m_Variable}, variableState.m_Range, + false); } }; @@ -197,7 +200,7 @@ struct DesynchronizeOperation : public IFuzzingOperation { qCInfo(LOG_FuzzingOperations()).noquote() << "Removing" << variableState.m_Variable->name() << "from synchronization group" << syncGroupId << "..."; - variableController.onAddSynchronized(variableState.m_Variable, syncGroupId); + variableController.desynchronize(variableState.m_Variable, syncGroupId); // Updates state fuzzingState.desynchronizeVariable(variableId, syncGroupId); diff --git a/plugins/amda/tests/FuzzingValidators.cpp b/plugins/amda/tests/FuzzingValidators.cpp index f4de229..069251d 100644 --- a/plugins/amda/tests/FuzzingValidators.cpp +++ b/plugins/amda/tests/FuzzingValidators.cpp @@ -96,7 +96,7 @@ public: auto dataHoleIt = std::adjacent_find( dataIts.first, dataIts.second, [](const auto &it1, const auto &it2) { /// @todo: validate resolution - return std::abs(it1.x() - it2.x()) > 2 * (LOCALHOST_SERVER_RESOLUTION - 1); + return std::abs(it1.x() - it2.x()) > 2 * LOCALHOST_SERVER_RESOLUTION; }); if (dataHoleIt != dataIts.second) { diff --git a/plugins/amda/tests/TestAmdaFuzzing.cpp b/plugins/amda/tests/TestAmdaFuzzing.cpp index 2dd6222..b2d299c 100644 --- a/plugins/amda/tests/TestAmdaFuzzing.cpp +++ b/plugins/amda/tests/TestAmdaFuzzing.cpp @@ -370,6 +370,10 @@ void TestAmdaFuzzing::testFuzzing() int main(int argc, char *argv[]) { + // Increases the test function timeout (which is 5 minutes by default) to 12 hours + // https://stackoverflow.com/questions/42655932/setting-timeout-to-qt-test + qputenv("QTEST_FUNCTION_TIMEOUT", QByteArray::number(12*60*60*1000)); + QLoggingCategory::setFilterRules( "*.warning=false\n" "*.info=false\n"