[dpdk-dev] [PATCH v3 2/2] test/service: add test for service active on two lcores

Honnappa Nagarahalli Honnappa.Nagarahalli at arm.com
Tue Jul 7 21:47:39 CEST 2020



> -----Original Message-----
> From: dev <dev-bounces at dpdk.org> On Behalf Of Andrew Rybchenko
> Sent: Tuesday, July 7, 2020 5:45 AM
> To: dev at dpdk.org
> Cc: Igor Romanov <igor.romanov at oktetlabs.ru>; Harry van Haaren
> <harry.van.haaren at intel.com>
> Subject: [dpdk-dev] [PATCH v3 2/2] test/service: add test for service active on
> two lcores
> 
> From: Igor Romanov <igor.romanov at oktetlabs.ru>
> 
> The test checks that the service may be active API works when there are two
> cores: a non-service lcore and a service one.
> 
> The API notes to take care when checking the status of a running service, but
> the test setup allows for a safe usage in that case.
> 
> Signed-off-by: Igor Romanov <igor.romanov at oktetlabs.ru>
> Signed-off-by: Andrew Rybchenko <arybchenko at solarflare.com>
Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli at arm.com>

> ---
> v3:
>  - skip the test if number of cores is insufficient
> 
>  app/test/test_service_cores.c | 54 +++++++++++++++++++++++++++++++++++
>  1 file changed, 54 insertions(+)
> 
> diff --git a/app/test/test_service_cores.c b/app/test/test_service_cores.c index
> 981e212130..4f003ed1af 100644
> --- a/app/test/test_service_cores.c
> +++ b/app/test/test_service_cores.c
> @@ -910,6 +910,59 @@ service_may_be_active(void)
>  	return unregister_all();
>  }
> 
> +/* check service may be active when service is running on a second
> +lcore */ static int
> +service_active_two_cores(void)
> +{
> +	if (!rte_lcore_is_enabled(0) || !rte_lcore_is_enabled(1) ||
> +	    !rte_lcore_is_enabled(2))
> +		return TEST_SKIPPED;
> +
> +	const uint32_t sid = 0;
> +	int i;
> +
> +	uint32_t lcore = rte_get_next_lcore(/* start core */ -1,
> +					    /* skip master */ 1,
> +					    /* wrap */ 0);
> +	uint32_t slcore = rte_get_next_lcore(/* start core */ lcore,
> +					     /* skip master */ 1,
> +					     /* wrap */ 0);
> +
> +	/* start the service on the second available lcore */
> +	TEST_ASSERT_EQUAL(0, rte_service_runstate_set(sid, 1),
> +			"Starting valid service failed");
> +	TEST_ASSERT_EQUAL(0, rte_service_lcore_add(slcore),
> +			"Add service core failed when not in use before");
> +	TEST_ASSERT_EQUAL(0, rte_service_map_lcore_set(sid, slcore, 1),
> +			"Enabling valid service on valid core failed");
> +	TEST_ASSERT_EQUAL(0, rte_service_lcore_start(slcore),
> +			"Service core start after add failed");
> +
> +	/* ensures core really is running the service function */
> +	TEST_ASSERT_EQUAL(1, service_lcore_running_check(),
> +			"Service core expected to poll service but it didn't");
> +
> +	/* ensures that service may be active reports running state */
> +	TEST_ASSERT_EQUAL(1, rte_service_may_be_active(sid),
> +			"Service may be active did not report running state");
> +
> +	/* stop the service */
> +	TEST_ASSERT_EQUAL(0, rte_service_runstate_set(sid, 0),
> +			"Error: Service stop returned non-zero");
> +
> +	/* give the service 100ms to stop running */
> +	for (i = 0; i < 100; i++) {
> +		if (!rte_service_may_be_active(sid))
> +			break;
> +		rte_delay_ms(SERVICE_DELAY);
> +	}
> +
> +	TEST_ASSERT_EQUAL(0, rte_service_may_be_active(sid),
> +			  "Error: Service not stopped after 100ms");
> +
> +	return unregister_all();
> +}
> +
>  static struct unit_test_suite service_tests  = {
>  	.suite_name = "service core test suite",
>  	.setup = testsuite_setup,
> @@ -931,6 +984,7 @@ static struct unit_test_suite service_tests  = {
>  		TEST_CASE_ST(dummy_register, NULL,
> service_app_lcore_mt_safe),
>  		TEST_CASE_ST(dummy_register, NULL,
> service_app_lcore_mt_unsafe),
>  		TEST_CASE_ST(dummy_register, NULL, service_may_be_active),
> +		TEST_CASE_ST(dummy_register, NULL,
> service_active_two_cores),
>  		TEST_CASES_END() /**< NULL terminate unit test array */
>  	}
>  };
> --
> 2.17.1



More information about the dev mailing list