Skip to content

Commit

Permalink
!fix: working on python proccessor
Browse files Browse the repository at this point in the history
  • Loading branch information
charliekush committed Jul 16, 2024
1 parent 602b3e4 commit 23cba02
Show file tree
Hide file tree
Showing 10 changed files with 813 additions and 274 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ set(GTEST_SOURCE_FILES
src/scheduler.cpp
tests/fixed_google_tests.cpp
tests/file_google_tests.cpp
tests/overlap_google_tests.cpp
)


Expand Down
8 changes: 1 addition & 7 deletions src/ensembles.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
/**
* @file ensembles.cpp
* @author your name ([email protected])
* @brief
* @version 1
* @date 2024-06-10
*
* @copyright Copyright (c) 2024
*
* @brief Contains efinitions of ensembles
*/
#include "ensembles.hpp"
#ifndef TEST_VERSION
Expand Down
17 changes: 3 additions & 14 deletions tests/file_google_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class SchedulerTestsFromFiles : public ::testing::TestWithParam<std::string>
{
if(!strcmp(nextEvent->taskName,
input.delays[i].taskName.c_str()) &&
(nextEvent->state.measurementCount ==
(nextEvent->state.measurementCount - 1 ==
input.delays[i].iteration))
{
if (input.delays[i].isBefore)
Expand Down Expand Up @@ -328,21 +328,10 @@ class SchedulerTestsFromFiles : public ::testing::TestWithParam<std::string>
}


/**
* @brief Run task and update time with delay and check values
*
* This function checks the correct task is being run, and the start time
* and end time is correct. The delay is added after the task is run.
*
*
* @param expectedTaskName expected task name character
* @param expectedStart time to check start time with
* @param expectedEnd time to check end time with
* @param additionalTime the amount of delay to add
*/


/**
* @brief Run task and update time and check values
* @brief Run task, update time, and check values
*
* This function checks the correct task is being run, and the start time
* and end time is correct
Expand Down
216 changes: 0 additions & 216 deletions tests/fixed_google_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -814,219 +814,3 @@ TEST_F(SchedulerFixedTests, LargeIntervalsSmallDurations)
}


/**
* @brief Testing no overlap with A before B
*
* A ***********
* B **********
*/
TEST_F(SchedulerFixedTests, NoOverlapBefore)
{
schedule2();

deploymentSchedule[0].state.deploymentStartTime = 0;
deploymentSchedule[0].ensembleDelay = 0;
deploymentSchedule[0].maxDuration = 300;
deploymentSchedule[0].ensembleInterval = 1000;

deploymentSchedule[1].state.deploymentStartTime = 0;
deploymentSchedule[1].ensembleDelay = 500;
deploymentSchedule[1].maxDuration = 200;
deploymentSchedule[1].ensembleInterval = 1000;

int i = 1;
uint32_t start = deploymentSchedule[i].state.deploymentStartTime +
deploymentSchedule[i].ensembleDelay;
uint32_t end = start + deploymentSchedule[i].maxDuration;
bool overlap = SCH_willOverlap(deploymentSchedule.data(), i, 0, start);
ASSERT_FALSE(overlap);
}



/**
* @brief Testing overlap with end of A and start of B
*
* A ***********
* B ***********
*/
TEST_F(SchedulerFixedTests, OverlapBefore)
{
schedule2();

deploymentSchedule[0].state.deploymentStartTime = 0;
deploymentSchedule[0].state.nextRunTime = 250;
deploymentSchedule[0].maxDuration = 300;
deploymentSchedule[0].ensembleInterval = 1000;


deploymentSchedule[1].state.deploymentStartTime = 0;
deploymentSchedule[1].state.nextRunTime = 500;
deploymentSchedule[1].maxDuration = 200;
deploymentSchedule[1].ensembleInterval = 1000;


int i = 1;
uint32_t start = deploymentSchedule[i].state.nextRunTime;
uint32_t end = start + deploymentSchedule[i].maxDuration;
bool overlap = SCH_willOverlap(deploymentSchedule.data(), i, 0, start);
ASSERT_TRUE(overlap);
}


/*
A ***********
B **********
*/
/**
* @brief Testing no overlap with A after B
*
*/
TEST_F(SchedulerFixedTests, NoOverlapAfter)
{
schedule2();

deploymentSchedule[0].state.deploymentStartTime = 0;
deploymentSchedule[0].ensembleDelay = 800;
deploymentSchedule[0].maxDuration = 300;
deploymentSchedule[0].ensembleInterval = 1000;

deploymentSchedule[1].state.deploymentStartTime = 0;
deploymentSchedule[1].ensembleDelay = 500;
deploymentSchedule[1].maxDuration = 200;
deploymentSchedule[1].ensembleInterval = 1000;

int i = 1;
uint32_t start = deploymentSchedule[i].state.deploymentStartTime +
deploymentSchedule[i].ensembleDelay;
uint32_t end = start + deploymentSchedule[i].maxDuration;
bool overlap = SCH_willOverlap(deploymentSchedule.data(), i, 0, start);
ASSERT_FALSE(overlap);
}

/**
* @brief Testing overlap with end of B and start of A
*
* A ***********
* B **********
*/
TEST_F(SchedulerFixedTests, OverlapAfter)
{
schedule2();

deploymentSchedule[0].state.deploymentStartTime = 0;
deploymentSchedule[0].state.nextRunTime = 650;
deploymentSchedule[0].maxDuration = 300;
deploymentSchedule[0].ensembleInterval = 1000;


deploymentSchedule[1].state.deploymentStartTime = 0;
deploymentSchedule[1].state.nextRunTime = 500;
deploymentSchedule[1].maxDuration = 200;
deploymentSchedule[1].ensembleInterval = 1000;


int i = 1;
uint32_t start = deploymentSchedule[i].state.nextRunTime;
uint32_t end = start + deploymentSchedule[i].maxDuration;
bool overlap = SCH_willOverlap(deploymentSchedule.data(), i, 0, start);
ASSERT_TRUE(overlap);
}


/**
* @brief Testing for overlap when B starts after A starts and before A ends
*
* A *****************
* B **********
*
*/
TEST_F(SchedulerFixedTests, InsideOverlap)
{
schedule2();

deploymentSchedule[0].state.deploymentStartTime = 0;
deploymentSchedule[0].state.nextRunTime = 0;
deploymentSchedule[0].maxDuration = 800;
deploymentSchedule[0].ensembleInterval = 1000;


deploymentSchedule[1].state.deploymentStartTime = 0;
deploymentSchedule[1].state.nextRunTime = 500;
deploymentSchedule[1].maxDuration = 200;
deploymentSchedule[1].ensembleInterval = 1000;


int i = 1;
uint32_t start = deploymentSchedule[i].state.nextRunTime;
uint32_t end = start + deploymentSchedule[i].maxDuration;
bool overlap = SCH_willOverlap(deploymentSchedule.data(), i, 0, start);
ASSERT_TRUE(overlap);
}


/**
* @brief Testing no overlap edge case when B starts as A ends
*
* A *********
* B **********
*/
TEST_F(SchedulerFixedTests, Boundary1)
{
schedule2();

deploymentSchedule[0].state.deploymentStartTime = 0;
deploymentSchedule[0].state.nextRunTime = 0;
deploymentSchedule[0].maxDuration = 500;
deploymentSchedule[0].ensembleInterval = 1000;

deploymentSchedule[1].state.deploymentStartTime = 0;
deploymentSchedule[1].state.nextRunTime = 500;
deploymentSchedule[1].maxDuration = 200;
deploymentSchedule[1].ensembleInterval = 1000;


int i = 1;
uint32_t start = deploymentSchedule[i].state.nextRunTime;
uint32_t end = start + deploymentSchedule[i].maxDuration;
bool overlap = SCH_willOverlap(deploymentSchedule.data(), i, 0, start);
ASSERT_FALSE(overlap);
}


/**
* @brief Testing no overlap edge case when A starts as B ends
*
* A *********
* B **********
*/
TEST_F(SchedulerFixedTests, Boundary2)
{
schedule2();

deploymentSchedule[0].state.deploymentStartTime = 0;
deploymentSchedule[0].ensembleDelay = 700;
deploymentSchedule[0].maxDuration = 300;
deploymentSchedule[0].ensembleInterval = 1000;


deploymentSchedule[1].state.deploymentStartTime = 0;
deploymentSchedule[1].ensembleDelay = 500;
deploymentSchedule[1].maxDuration = 200;
deploymentSchedule[1].ensembleInterval = 1000;


int i = 1;
uint32_t start = deploymentSchedule[i].state.deploymentStartTime +
deploymentSchedule[i].ensembleDelay;
uint32_t end = start + deploymentSchedule[i].maxDuration;
bool overlap = SCH_willOverlap(deploymentSchedule.data(), i, 0, start);
ASSERT_FALSE(overlap);
SCH_getNextEvent(deploymentSchedule.data(), &nextEvent,
&nextEventTime, millis());
runAndCheckEvent("B", 500, 700);
SCH_getNextEvent(deploymentSchedule.data(), &nextEvent,
&nextEventTime, millis());
runAndCheckEvent("A", 700, 1000);
}

6 changes: 3 additions & 3 deletions tests/inputs/example.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ ENSEMBLES #taskname|interval|duration or taskname|interval|duration|maxDelay
A|2000|200
B|2000|400|1000
C|500|100
DELAYS #"taskname|iteration|delay" or "taskname|iteration|delay|before" (after implied)
DELAYS #0 indexed: "taskname|iteration|delay" or "taskname|iteration|delay|before" (after implied)
A|0|100|before
B|3|200
EXPECTED #"taskname|start|end|
A|0|200
EXPECTED #"taskname|start|end"
A|100|300
B|300|700
C|700|800
Loading

0 comments on commit 23cba02

Please sign in to comment.