Esempio n. 1
0
/*test case:test the reaction of the system called with 
 an activation of a task*/
static void test_t1_instance(void)
{
	StatusType result_inst_1,result_inst_4,result_inst_5,result_inst_6,result_inst_7;
	TaskStateType result_inst_3;
	
	SCHEDULING_CHECK_INIT(1);
	result_inst_1 = ActivateTask(t2);
	SCHEDULING_CHECK_AND_EQUAL_INT(4 , E_OK , result_inst_1);
	
	SCHEDULING_CHECK_INIT(5);
	result_inst_4 = GetTaskState(t2,&result_inst_3);
	SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(5 , WAITING , result_inst_3);
	SCHEDULING_CHECK_AND_EQUAL_INT(5 , E_OK , result_inst_4);
	
	SCHEDULING_CHECK_INIT(6);
	result_inst_5 = ActivateTask(t2);
	SCHEDULING_CHECK_AND_EQUAL_INT(6 , E_OS_LIMIT , result_inst_5);
	
	SCHEDULING_CHECK_INIT(7);
	result_inst_6 = ChainTask(t2);
	SCHEDULING_CHECK_AND_EQUAL_INT(7 , E_OS_LIMIT , result_inst_6);	
	
	SCHEDULING_CHECK_INIT(8);
	result_inst_7 = SetEvent(t2,Event2);
	SCHEDULING_CHECK_AND_EQUAL_INT(10 , E_OK , result_inst_7);

}
/*test case:test the reaction of the system called with 
 an activation of a task*/
static void test_pretask_instance2(void)
{
	StatusType result_inst_1, result_inst_2, result_inst_3, result_inst_4, result_inst_5;
	TaskType task_id;
	TaskStateType task_state;
	EventMaskType event_mask;
	AlarmBaseType alarm_base;
	TickType tik;
	
	SCHEDULING_CHECK_INIT(15);
	result_inst_1 = GetTaskID(&task_id);
	SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(15,INVALID_TASK , task_id); 
	SCHEDULING_CHECK_AND_EQUAL_INT(15,E_OK , result_inst_1); 
	
	SCHEDULING_CHECK_INIT(16);
	result_inst_2 = GetTaskState(task_id, &task_state);
	SCHEDULING_CHECK_AND_EQUAL_INT(17,E_OS_ID , result_inst_2);
	
	SCHEDULING_CHECK_INIT(18);
	result_inst_3 = GetEvent(task_id,&event_mask);
	SCHEDULING_CHECK_AND_EQUAL_INT(19,E_OS_ID , result_inst_3);
	
	SCHEDULING_CHECK_INIT(20);
	result_inst_4 = GetAlarmBase(Alarm1, &alarm_base);
	SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(20,OSMAXALLOWEDVALUE_Counter1, (int)(alarm_base.maxallowedvalue));
	SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(20,OSTICKSPERBASE_Counter1, (int)(alarm_base.ticksperbase));
	SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(20,OSMINCYCLE_Counter1, (int)(alarm_base.mincycle));
	SCHEDULING_CHECK_AND_EQUAL_INT(20,E_OK , result_inst_4);
	
	SCHEDULING_CHECK_INIT(21);
	result_inst_5 = GetAlarm(Alarm1,&tik);
	SCHEDULING_CHECK_AND_EQUAL_INT(21,E_OK , result_inst_5);
}
Esempio n. 3
0
/* Standard posttask hook
 * 
 * $Req: artf1225 $
 */
void PostTaskHook(void)
{
	TaskType task;
	StatusType rc;
	TaskStateType state;
#ifdef USEPOSTTASKHOOK
	/* PostTaskHook() should be called with cat2 interrupts locked.
	 * 
	 * $Req: artf1110 $
	 * 
	 * Following code will trigger the cat2 ISR here but it should not actually run. Dismiss it later.
	 * Safe to do this because PostTaskHook() is never called from an ISR and so won't mess with the cat2 ISR in
	 * the tests.
	 * 
	 * In mosts tests the ISR running is logged, and this would cause the test to fail
	 * because there should be no expect ISR log entries at this point.
	 */
	SET_TESTEVENT("PostTaskHook");
	testing_trigger_isr();
	/* Task should now be RUNNING when the hook is called
	 * 
	 * $Req: artf1140
	 */
	rc = GetTaskID(&task);			/* $Req: artf1139 $ */
	if(rc != E_OK) {
		test_failed(OS_HERE);
	}
	if(task == INVALID_TASK) {		/* $Req: artf1118 $ */
		test_failed(OS_HERE);
	}
	GetTaskState(task, &state);		/* $Req: artf1141 $ */
	if(rc != E_OK) {
		test_failed(OS_HERE);
	}
	if(state != RUNNING) {			/* $Req: artf1118 $ */
		test_failed(OS_HERE);
	}
	
#ifdef INCLUDE_HANDLE_NAME_MAP
	SET_TESTEVENT(TaskType2string(task));
#else
	SET_TESTEVENT("A task");
#endif
#ifdef USEPRETASKHOOK
	/* If there is a pretask hook then make sure the posttask hook gets called in a paired sequence */
	if(pretaskhook_task != task) {
		test_failed(OS_HERE);
	}
	else {
		pretaskhook_task = 0;
	}
#endif
	testing_dismiss_isr();
#else
	test_failed(OS_HERE);
#endif
}
Esempio n. 4
0
void __attribute__((__interrupt__)) _INT0Interrupt(void)
{
  TaskStateType State;

  EnterISR();
  IEC0bits.INT0IE = 0;
  GetTaskState(TASK2_ID, &State);
  if (State == SUSPENDED) 
    ActivateTask(TASK2_ID);
  LeaveISR();
}
Esempio n. 5
0
void PreTaskHook( void ) {
	StatusType rv;
	TaskType task;
	TaskStateType state;
	printf("prehook\r\n");
	rv = GetTaskID(&task);
	assert( rv == E_OK );
	LDEBUG_PRINTF("## PreTaskHook, taskid=%d\n",task);
	rv = GetTaskState(task,&state);
	assert( rv == E_OK );
	assert( state == TASK_STATE_RUNNING );
}
Esempio n. 6
0
/*test case:test the reaction of the system called with 
 an activation of a task*/
static void test_t2_instance(void)
{
	StatusType result_inst_2, result_inst_3;
	TaskStateType result_inst_1;
	
	SCHEDULING_CHECK_INIT(5);
	result_inst_2 = GetTaskState(t1,&result_inst_1);
	SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(5,READY , result_inst_1);
	SCHEDULING_CHECK_AND_EQUAL_INT(5,E_OK , result_inst_2);
	
	SCHEDULING_CHECK_INIT(6);
	result_inst_3 = TerminateTask();
	SCHEDULING_CHECK_AND_EQUAL_INT(6,E_OK , result_inst_3);
}
Esempio n. 7
0
/*test case:test the reaction of the system called with 
an activation of a task*/
static void test_t1_instance(void)
{
	StatusType result_inst_2, result_inst_3, result_inst_4, result_inst_5, result_inst_6, result_inst_7, result_inst_8, result_inst_9, result_inst_10, result_inst_11;
	TaskStateType result_inst_3_5;
		
	SCHEDULING_CHECK_INIT(1);
	result_inst_2 = ActivateTask(INVALID_TASK);	
	SCHEDULING_CHECK_AND_EQUAL_INT(1,E_OS_ID, result_inst_2);
	
	SCHEDULING_CHECK_INIT(2);
	result_inst_3 = GetTaskState(INVALID_TASK,&result_inst_3_5);
	SCHEDULING_CHECK_AND_EQUAL_INT(2,E_OS_ID, result_inst_3);
	
	SCHEDULING_CHECK_INIT(3);
	result_inst_4 = ChainTask(INVALID_TASK);
	SCHEDULING_CHECK_AND_EQUAL_INT(3,E_OS_ID, result_inst_4);
	
	SCHEDULING_CHECK_INIT(4);
	result_inst_5 = ActivateTask(t2);
	SCHEDULING_CHECK_AND_EQUAL_INT(4,E_OK, result_inst_5);
	
	SCHEDULING_CHECK_INIT(5);
	result_inst_6 = Schedule();
	SCHEDULING_CHECK_AND_EQUAL_INT(9,E_OK, result_inst_6);
	
	SCHEDULING_CHECK_INIT(10);
	result_inst_7 = GetResource(RES_SCHEDULER);
	SCHEDULING_CHECK_AND_EQUAL_INT(10,E_OK, result_inst_7);
	
	SCHEDULING_CHECK_INIT(11);
	result_inst_8 = TerminateTask();
	SCHEDULING_CHECK_AND_EQUAL_INT(11,E_OS_RESOURCE, result_inst_8);
	
	SCHEDULING_CHECK_INIT(12);
	result_inst_9 = ChainTask(t2);
	SCHEDULING_CHECK_AND_EQUAL_INT(12,E_OS_RESOURCE, result_inst_9);
	
	SCHEDULING_CHECK_INIT(13);
	result_inst_10 = Schedule();
	SCHEDULING_CHECK_AND_EQUAL_INT(13,E_OS_RESOURCE, result_inst_10);
	
	SCHEDULING_CHECK_INIT(14);
	result_inst_11 = ReleaseResource(RES_SCHEDULER);
	SCHEDULING_CHECK_AND_EQUAL_INT(14,E_OK, result_inst_11);
	
	sendSoftwareIt(0, SOFT_IRQ0);
	
	SCHEDULING_CHECK_STEP(19);
}
Esempio n. 8
0
/*test case:test the reaction of the system called with 
 an activation of a task*/
static void test_t1_instance(void)
{
	StatusType result_inst_2, result_inst_3, result_inst_4, result_inst_5, result_inst_6, result_inst_7, result_inst_8, result_inst_9;
	TaskStateType result_inst_3_5;
		
	SCHEDULING_CHECK_INIT(1);
	result_inst_2 = ActivateTask(INVALID_TASK);	
	SCHEDULING_CHECK_AND_EQUAL_INT(1,E_OS_ID, result_inst_2);
	
	SCHEDULING_CHECK_INIT(2);
	result_inst_3 = GetTaskState(INVALID_TASK,&result_inst_3_5);
	SCHEDULING_CHECK_AND_EQUAL_INT(2,E_OS_ID, result_inst_3);
	
	SCHEDULING_CHECK_INIT(3);
	result_inst_4 = ChainTask(INVALID_TASK);
	SCHEDULING_CHECK_AND_EQUAL_INT(3,E_OS_ID, result_inst_4);
	
	SCHEDULING_CHECK_INIT(4);
	result_inst_5 = ActivateTask(t2);
	SCHEDULING_CHECK_AND_EQUAL_INT(8,E_OK, result_inst_5);
		
	SCHEDULING_CHECK_INIT(9);
	result_inst_6 = GetResource(RES_SCHEDULER);
	SCHEDULING_CHECK_AND_EQUAL_INT(9,E_OK, result_inst_6);
	
	SCHEDULING_CHECK_INIT(10);
	result_inst_7 = TerminateTask();
	SCHEDULING_CHECK_AND_EQUAL_INT(10,E_OS_RESOURCE, result_inst_7);
	
	SCHEDULING_CHECK_INIT(11);
	result_inst_8 = ChainTask(t2);
	SCHEDULING_CHECK_AND_EQUAL_INT(11,E_OS_RESOURCE, result_inst_8);
	
	SCHEDULING_CHECK_INIT(12);
	result_inst_9 = ReleaseResource(RES_SCHEDULER);
	SCHEDULING_CHECK_AND_EQUAL_INT(12,E_OK, result_inst_9);
	
	tpl_send_it1();
	
	SCHEDULING_CHECK_STEP(17);
	
}
Esempio n. 9
0
/*test case:test the reaction of the system called with 
an activation of a task*/
static void test_t1_instance(void)
{
	
	StatusType result_inst_1, result_inst_3, result_inst_4;
	TaskStateType result_inst_2;
	
	SCHEDULING_CHECK_INIT(1);
	result_inst_1 = SetRelAlarm(Alarm1, 0, 0);
	SCHEDULING_CHECK_AND_EQUAL_INT(1,E_OK, result_inst_1);
	
	WaitActivationOneShotAlarm(Alarm1);
	
	SCHEDULING_CHECK_INIT(2);
	result_inst_3 = GetTaskState(t2, &result_inst_2);
	SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(2,READY, result_inst_2);
	SCHEDULING_CHECK_AND_EQUAL_INT(2,E_OK, result_inst_3);
	
	SCHEDULING_CHECK_INIT(3);
	result_inst_4 = TerminateTask();
	SCHEDULING_CHECK_AND_EQUAL_INT(3,E_OK, result_inst_4);
}
Esempio n. 10
0
/*test case:test the reaction of the system called with 
an activation of a task*/
static void test_error_instance(void)
{
	StatusType result_inst_1, result_inst_2, result_inst_3, result_inst_4, result_inst_5, result_inst_6;
	TaskType task_id;
	TaskStateType task_state;
	EventMaskType event_mask;
	AlarmBaseType alarm_base;
	TickType tik;

	SCHEDULING_CHECK_INIT(4);
	result_inst_1 = GetActiveApplicationMode();
	SCHEDULING_CHECK_AND_EQUAL_INT(4,OSDEFAULTAPPMODE , result_inst_1); 
	
	SCHEDULING_CHECK_INIT(5);
	result_inst_2 = GetTaskID(&task_id);
	SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(5,E_OK , result_inst_2); 
	SCHEDULING_CHECK_AND_EQUAL_INT(5,t1 , task_id); 
		
	SCHEDULING_CHECK_INIT(6);
	result_inst_3 = GetTaskState(task_id, &task_state);
	SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(6,E_OK , result_inst_3); 
	SCHEDULING_CHECK_AND_EQUAL_INT(6,RUNNING , task_state); 
	
	SCHEDULING_CHECK_INIT(7);
	result_inst_4 = GetEvent(task_id,&event_mask);
	SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(7,E_OK , result_inst_2); 
	SCHEDULING_CHECK_AND_EQUAL_INT(7,E_OK , result_inst_2); 
	
	SCHEDULING_CHECK_INIT(8);
	result_inst_5 = GetAlarmBase(Alarm1, &alarm_base);
	SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(8,OSMAXALLOWEDVALUE_Counter1, (int)(alarm_base.maxallowedvalue));
	SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(8,OSTICKSPERBASE_Counter1, (int)(alarm_base.ticksperbase));
	SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(8,OSMINCYCLE_Counter1, (int)(alarm_base.mincycle));
	SCHEDULING_CHECK_AND_EQUAL_INT(8,E_OK , result_inst_5);
	
	SCHEDULING_CHECK_INIT(9);
	result_inst_6 = GetAlarm(Alarm1,&tik);
	SCHEDULING_CHECK_AND_EQUAL_INT(9,E_OK , result_inst_6); 
	
}
/*test case:test the reaction of the system called with 
 an activation of a task*/
static void test_posttask_instance3(void)
{
	StatusType result_inst_1, result_inst_2, result_inst_3;
	TaskType task_id;
	TaskStateType task_state;
	EventMaskType event_mask;
	
	SCHEDULING_CHECK_INIT(33);
	result_inst_1 = GetTaskID(&task_id);
	SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(33,t1 , task_id);
	SCHEDULING_CHECK_AND_EQUAL_INT(33,E_OK , result_inst_1); 
	
	SCHEDULING_CHECK_INIT(34);
	result_inst_2 = GetTaskState(task_id, &task_state);
	SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(34,RUNNING , task_state);
	SCHEDULING_CHECK_AND_EQUAL_INT(34,E_OK , result_inst_2);
	
	SCHEDULING_CHECK_INIT(35);
	result_inst_3 = GetEvent(task_id,&event_mask);
	SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(35,Event1 , event_mask);
	SCHEDULING_CHECK_AND_EQUAL_INT(35,E_OK , result_inst_3);	
	
}
Esempio n. 12
0
/*test case:test the reaction of the system called with 
 an activation of a task*/
static void test_pretask_instance3(void)
{
	StatusType result_inst_1, result_inst_2, result_inst_3, result_inst_4, result_inst_5;
	TaskType task_id;
	TaskStateType task_state;
	EventMaskType event_mask;
	AlarmBaseType alarm_base;
	TickType tik;
	
	SCHEDULING_CHECK_INIT(25);
	result_inst_1 = GetTaskID(&task_id);
	SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(25,t1 , task_id); 
	SCHEDULING_CHECK_AND_EQUAL_INT(25,E_OK , result_inst_1); 
	
	SCHEDULING_CHECK_INIT(26);
	result_inst_2 = GetTaskState(task_id, &task_state);
	SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(26,RUNNING , task_state);
	SCHEDULING_CHECK_AND_EQUAL_INT(26,E_OK , result_inst_2);
	
	SCHEDULING_CHECK_INIT(27);
	result_inst_3 = GetEvent(task_id,&event_mask);
	SCHEDULING_CHECK_AND_EQUAL_INT(27,E_OK , result_inst_3);
	
	SCHEDULING_CHECK_INIT(28);
	result_inst_4 = GetAlarmBase(Alarm1, &alarm_base);
	SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(28,OSMAXALLOWEDVALUE_Counter1, (int)(alarm_base.maxallowedvalue));
	SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(28,OSTICKSPERBASE_Counter1, (int)(alarm_base.ticksperbase));
	SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(28,OSMINCYCLE_Counter1, (int)(alarm_base.mincycle));
	SCHEDULING_CHECK_AND_EQUAL_INT(28,E_OK , result_inst_4);
	
	SCHEDULING_CHECK_INIT(29);
	result_inst_5 = GetAlarm(Alarm1,&tik);
	SCHEDULING_CHECK_AND_EQUAL_INT(30,E_OS_NOFUNC , result_inst_5);
	
	
}
Esempio n. 13
0
/*test case:test the reaction of the system called with 
an activation of a task*/
static void test_t1_instance(void)
{
	AlarmBaseType AlarmBaseType_inst_1;
	EventMaskType EventMaskType_inst_1;
	StatusType result_inst_2, result_inst_3, result_inst_4, result_inst_5, result_inst_6, result_inst_7, result_inst_8, result_inst_9, result_inst_10, result_inst_11, result_inst_12, result_inst_13, result_inst_14, result_inst_15, result_inst_16, result_inst_17, result_inst_18, result_inst_19;
	TaskStateType TaskStateType_inst_1;
	TaskType TaskType_inst_1;
	TickType TickType_inst_1;
		
	SCHEDULING_CHECK_STEP(1);
	
	SCHEDULING_CHECK_STEP(2);
	SuspendAllInterrupts();
	
	SCHEDULING_CHECK_INIT(3);
	result_inst_2 = ActivateTask(t2);
	SCHEDULING_CHECK_AND_EQUAL_INT(4,E_OS_DISABLEDINT, result_inst_2);
	
	SCHEDULING_CHECK_INIT(5);
	result_inst_3 = TerminateTask();
	SCHEDULING_CHECK_AND_EQUAL_INT(6,E_OS_DISABLEDINT, result_inst_3);
	
	SCHEDULING_CHECK_INIT(7);
	result_inst_4 = ChainTask(t2);
	SCHEDULING_CHECK_AND_EQUAL_INT(8,E_OS_DISABLEDINT, result_inst_4);
	
	SCHEDULING_CHECK_INIT(9);
	result_inst_5 = Schedule();
	SCHEDULING_CHECK_AND_EQUAL_INT(10,E_OS_DISABLEDINT, result_inst_5);
	
	SCHEDULING_CHECK_INIT(11);
	result_inst_6 = GetTaskID(&TaskType_inst_1);
	SCHEDULING_CHECK_AND_EQUAL_INT(12,E_OS_DISABLEDINT, result_inst_6);
	
	SCHEDULING_CHECK_INIT(13);
	result_inst_7 = GetTaskState(t2, &TaskStateType_inst_1);
	SCHEDULING_CHECK_AND_EQUAL_INT(14,E_OS_DISABLEDINT, result_inst_7);
	
	SCHEDULING_CHECK_INIT(15);
	result_inst_8 = GetResource(Resource1);
	SCHEDULING_CHECK_AND_EQUAL_INT(16,E_OS_DISABLEDINT, result_inst_8);
	
	SCHEDULING_CHECK_INIT(17);
	result_inst_9 = ReleaseResource(Resource1);
	SCHEDULING_CHECK_AND_EQUAL_INT(18,E_OS_DISABLEDINT, result_inst_9);
	
	SCHEDULING_CHECK_INIT(19);
	result_inst_10 = SetEvent(t2, Event1);
	SCHEDULING_CHECK_AND_EQUAL_INT(20,E_OS_DISABLEDINT, result_inst_10);
	
	SCHEDULING_CHECK_INIT(21);
	result_inst_11 = ClearEvent(Event1);
	SCHEDULING_CHECK_AND_EQUAL_INT(22,E_OS_DISABLEDINT, result_inst_11);
	
	SCHEDULING_CHECK_INIT(23);
	result_inst_12 = GetEvent(t2, &EventMaskType_inst_1);
	SCHEDULING_CHECK_AND_EQUAL_INT(24,E_OS_DISABLEDINT, result_inst_12);
	
	SCHEDULING_CHECK_INIT(25);
	result_inst_13 = WaitEvent(Event1);
	SCHEDULING_CHECK_AND_EQUAL_INT(26,E_OS_DISABLEDINT, result_inst_13);
	
	SCHEDULING_CHECK_INIT(27);
	result_inst_14 = GetAlarmBase(Alarm1, &AlarmBaseType_inst_1);
	SCHEDULING_CHECK_AND_EQUAL_INT(28,E_OS_DISABLEDINT, result_inst_14);
	
	SCHEDULING_CHECK_INIT(29);
	result_inst_15 = GetAlarm(Alarm1, &TickType_inst_1);
	SCHEDULING_CHECK_AND_EQUAL_INT(30,E_OS_DISABLEDINT, result_inst_15);
	
	SCHEDULING_CHECK_INIT(31);
	result_inst_16 = SetRelAlarm(Alarm1, 1, 0);
	SCHEDULING_CHECK_AND_EQUAL_INT(32,E_OS_DISABLEDINT, result_inst_16);
	
	SCHEDULING_CHECK_INIT(33);
	result_inst_17 = SetAbsAlarm(Alarm1, 1, 0);
	SCHEDULING_CHECK_AND_EQUAL_INT(34,E_OS_DISABLEDINT, result_inst_17);
	
	SCHEDULING_CHECK_INIT(35);
	result_inst_18 = CancelAlarm(Alarm1);
	SCHEDULING_CHECK_AND_EQUAL_INT(36,E_OS_DISABLEDINT, result_inst_18);
	
	SCHEDULING_CHECK_INIT(37);
	result_inst_19 = GetActiveApplicationMode();
	SCHEDULING_CHECK_AND_EQUAL_INT(38,OSDEFAULTAPPMODE, result_inst_19);
	
	SCHEDULING_CHECK_STEP(39);
	ResumeAllInterrupts();
}
Esempio n. 14
0
/* Error hook for all tests
 * 
 * $Req: artf1222 $
 */
void ErrorHook(StatusType rc)
{
#ifdef USEERRORHOOK
#ifdef EXPECTSERRORS
	TaskType from_task;
	ISRType from_isr;
	TaskStateType state;
	
	if(in_error_hook) {
		test_failed(OS_HERE);		/* Error hook not permitted to be called recursively $Req: artf1112 $ */
	}
	in_error_hook = 1U;
	
	SET_TESTEVENT("ErrorHook");
	
#ifdef OS_EXTENDED_STATUS
	/* Test for recursive error hook call by making a legal call which generates an error */
	GetTaskState(0, &state);
#endif

	/* $Req: artf1140 $ */
	GetTaskID(&from_task);
	from_isr = GetISRID();
	
	if(from_isr == INVALID_ISR) {
		if(from_task == INVALID_TASK) {
			SET_TESTEVENT("<No runnable>");		/* Not sure how to get an error hook called if no task or ISR running.. */
		}
		else {	/* Must be a task that caused the error hook to run since there is no ISR running */
#ifdef INCLUDE_HANDLE_NAME_MAP
			SET_TESTEVENT(TaskType2string(from_task));
#else
			SET_TESTEVENT("<A task>");
#endif
			/* ErrorHook() should be called with cat2 interrupts locked.
			 * 
			 * $Req: artf1110 $
			 * 
			 * Following code will trigger the cat2 ISR here but it should not actually run. Dismiss it immediately.
			 * 
			 * Only do this if the error hook is called from outside an ISR because otherwise this would mess up
			 * the only cat2 ISR. In mosts tests the ISR running is logged, and this would cause the test to fail
			 * because there should be no expect ISR log entries at this point.
			 */
			testing_trigger_isr();
			testing_dismiss_isr();
		}
	}
	else {	/* An ISR must be running; this takes precedence over a task: the error must have
			 * been raised in the ISR since the task can't be running (all ISRs have higher priorities
			 * than all tasks)
			 */
#ifdef INCLUDE_HANDLE_NAME_MAP
		SET_TESTEVENT(ISRType2string(from_isr));
#else
		SET_TESTEVENT("<An ISR>");
#endif
	}
	/* If E_OS_MISSING end called then the task is still valid and still RUNNING when the error hook called */
	if(rc == E_OS_MISSINGEND) {				/* $Req: artf1041 $ */
		if(from_task == INVALID_TASK) {
			test_failed(OS_HERE);
		}
		else {
			GetTaskState(from_task, &state);
			if(state != RUNNING) {
				test_failed(OS_HERE);
			}
		}
	}

	/* OSErrorGetServiceId() callable from ErrorHook()
	 * 
	 * $Req: artf1114 $
	 * $Req: artf1228 $
	 */

	SET_TESTEVENT(OSServiceIdType2string(OSErrorGetServiceId(), "<Unknown service ID>"));		
	SET_TESTEVENT(StatusType2string(rc, "<Unknown StatusType code>"));
	set_error_hook_parameters(OSErrorGetServiceId());

	in_error_hook = 0U;

#else /* don't expect errors */
	test_failed(OS_HERE);
#endif
#else
	/* don't use error hook
	 * 
	 * $Req: artf1223 $
	 */
	test_failed(OS_HERE);
#endif
}
Esempio n. 15
0
void PostTaskHook(void)
{
   static uint8 count = 0;
   StatusType ret;
   TaskType TaskID;
   TaskStateType TaskState;

   switch (count)
   {
      case 0:
         /* increment post task hook call count */
         count++;

         Sequence(5);
         /* \treq EH_04 nmf B1B2E1E2 se Check PreTaskHook/PostTaskHook:
          * Force rescheduling
          *
          * \result PreTaskHook is called before executing the new task,
          * but after the transition to running state. PostTaskHook is called
          * after existing the current task but before leaving the task's
          * running state.
          */
         ret = GetTaskID(&TaskID);
         ASSERT(EH_04, ret != E_OK);
         ASSERT(EH_04, TaskID != Task1);

         Sequence(6);
         ret = GetTaskState(Task1, &TaskState);
         ASSERT(OTHER, ret != E_OK);
         ASSERT(OTHER, TaskState != RUNNING);

         Sequence(7);
         ret = GetTaskState(Task2, &TaskState);
         ASSERT(OTHER, ret != E_OK);
         ASSERT(OTHER, TaskState != READY);
         break;
      case 1:
         /* increment post task hook call count */
         count++;

         Sequence(14);
         /* \treq EH_04 nmf B1B2E1E2 se Check PreTaskHook/PostTaskHook:
          * Force rescheduling
          *
          * \result PreTaskHook is called before executing the new task,
          * but after the transition to running state. PostTaskHook is called
          * after existing the current task but before leaving the task's
          * running state.
          */
         ret = GetTaskID(&TaskID);
         ASSERT(EH_04, ret != E_OK);
         ASSERT(EH_04, TaskID != Task2);

         Sequence(15);
         ret = GetTaskState(Task1, &TaskState);
         ASSERT(OTHER, ret != E_OK);
         ASSERT(OTHER, TaskState != READY);

         Sequence(16);
         ret = GetTaskState(Task2, &TaskState);
         ASSERT(OTHER, ret != E_OK);
         ASSERT(OTHER, TaskState != RUNNING);
         break;
      case 2:
         /* increment post task hook call count */
         count++;

         Sequence(21);
         /* \treq EH_04 nmf B1B2E1E2 se Check PreTaskHook/PostTaskHook:
          * Force rescheduling
          *
          * \result PreTaskHook is called before executing the new task,
          * but after the transition to running state. PostTaskHook is called
          * after existing the current task but before leaving the task's
          * running state.
          */
         ret = GetTaskID(&TaskID);
         ASSERT(EH_04, ret != E_OK);
         ASSERT(EH_04, TaskID != Task1);

         Sequence(22);
         ret = GetTaskState(Task1, &TaskState);
         ASSERT(OTHER, ret != E_OK);
         ASSERT(OTHER, TaskState != RUNNING);

         Sequence(23);
         ret = GetTaskState(Task2, &TaskState);
         ASSERT(OTHER, ret != E_OK);
         ASSERT(OTHER, TaskState != SUSPENDED);

         Sequence(24);

         /* evaluate conformance tests */
         ConfTestEvaluation();

         /* finish the conformance test */
         ConfTestFinish();
         break;
      default:
         while(1);
         break;
   }
}