def test_can_add_task_returns_true_when_task_can_fit_in_secondary_period_and_was_not_executed_in_this_deadline_slice( ): tasks = [Task('T1', 30, 6), Task('T2', 20, 3), Task('T3', 120, 14)] planner = CyclicExecutivePlanner(tasks) planner.matrix = ExecutionMatrix(planner.hyperperiod, planner.hyperperiod, planner.secondary_period) assert planner.can_add_task(tasks[0], 0)
def test_can_add_task_returns_false_when_task_not_fit_in_secondary_period(): tasks = [Task('T1', 30, 6), Task('T2', 20, 3), Task('T3', 120, 14)] planner = CyclicExecutivePlanner(tasks) planner.matrix = ExecutionMatrix(planner.hyperperiod, planner.hyperperiod, planner.secondary_period) time_stamp = 15 for x in range(time_stamp): planner.matrix.processors[0].add_time_unit() assert not planner.can_add_task(tasks[0], time_stamp)
def test_can_add_task_returns_false_when_task_was_already_enqueued_in_this_deadline_slice( ): tasks = [Task('T1', 30, 6), Task('T2', 20, 3), Task('T3', 120, 14)] planner = CyclicExecutivePlanner(tasks) planner.matrix = ExecutionMatrix(planner.hyperperiod, planner.hyperperiod, planner.secondary_period) planner.matrix.processors[0].add_time_unit() planner.matrix.processors[0].set_task(tasks[0]) for x in range(tasks[0].deadline - 1): planner.matrix.processors[0].add_time_unit() assert not planner.can_add_task(tasks[0], planner.secondary_period + 1)