Beispiel #1
0
void
test_lagopus_pipeline_stage_setup_double_call(void) {
  lagopus_result_t ret = LAGOPUS_RESULT_ANY_FAILURES;
  lagopus_pipeline_stage_t stage = NULL;

  /* create data. */
  pipeline_stage_create(&stage,
                        pipeline_pre_pause,
                        pipeline_sched,
                        pipeline_setup,
                        pipeline_fetch,
                        pipeline_main,
                        pipeline_throw,
                        pipeline_shutdown,
                        pipeline_finalize,
                        pipeline_freeup);

  ret = lagopus_pipeline_stage_setup(&stage);
  TEST_ASSERT_EQUAL_MESSAGE(LAGOPUS_RESULT_OK, ret,
                            "lagopus_pipeline_stage_setup error.");

  /* call func. (double call) */
  ret = lagopus_pipeline_stage_setup(&stage);
  TEST_ASSERT_EQUAL_MESSAGE(LAGOPUS_RESULT_OK, ret,
                            "double call error.");

  /* after. */
  lagopus_pipeline_stage_destroy(&stage);
}
Beispiel #2
0
void
test_lagopus_pipeline_stage_setup_invalid_state(void) {
  lagopus_result_t ret = LAGOPUS_RESULT_ANY_FAILURES;
  lagopus_pipeline_stage_t stage = NULL;

  /* create data. */
  pipeline_stage_create(&stage,
                        pipeline_pre_pause,
                        pipeline_sched,
                        pipeline_setup,
                        pipeline_fetch,
                        pipeline_main,
                        pipeline_throw,
                        pipeline_shutdown,
                        pipeline_finalize,
                        pipeline_freeup);

  ret = lagopus_pipeline_stage_start(&stage);
  TEST_ASSERT_EQUAL_MESSAGE(LAGOPUS_RESULT_OK, ret,
                            "lagopus_pipeline_stage_start error.");

  /* call func. (state is STAGE_STATE_STARTED) */
  ret = lagopus_pipeline_stage_setup(&stage);
  TEST_ASSERT_EQUAL_MESSAGE(LAGOPUS_RESULT_INVALID_STATE_TRANSITION, ret,
                            "not invalid state.");

  /* after. */
  lagopus_pipeline_stage_destroy(&stage);
}
Beispiel #3
0
static void
pipeline_stage_create_start(lagopus_pipeline_stage_t *sptr,
                            lagopus_pipeline_stage_pre_pause_proc_t pre_pause_proc,
                            lagopus_pipeline_stage_sched_proc_t sched_proc,
                            lagopus_pipeline_stage_setup_proc_t setup_proc,
                            lagopus_pipeline_stage_fetch_proc_t fetch_proc,
                            lagopus_pipeline_stage_main_proc_t main_proc,
                            lagopus_pipeline_stage_throw_proc_t throw_proc,
                            lagopus_pipeline_stage_shutdown_proc_t shutdown_proc,
                            lagopus_pipeline_stage_finalize_proc_t finalize_proc,
                            lagopus_pipeline_stage_freeup_proc_t freeup_proc) {
  lagopus_result_t ret = LAGOPUS_RESULT_ANY_FAILURES;

  pipeline_stage_create(sptr,
                        pre_pause_proc,
                        sched_proc,
                        setup_proc,
                        fetch_proc,
                        main_proc,
                        throw_proc,
                        shutdown_proc,
                        finalize_proc,
                        freeup_proc);

  ret = lagopus_pipeline_stage_start(sptr);
  TEST_ASSERT_EQUAL_MESSAGE(LAGOPUS_RESULT_OK, ret,
                            "lagopus_pipeline_stage_start error.");
  SLEEP;
  ret = global_state_set(GLOBAL_STATE_STARTED);
  TEST_ASSERT_EQUAL_MESSAGE(LAGOPUS_RESULT_OK, ret,
                            "global_state_set error.");
  SLEEP;
}
Beispiel #4
0
void
test_lagopus_pipeline_stage_setup_normal(void) {
  lagopus_result_t ret = LAGOPUS_RESULT_ANY_FAILURES;
  uint64_t counter[PIPELINE_FUNC_MAX] = {0, 0, 1, 0, 0, 0, 0, 0, 0, 0};
  lagopus_pipeline_stage_t stage = NULL;

  /* create data. */
  pipeline_stage_create(&stage,
                        pipeline_pre_pause,
                        pipeline_sched,
                        pipeline_setup,
                        pipeline_fetch,
                        pipeline_main,
                        pipeline_throw,
                        pipeline_shutdown,
                        pipeline_finalize,
                        pipeline_freeup);

  /* call func. */
  ret = lagopus_pipeline_stage_setup(&stage);
  TEST_ASSERT_EQUAL_MESSAGE(LAGOPUS_RESULT_OK, ret,
                            "lagopus_pipeline_stage_setup(nomal) error.");
  TEST_ASSERT_COUNTER(true, counter,
                      "counter error.");

  /* after. */
  lagopus_pipeline_stage_destroy(&stage);
}
Beispiel #5
0
void
test_lagopus_pipeline_stage_schedule_maintenance_invalid_state_transition(
  void) {
  lagopus_result_t ret = LAGOPUS_RESULT_ANY_FAILURES;
  lagopus_pipeline_stage_t stage = NULL;

  /* create data. */
  pipeline_stage_create(&stage,
                        pipeline_pre_pause,
                        pipeline_sched,
                        pipeline_setup,
                        pipeline_fetch,
                        pipeline_main,
                        pipeline_throw,
                        pipeline_shutdown,
                        pipeline_finalize,
                        pipeline_freeup);

  /* call func (invalid state transition).  */
  ret = lagopus_pipeline_stage_schedule_maintenance(&stage, pipeline_maint,
        NULL);
  TEST_ASSERT_EQUAL_MESSAGE(LAGOPUS_RESULT_INVALID_STATE_TRANSITION, ret,
                            "lagopus_pipeline_stage_schedule_maintenance"
                            "(invalid state transition) error.");

  /* after. */
  do_stop = true;
  lagopus_pipeline_stage_destroy(&stage);
}
Beispiel #6
0
void
test_lagopus_pipeline_stage_create_destroy_normal(void) {
  uint64_t counter[PIPELINE_FUNC_MAX] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 0};
  lagopus_pipeline_stage_t stage = NULL;

  pipeline_stage_create(&stage,
                        pipeline_pre_pause,
                        pipeline_sched,
                        pipeline_setup,
                        pipeline_fetch,
                        pipeline_main,
                        pipeline_throw,
                        pipeline_shutdown,
                        pipeline_finalize,
                        pipeline_freeup);

  lagopus_pipeline_stage_destroy(&stage);
  TEST_ASSERT_COUNTER(true, counter,
                      "counter error.");
}
Beispiel #7
0
void
test_lagopus_pipeline_stage_destroy_double_call(void) {
  lagopus_pipeline_stage_t stage = NULL;

  /* create data. */
  pipeline_stage_create(&stage,
                        pipeline_pre_pause,
                        pipeline_sched,
                        pipeline_setup,
                        pipeline_fetch,
                        pipeline_main,
                        pipeline_throw,
                        pipeline_shutdown,
                        pipeline_finalize,
                        pipeline_freeup);

  lagopus_pipeline_stage_destroy(&stage);

  /* call func (double call). */
  lagopus_pipeline_stage_destroy(&stage);
}
Beispiel #8
0
void
test_lagopus_pipeline_stage_find_normal(void) {
  lagopus_result_t ret = LAGOPUS_RESULT_ANY_FAILURES;
  lagopus_pipeline_stage_t stage = NULL;
  lagopus_pipeline_stage_t ret_stage1 = NULL;
  lagopus_pipeline_stage_t ret_stage2 = NULL;

  /* create data. */
  pipeline_stage_create(&stage,
                        pipeline_pre_pause,
                        pipeline_sched,
                        pipeline_setup,
                        pipeline_fetch,
                        pipeline_main,
                        pipeline_throw,
                        pipeline_shutdown,
                        pipeline_finalize,
                        pipeline_freeup);

  /* call func (normal - found). */
  ret = lagopus_pipeline_stage_find("lagopus_pipeline_stage_create",
                                    &ret_stage1);
  TEST_ASSERT_EQUAL_MESSAGE(LAGOPUS_RESULT_OK, ret,
                            "lagopus_pipeline_stage_find(normal - found) error.");
  TEST_ASSERT_NOT_EQUAL_MESSAGE(NULL, ret_stage1,
                                "ret_stage is NULL.");

  /* call func (normal - not found). */
  ret = lagopus_pipeline_stage_find("test_not_found",
                                    &ret_stage2);
  TEST_ASSERT_EQUAL_MESSAGE(LAGOPUS_RESULT_NOT_FOUND, ret,
                            "lagopus_pipeline_stage_find(normal- not found) "
                            "error.");
  TEST_ASSERT_EQUAL_MESSAGE(NULL, ret_stage2,
                            "ret_stage is not NULL.");

  /* after. */
  do_stop = true;
  lagopus_pipeline_stage_destroy(&stage);
}
Beispiel #9
0
/** @brief Add a stage to pipeline.
 *
 * @param       pipeline      Pointer to the pipeline to be added to.
 * @param[in]   stage_desc    The description of the stage
 * @param[out]	stage         The successor of the stage.
 * @return      IA_CSS_SUCCESS or error code upon error.
 *
 * Add a new stage to a non-NULL pipeline.
 * The stage consists of an ISP binary or firmware and input and
 * output arguments.
*/
enum ia_css_err ia_css_pipeline_create_and_add_stage(
		struct ia_css_pipeline *pipeline,
		struct ia_css_pipeline_stage_desc *stage_desc,
		struct ia_css_pipeline_stage **stage)
{
	struct ia_css_pipeline_stage *last, *new_stage = NULL;
	enum ia_css_err err;

	/* other arguments can be NULL */
	assert(pipeline != NULL);
	assert(stage_desc != NULL);
	last = pipeline->stages;

	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE,
		      "ia_css_pipeline_create_and_add_stage() enter:\n");
	if (!stage_desc->binary && !stage_desc->firmware
	    && (stage_desc->sp_func == IA_CSS_PIPELINE_NO_FUNC)) {
		ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE,
			      "ia_css_pipeline_create_and_add_stage() done:"
			      " Invalid args\n");

		return IA_CSS_ERR_INTERNAL_ERROR;
	}

	/* Find the last stage */
	while (last && last->next)
		last = last->next;

	/* if in_frame is not set, we use the out_frame from the previous
	 * stage, if no previous stage, it's an error.
	 */
	if ((stage_desc->sp_func == IA_CSS_PIPELINE_NO_FUNC)
		&& (!stage_desc->in_frame)
		&& (!stage_desc->firmware)
		&& (!stage_desc->binary->online)) {

		/* Do this only for ISP stages*/
		if (last && last->args.out_frame[0])
			stage_desc->in_frame = last->args.out_frame[0];

		if (!stage_desc->in_frame)
			return IA_CSS_ERR_INTERNAL_ERROR;
	}

	/* Create the new stage */
	err = pipeline_stage_create(stage_desc, &new_stage);
	if (err != IA_CSS_SUCCESS) {
		ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE,
			      "ia_css_pipeline_create_and_add_stage() done:"
			      " stage_create_failed\n");
		return err;
	}

	if (last)
		last->next = new_stage;
	else
		pipeline->stages = new_stage;

	/* Output the new stage */
	if (stage)
		*stage = new_stage;

	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE,
		      "ia_css_pipeline_create_and_add_stage() done:\n");
	return IA_CSS_SUCCESS;
}