Skip to content

Commit

Permalink
fix: modified file writing and proccessing
Browse files Browse the repository at this point in the history
  • Loading branch information
charliekush committed Aug 29, 2024
1 parent bd3ae6a commit 851fff4
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 38 deletions.
Empty file removed tests/.gitinclude
Empty file.
43 changes: 7 additions & 36 deletions tests/file_google_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,39 +73,10 @@ class SchedulerTestsFromFiles : public ::testing::TestWithParam<std::string>
std::unique_ptr<Scheduler> scheduler;


/**
* @brief Construct a new Scheduler Test object
*
* Creates a deployment schedule with three ensembles:
* Ensemble A runs every 2000ms with a max duration of 400ms
* Ensemble B runs every 2000ms with a max duration of 200ms
* Ensemble C runs every 2000ms with a max duration of 600ms
*/


/**
* @brief Add expected log to vector
* @param task the name of the task being run
* @param start the start time
* @param end the end tim
*/
inline void appendExpectedFile(std::string task,
std::uint32_t start,
std::uint32_t end)
{
expected.emplace_back(task, start, end);
}
/**
* @brief Add actual log to vector
* @param task the name of the task being run
* @param start the start time
* @param end the end tim
*/
inline void appendActualFile(std::string task,
std::uint32_t start,
std::uint32_t end)
{
actual.emplace_back(task, start, end);
}


/**
* @brief Sets up the test envirnoment before each test
*
Expand Down Expand Up @@ -150,8 +121,8 @@ class SchedulerTestsFromFiles : public ::testing::TestWithParam<std::string>
addTime(nextEvent->maxDuration);
if (!useCompareLogs)
{
appendExpectedFile(nextEvent->taskName, nextEventTime, millis());
appendActualFile(nextEvent->taskName, nextEventTime, millis());
expected.emplace_back(nextEvent->taskName, nextEventTime, millis());
actual.emplace_back(nextEvent->taskName, nextEventTime, millis());
}
}

Expand Down Expand Up @@ -248,8 +219,8 @@ class SchedulerTestsFromFiles : public ::testing::TestWithParam<std::string>
addTime(trailingDelay);
std::uint32_t actualEnd = millis();

appendExpectedFile(expectedTaskName, expectedStart, expectedEnd);
appendActualFile(nextEvent->taskName, actualStart, actualEnd);
expected.emplace_back(expectedTaskName, expectedStart, expectedEnd);
actual.emplace_back(nextEvent->taskName, actualStart, actualEnd);

ASSERT_EQ(expectedTaskName, nextEvent->taskName) << failMessage.str();
ASSERT_EQ(expectedStart, actualStart) << failMessage.str();
Expand Down
4 changes: 2 additions & 2 deletions tests/scheduler_proccessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def plot_gantt(tasks: List[Dict[str, Union[str, int]]], title: str, dir_path: Pa
def parse_logs() -> Tuple[Dict[str, List[Dict[str, Union[str, int]]]], Dict[str, List[Dict[str, Union[str, int]]]]]:
expected_json = {}
actual_json = {}
for filepath in glob.iglob('outputs/actual*.log'):
for filepath in glob.iglob('tests/outputs/actual*.log'):
expected_file_path = Path(str(filepath).replace("actual", "expected"))
actual_file_path = Path(filepath)

Expand Down Expand Up @@ -160,7 +160,7 @@ def plot_examine_gantt(tasks: List[Dict[str, Union[str, int]]], title: str, dir_
compare_logs()
examine_logs()
root = Path('tests/outputs/')
folders = list(root.glob('*/'))
folders = [f for f in root.glob('*/') if f.is_dir()]

for folder in folders:
if not any(folder.iterdir()):
Expand Down
18 changes: 18 additions & 0 deletions tests/test_file_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,12 @@ void TestInput::parseInputFile(std::string filename)
currentSection = "RESETS";
continue;
}
else if (line == "EXPECTED")
{
currentSection = "EXPECTED";
continue;
}


std::istringstream iss(line);
if (currentSection == "START")
Expand Down Expand Up @@ -246,6 +252,18 @@ void TestInput::parseInputFile(std::string filename)
iss >> iteration;
resets.emplace_back(std::make_pair(resetName, iteration));
}
else if (currentSection == "EXPECTED" )
{
std::string name;
std::uint32_t start;
std::uint32_t end;
std::getline(iss, name, '|');
iss >> start;
iss.ignore(1, '|');
iss >> end;
this->expectedValues.emplace_back(name,start,end);

}
}


Expand Down

0 comments on commit 851fff4

Please sign in to comment.