From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jerin Jacob Subject: Re: [PATCH 5/6] service core: add unit tests Date: Mon, 26 Jun 2017 18:36:10 +0530 Message-ID: <20170626130609.GD5612@jerin> References: <1498208779-166205-1-git-send-email-harry.van.haaren@intel.com> <1498208779-166205-5-git-send-email-harry.van.haaren@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: dev@dpdk.org, thomas@monjalon.net, keith.wiles@intel.com, bruce.richardson@intel.com To: Harry van Haaren Return-path: Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-bn3nam01on0078.outbound.protection.outlook.com [104.47.33.78]) by dpdk.org (Postfix) with ESMTP id 649B0374 for ; Mon, 26 Jun 2017 15:06:32 +0200 (CEST) Content-Disposition: inline In-Reply-To: <1498208779-166205-5-git-send-email-harry.van.haaren@intel.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" -----Original Message----- > Date: Fri, 23 Jun 2017 10:06:18 +0100 > From: Harry van Haaren > To: dev@dpdk.org > CC: thomas@monjalon.net, jerin.jacob@caviumnetworks.com, > keith.wiles@intel.com, bruce.richardson@intel.com, Harry van Haaren > > Subject: [PATCH 5/6] service core: add unit tests > X-Mailer: git-send-email 2.7.4 > > Add a bunch of unit tests, to ensure that the service > core functions are operating as expected. > > As part of these tests a dummy service is registered which > allows identifying if a service callback has been invoked > by using the CPU tick counter. This allows identifying if > functions to start and stop service lcores are actually having > effect. > > Signed-off-by: Harry van Haaren > --- > +#define SERVICE_DELAY 1 > + > +static int > +testsuite_setup(void) > +{ > + /* assuming lcore 1 is available for service-core testing */ We can check the number of available lcores is >= 2. > + score_id = 1; How about slcore_id? > + return TEST_SUCCESS; > +} > + > +static void > +testsuite_teardown(void) > +{ > + /* release service cores? */ > +} > + > +static int32_t dummy_cb(void *args) > +{ > + RTE_SET_USED(args); > + service_tick++; > + rte_delay_ms(SERVICE_DELAY); > + return 0; > +} > + > +/* unregister all services */ > +static int > +dummy_unregister(void) How about unregister_all(void) as it is un registering all services. > +{ > + uint32_t i; > + struct rte_service_spec *dead = (struct rte_service_spec *)0xdead; > + > + TEST_ASSERT_EQUAL(-EINVAL, rte_service_unregister(0), > + "Unregistered NULL pointer"); > + TEST_ASSERT_EQUAL(-EINVAL, rte_service_unregister(dead), > + "Unregistered invalid pointer"); > + > + uint32_t c = rte_service_get_count(); > + for (i = 0; i < c; i++) { > + struct rte_service_spec *s = rte_service_get_by_id(i); > + TEST_ASSERT_EQUAL(0, rte_service_unregister(s), > + "Error unregistering a valid service"); > + } > + > + rte_service_core_reset_all(); > + > + return TEST_SUCCESS; > +} > + > +/* enable and disable a core for a service */ > +static int > +service_core_enable_disable(void) > +{ > + struct rte_service_spec *s = rte_service_get_by_id(0); > + > + /* expected failure cases */ > + TEST_ASSERT_EQUAL(-EINVAL, rte_service_enable_on_core(s, 100000), > + "Enable on invalid core did not fail"); > + TEST_ASSERT_EQUAL(-EINVAL, rte_service_disable_on_core(s, 100000), > + "Dispable on invalid core did not fail"); s/Dispable/Disable > + > + /* add service core to allow enabling */ > + TEST_ASSERT_EQUAL(0, rte_service_core_add(score_id), > + "Add service core failed when not in use before"); > + > + /* valid enable */ > + TEST_ASSERT_EQUAL(0, rte_service_enable_on_core(s, score_id), > + "Enabling valid service and core failed"); > + TEST_ASSERT_EQUAL(1, rte_service_get_enabled_on_core(s, score_id), > + "Enabled core returned not-enabled"); > + > + /* valid disable */ > + TEST_ASSERT_EQUAL(0, rte_service_disable_on_core(s, score_id), > + "Disabling valid service and core failed"); > + TEST_ASSERT_EQUAL(0, rte_service_get_enabled_on_core(s, score_id), > + "Disabled core returned enabled"); > + > + return dummy_unregister(); > +} > + > +static struct unit_test_suite service_tests = { > + .suite_name = "service core test suite", > + .setup = testsuite_setup, > + .teardown = testsuite_teardown, > + .unit_test_cases = { > + TEST_CASE_ST(dummy_register, NULL, dummy_unregister), > + TEST_CASE_ST(dummy_register, NULL, service_start_stop), > + TEST_CASE_ST(dummy_register, NULL, service_core_add_del), > + TEST_CASE_ST(dummy_register, NULL, service_core_start_stop), > + TEST_CASE_ST(dummy_register, NULL, service_core_enable_disable), IMO, Following functions/functionality coverage is missing. How about add that in unit test case. 1) rte_service_get_name() 2) Verify RTE_SERVICE_CAP_MT_SAFE with available lcores 3) rte_service_probe_capability() 4) rte_service_dump() 5) Moving service lcore to/from rte lcore back and forth.