Skip to content

Commit

Permalink
added default test, write out for assertions, fixed deploy function
Browse files Browse the repository at this point in the history
  • Loading branch information
antara-chugh committed Aug 21, 2024
1 parent 0f3bdaa commit 8c9bc2f
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 5 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ include_directories(../external/googletest/googletest/include src/ tests)
set(GTEST_SOURCE_FILES
tests/scheduler_test_system.cpp
tests/test_ensembles.cpp
tests/fixed_google_tests.cpp
tests/fixed_google_tests_v2.cpp
src/scheduler.cpp
tests/test_log.cpp
#tests/file_google_tests.cpp
#tests/overlap_google_tests.cpp
tests/scheduler_test_flog.cpp
Expand Down
20 changes: 16 additions & 4 deletions tests/fixed_google_tests_v2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,11 @@ class SchedulerTest : public ::testing::Test

/*returns array of task size to be inputed to scheduler*/
DeploymentSchedule_ * get_table(int size){
if(size>deployment_table.size()){
return nullptr;
}
DeploymentSchedule_ deploy[size];
std::copy(deployment_table.begin(), deployment_table.end(), deploy);
std::copy(deployment_table.begin(), deployment_table.begin() + size, deploy);
return deploy;
}

Expand All @@ -115,13 +118,20 @@ class SchedulerTest : public ::testing::Test
/*compares the test log with the expected values, as set in the test case*/
void compare(std::vector<Log> expected, int iterations){
for(int i=0; i<iterations; i++){
EXPECT_TRUE(test_log[i]==expected[i]);
EXPECT_TRUE(test_log[i]==expected[i]) << "test log failed:\n"
<< "Expected \t Actual\n"
<< expected[i].getName() << "\t\t" << test_log[i].getName() << "\n"
<< expected[i].getRunTime() << "\t\t" << test_log[i].getRunTime();
}
}

/*creates scheduler based on tasks set in test, compares scheduler behaviour with expected behaviour*/
void run(int num_tasks, int iterations, int task_delay, int delay_amount, std::vector<Log> expected){
Scheduler s=get_table(num_tasks);
DeploymentSchedule_ * table=get_table(num_tasks);
if(table==nullptr){
return;
}
Scheduler s(table);
u_int32_t nextTaskTime=0;
DeploymentSchedule_ ** nextTask;

Expand Down Expand Up @@ -157,7 +167,9 @@ class SchedulerTest : public ::testing::Test
TEST_F(SchedulerTest, TestDefault)
{


std::vector<Log> expected={
{"A", 0}, {"B", 25}, {"C", 50}, {"A", 75}, {"B", 100}, {"C", 125},
};



Expand Down
9 changes: 9 additions & 0 deletions tests/test_log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@

}

string Log:: getName(){
return taskName;
}
u_int32_t Log :: getRunTime(){
return runTime;

}


bool operator== (const Log& a, const Log& b){
return ((a.taskName==b.taskName)&& (a.runTime==b.runTime));
}
3 changes: 3 additions & 0 deletions tests/test_log.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ class Log{

friend bool operator== (const Log& a, const Log& b);

string getName();
u_int32_t getRunTime();

private:
string taskName;
u_int32_t runTime;
Expand Down

0 comments on commit 8c9bc2f

Please sign in to comment.