2015-02-26 15:02:31 +00:00
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <signal.h>
|
|
|
|
|
|
|
|
#include "gtest/gtest.h"
|
2015-06-22 21:11:08 +00:00
|
|
|
#include "trick/ScheduledJobQueue.hh"
|
|
|
|
//#include "trick/RequirementScribe.hh"
|
2015-02-26 15:02:31 +00:00
|
|
|
|
|
|
|
namespace Trick {
|
|
|
|
|
|
|
|
class ScheduledJobQueueTest : public ::testing::Test {
|
|
|
|
|
|
|
|
protected:
|
|
|
|
Trick::ScheduledJobQueue sjq;
|
2015-06-22 21:11:08 +00:00
|
|
|
//Trick::RequirementScribe req;
|
2015-02-26 15:02:31 +00:00
|
|
|
|
|
|
|
ScheduledJobQueueTest() {}
|
|
|
|
~ScheduledJobQueueTest() {}
|
2016-11-08 09:25:07 +00:00
|
|
|
virtual void SetUp() {}
|
|
|
|
virtual void TearDown() {}
|
2015-02-26 15:02:31 +00:00
|
|
|
|
|
|
|
} ;
|
|
|
|
|
|
|
|
TEST_F( ScheduledJobQueueTest , PushJobsbyJobOrder ) {
|
2015-06-22 21:11:08 +00:00
|
|
|
//req.add_requirement("815793485");
|
2015-02-26 15:02:31 +00:00
|
|
|
|
|
|
|
Trick::JobData * job_ptr ;
|
|
|
|
|
|
|
|
EXPECT_EQ( sjq.size() , (unsigned int)0) ;
|
|
|
|
EXPECT_TRUE( sjq.empty() ) ;
|
|
|
|
|
2016-11-08 09:25:07 +00:00
|
|
|
job_ptr = new Trick::JobData(0, 2 , "class_100", NULL, 1.0 , "job_1") ;
|
2015-02-26 15:02:31 +00:00
|
|
|
job_ptr->sim_object_id = 1 ;
|
|
|
|
job_ptr->job_class = 100 ;
|
|
|
|
sjq.push(job_ptr) ;
|
|
|
|
|
2016-11-08 09:25:07 +00:00
|
|
|
job_ptr = new Trick::JobData(0, 2 , "class_100", NULL, 1.0 , "job_2") ;
|
2015-02-26 15:02:31 +00:00
|
|
|
job_ptr->sim_object_id = 1 ;
|
|
|
|
job_ptr->job_class = 100 ;
|
|
|
|
sjq.push(job_ptr) ;
|
|
|
|
|
2016-11-08 09:25:07 +00:00
|
|
|
job_ptr = new Trick::JobData(0, 2 , "class_100", NULL, 1.0 , "job_3") ;
|
2015-02-26 15:02:31 +00:00
|
|
|
job_ptr->sim_object_id = 1 ;
|
|
|
|
job_ptr->job_class = 100 ;
|
|
|
|
sjq.push(job_ptr) ;
|
|
|
|
|
2016-11-08 09:25:07 +00:00
|
|
|
job_ptr = new Trick::JobData(0, 2 , "class_100", NULL, 1.0 , "job_4") ;
|
2015-02-26 15:02:31 +00:00
|
|
|
job_ptr->sim_object_id = 1 ;
|
|
|
|
job_ptr->job_class = 100 ;
|
|
|
|
sjq.push(job_ptr) ;
|
|
|
|
|
|
|
|
EXPECT_EQ( sjq.size() , (unsigned int)4) ;
|
|
|
|
EXPECT_FALSE( sjq.empty() ) ;
|
|
|
|
|
|
|
|
job_ptr = sjq.get_next_job() ;
|
|
|
|
EXPECT_STREQ( job_ptr->name.c_str() , "job_1") ;
|
|
|
|
|
|
|
|
job_ptr = sjq.get_next_job() ;
|
|
|
|
EXPECT_STREQ( job_ptr->name.c_str() , "job_2") ;
|
|
|
|
|
|
|
|
job_ptr = sjq.get_next_job() ;
|
|
|
|
EXPECT_STREQ( job_ptr->name.c_str() , "job_3") ;
|
|
|
|
|
|
|
|
job_ptr = sjq.get_next_job() ;
|
|
|
|
EXPECT_STREQ( job_ptr->name.c_str() , "job_4") ;
|
|
|
|
|
|
|
|
sjq.clear() ;
|
|
|
|
EXPECT_EQ( sjq.size() , (unsigned int)0) ;
|
|
|
|
EXPECT_TRUE( sjq.empty() ) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F( ScheduledJobQueueTest , PushJobsbySimObjectOrder ) {
|
2015-06-22 21:11:08 +00:00
|
|
|
//req.add_requirement("512154259");
|
2015-02-26 15:02:31 +00:00
|
|
|
|
|
|
|
Trick::JobData * job_ptr ;
|
|
|
|
|
|
|
|
EXPECT_EQ( sjq.size() , (unsigned int)0) ;
|
|
|
|
|
2016-11-08 09:25:07 +00:00
|
|
|
job_ptr = new Trick::JobData(0, 2 , "class_100", NULL, 1.0 , "job_3") ;
|
2015-02-26 15:02:31 +00:00
|
|
|
job_ptr->sim_object_id = 3 ;
|
|
|
|
job_ptr->job_class = 100 ;
|
|
|
|
sjq.push(job_ptr) ;
|
|
|
|
|
2016-11-08 09:25:07 +00:00
|
|
|
job_ptr = new Trick::JobData(0, 2 , "class_100", NULL, 1.0 , "job_4") ;
|
2015-02-26 15:02:31 +00:00
|
|
|
job_ptr->sim_object_id = 4 ;
|
|
|
|
job_ptr->job_class = 100 ;
|
|
|
|
sjq.push(job_ptr) ;
|
|
|
|
|
2016-11-08 09:25:07 +00:00
|
|
|
job_ptr = new Trick::JobData(0, 2 , "class_100", NULL, 1.0 , "job_1") ;
|
2015-02-26 15:02:31 +00:00
|
|
|
job_ptr->sim_object_id = 1 ;
|
|
|
|
job_ptr->job_class = 100 ;
|
|
|
|
sjq.push(job_ptr) ;
|
|
|
|
|
2016-11-08 09:25:07 +00:00
|
|
|
job_ptr = new Trick::JobData(0, 2 , "class_100", NULL, 1.0 , "job_2") ;
|
2015-02-26 15:02:31 +00:00
|
|
|
job_ptr->sim_object_id = 2 ;
|
|
|
|
job_ptr->job_class = 100 ;
|
|
|
|
sjq.push(job_ptr) ;
|
|
|
|
|
|
|
|
EXPECT_EQ( sjq.size() , (unsigned int)4) ;
|
|
|
|
|
|
|
|
job_ptr = sjq.get_next_job() ;
|
|
|
|
EXPECT_STREQ( job_ptr->name.c_str() , "job_1") ;
|
|
|
|
|
|
|
|
job_ptr = sjq.get_next_job() ;
|
|
|
|
EXPECT_STREQ( job_ptr->name.c_str() , "job_2") ;
|
|
|
|
|
|
|
|
job_ptr = sjq.get_next_job() ;
|
|
|
|
EXPECT_STREQ( job_ptr->name.c_str() , "job_3") ;
|
|
|
|
|
|
|
|
job_ptr = sjq.get_next_job() ;
|
|
|
|
EXPECT_STREQ( job_ptr->name.c_str() , "job_4") ;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F( ScheduledJobQueueTest , PushJobsbyPhaseOrder ) {
|
2015-06-22 21:11:08 +00:00
|
|
|
//req.add_requirement("3144632784");
|
2015-02-26 15:02:31 +00:00
|
|
|
|
|
|
|
Trick::JobData * job_ptr ;
|
|
|
|
|
|
|
|
EXPECT_EQ( sjq.size() , (unsigned int)0) ;
|
|
|
|
|
2016-11-08 09:25:07 +00:00
|
|
|
job_ptr = new Trick::JobData(0, 2 , "class_100", NULL, 1.0 , "job_3", "", 3) ;
|
2015-02-26 15:02:31 +00:00
|
|
|
job_ptr->sim_object_id = 1 ;
|
|
|
|
job_ptr->job_class = 100 ;
|
|
|
|
sjq.push(job_ptr) ;
|
|
|
|
|
2016-11-08 09:25:07 +00:00
|
|
|
job_ptr = new Trick::JobData(0, 2 , "class_100", NULL, 1.0 , "job_4", "", 4) ;
|
2015-02-26 15:02:31 +00:00
|
|
|
job_ptr->sim_object_id = 1 ;
|
|
|
|
job_ptr->job_class = 100 ;
|
|
|
|
sjq.push(job_ptr) ;
|
|
|
|
|
2016-11-08 09:25:07 +00:00
|
|
|
job_ptr = new Trick::JobData(0, 2 , "class_100", NULL, 1.0 , "job_1", "", 1) ;
|
2015-02-26 15:02:31 +00:00
|
|
|
job_ptr->sim_object_id = 1 ;
|
|
|
|
job_ptr->job_class = 100 ;
|
|
|
|
sjq.push(job_ptr) ;
|
|
|
|
|
2016-11-08 09:25:07 +00:00
|
|
|
job_ptr = new Trick::JobData(0, 2 , "class_100", NULL, 1.0 , "job_2", "", 2) ;
|
2015-02-26 15:02:31 +00:00
|
|
|
job_ptr->sim_object_id = 1 ;
|
|
|
|
job_ptr->job_class = 100 ;
|
|
|
|
sjq.push(job_ptr) ;
|
|
|
|
|
|
|
|
EXPECT_EQ( sjq.size() , (unsigned int)4) ;
|
|
|
|
|
|
|
|
job_ptr = sjq.get_next_job() ;
|
|
|
|
EXPECT_STREQ( job_ptr->name.c_str() , "job_1") ;
|
|
|
|
|
|
|
|
job_ptr = sjq.get_next_job() ;
|
|
|
|
EXPECT_STREQ( job_ptr->name.c_str() , "job_2") ;
|
|
|
|
|
|
|
|
job_ptr = sjq.get_next_job() ;
|
|
|
|
EXPECT_STREQ( job_ptr->name.c_str() , "job_3") ;
|
|
|
|
|
|
|
|
job_ptr = sjq.get_next_job() ;
|
|
|
|
EXPECT_STREQ( job_ptr->name.c_str() , "job_4") ;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F( ScheduledJobQueueTest , PushJobsbyJobClassOrder ) {
|
2015-06-22 21:11:08 +00:00
|
|
|
//req.add_requirement("925196430");
|
2015-02-26 15:02:31 +00:00
|
|
|
|
|
|
|
Trick::JobData * job_ptr ;
|
|
|
|
|
|
|
|
EXPECT_EQ( sjq.size() , (unsigned int)0) ;
|
|
|
|
|
2016-11-08 09:25:07 +00:00
|
|
|
job_ptr = new Trick::JobData(0, 2 , "class_103", NULL, 1.0 , "job_3", "", 1) ;
|
2015-02-26 15:02:31 +00:00
|
|
|
job_ptr->sim_object_id = 1 ;
|
|
|
|
job_ptr->job_class = 103 ;
|
|
|
|
sjq.push(job_ptr) ;
|
|
|
|
|
2016-11-08 09:25:07 +00:00
|
|
|
job_ptr = new Trick::JobData(0, 2 , "class_101", NULL, 1.0 , "job_4", "", 1) ;
|
2015-02-26 15:02:31 +00:00
|
|
|
job_ptr->sim_object_id = 1 ;
|
|
|
|
job_ptr->job_class = 104 ;
|
|
|
|
sjq.push(job_ptr) ;
|
|
|
|
|
2016-11-08 09:25:07 +00:00
|
|
|
job_ptr = new Trick::JobData(0, 2 , "class_102", NULL, 1.0 , "job_1", "", 1) ;
|
2015-02-26 15:02:31 +00:00
|
|
|
job_ptr->sim_object_id = 1 ;
|
|
|
|
job_ptr->job_class = 101 ;
|
|
|
|
sjq.push(job_ptr) ;
|
|
|
|
|
2016-11-08 09:25:07 +00:00
|
|
|
job_ptr = new Trick::JobData(0, 2 , "class_100", NULL, 1.0 , "job_2", "", 1) ;
|
2015-02-26 15:02:31 +00:00
|
|
|
job_ptr->sim_object_id = 1 ;
|
|
|
|
job_ptr->job_class = 102 ;
|
|
|
|
sjq.push(job_ptr) ;
|
|
|
|
|
|
|
|
EXPECT_EQ( sjq.size() , (unsigned int)4) ;
|
|
|
|
|
|
|
|
job_ptr = sjq.get_next_job() ;
|
|
|
|
EXPECT_STREQ( job_ptr->name.c_str() , "job_1") ;
|
|
|
|
|
|
|
|
job_ptr = sjq.get_next_job() ;
|
|
|
|
EXPECT_STREQ( job_ptr->name.c_str() , "job_2") ;
|
|
|
|
|
|
|
|
job_ptr = sjq.get_next_job() ;
|
|
|
|
EXPECT_STREQ( job_ptr->name.c_str() , "job_3") ;
|
|
|
|
|
|
|
|
job_ptr = sjq.get_next_job() ;
|
|
|
|
EXPECT_STREQ( job_ptr->name.c_str() , "job_4") ;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F( ScheduledJobQueueTest , PushJobsIgnoreSimObject ) {
|
2015-06-22 21:11:08 +00:00
|
|
|
//req.add_requirement("815793485");
|
2015-02-26 15:02:31 +00:00
|
|
|
|
|
|
|
Trick::JobData * job_ptr ;
|
|
|
|
|
|
|
|
EXPECT_EQ( sjq.size() , (unsigned int)0) ;
|
|
|
|
|
2016-11-08 09:25:07 +00:00
|
|
|
job_ptr = new Trick::JobData(0, 2 , "class_103", NULL, 1.0 , "job_1", "", 1) ;
|
2015-02-26 15:02:31 +00:00
|
|
|
job_ptr->sim_object_id = 3 ;
|
|
|
|
job_ptr->job_class = 100 ;
|
|
|
|
sjq.push_ignore_sim_object(job_ptr) ;
|
|
|
|
|
2016-11-08 09:25:07 +00:00
|
|
|
job_ptr = new Trick::JobData(0, 2 , "class_101", NULL, 1.0 , "job_2", "", 1) ;
|
2015-02-26 15:02:31 +00:00
|
|
|
job_ptr->sim_object_id = 4 ;
|
|
|
|
job_ptr->job_class = 100 ;
|
|
|
|
sjq.push_ignore_sim_object(job_ptr) ;
|
|
|
|
|
2016-11-08 09:25:07 +00:00
|
|
|
job_ptr = new Trick::JobData(0, 2 , "class_102", NULL, 1.0 , "job_3", "", 1) ;
|
2015-02-26 15:02:31 +00:00
|
|
|
job_ptr->sim_object_id = 1 ;
|
|
|
|
job_ptr->job_class = 100 ;
|
|
|
|
sjq.push_ignore_sim_object(job_ptr) ;
|
|
|
|
|
2016-11-08 09:25:07 +00:00
|
|
|
job_ptr = new Trick::JobData(0, 2 , "class_100", NULL, 1.0 , "job_4", "", 1) ;
|
2015-02-26 15:02:31 +00:00
|
|
|
job_ptr->sim_object_id = 2 ;
|
|
|
|
job_ptr->job_class = 100 ;
|
|
|
|
sjq.push_ignore_sim_object(job_ptr) ;
|
|
|
|
|
|
|
|
EXPECT_EQ( sjq.size() , (unsigned int)4) ;
|
|
|
|
|
|
|
|
job_ptr = sjq.get_next_job() ;
|
|
|
|
EXPECT_STREQ( job_ptr->name.c_str() , "job_1") ;
|
|
|
|
|
|
|
|
job_ptr = sjq.get_next_job() ;
|
|
|
|
EXPECT_STREQ( job_ptr->name.c_str() , "job_2") ;
|
|
|
|
|
|
|
|
job_ptr = sjq.get_next_job() ;
|
|
|
|
EXPECT_STREQ( job_ptr->name.c_str() , "job_3") ;
|
|
|
|
|
|
|
|
job_ptr = sjq.get_next_job() ;
|
|
|
|
EXPECT_STREQ( job_ptr->name.c_str() , "job_4") ;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F( ScheduledJobQueueTest , TopJob ) {
|
2015-06-22 21:11:08 +00:00
|
|
|
//req.add_requirement("");
|
2015-02-26 15:02:31 +00:00
|
|
|
|
|
|
|
Trick::JobData * job_ptr ;
|
|
|
|
|
|
|
|
EXPECT_TRUE( sjq.top() == NULL ) ;
|
|
|
|
|
2016-11-08 09:25:07 +00:00
|
|
|
job_ptr = new Trick::JobData(0, 2 , "class_100", NULL, 1.0 , "job_1") ;
|
2015-02-26 15:02:31 +00:00
|
|
|
job_ptr->sim_object_id = 1 ;
|
|
|
|
job_ptr->job_class = 100 ;
|
|
|
|
sjq.push(job_ptr) ;
|
|
|
|
|
2016-11-08 09:25:07 +00:00
|
|
|
job_ptr = new Trick::JobData(0, 2 , "class_100", NULL, 1.0 , "job_2") ;
|
2015-02-26 15:02:31 +00:00
|
|
|
job_ptr->sim_object_id = 1 ;
|
|
|
|
job_ptr->job_class = 100 ;
|
|
|
|
sjq.push(job_ptr) ;
|
|
|
|
|
2016-11-08 09:25:07 +00:00
|
|
|
job_ptr = new Trick::JobData(0, 2 , "class_100", NULL, 1.0 , "job_3") ;
|
2015-02-26 15:02:31 +00:00
|
|
|
job_ptr->sim_object_id = 1 ;
|
|
|
|
job_ptr->job_class = 100 ;
|
|
|
|
sjq.push(job_ptr) ;
|
|
|
|
|
2016-11-08 09:25:07 +00:00
|
|
|
job_ptr = new Trick::JobData(0, 2 , "class_100", NULL, 1.0 , "job_4") ;
|
2015-02-26 15:02:31 +00:00
|
|
|
job_ptr->sim_object_id = 1 ;
|
|
|
|
job_ptr->job_class = 100 ;
|
|
|
|
sjq.push(job_ptr) ;
|
|
|
|
|
|
|
|
job_ptr = sjq.top() ;
|
|
|
|
EXPECT_STREQ( job_ptr->name.c_str() , "job_1") ;
|
|
|
|
|
|
|
|
job_ptr = sjq.top() ;
|
|
|
|
EXPECT_STREQ( job_ptr->name.c_str() , "job_1") ;
|
|
|
|
|
|
|
|
sjq.get_next_job() ;
|
|
|
|
job_ptr = sjq.top() ;
|
|
|
|
EXPECT_STREQ( job_ptr->name.c_str() , "job_2") ;
|
|
|
|
|
|
|
|
sjq.reset_curr_index() ;
|
|
|
|
job_ptr = sjq.top() ;
|
|
|
|
EXPECT_STREQ( job_ptr->name.c_str() , "job_1") ;
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F( ScheduledJobQueueTest , FindNextJob ) {
|
2015-06-22 21:11:08 +00:00
|
|
|
//req.add_requirement("3664773300 1758653947");
|
2015-02-26 15:02:31 +00:00
|
|
|
|
|
|
|
Trick::JobData * job_ptr ;
|
|
|
|
long long curr_time ;
|
|
|
|
|
2016-11-08 09:25:07 +00:00
|
|
|
job_ptr = new Trick::JobData(0, 2 , "class_100", NULL, 1.0 , "job_1") ;
|
2015-02-26 15:02:31 +00:00
|
|
|
job_ptr->sim_object_id = 1 ;
|
|
|
|
job_ptr->job_class = 100 ;
|
|
|
|
job_ptr->cycle_tics = (long long)(job_ptr->cycle * 1000000) ;
|
|
|
|
job_ptr->stop_tics = 1000000000 ;
|
|
|
|
sjq.push(job_ptr) ;
|
|
|
|
|
2016-11-08 09:25:07 +00:00
|
|
|
job_ptr = new Trick::JobData(0, 2 , "class_100", NULL, 2.0 , "job_2") ;
|
2015-02-26 15:02:31 +00:00
|
|
|
job_ptr->sim_object_id = 1 ;
|
|
|
|
job_ptr->job_class = 100 ;
|
|
|
|
job_ptr->cycle_tics = (long long)(job_ptr->cycle * 1000000) ;
|
|
|
|
job_ptr->stop_tics = 1000000000 ;
|
|
|
|
sjq.push(job_ptr) ;
|
|
|
|
|
2016-11-08 09:25:07 +00:00
|
|
|
job_ptr = new Trick::JobData(0, 2 , "class_100", NULL, 4.0 , "job_3") ;
|
2015-02-26 15:02:31 +00:00
|
|
|
job_ptr->sim_object_id = 1 ;
|
|
|
|
job_ptr->job_class = 100 ;
|
|
|
|
job_ptr->cycle_tics = (long long)(job_ptr->cycle * 1000000) ;
|
|
|
|
job_ptr->stop_tics = 1000000000 ;
|
|
|
|
sjq.push(job_ptr) ;
|
|
|
|
|
2016-11-08 09:25:07 +00:00
|
|
|
// Time = 0.0
|
2015-02-26 15:02:31 +00:00
|
|
|
curr_time = 0 ;
|
|
|
|
sjq.reset_curr_index() ;
|
|
|
|
sjq.set_next_job_call_time(1000000000) ;
|
|
|
|
|
|
|
|
job_ptr = sjq.find_next_job(curr_time) ;
|
|
|
|
EXPECT_STREQ( job_ptr->name.c_str() , "job_1") ;
|
|
|
|
|
|
|
|
job_ptr = sjq.find_next_job(curr_time) ;
|
|
|
|
EXPECT_STREQ( job_ptr->name.c_str() , "job_2") ;
|
|
|
|
|
|
|
|
job_ptr = sjq.find_next_job(curr_time) ;
|
|
|
|
EXPECT_STREQ( job_ptr->name.c_str() , "job_3") ;
|
|
|
|
|
|
|
|
job_ptr = sjq.find_next_job(curr_time) ;
|
|
|
|
EXPECT_TRUE( job_ptr == NULL ) ;
|
|
|
|
|
2016-11-08 09:25:07 +00:00
|
|
|
// Time = 1.0
|
2015-02-26 15:02:31 +00:00
|
|
|
curr_time = sjq.get_next_job_call_time() ;
|
|
|
|
EXPECT_EQ( curr_time , 1000000 ) ;
|
|
|
|
sjq.reset_curr_index() ;
|
|
|
|
sjq.set_next_job_call_time(1000000000) ;
|
|
|
|
|
|
|
|
job_ptr = sjq.find_next_job(curr_time) ;
|
|
|
|
EXPECT_STREQ( job_ptr->name.c_str() , "job_1") ;
|
|
|
|
|
|
|
|
job_ptr = sjq.find_next_job(curr_time) ;
|
|
|
|
EXPECT_TRUE( job_ptr == NULL ) ;
|
|
|
|
|
2016-11-08 09:25:07 +00:00
|
|
|
// Time = 2.0
|
2015-02-26 15:02:31 +00:00
|
|
|
curr_time = sjq.get_next_job_call_time() ;
|
|
|
|
EXPECT_EQ( curr_time , 2000000 ) ;
|
|
|
|
sjq.reset_curr_index() ;
|
|
|
|
sjq.set_next_job_call_time(1000000000) ;
|
|
|
|
|
|
|
|
job_ptr = sjq.find_next_job(curr_time) ;
|
|
|
|
EXPECT_STREQ( job_ptr->name.c_str() , "job_1") ;
|
|
|
|
|
|
|
|
job_ptr = sjq.find_next_job(curr_time) ;
|
|
|
|
EXPECT_STREQ( job_ptr->name.c_str() , "job_2") ;
|
|
|
|
|
|
|
|
job_ptr = sjq.find_next_job(curr_time) ;
|
|
|
|
EXPECT_TRUE( job_ptr == NULL ) ;
|
|
|
|
|
2016-11-08 09:25:07 +00:00
|
|
|
// Time = 3.0
|
2015-02-26 15:02:31 +00:00
|
|
|
curr_time = sjq.get_next_job_call_time() ;
|
|
|
|
EXPECT_EQ( curr_time , 3000000 ) ;
|
|
|
|
sjq.reset_curr_index() ;
|
|
|
|
sjq.set_next_job_call_time(1000000000) ;
|
|
|
|
|
|
|
|
job_ptr = sjq.find_next_job(curr_time) ;
|
|
|
|
EXPECT_STREQ( job_ptr->name.c_str() , "job_1") ;
|
|
|
|
|
|
|
|
job_ptr = sjq.find_next_job(curr_time) ;
|
|
|
|
EXPECT_TRUE( job_ptr == NULL ) ;
|
|
|
|
|
2016-11-08 09:25:07 +00:00
|
|
|
// Time = 4.0
|
2015-02-26 15:02:31 +00:00
|
|
|
curr_time = sjq.get_next_job_call_time() ;
|
|
|
|
EXPECT_EQ( curr_time , 4000000 ) ;
|
|
|
|
sjq.reset_curr_index() ;
|
|
|
|
sjq.set_next_job_call_time(1000000000) ;
|
|
|
|
|
|
|
|
job_ptr = sjq.find_next_job(curr_time) ;
|
|
|
|
EXPECT_STREQ( job_ptr->name.c_str() , "job_1") ;
|
|
|
|
|
|
|
|
job_ptr = sjq.find_next_job(curr_time) ;
|
|
|
|
EXPECT_STREQ( job_ptr->name.c_str() , "job_2") ;
|
|
|
|
|
|
|
|
job_ptr = sjq.find_next_job(curr_time) ;
|
|
|
|
EXPECT_STREQ( job_ptr->name.c_str() , "job_3") ;
|
|
|
|
|
|
|
|
job_ptr = sjq.find_next_job(curr_time) ;
|
|
|
|
EXPECT_TRUE( job_ptr == NULL ) ;
|
|
|
|
|
2016-11-08 09:25:07 +00:00
|
|
|
// Time = 5.0
|
2015-02-26 15:02:31 +00:00
|
|
|
curr_time = sjq.get_next_job_call_time() ;
|
|
|
|
EXPECT_EQ( curr_time , 5000000 ) ;
|
|
|
|
sjq.reset_curr_index() ;
|
|
|
|
sjq.set_next_job_call_time(1000000000) ;
|
|
|
|
|
|
|
|
job_ptr = sjq.find_next_job(curr_time) ;
|
|
|
|
EXPECT_STREQ( job_ptr->name.c_str() , "job_1") ;
|
|
|
|
|
|
|
|
job_ptr = sjq.find_next_job(curr_time) ;
|
|
|
|
EXPECT_TRUE( job_ptr == NULL ) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F( ScheduledJobQueueTest , TestNextJob ) {
|
2016-11-08 09:25:07 +00:00
|
|
|
//req.add_requirement("1758653947 3664773300");
|
2015-02-26 15:02:31 +00:00
|
|
|
|
|
|
|
Trick::JobData * job_ptr ;
|
|
|
|
long long curr_time ;
|
|
|
|
|
2016-11-08 09:25:07 +00:00
|
|
|
job_ptr = new Trick::JobData(0, 2 , "class_100", NULL, 3.0 , "job_1") ;
|
2015-02-26 15:02:31 +00:00
|
|
|
job_ptr->sim_object_id = 1 ;
|
|
|
|
job_ptr->job_class = 100 ;
|
|
|
|
job_ptr->cycle_tics = (long long)(job_ptr->cycle * 1000000) ;
|
|
|
|
job_ptr->stop_tics = 1000000000 ;
|
|
|
|
job_ptr->system_job_class = true ;
|
|
|
|
sjq.push(job_ptr) ;
|
|
|
|
|
2016-11-08 09:25:07 +00:00
|
|
|
job_ptr = new Trick::JobData(0, 2 , "class_100", NULL, 1.0 , "job_2") ;
|
2015-02-26 15:02:31 +00:00
|
|
|
job_ptr->sim_object_id = 1 ;
|
|
|
|
job_ptr->job_class = 100 ;
|
|
|
|
job_ptr->cycle_tics = (long long)(job_ptr->cycle * 1000000) ;
|
|
|
|
job_ptr->stop_tics = 1000000000 ;
|
|
|
|
job_ptr->system_job_class = true ;
|
|
|
|
sjq.push(job_ptr) ;
|
|
|
|
|
2016-11-08 09:25:07 +00:00
|
|
|
job_ptr = new Trick::JobData(0, 2 , "class_100", NULL, 2.0 , "job_3") ;
|
2015-02-26 15:02:31 +00:00
|
|
|
job_ptr->sim_object_id = 1 ;
|
|
|
|
job_ptr->job_class = 100 ;
|
|
|
|
job_ptr->cycle_tics = (long long)(job_ptr->cycle * 1000000) ;
|
|
|
|
job_ptr->stop_tics = 1000000000 ;
|
|
|
|
job_ptr->system_job_class = true ;
|
|
|
|
sjq.push(job_ptr) ;
|
|
|
|
|
2016-11-08 09:25:07 +00:00
|
|
|
// Time = 0.0
|
2015-02-26 15:02:31 +00:00
|
|
|
curr_time = 0 ;
|
|
|
|
sjq.reset_curr_index() ;
|
|
|
|
sjq.set_next_job_call_time(1000000000) ;
|
|
|
|
|
|
|
|
job_ptr = sjq.find_next_job(curr_time) ;
|
|
|
|
EXPECT_STREQ( job_ptr->name.c_str() , "job_1") ;
|
|
|
|
job_ptr->next_tics += job_ptr->cycle_tics ;
|
|
|
|
sjq.test_next_job_call_time(job_ptr , curr_time) ;
|
|
|
|
EXPECT_EQ( sjq.get_next_job_call_time() , 0 ) ;
|
|
|
|
|
|
|
|
job_ptr = sjq.find_next_job(curr_time) ;
|
|
|
|
EXPECT_STREQ( job_ptr->name.c_str() , "job_2") ;
|
|
|
|
job_ptr->next_tics += job_ptr->cycle_tics ;
|
|
|
|
sjq.test_next_job_call_time(job_ptr , curr_time) ;
|
|
|
|
EXPECT_EQ( sjq.get_next_job_call_time() , 0 ) ;
|
|
|
|
|
|
|
|
job_ptr = sjq.find_next_job(curr_time) ;
|
|
|
|
EXPECT_STREQ( job_ptr->name.c_str() , "job_3") ;
|
|
|
|
job_ptr->next_tics += job_ptr->cycle_tics ;
|
|
|
|
sjq.test_next_job_call_time(job_ptr , curr_time) ;
|
|
|
|
EXPECT_EQ( sjq.get_next_job_call_time() , 0 ) ;
|
|
|
|
|
|
|
|
job_ptr = sjq.find_next_job(curr_time) ;
|
|
|
|
EXPECT_TRUE( job_ptr == NULL ) ;
|
|
|
|
|
|
|
|
sjq.reset_curr_index() ;
|
|
|
|
sjq.set_next_job_call_time(1000000000) ;
|
|
|
|
EXPECT_EQ( sjq.get_next_job_call_time() , 1000000 ) ;
|
|
|
|
|
2016-11-08 09:25:07 +00:00
|
|
|
// Time = 1.0
|
2015-02-26 15:02:31 +00:00
|
|
|
curr_time = sjq.get_next_job_call_time() ;
|
|
|
|
EXPECT_EQ( curr_time , 1000000 ) ;
|
|
|
|
sjq.reset_curr_index() ;
|
|
|
|
sjq.set_next_job_call_time(1000000000) ;
|
|
|
|
|
|
|
|
job_ptr = sjq.find_next_job(curr_time) ;
|
|
|
|
EXPECT_STREQ( job_ptr->name.c_str() , "job_2") ;
|
|
|
|
job_ptr->next_tics += job_ptr->cycle_tics ;
|
|
|
|
sjq.test_next_job_call_time(job_ptr , curr_time) ;
|
|
|
|
EXPECT_EQ( sjq.get_next_job_call_time() , 2000000 ) ;
|
|
|
|
|
|
|
|
job_ptr = sjq.find_next_job(curr_time) ;
|
|
|
|
EXPECT_TRUE( job_ptr == NULL ) ;
|
|
|
|
|
2016-11-08 09:25:07 +00:00
|
|
|
// Time = 2.0
|
2015-02-26 15:02:31 +00:00
|
|
|
curr_time = sjq.get_next_job_call_time() ;
|
|
|
|
EXPECT_EQ( curr_time , 2000000 ) ;
|
|
|
|
sjq.reset_curr_index() ;
|
|
|
|
sjq.set_next_job_call_time(1000000000) ;
|
|
|
|
|
|
|
|
job_ptr = sjq.find_next_job(curr_time) ;
|
|
|
|
EXPECT_STREQ( job_ptr->name.c_str() , "job_2") ;
|
|
|
|
job_ptr->next_tics += job_ptr->cycle_tics ;
|
|
|
|
sjq.test_next_job_call_time(job_ptr , curr_time) ;
|
|
|
|
EXPECT_EQ( sjq.get_next_job_call_time() , 2000000 ) ;
|
|
|
|
|
|
|
|
job_ptr = sjq.find_next_job(curr_time) ;
|
|
|
|
EXPECT_STREQ( job_ptr->name.c_str() , "job_3") ;
|
|
|
|
job_ptr->next_tics += job_ptr->cycle_tics ;
|
|
|
|
sjq.test_next_job_call_time(job_ptr , curr_time) ;
|
|
|
|
EXPECT_EQ( sjq.get_next_job_call_time() , 2000000 ) ;
|
|
|
|
|
|
|
|
job_ptr = sjq.find_next_job(curr_time) ;
|
|
|
|
EXPECT_TRUE( job_ptr == NULL ) ;
|
|
|
|
|
2016-11-08 09:25:07 +00:00
|
|
|
// Time = 3.0
|
2015-02-26 15:02:31 +00:00
|
|
|
sjq.reset_curr_index() ;
|
|
|
|
sjq.set_next_job_call_time(1000000000) ;
|
|
|
|
curr_time = sjq.get_next_job_call_time() ;
|
|
|
|
EXPECT_EQ( curr_time , 3000000 ) ;
|
|
|
|
|
|
|
|
job_ptr = sjq.find_next_job(curr_time) ;
|
|
|
|
EXPECT_STREQ( job_ptr->name.c_str() , "job_1") ;
|
|
|
|
job_ptr->next_tics += job_ptr->cycle_tics ;
|
|
|
|
sjq.test_next_job_call_time(job_ptr , curr_time) ;
|
|
|
|
EXPECT_EQ( sjq.get_next_job_call_time() , 3000000 ) ;
|
|
|
|
|
|
|
|
job_ptr = sjq.find_next_job(curr_time) ;
|
|
|
|
EXPECT_STREQ( job_ptr->name.c_str() , "job_2") ;
|
|
|
|
job_ptr->next_tics += job_ptr->cycle_tics ;
|
|
|
|
sjq.test_next_job_call_time(job_ptr , curr_time) ;
|
|
|
|
EXPECT_EQ( sjq.get_next_job_call_time() , 3000000 ) ;
|
|
|
|
|
|
|
|
job_ptr = sjq.find_next_job(curr_time) ;
|
|
|
|
EXPECT_TRUE( job_ptr == NULL ) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F( ScheduledJobQueueTest , InstrumentBeforeAll ) {
|
2015-06-22 21:11:08 +00:00
|
|
|
//req.add_requirement("3990429752");
|
2015-02-26 15:02:31 +00:00
|
|
|
|
|
|
|
Trick::JobData * job_ptr ;
|
|
|
|
|
2016-11-08 09:25:07 +00:00
|
|
|
job_ptr = new Trick::JobData(0, 2 , "class_100", NULL, 1.0 , "job_1") ;
|
2015-02-26 15:02:31 +00:00
|
|
|
job_ptr->sim_object_id = 1 ;
|
|
|
|
job_ptr->job_class = 100 ;
|
|
|
|
sjq.push(job_ptr) ;
|
|
|
|
|
2016-11-08 09:25:07 +00:00
|
|
|
job_ptr = new Trick::JobData(0, 2 , "class_100", NULL, 1.0 , "job_2") ;
|
2015-02-26 15:02:31 +00:00
|
|
|
job_ptr->sim_object_id = 1 ;
|
|
|
|
job_ptr->job_class = 100 ;
|
|
|
|
sjq.push(job_ptr) ;
|
|
|
|
|
2016-11-08 09:25:07 +00:00
|
|
|
job_ptr = new Trick::JobData(0, 2 , "class_100", NULL, 1.0 , "job_3") ;
|
2015-02-26 15:02:31 +00:00
|
|
|
job_ptr->sim_object_id = 1 ;
|
|
|
|
job_ptr->job_class = 100 ;
|
|
|
|
sjq.push(job_ptr) ;
|
|
|
|
|
2016-11-08 09:25:07 +00:00
|
|
|
job_ptr = new Trick::JobData(0, 2 , "class_100", NULL, 1.0 , "job_4") ;
|
2015-02-26 15:02:31 +00:00
|
|
|
job_ptr->sim_object_id = 1 ;
|
|
|
|
job_ptr->job_class = 100 ;
|
|
|
|
sjq.push(job_ptr) ;
|
|
|
|
|
2016-11-08 09:25:07 +00:00
|
|
|
job_ptr = new Trick::JobData(0, 2 , "instrumentation", NULL, 1.0 , "instrument_1") ;
|
2015-02-26 15:02:31 +00:00
|
|
|
sjq.instrument_before( job_ptr ) ;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|