diff --git a/src/Compiler/TaskManager.cpp b/src/Compiler/TaskManager.cpp index 7cb30776c0..a63d9f4204 100644 --- a/src/Compiler/TaskManager.cpp +++ b/src/Compiler/TaskManager.cpp @@ -406,6 +406,12 @@ void TaskManager::resetTask(Task *t) { QVector TaskManager::getDownstreamCleanTasks(Task *t) const { QVector tasks; + for (auto task : m_taskQueue) { + if ((task->cleanTask() == t) && isSimulation(task)) { + tasks.append(t); + return tasks; + } + } for (auto it{m_taskQueue.rbegin()}; it != m_taskQueue.rend(); ++it) { if ((*it)->type() == TaskType::Clean) tasks.append(*it); if (*it == t) break; diff --git a/src/Compiler/TaskManager.h b/src/Compiler/TaskManager.h index e25b31cc96..0f942b5a99 100644 --- a/src/Compiler/TaskManager.h +++ b/src/Compiler/TaskManager.h @@ -101,6 +101,14 @@ class TaskManager : public QObject { static bool isSimulation(const Task *const task); void setDialogProvider(const DialogProvider *const dProvider); + /*! + * \brief getDownstreamClearTasks + * \return vector of clean tasks in reverse order. Vector includes \param t. + * If \param t is simulation clean, return only this task since simulation + * doesn't trigger clean for downstream. + */ + QVector getDownstreamCleanTasks(Task *t) const; + signals: /*! * \brief taskStateChanged. Emits whenever any task change its status. @@ -134,12 +142,6 @@ class TaskManager : public QObject { void cleanDownStreamStatus(Task *t); void appendTask(Task *t); void resetTask(Task *t); - - /*! - * \brief getDownstreamClearTasks - * \return vector of clean tasks in reverse order. Vector includes \param t. - */ - QVector getDownstreamCleanTasks(Task *t) const; void registerReportManager(uint type, AbstractReportManager *manager); private: diff --git a/tests/unittest/CMakeLists.txt b/tests/unittest/CMakeLists.txt index cb67355dd7..bcc5b1c4bb 100644 --- a/tests/unittest/CMakeLists.txt +++ b/tests/unittest/CMakeLists.txt @@ -64,6 +64,7 @@ set(CPP_LIST DeviceModeling/rs_parameter_test.cpp DeviceModeling/device_signal_test.cpp DeviceModeling/device_net_test.cpp + Compiler/TaskManager_test.cpp ) set(H_LIST PinAssignment/TestLoader.h diff --git a/tests/unittest/Compiler/TaskManager_test.cpp b/tests/unittest/Compiler/TaskManager_test.cpp new file mode 100644 index 0000000000..47ac2f2f97 --- /dev/null +++ b/tests/unittest/Compiler/TaskManager_test.cpp @@ -0,0 +1,70 @@ +/* +Copyright 2022 The Foedag team + +GPL License + +Copyright (c) 2022 The Open-Source FPGA Foundation + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#include "Compiler/TaskManager.h" + +#include "Compiler/Compiler.h" +#include "Compiler/CompilerDefines.h" +#include "gtest/gtest.h" + +using namespace FOEDAG; + +TEST(TaskManager, getDownstreamCleanTasks) { + TaskManager taskManager{nullptr}; + + taskManager.task(SIMULATE_RTL) + ->setCustomData({CustomDataType::Sim, + QVariant::fromValue(Simulator::SimulationType::RTL)}); + taskManager.task(SIMULATE_PNR) + ->setCustomData({CustomDataType::Sim, + QVariant::fromValue(Simulator::SimulationType::PNR)}); + taskManager.task(SIMULATE_GATE) + ->setCustomData({CustomDataType::Sim, + QVariant::fromValue(Simulator::SimulationType::Gate)}); + taskManager.task(SIMULATE_BITSTREAM) + ->setCustomData( + {CustomDataType::Sim, + QVariant::fromValue(Simulator::SimulationType::BitstreamBackDoor)}); + + auto simulationRtl = taskManager.task(SIMULATE_RTL_CLEAN); + auto cleanTasks = taskManager.getDownstreamCleanTasks(simulationRtl); + EXPECT_EQ(cleanTasks.count(), 1); + EXPECT_EQ(cleanTasks.at(0), simulationRtl); + + auto simulationGate = taskManager.task(SIMULATE_GATE_CLEAN); + cleanTasks = taskManager.getDownstreamCleanTasks(simulationGate); + EXPECT_EQ(cleanTasks.count(), 1); + EXPECT_EQ(cleanTasks.at(0), simulationGate); + + auto simulationPnr = taskManager.task(SIMULATE_PNR_CLEAN); + cleanTasks = taskManager.getDownstreamCleanTasks(simulationPnr); + EXPECT_EQ(cleanTasks.count(), 1); + EXPECT_EQ(cleanTasks.at(0), simulationPnr); + + auto simulationBitstream = taskManager.task(SIMULATE_BITSTREAM_CLEAN); + cleanTasks = taskManager.getDownstreamCleanTasks(simulationBitstream); + EXPECT_EQ(cleanTasks.count(), 1); + EXPECT_EQ(cleanTasks.at(0), simulationBitstream); + + auto analysis = taskManager.task(ANALYSIS_CLEAN); + cleanTasks = taskManager.getDownstreamCleanTasks(analysis); + EXPECT_EQ(cleanTasks.count(), 12); +}