コード例 #1
0
ファイル: Executive_test.cpp プロジェクト: Arafatk/trick
TEST_F(ExecutiveTest , ClearScheduledQueues) {
	//req.add_requirement("");

    exec_add_sim_object(&so1 , "so1") ;

    EXPECT_FALSE(get_default_data_queue()->empty()) ;
    EXPECT_FALSE(get_initialization_queue()->empty()) ;
    EXPECT_FALSE(get_scheduled_queue()->empty()) ;
    EXPECT_FALSE(get_end_of_frame_queue()->empty()) ;
    EXPECT_FALSE(get_shutdown_queue()->empty()) ;
    EXPECT_FALSE(get_freeze_init_queue()->empty()) ;
    EXPECT_FALSE(get_freeze_queue()->empty()) ;
    EXPECT_FALSE(get_unfreeze_queue()->empty()) ;

    exec.clear_scheduled_queues() ;

    EXPECT_TRUE(get_default_data_queue()->empty()) ;
    EXPECT_TRUE(get_initialization_queue()->empty()) ;
    EXPECT_TRUE(get_scheduled_queue()->empty()) ;
    EXPECT_TRUE(get_end_of_frame_queue()->empty()) ;
    EXPECT_TRUE(get_shutdown_queue()->empty()) ;
    EXPECT_TRUE(get_freeze_init_queue()->empty()) ;
    EXPECT_TRUE(get_freeze_queue()->empty()) ;
    EXPECT_TRUE(get_unfreeze_queue()->empty()) ;

}
コード例 #2
0
ファイル: Executive_test.cpp プロジェクト: Arafatk/trick
TEST_F(ExecutiveTest , GetJob) {
	//req.add_requirement("");

    Trick::JobData * curr_job ;

    /* Add a second job of the same name of an existing job */
    curr_job = so1.add_job(0, 100, "sensor", NULL, 1, "shutdown_1", "TRK") ;

    exec_add_sim_object(&so1 , "so1") ;

    curr_job = exec.get_job( std::string("so1.shutdown_1")) ;
    ASSERT_FALSE( curr_job == NULL ) ;
    EXPECT_STREQ( curr_job->job_class_name.c_str() , "shutdown") ;

    curr_job = exec.get_job( std::string("so1.shutdown_1"), 2) ;
    ASSERT_FALSE( curr_job == NULL ) ;
    EXPECT_STREQ( curr_job->job_class_name.c_str() , "sensor") ;

    curr_job = exec.get_job( std::string("so1.shutdown_1"), 3) ;
    ASSERT_TRUE( curr_job == NULL ) ;

    curr_job = exec.get_job( std::string("so1.does_not_exist")) ;
    ASSERT_TRUE( curr_job == NULL ) ;

}
コード例 #3
0
ファイル: Executive_test.cpp プロジェクト: Arafatk/trick
TEST_F(ExecutiveTest , AddDepends) {
    //req.add_requirement("r_exec_jobs");
	//"The Executive Scheduler shall provide the capability to add dependency jobs to scheduled jobs"

    Trick::JobData * curr_job ;

    so1.add_job(1, 100, "scheduled", NULL, 1, "child_job_1", "TRK") ;
    so1.add_job(2, 100, "scheduled", NULL, 1, "child_job_2a", "TRK") ;
    so1.add_job(2, 100, "scheduled", NULL, 1, "child_job_2b", "TRK") ;

    exec_add_sim_object(&so1 , "so1") ;

    EXPECT_EQ(exec.add_depends_on_job("so1.child_job_3" , 1 , "so1.scheduled_1" , 1), -1) ;
    EXPECT_EQ(exec.add_depends_on_job("so1.child_job_1" , 1 , "so1.scheduled_4" , 1), -2) ;
    EXPECT_EQ(exec.add_depends_on_job("so1.child_job_2a" , 1 , "so1.child_job_2b" , 1), -3) ;
    EXPECT_EQ(exec.add_depends_on_job("so1.scheduled_1" , 1 , "so1.scheduled_1" , 1), -3) ;

    curr_job = exec.get_job("so1.child_job_1") ;
    ASSERT_FALSE( curr_job == NULL ) ;
    EXPECT_EQ(curr_job->depends.size(), (unsigned int)0) ;
    EXPECT_EQ(exec.add_depends_on_job("so1.child_job_1" , 1 , "so1.scheduled_1" , 1), 0) ;
    EXPECT_EQ(curr_job->depends.size(), (unsigned int)1) ;
    EXPECT_STREQ(curr_job->depends[0]->name.c_str(), "so1.scheduled_1") ;

}
コード例 #4
0
ファイル: Executive_test.cpp プロジェクト: Arafatk/trick
TEST_F(ExecutiveTest , SetThreadParameters) {
	//req.add_requirement("3839914374");

    so1.add_job(1, 100, "scheduled", NULL, 1, "child_job_1", "TRK") ;
    exec_add_sim_object(&so1 , "so1") ;

    EXPECT_EQ( exec.set_thread_process_type(0 , PROCESS_TYPE_SCHEDULED) , -2 ) ;
    EXPECT_EQ( exec.set_thread_process_type(2 , PROCESS_TYPE_SCHEDULED) , -2 ) ;

    EXPECT_EQ( exec.set_thread_amf_cycle_time(0 , 1.0) , -2 ) ;
    EXPECT_EQ( exec.set_thread_amf_cycle_time(2 , 1.0) , -2 ) ;

    EXPECT_EQ( exec.set_thread_process_type(1 , PROCESS_TYPE_SCHEDULED) , 0 ) ;
    EXPECT_EQ( exec.set_thread_amf_cycle_time(1 , 1.0) , 0 ) ;

    EXPECT_EQ( exec.set_thread_process_type(1 , PROCESS_TYPE_ASYNC_CHILD) , 0 ) ;
    EXPECT_EQ( exec.set_thread_amf_cycle_time(1 , 1.0) , 0 ) ;

    EXPECT_EQ( exec.set_thread_process_type(1 , PROCESS_TYPE_AMF_CHILD) , 0 ) ;
    EXPECT_EQ( exec.set_thread_amf_cycle_time(1 , 1.0) , 0 ) ;

    EXPECT_EQ( exec.set_thread_async_wait(0 , 1) , -2 ) ;
    EXPECT_EQ( exec.set_thread_async_wait(2 , 1) , -2 ) ;
    EXPECT_EQ( exec.set_thread_async_wait(1 , 1) , 0 ) ;

    EXPECT_EQ( exec.set_thread_cpu_affinity(0 , 1) , 0 ) ;
    EXPECT_EQ( exec.set_thread_cpu_affinity(1 , 2) , 0 ) ;
    EXPECT_EQ( exec.set_thread_cpu_affinity(2 , 1) , -2 ) ;

    EXPECT_EQ( exec.set_thread_priority(0 , 1) , 0 ) ;
    EXPECT_EQ( exec.set_thread_priority(1 , 2) , 0 ) ;
    EXPECT_EQ( exec.set_thread_priority(2 , 1) , -2 ) ;
}
コード例 #5
0
ファイル: Executive_test.cpp プロジェクト: Arafatk/trick
TEST_F(ExecutiveTest , AddJobsToQueue) {
    //req.add_requirement( "r_exec_jobs");
	//"The Executive Scheduler shall sort jobs with executive job classes in ScheduledJobQueues"
    exec_add_sim_object(&so1 , "so1") ;

    Trick::JobData * curr_job ;
    curr_job = get_default_data_queue()->get_next_job() ;
    ASSERT_FALSE( curr_job == NULL ) ;
    EXPECT_STREQ( curr_job->name.c_str() , "so1.default_data_1") ;

    curr_job = get_input_processor_queue()->get_next_job() ;
    ASSERT_FALSE( curr_job == NULL ) ;
    EXPECT_STREQ( curr_job->name.c_str() , "so1.input_processor_1") ;

    curr_job = get_initialization_queue()->get_next_job() ;
    ASSERT_FALSE( curr_job == NULL ) ;
    EXPECT_STREQ( curr_job->name.c_str() , "so1.initialization_1") ;

    curr_job = get_scheduled_queue()->get_next_job() ;
    ASSERT_FALSE( curr_job == NULL ) ;
    EXPECT_STREQ( curr_job->name.c_str() , "so1.automatic_1") ;

    curr_job = get_scheduled_queue()->get_next_job() ;
    ASSERT_FALSE( curr_job == NULL ) ;
    EXPECT_STREQ( curr_job->name.c_str() , "so1.scheduled_1") ;

    curr_job = get_scheduled_queue()->get_next_job() ;
    ASSERT_FALSE( curr_job == NULL ) ;
    EXPECT_STREQ( curr_job->name.c_str() , "so1.scheduled_2") ;

    curr_job = get_scheduled_queue()->get_next_job() ;
    ASSERT_FALSE( curr_job == NULL ) ;
    EXPECT_STREQ( curr_job->name.c_str() , "so1.scheduled_3") ;
}
コード例 #6
0
ファイル: Executive_test.cpp プロジェクト: Arafatk/trick
TEST_F(ExecutiveTest , JobCycleNotDivisibleByTimeTic) {
    //req.add_requirement("r_exec_jobs");
	//"The Executive Scheduler shall provide the capability to list jobs not handled by any scheduler."

    EXPECT_EQ(exec_get_time_tic_value(), 1000000) ;
    exec_add_sim_object(&empty_so , "empty_so") ;
    EXPECT_EQ(exec.check_all_job_cycle_times() , -1 ) ;
}
コード例 #7
0
ファイル: Executive_test.cpp プロジェクト: Arafatk/trick
TEST_F(ExecutiveTest , UnhandledJobs) {
    //req.add_requirement("r_exec_jobs");
	//"The Executive Scheduler shall provide the capability to list jobs not handled by any scheduler."
    Trick::JobData * curr_job ;

    curr_job = so1.add_job(0, 100, "unhandled", NULL, 1, "unhandled_job", "") ;
    exec_add_sim_object(&so1 , "so1") ;
    EXPECT_EQ(exec.check_all_jobs_handled() , 1 ) ;
}
コード例 #8
0
ファイル: Executive_test.cpp プロジェクト: Arafatk/trick
TEST_F(ExecutiveTest , JobCycle) {
	//req.add_requirement("");

    exec_add_sim_object(&so1 , "so1") ;
    EXPECT_NEAR( exec.get_job_cycle(std::string("so1.scheduled_3")) , 3.0 , 0.000001) ;
    EXPECT_NEAR( exec.get_job_cycle(std::string("so1.scheduled_2")) , 2.0 , 0.000001) ;

    EXPECT_EQ(exec.set_job_cycle("so1.scheduled_2", 1, 22.2), 0) ;
    EXPECT_NEAR( exec.get_job_cycle(std::string("so1.scheduled_2")) , 22.2 , 0.000001) ;

    EXPECT_EQ(exec.set_job_cycle("so1.scheduled_2", 1, -3.3), -1) ;

    EXPECT_EQ(exec.set_job_cycle("so1.scheduled_4", 1, 22.2), -2) ;

    // All other job classes are defaulted to cycle time of 1.0 seconds even though they are not used.
    EXPECT_NEAR( exec.get_job_cycle(std::string("so1.shutdown_1")) , 1.0 , 0.000001) ;
}
コード例 #9
0
ファイル: Executive_test.cpp プロジェクト: Arafatk/trick
TEST_F(ExecutiveTest , JobOnOff) {
	//req.add_requirement("2445198072");
	
    Trick::JobData * curr_job ;

    exec_add_sim_object(&so1 , "so1") ;

    EXPECT_EQ(exec.set_job_onoff("so1.scheduled_1" , 1 , 1), 0) ;
    curr_job = exec.get_job( std::string("so1.scheduled_1")) ;
    ASSERT_FALSE( curr_job == NULL ) ;
    EXPECT_EQ( curr_job->disabled , false) ;

    EXPECT_EQ(exec.set_job_onoff("so1.scheduled_1" , 1 , 0), 0) ;
    EXPECT_EQ( curr_job->disabled , true) ;

    EXPECT_EQ(exec.set_job_onoff("so1.scheduled_4" , 1 , 0), -1) ;
}
コード例 #10
0
ファイル: DataRecordDispatcher.cpp プロジェクト: aissat/trick
/**
@details
-# Test if the incoming data record group name has been used.
 -# If true return an error.
-# Set the group buffering type to the incoming type
-# Add the group to the executive.
*/
int Trick::DataRecordDispatcher::add_group(Trick::DataRecordGroup * in_group, Trick::DR_Buffering buffering) {

    unsigned int ii ;
    for (  ii = 0 ; ii < groups.size() ; ii++ ) {
        if ( !groups[ii]->group_name.compare(in_group->group_name) ) {
            message_publish(MSG_ERROR, "Data Record group with duplicate name %s.\n", in_group->group_name.c_str()) ;
            return -1 ;
        }
    }
    if ( buffering != Trick::DR_Not_Specified ) {
        in_group->set_buffer_type(buffering) ;
    }

    exec_add_sim_object(in_group , (char *)in_group->name.c_str()) ;

    return 0 ;
}
コード例 #11
0
ファイル: Executive_test.cpp プロジェクト: Arafatk/trick
TEST_F(ExecutiveTest , AdvanceSimTimeToBoundary) {

    //req.add_requirement("4140012270");
	// "The Executive Scheduler shall advance simulation time to the time of the next software boundary if the next lowest job call time is greater than or equal to the next software frame boundary ") ;
    Trick::Threads * curr_thread ;

    exec_add_sim_object(&empty_so , "empty_so") ;

    curr_thread = get_thread(0) ;

    // Test where next job call time is less than the frame boundary
    exec.set_software_frame(0.05) ;
    exec.init() ;
    curr_thread->job_queue.set_next_job_call_time(200000) ;
    EXPECT_EQ( exec.get_time_tics() , 0 ) ;
    exec.advance_sim_time() ;
    EXPECT_EQ( exec.get_time_tics() , 50000 ) ;

}
コード例 #12
0
ファイル: Executive_test.cpp プロジェクト: Arafatk/trick
TEST_F(ExecutiveTest , ExeceptionInitialization) {
    //req.add_requirement("2605574440") ;
    so1.add_job(0, 102, "initialization", NULL, 1, "throw_exception", "TRK") ;
    exec_add_sim_object(&so1 , "so1") ;
    EXPECT_EQ(exec.init() , -1 ) ;

    EXPECT_EQ(so1.default_data_ran , 1 ) ;
    EXPECT_EQ(so1.input_processor_ran , 1 ) ;
    EXPECT_EQ(so1.initialization_ran , 1 ) ;
    EXPECT_EQ(so1.top_of_frame_ran , 0 ) ;
    EXPECT_EQ(so1.scheduled_ran , 0 ) ;
    EXPECT_EQ(so1.end_of_frame_ran , 0 ) ;
    EXPECT_EQ(so1.shutdown_ran , 0 ) ;
    EXPECT_EQ(so1.freeze_init_ran , 0 ) ;
    EXPECT_EQ(so1.freeze_ran , 0 ) ;
    EXPECT_EQ(so1.freeze_scheduled_ran , 0 ) ;
    EXPECT_EQ(so1.unfreeze_ran , 0 ) ;
    EXPECT_EQ(so1.time_tic_changed_ran , 0 ) ;
}
コード例 #13
0
ファイル: Executive_test.cpp プロジェクト: Arafatk/trick
TEST_F(ExecutiveTest , ErrorInitialization) {
    //req.add_requirement("773089468") ;

    so1.add_job(0, 101, "initialization", NULL, 1, "return_error", "TRK") ;
    exec_add_sim_object(&so1 , "so1") ;
    EXPECT_EQ(exec.init() , -1 ) ;

    EXPECT_EQ(so1.default_data_ran , 1 ) ;
    EXPECT_EQ(so1.input_processor_ran , 1 ) ;
    EXPECT_EQ(so1.initialization_ran , 1 ) ;
    EXPECT_EQ(so1.top_of_frame_ran , 0 ) ;
    EXPECT_EQ(so1.scheduled_ran , 0 ) ;
    EXPECT_EQ(so1.end_of_frame_ran , 0 ) ;
    EXPECT_EQ(so1.shutdown_ran , 0 ) ;
    EXPECT_EQ(so1.freeze_init_ran , 0 ) ;
    EXPECT_EQ(so1.freeze_ran , 0 ) ;
    EXPECT_EQ(so1.freeze_scheduled_ran , 0 ) ;
    EXPECT_EQ(so1.unfreeze_ran , 0 ) ;
    EXPECT_EQ(so1.time_tic_changed_ran , 0 ) ;
}
コード例 #14
0
ファイル: Executive_test.cpp プロジェクト: Arafatk/trick
TEST_F(ExecutiveTest , GoodInitialization) {
    //req.add_requirement("2605574440") ;

    exec_add_sim_object(&so1 , "so1") ;

    EXPECT_EQ(exec.init() , 0 ) ;

    EXPECT_EQ(so1.default_data_ran , 1 ) ;
    EXPECT_EQ(so1.input_processor_ran , 1 ) ;
    EXPECT_EQ(so1.initialization_ran , 1 ) ;
    EXPECT_EQ(so1.top_of_frame_ran , 0 ) ;
    EXPECT_EQ(so1.scheduled_ran , 0 ) ;
    EXPECT_EQ(so1.end_of_frame_ran , 0 ) ;
    EXPECT_EQ(so1.shutdown_ran , 0 ) ;
    EXPECT_EQ(so1.freeze_init_ran , 0 ) ;
    EXPECT_EQ(so1.freeze_ran , 0 ) ;
    EXPECT_EQ(so1.freeze_scheduled_ran , 0 ) ;
    EXPECT_EQ(so1.unfreeze_ran , 0 ) ;
    EXPECT_EQ(so1.time_tic_changed_ran , 0 ) ;

}
コード例 #15
0
ファイル: Executive_test.cpp プロジェクト: Arafatk/trick
TEST_F(ExecutiveTest , AdvanceSimTimeToNextJob) {

    //req.add_requirement("2449626778");
	//"The Executive Scheduler shall advance simulation time to the time of the next lowest job call time if the next lowest job call time is less than the next software frame boundary ") ;
    Trick::Threads * curr_thread ;
    Trick::JobData * curr_job ;

    exec_add_sim_object(&empty_so , "empty_so") ;

    curr_thread = get_thread(0) ;

    // Test where next job call time is less than the frame boundary
    exec.set_time_tics(0) ;
    do {
       curr_job = curr_thread->job_queue.get_next_job() ;
    } while ( curr_job != NULL ) ;
    curr_thread->job_queue.set_next_job_call_time(20000) ;
    exec.set_software_frame(0.05) ;
    EXPECT_EQ( exec.get_time_tics() , 0 ) ;
    exec.advance_sim_time() ;
    EXPECT_EQ( exec.get_time_tics() , 20000 ) ;
}
コード例 #16
0
ファイル: Executive_test.cpp プロジェクト: Arafatk/trick
TEST_F(ExecutiveTest , AddSimObject) {
    //req.add_requirement( "r_exec_jobs");
	//"The Executive Scheduler shall provide a method for adding simulation objects to the scheduler"
    exec_add_sim_object(&so1 , "so1") ;
}
コード例 #17
0
ファイル: Executive_test.cpp プロジェクト: Arafatk/trick
TEST_F(ExecutiveTest , Checkpoint) {

    //req.add_requirement("2678139818 1653083281");
	//"The Executive Scheduler shall copy all job information to a checkpointable array before a checkpoint is executed") ;

    unsigned int ii = 0 ;
    Trick::JobData * curr_job ;
    Trick::SimObject * curr_obj ;

    exec_add_sim_object(&so1 , "so1") ;
    exec.checkpoint() ;

    curr_job = get_job_from_all_jobs(ii++) ;
    ASSERT_FALSE( curr_job == NULL ) ;
    EXPECT_STREQ( curr_job->name.c_str() , "so1.default_data_1") ;

    curr_job = get_job_from_all_jobs(ii++) ;
    ASSERT_FALSE( curr_job == NULL ) ;
    EXPECT_STREQ( curr_job->name.c_str() , "so1.input_processor_1") ;

    curr_job = get_job_from_all_jobs(ii++) ;
    ASSERT_FALSE( curr_job == NULL ) ;
    EXPECT_STREQ( curr_job->name.c_str() , "so1.initialization_1") ;

    curr_job = get_job_from_all_jobs(ii++) ;
    ASSERT_FALSE( curr_job == NULL ) ;
    EXPECT_STREQ( curr_job->name.c_str() , "so1.top_of_frame_1") ;

    curr_job = get_job_from_all_jobs(ii++) ;
    ASSERT_FALSE( curr_job == NULL ) ;
    EXPECT_STREQ( curr_job->name.c_str() , "so1.automatic_1") ;

    curr_job = get_job_from_all_jobs(ii++) ;
    ASSERT_FALSE( curr_job == NULL ) ;
    EXPECT_STREQ( curr_job->name.c_str() , "so1.scheduled_3") ;

    curr_job = get_job_from_all_jobs(ii++) ;
    ASSERT_FALSE( curr_job == NULL ) ;
    EXPECT_STREQ( curr_job->name.c_str() , "so1.scheduled_2") ;

    curr_job = get_job_from_all_jobs(ii++) ;
    ASSERT_FALSE( curr_job == NULL ) ;
    EXPECT_STREQ( curr_job->name.c_str() , "so1.scheduled_1") ;

    curr_job = get_job_from_all_jobs(ii++) ;
    ASSERT_FALSE( curr_job == NULL ) ;
    EXPECT_STREQ( curr_job->name.c_str() , "so1.advance_sim_time") ;

    curr_job = get_job_from_all_jobs(ii++) ;
    ASSERT_FALSE( curr_job == NULL ) ;
    EXPECT_STREQ( curr_job->name.c_str() , "so1.end_of_frame_1") ;

    curr_job = get_job_from_all_jobs(ii++) ;
    ASSERT_FALSE( curr_job == NULL ) ;
    EXPECT_STREQ( curr_job->name.c_str() , "so1.shutdown_1") ;

    curr_job = get_job_from_all_jobs(ii++) ;
    ASSERT_FALSE( curr_job == NULL ) ;
    EXPECT_STREQ( curr_job->name.c_str() , "so1.freeze_init_1") ;

    curr_job = get_job_from_all_jobs(ii++) ;
    ASSERT_FALSE( curr_job == NULL ) ;
    EXPECT_STREQ( curr_job->name.c_str() , "so1.freeze_1") ;

    curr_job = get_job_from_all_jobs(ii++) ;
    ASSERT_FALSE( curr_job == NULL ) ;
    EXPECT_STREQ( curr_job->name.c_str() , "so1.freeze_scheduled_1") ;

    curr_job = get_job_from_all_jobs(ii++) ;
    ASSERT_FALSE( curr_job == NULL ) ;
    EXPECT_STREQ( curr_job->name.c_str() , "so1.unfreeze_1") ;

    curr_job = get_job_from_all_jobs(ii++) ;
    ASSERT_FALSE( curr_job == NULL ) ;
    EXPECT_STREQ( curr_job->name.c_str() , "so1.time_tic_changed_1") ;

    ii = 0 ;
    curr_obj = get_sim_object(ii++) ;
    ASSERT_FALSE( curr_obj == NULL ) ;
    EXPECT_STREQ( curr_obj->name.c_str() , "so1") ;
}