diff --git a/CMakeLists.txt b/CMakeLists.txt index 7f93fd60..85910b99 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,6 +23,7 @@ set(GTEST_SOURCE_FILES src/antara_scheduler.cpp src/charlie_scheduler.cpp tests/fixed_google_tests.cpp + src/scheduler.cpp #tests/file_google_tests.cpp #tests/overlap_google_tests.cpp tests/scheduler_test_flog.cpp @@ -32,6 +33,7 @@ set(EXAMINE_BEHAVIOR_SOURCE_FILES tests/test_ensembles.cpp src/charlie_scheduler.cpp src/antara_scheduler.cpp + src/scheduler.cpp tests/scheduler_test_flog.cpp tests/examine_behavior.cpp ) diff --git a/src/abstractScheduler.hpp b/src/abstractScheduler.hpp index 05e14979..c497206b 100644 --- a/src/abstractScheduler.hpp +++ b/src/abstractScheduler.hpp @@ -2,7 +2,7 @@ #define __ABSTRACT_SCHEDULER_HPP__ #include #include "deploymentSchedule.hpp" - +#include class AbstractScheduler { @@ -25,8 +25,16 @@ class AbstractScheduler { * @return 0 if successful, otherwise error code to be defined by * implementation */ - virtual int getNextTask(DeploymentSchedule_t** p_next_task, + virtual SCH_error_e getNextTask(DeploymentSchedule_t** p_next_task, std::uint32_t* p_next_runtime, std::uint32_t current_time) = 0; }; + +typedef enum error_ +{ + SUCCESS, + TASK_SEARCH_FAIL, + FLOG_SCHEDULER_DELAY_EXCEEDED +}SCH_error_e; + #endif // __ABSTRACT_SCHEDULER_HPP__ \ No newline at end of file diff --git a/src/antara_scheduler.hpp b/src/antara_scheduler.hpp index 44158fe6..f03e5525 100644 --- a/src/antara_scheduler.hpp +++ b/src/antara_scheduler.hpp @@ -57,11 +57,7 @@ class Scheduler : public AbstractScheduler std::uint32_t current_time); void initializeScheduler(); }; -typedef enum error_ -{ - SUCCESS, - TASK_SEARCH_FAIL, -}SCH_error_e; + #endif diff --git a/src/charlie_scheduler.hpp b/src/charlie_scheduler.hpp index 708dbead..a1479cbe 100644 --- a/src/charlie_scheduler.hpp +++ b/src/charlie_scheduler.hpp @@ -132,11 +132,7 @@ class Scheduler : public AbstractScheduler { }; -typedef enum error_ -{ - SUCCESS, - TASK_SEARCH_FAIL, -}SCH_error_e; + diff --git a/src/ensembles.hpp b/src/ensembles.hpp index 0b728a96..be61ab0a 100644 --- a/src/ensembles.hpp +++ b/src/ensembles.hpp @@ -5,11 +5,8 @@ #ifndef __ENSEMBLES_HPP__ #define __ENSEMBLES_HPP__ - -#if SCHEDULER_VERSION == CHARLIE_VERSION #include "charlie_scheduler.hpp" -#else #include "antara_scheduler.hpp" -#endif +#include "scheduler.hpp" -#endif \ No newline at end of file +#endif //__ENSEMBLES_HPP__ \ No newline at end of file diff --git a/src/rideTask.cpp b/src/rideTask.cpp index f8a16509..9f0d8fa4 100644 --- a/src/rideTask.cpp +++ b/src/rideTask.cpp @@ -15,11 +15,9 @@ #include "vers.hpp" #include "ensembles.hpp" #include "cli/flog.hpp" -#if SCHEDULER_VERSION == CHARLIE_VERSION #include "charlie_scheduler.hpp" -#else #include "antara_scheduler.hpp" -#endif +#include "scheduler.hpp" /** * @brief creates file name for log diff --git a/src/scheduler.cpp b/src/scheduler.cpp index f407019a..ea7db0b1 100644 --- a/src/scheduler.cpp +++ b/src/scheduler.cpp @@ -10,6 +10,7 @@ #else #include "scheduler_test_system.hpp" #endif +#include #include "cli/conio.hpp" #include "ensembles.hpp" #include "scheduler.hpp" @@ -35,7 +36,7 @@ void Scheduler::initializeScheduler() tableSize++; memset(&(pDeployment->state), 0, sizeof(StateInformation)); - pDeployment->state.lastMeasurementTime = UINT32_MAX; + pDeployment->init(pDeployment); pDeployment++; } @@ -88,7 +89,7 @@ int Scheduler::getNextTask(DeploymentSchedule_t** p_nextEvent, { delay = 0; } - if (delay == currentEvent.maxDelay) + if (delay >= currentEvent.maxDelay) { //send warning } diff --git a/src/scheduler.hpp b/src/scheduler.hpp index d7a72dcf..85ca549d 100644 --- a/src/scheduler.hpp +++ b/src/scheduler.hpp @@ -5,7 +5,7 @@ * @version 1 */ #ifndef __CONSOLODATED_SCHEDULER__HPP__ -#define __CHARLIE_SCHEDULER__HPP__ +#define __CONSOLODATED_SCHEDULER__HPP__ #include "product.hpp" #if SCHEDULER_VERSION == CONSOLODATED_VERSION @@ -19,7 +19,7 @@ #include "Particle.h" #else #include "scheduler_test_system.hpp" -#endif +#endif // TEST_VERSION /** @@ -50,11 +50,10 @@ typedef void (*EnsembleInit)(DeploymentSchedule_t* pDeployment); struct StateInformation { //! how many times ensemble was scheduled - uint32_t measurementCount; - + std::uint32_t measurementCount; + //! store the next time the task should run - uint32_t nextRunTime; - + std::uint32_t nextRunTime; }; /** @@ -91,7 +90,7 @@ class Scheduler : public AbstractScheduler { DeploymentSchedule_t* scheduleTable; - + Scheduler(DeploymentSchedule_t* scheduler); @@ -116,7 +115,7 @@ class Scheduler : public AbstractScheduler { * @param nextStartTime The proposed start time of the current task. * @return True if there is an overlap with another task; false otherwise. */ - int getNextTask(DeploymentSchedule_t** p_next_task, + SCH_error_e getNextTask(DeploymentSchedule_t** p_next_task, uint32_t* p_next_runtime, uint32_t current_time); @@ -124,23 +123,5 @@ class Scheduler : public AbstractScheduler { uint32_t nextStartTime); }; - -typedef enum error_ -{ - SUCCESS, - TASK_SEARCH_FAIL, -}SCH_error_e; - - - - - - - - - - - -#endif - -#endif //__CHARLIE_SCHEDULER__HPP__ \ No newline at end of file +#endif //SCHEDULER_VERSION +#endif //__CONSOLODATED_SCHEDULER__HPP__ \ No newline at end of file diff --git a/tests/examine_behavior.cpp b/tests/examine_behavior.cpp index 5b72232a..63332dd2 100644 --- a/tests/examine_behavior.cpp +++ b/tests/examine_behavior.cpp @@ -1,6 +1,8 @@ #include "scheduler_test_system.hpp" #include "test_ensembles.hpp" #include "cli/conio.hpp" +#include "scheduler.hpp" + #include #include #include @@ -13,6 +15,7 @@ #include #include + class ExamineBehavior { public: @@ -21,16 +24,21 @@ class ExamineBehavior static void SetUpTestSuite() { - #if SCHEDULER_VERSION == CHARLIE_VERSION + #if SCHEDULER_VERSION == CHARLIE_VERSION files = std::make_unique( "/dev/null", "tests/no_check_outputs/charlie_actual_file_tests.log"); SF_OSAL_printf("Using Charlie's Version\n"); - #else + #elif SCHEDULER_VERSION == ANTARA_VERSION files = std::make_unique( "/dev/null", "tests/no_check_outputs/antara_actual_file_tests.log"); SF_OSAL_printf("Using Antara's Version\n"); + #else + files = std::make_unique( + "/dev/null", + "tests/no_check_outputs/consolodated_actual_file_tests.log"); + SF_OSAL_printf("Using consolodated version\n"); #endif } @@ -63,7 +71,7 @@ class ExamineBehavior //! for writing test output bool useCompareLogs; std::unique_ptr scheduler; - + std::vector> exceededDelays; @@ -144,12 +152,19 @@ class ExamineBehavior input.ensembles[i].delay, input.ensembles[i].taskName.c_str(), {0} }; - #else + #elif SCHEDULER_VERSION == ANTARA_VERSION e = {SS_ensembleAFunc, SS_ensembleAInit, 0, input.ensembles[i].interval, input.ensembles[i].duration, input.ensembles[i].taskName.c_str(), UINT32_MAX, 0, 0}; + #else + e = { SS_ensembleAFunc, SS_ensembleAInit, 1, 0, + input.ensembles[i].interval, + input.ensembles[i].duration, + input.ensembles[i].delay, + input.ensembles[i].taskName.c_str(), + {0} }; #endif deploymentSchedule.emplace_back(e); } @@ -157,9 +172,13 @@ class ExamineBehavior e = { nullptr, nullptr, 0, 0, 0, 0, 0, "",{0} }; deploymentSchedule.emplace_back(e); scheduler = std::make_unique(deploymentSchedule.data()); - #else + #elif SCHEDULER_VERSION == ANTARA_VERSION scheduler = std::make_unique(deploymentSchedule.data(), deploymentSchedule.size()); + #else + e = { nullptr, nullptr, 0, 0, 0, 0, 0, "",{0} }; + deploymentSchedule.emplace_back(e); + scheduler = std::make_unique(deploymentSchedule.data()); #endif @@ -169,49 +188,12 @@ class ExamineBehavior { scheduler->getNextTask(&nextEvent, &nextEventTime, millis()); - uint32_t beforeDelay = 0; - uint32_t afterDelay = 0; - for (size_t i = 0; i < input.delays.size(); i++) - { - #if SCHEDULER_VERSION == CHARLIE_VERSION - if (!strcmp(nextEvent->taskName, - input.delays[i].taskName.c_str()) && - (nextEvent->state.measurementCount - 1 == - input.delays[i].iteration)) - { - if (input.delays[i].isBefore) - { - beforeDelay = input.delays[i].delay; - } - else - { - afterDelay = input.delays[i].delay; - } - input.delays.erase(input.delays.begin() + i); - if ((beforeDelay != 0) && (afterDelay != 0)) - break; - } - #else - if (!strcmp(nextEvent->taskName, - input.delays[i].taskName.c_str()) && - (nextEvent->measurementCount - 1 == - input.delays[i].iteration)) - { - if (input.delays[i].isBefore) - { - beforeDelay = input.delays[i].delay; - } - else - { - afterDelay = input.delays[i].delay; - } - input.delays.erase(input.delays.begin() + i); - if ((beforeDelay != 0) && (afterDelay != 0)) - break; - } - #endif - } - runAndCheckEventWithDelays(beforeDelay, afterDelay); + + uint32_t afterDelay = input.getDelay(nextEvent->taskName, + nextEvent->state.measurementCount - 1); + + + runAndCheckEventWithDelays(afterDelay); } @@ -313,27 +295,25 @@ class ExamineBehavior } else if (currentSection == "DELAYS") { - Delay d; + std::string delayName; std::getline(iss, delayName, '|'); - d.taskName = delayName.c_str(); - iss >> d.iteration; + std::string taskName = delayName.c_str(); + uint32_t iteration, delay; + iss >> iteration; iss.ignore(1, '|'); - iss >> d.delay; - d.isBefore = false; - char checkChar = iss.peek(); - if (checkChar == '|') + iss >> delay; + + if (out.delays.find(taskName) != out.delays.end()) { - iss.ignore(1, '|'); - std::string position; - iss >> position; - if (position == "before") d.isBefore = true; + out.delays[taskName] = std::unordered_map(); } - out.delays.emplace_back(d); + out.delays[taskName][iteration] = delay; + } else if (currentSection == "RESETS") { - std::string resetName; uint32_t iteration; std::getline(iss, resetName, '|'); @@ -350,8 +330,7 @@ class ExamineBehavior - void runAndCheckEventWithDelays(uint32_t preceedingDelay, - uint32_t trailingDelay) + void runAndCheckEventWithDelays(uint32_t trailingDelay) { @@ -367,7 +346,6 @@ class ExamineBehavior appendActualFile(nextEvent->taskName, actualStart, actualEnd); - } std::vector GetFilesInDirectory(const std::string& directory) { std::vector filesInDir; diff --git a/tests/file_google_tests.cpp b/tests/file_google_tests.cpp index 50a7f110..c18a07a7 100644 --- a/tests/file_google_tests.cpp +++ b/tests/file_google_tests.cpp @@ -6,6 +6,9 @@ #include #include "scheduler_test_system.hpp" #include "test_ensembles.hpp" +#include "scheduler.hpp" +#include "charlie_scheduler.hpp" +#include "antara_scheduler.hpp" #include #include #include @@ -17,6 +20,7 @@ #include + class SchedulerTestsFromFiles : public ::testing::TestWithParam { public: @@ -47,6 +51,7 @@ class SchedulerTestsFromFiles : public ::testing::TestWithParam //! output file for actual values std::ofstream actualFile; + //! holds all data from a file TestInput input; @@ -149,98 +154,68 @@ class SchedulerTestsFromFiles : public ::testing::TestWithParam void runTestFile(std::string filename) { + input.clear(); input = parseInputFile(filename); - - setTime(input.start); + + setTime(input.start); deploymentSchedule.clear(); DeploymentSchedule_t e; - #if SCHEDULER_VERSION == CHARLIE_VERSION - for(size_t i = 0; i < input.ensembles.size(); i++) + for (size_t i = 0; i < input.ensembles.size(); i++) { - - e = { SS_ensembleAFunc, SS_ensembleAInit, 1, 0, + #if SCHEDULER_VERSION == CHARLIE_VERSION + e = { SS_ensembleAFunc, SS_ensembleAInit, 1, 0, + input.ensembles[i].interval, + input.ensembles[i].duration, + input.ensembles[i].delay, + input.ensembles[i].taskName.c_str(), + {0} }; + #elif SCHEDULER_VERSION == ANTARA_VERSION + e = {SS_ensembleAFunc, SS_ensembleAInit, 0, + input.ensembles[i].interval, + input.ensembles[i].duration, + input.ensembles[i].taskName.c_str(), + UINT32_MAX, 0, 0}; + #else + e = { SS_ensembleAFunc, SS_ensembleAInit, 1, 0, input.ensembles[i].interval, - input.ensembles[i].duration, - input.ensembles[i].delay, - input.ensembles[i].taskName.c_str(), + input.ensembles[i].duration, + input.ensembles[i].delay, + input.ensembles[i].taskName.c_str(), {0} }; + #endif deploymentSchedule.emplace_back(e); } + #if SCHEDULER_VERSION == CHARLIE_VERSION e = { nullptr, nullptr, 0, 0, 0, 0, 0, "",{0} }; deploymentSchedule.emplace_back(e); scheduler = std::make_unique(deploymentSchedule.data()); - scheduler->initializeScheduler(); + #elif SCHEDULER_VERSION == ANTARA_VERSION + scheduler = std::make_unique(deploymentSchedule.data(), + deploymentSchedule.size()); #else - for(size_t i = 0; i < input.ensembles.size(); i++) - { - - e = { - SS_ensembleAFunc, //measure - SS_ensembleAInit, //init - 0, // startDelay - input.ensembles[i].interval, //ensembleInterval - input.ensembles[i].duration, //maxDuration - input.ensembles[i].taskName.c_str(), //taskName - UINT32_MAX, //maxDelay - 0 //nextRunTime - }; - deploymentSchedule.emplace_back(e); - } + e = { nullptr, nullptr, 0, 0, 0, 0, 0, "",{0} }; + deploymentSchedule.emplace_back(e); + scheduler = std::make_unique(deploymentSchedule.data()); #endif - - while(millis() < input.end) + scheduler->initializeScheduler(); + + while (millis() < input.end) { - scheduler->getNextTask(&nextEvent,&nextEventTime, + scheduler->getNextTask(&nextEvent, &nextEventTime, millis()); - uint32_t beforeDelay = 0; - uint32_t afterDelay = 0; - for(size_t i = 0; i < input.delays.size(); i++) - { - #if SCHEDULER_VERSION == CHARLIE_VERSION - if(!strcmp(nextEvent->taskName, - input.delays[i].taskName.c_str()) && - (nextEvent->state.measurementCount - 1 == - input.delays[i].iteration)) - { - if (input.delays[i].isBefore) - { - beforeDelay = input.delays[i].delay; - } - else - { - afterDelay = input.delays[i].delay; - } - input.delays.erase(input.delays.begin() + i); - if ((beforeDelay != 0) && (afterDelay != 0)) - break; - } - #else - if(!strcmp(nextEvent->taskName, - input.delays[i].taskName.c_str()) && - (nextEvent->measurementCount - 1 == - input.delays[i].iteration)) - { - if (input.delays[i].isBefore) - { - beforeDelay = input.delays[i].delay; - } - else - { - afterDelay = input.delays[i].delay; - } - input.delays.erase(input.delays.begin() + i); - if ((beforeDelay != 0) && (afterDelay != 0)) - break; - } - #endif - } - if (input.expectedValues.size() > 0) + + uint32_t afterDelay = input.getDelay(nextEvent->taskName, + nextEvent->state.measurementCount - 1); + + + + if(input.expectedValues.size() > 0) { TestLog exp = input.expectedValues.front(); runAndCheckEventWithDelays(exp.name, exp.start, exp.end, - beforeDelay,afterDelay); + afterDelay); input.expectedValues.erase(input.expectedValues.begin()); for(size_t i = 0; i < input.resets.size(); i++) { @@ -258,11 +233,12 @@ class SchedulerTestsFromFiles : public ::testing::TestWithParam else { return; - } - + } } + } + TestInput parseInputFile(std::string filename) { std::ifstream inputFile(filename); @@ -348,22 +324,20 @@ class SchedulerTestsFromFiles : public ::testing::TestWithParam } else if (currentSection == "DELAYS") { - Delay d; std::string delayName; std::getline(iss, delayName, '|'); - d.taskName = delayName.c_str(); - iss >> d.iteration; + std::string taskName = delayName.c_str(); + uint32_t iteration, delay; + iss >> iteration; iss.ignore(1, '|'); - iss >> d.delay; - d.isBefore = false; - char checkChar = iss.peek(); - if (checkChar == '|') { - iss.ignore(1, '|'); - std::string position; - iss >> position; - if (position == "before") d.isBefore = true; + iss >> delay; + + if (out.delays.find(taskName) != out.delays.end()) + { + out.delays[taskName] = std::unordered_map(); } - out.delays.emplace_back(d); + out.delays[taskName][iteration] = delay; } else if (currentSection == "EXPECTED") { std::string expectedTaskName; @@ -411,12 +385,12 @@ class SchedulerTestsFromFiles : public ::testing::TestWithParam uint32_t expectedEnd) { runAndCheckEventWithDelays(expectedTaskName, expectedStart, - expectedEnd, 0, 0); + expectedEnd, 0); } void runAndCheckEventWithDelays(std::string expectedTaskName, uint32_t expectedStart, uint32_t expectedEnd, - uint32_t preceedingDelay, + uint32_t trailingDelay) { ASSERT_NE(nextEvent, nullptr) << "Scheduler returned nullptr."; diff --git a/tests/fixed_google_tests.cpp b/tests/fixed_google_tests.cpp index 665b5c59..35545c23 100644 --- a/tests/fixed_google_tests.cpp +++ b/tests/fixed_google_tests.cpp @@ -5,6 +5,9 @@ */ #include #include "scheduler_test_system.hpp" +#include "scheduler.hpp" +#include "charlie_scheduler.hpp" +#include "antara_scheduler.hpp" #include "test_ensembles.hpp" #include #include @@ -92,7 +95,7 @@ class SchedulerFixedTests : public ::testing::Test scheduler = std::make_unique(deploymentSchedule.data()); scheduler->initializeScheduler(); - #else + #elif SCHEDULER_VERSION == ANTARA_VERSION deploymentSchedule = { { SS_ensembleAFunc, //measure @@ -111,6 +114,27 @@ class SchedulerFixedTests : public ::testing::Test }; scheduler = std::make_unique(deploymentSchedule.data(), 3); + #else + deploymentSchedule = { + { SS_ensembleAFunc, //measure + SS_ensembleAInit, //init + 1, // measurementsToAccumulate + 0, // ensembleDelay + 2000, //ensembleInterval + 400, //maxDuration + UINT32_MAX, //maxDelay + "A", //taskName + {0} //state + }, + + {SS_ensembleBFunc, SS_ensembleBInit, 1, 0, 2000, 200, UINT32_MAX, "B", {0}}, + {SS_ensembleCFunc, SS_ensembleCInit, 1, 0, 2000, 600, UINT32_MAX, "C", {0}}, + { nullptr, nullptr, 0, 0, 0, 0, 0, "", {0}} + }; + + + scheduler = std::make_unique(deploymentSchedule.data()); + scheduler->initializeScheduler(); #endif } /** @@ -124,11 +148,15 @@ class SchedulerFixedTests : public ::testing::Test deploymentSchedule[2] = { nullptr, nullptr, 0, 0, 0, 0, 0, "\0",{0} }; scheduler = std::make_unique(deploymentSchedule.data()); scheduler->initializeScheduler(); - #else + #elif SCHEDULER_VERSION == ANTARA_VERSION deploymentSchedule.erase(deploymentSchedule.begin() + 1, deploymentSchedule.end()); scheduler = std::make_unique(deploymentSchedule.data(),1); - + #else + + deploymentSchedule[2] = { nullptr, nullptr, 0, 0, 0, 0, 0, "\0",{0} }; + scheduler = std::make_unique(deploymentSchedule.data()); + scheduler->initializeScheduler(); #endif @@ -148,11 +176,17 @@ class SchedulerFixedTests : public ::testing::Test deploymentSchedule[2] = { SS_ensembleCFunc, SS_ensembleCInit, 1, 0, 800, 250, UINT32_MAX, "C", {0} }; scheduler = std::make_unique(deploymentSchedule.data()); scheduler->initializeScheduler(); - #else + #elif SCHEDULER_VERSION == ANTARA_VERSION deploymentSchedule[0] = {SS_ensembleBFunc, SS_ensembleBInit, 0, 500, 200, "A", UINT32_MAX, 0, 0}; deploymentSchedule[1] = {SS_ensembleBFunc, SS_ensembleBInit, 0, 200, 100, "B", UINT32_MAX, 0, 0}; deploymentSchedule[2] = {SS_ensembleBFunc, SS_ensembleBInit, 0, 800, 250, "C", UINT32_MAX, 0, 0}; scheduler = std::make_unique(deploymentSchedule.data(),3); + #else + deploymentSchedule[0] = { SS_ensembleAFunc, SS_ensembleAInit, 1, 0, 500, 200, UINT32_MAX, "A", {0} }; + deploymentSchedule[1] = { SS_ensembleBFunc, SS_ensembleBInit, 1, 0, 200, 100, UINT32_MAX, "B", {0} }; + deploymentSchedule[2] = { SS_ensembleCFunc, SS_ensembleCInit, 1, 0, 800, 250, UINT32_MAX, "C", {0} }; + scheduler = std::make_unique(deploymentSchedule.data()); + scheduler->initializeScheduler(); #endif } /** @@ -167,11 +201,16 @@ class SchedulerFixedTests : public ::testing::Test deploymentSchedule[1] = { nullptr, nullptr, 0, 0, 0, 0, 0, "", {0} }; scheduler = std::make_unique(deploymentSchedule.data()); scheduler->initializeScheduler(); - #else + #elif SCHEDULER_VERSION == ANTARA_VERSION deploymentSchedule.erase(deploymentSchedule.begin() + 1, deploymentSchedule.end()); deploymentSchedule[0] = {SS_ensembleBFunc, SS_ensembleBInit, 0, 500, 150, "A", UINT32_MAX, 0, 0}; scheduler = std::make_unique(deploymentSchedule.data(),1); + #else + deploymentSchedule[0] = { SS_ensembleAFunc, SS_ensembleAInit, 1, 0, 200, 150, UINT32_MAX, "A", {0} }; + deploymentSchedule[1] = { nullptr, nullptr, 0, 0, 0, 0, 0, "", {0} }; + scheduler = std::make_unique(deploymentSchedule.data()); + scheduler->initializeScheduler(); #endif } diff --git a/tests/fixed_google_tests_v2.cpp b/tests/fixed_google_tests_v2.cpp new file mode 100644 index 00000000..026ed405 --- /dev/null +++ b/tests/fixed_google_tests_v2.cpp @@ -0,0 +1,45 @@ +#include +#include +#include +/** + * name of test class: ClassName +*/ + +class ClassName : public ::testing::Test +{ +//required +protected: + std::vector test; + + ClassName() + { + test.reserve(5); + test.emplace_back(5); + } + void SetUp() override{ + test.emplace_back(10); + } + void TearDown() override{ + for (int i = 0; i < get_size(); i++) + { + std::cout << test[i] << "\t"; + } + std::cout << "\n"; + + } + + + int get_size() + { + return test.size(); + } + + +}; + +TEST_F(ClassName, Test1) +{ + test.emplace_back(20); + ASSERT_EQ(test[1], 20); + +}; diff --git a/tests/scheduler_test_system.cpp b/tests/scheduler_test_system.cpp index b7e2d9e8..6d2883ce 100644 --- a/tests/scheduler_test_system.cpp +++ b/tests/scheduler_test_system.cpp @@ -97,6 +97,19 @@ void delay(uint32_t time) addTime(time); } + +uint32_t TestInput::getDelay(std::string name, uint32_t iteration) +{ + uint32_t delay = 0; + if (delays.find(name) != delays.end()) + { + if (delays[name].find(iteration) != delays[name].end()) + { + delay = delays[name][iteration]; + } + } + return delay; +} FileWriter::FileWriter(std::string expectedFileName, std::string actualFileName) { this->firstTest = true; diff --git a/tests/scheduler_test_system.hpp b/tests/scheduler_test_system.hpp index b72e43b0..4151571c 100644 --- a/tests/scheduler_test_system.hpp +++ b/tests/scheduler_test_system.hpp @@ -12,6 +12,8 @@ #include #include #include +#include + @@ -89,17 +91,11 @@ struct TestLog bool operator==(const TestLog& rhs); }; -struct Delay -{ - std::string taskName; //!< name of the task - uint32_t iteration; - int32_t delay; - bool isBefore; - -}; + struct EnsembleInput { - EnsembleInput(std::string taskName,uint32_t interval, uint32_t duration, uint32_t delay); + EnsembleInput(std::string taskName,uint32_t interval, uint32_t duration, + uint32_t delay); std::string taskName; //!< name of the task uint32_t interval; uint32_t duration; @@ -111,9 +107,12 @@ struct TestInput uint32_t end; std::vector ensembles; std::vector expectedValues; - std::vector delays; + std::unordered_map> delays; std::vector> resets; + uint32_t getDelay(std::string name, uint32_t iteration); + void clear(); std::string serialize() const { std::stringstream ss; @@ -136,15 +135,7 @@ struct TestInput } ss << " ]\n"; - ss << " Delays: [\n"; - for (const auto& delay : delays) { - ss << " { TaskName: " << delay.taskName - << ", Iteration: " << delay.iteration - << ", Delay: " << delay.delay - << ", IsBefore: " << (delay.isBefore ? "true" : "false") - << " }\n"; - } - ss << " ]\n"; + ss << "}"; return ss.str(); diff --git a/tests/test_ensembles.hpp b/tests/test_ensembles.hpp index f8a766ea..4599a8a9 100644 --- a/tests/test_ensembles.hpp +++ b/tests/test_ensembles.hpp @@ -6,11 +6,11 @@ #ifndef __TEST_ENSEMBLES_HPP__ #define __TEST_ENSEMBLES_HPP__ #include "product.hpp" -#if SCHEDULER_VERSION == CHARLIE_VERSION #include "charlie_scheduler.hpp" -#else + +#include "antara_scheduler.hpp" #include "antara_scheduler.hpp" -#endif +#include "scheduler.hpp" /** * @brief dummy ensemble init function * @param pDeployment schedule table