From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 1C4121B1DC for ; Thu, 11 Jan 2018 01:21:37 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Jan 2018 16:21:37 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,342,1511856000"; d="scan'208";a="192627442" Received: from txasoft-yocto.an.intel.com (HELO txasoft-yocto.an.intel.com.) ([10.123.72.111]) by orsmga005.jf.intel.com with ESMTP; 10 Jan 2018 16:21:37 -0800 From: Erik Gabriel Carrillo To: pbhagavatula@caviumnetworks.com Cc: dev@dpdk.org, jerin.jacob@caviumnetworks.com, nipun.gupta@nxp.com, hemant.agrawal@nxp.com Date: Wed, 10 Jan 2018 18:20:57 -0600 Message-Id: <1515630074-29020-7-git-send-email-erik.g.carrillo@intel.com> X-Mailer: git-send-email 1.7.10 In-Reply-To: <1515630074-29020-1-git-send-email-erik.g.carrillo@intel.com> References: <1512158458-22661-1-git-send-email-erik.g.carrillo@intel.com> <1515630074-29020-1-git-send-email-erik.g.carrillo@intel.com> Subject: [dpdk-dev] [PATCH v6 06/23] test: exercise event timer adapter allocation functions X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Jan 2018 00:21:40 -0000 Exercise the create and free functions in the event timer adapter auto-test. Signed-off-by: Erik Gabriel Carrillo --- test/test/test_event_timer_adapter.c | 88 ++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/test/test/test_event_timer_adapter.c b/test/test/test_event_timer_adapter.c index cbd206a..c8623aa 100644 --- a/test/test/test_event_timer_adapter.c +++ b/test/test/test_event_timer_adapter.c @@ -158,11 +158,99 @@ testsuite_teardown(void) rte_mempool_free(g_event_timer_pool); } +#define NSECPERSEC 1E9 +static int +adapter_create_free(void) +{ + int adapter_id = 0; + uint32_t svc_start_count, svc_end_count; + struct rte_event_timer_adapter *adapters[ + RTE_EVENT_TIMER_ADAPTER_NUM_MAX + 1]; + + struct rte_event_timer_adapter_conf conf = { + .event_dev_id = evdev + 1, // invalid event dev id + .timer_adapter_id = adapter_id, + .clk_src = RTE_EVENT_TIMER_ADAPTER_CPU_CLK, + .timer_tick_ns = NSECPERSEC / 10, + .max_tmo_ns = 180 * NSECPERSEC, + .nb_timers = NB_TEST_EVENT_TIMERS, + .flags = 0, + }; + + svc_start_count = rte_service_get_count(); + + /* Test create */ + + /* Test invalid conf */ + adapters[0] = rte_event_timer_adapter_create(&conf); + TEST_ASSERT(adapters[0] == NULL, "Erroneously created adapter with " + "invalid event device id"); + /* TODO: Should errno values be negative? */ + TEST_ASSERT(rte_errno == -EINVAL, "Incorrect errno value for invalid " + "event device id"); + + /* Test valid conf */ + conf.event_dev_id = evdev; + adapters[0] = rte_event_timer_adapter_create(&conf); + TEST_ASSERT(adapters[0] != NULL, "Failed to create adapter with valid " + "configuration"); + + /* Test existing id */ + adapters[1] = rte_event_timer_adapter_create(&conf); + TEST_ASSERT(adapters[1] == NULL, "Erroneusly created adapter with " + "existing id"); + TEST_ASSERT(rte_errno == -EEXIST, "Incorrect errno value for existing " + "id"); + + /* Test instance limit */ + int i; + for (i = adapter_id + 1; i < RTE_EVENT_TIMER_ADAPTER_NUM_MAX; i++) { + conf.timer_adapter_id = i; + adapters[i] = rte_event_timer_adapter_create(&conf); + TEST_ASSERT(adapters[i] != NULL, "Failed to create adapter " + "with valid configuration"); + } + conf.timer_adapter_id = i; + adapters[i] = rte_event_timer_adapter_create(&conf); + TEST_ASSERT(adapters[i] == NULL, "Erroneously created excess adapters"); + + /* Check that at least RTE_EVENT_TIMER_ADAPTER_NUM_MAX services + * have been created + */ + svc_end_count = rte_service_get_count(); + TEST_ASSERT(svc_end_count - svc_start_count == + RTE_EVENT_TIMER_ADAPTER_NUM_MAX, + "Failed to create expected number of services"); + + /* Test free */ + + int ret; + for (i = 0; i < RTE_EVENT_TIMER_ADAPTER_NUM_MAX; i++) { + ret = rte_event_timer_adapter_free(adapters[i]); + TEST_ASSERT(ret == 0, "Failed to free adapter %d, ret = %d", i, + ret); + } + + /* Test free of already freed adapter */ + ret = rte_event_timer_adapter_free(adapters[0]); + TEST_ASSERT(ret < 0, "Erroneously freed adapter that was previously " + "freed"); + + /* Test free of null adapter */ + adapters[0] = NULL; + ret = rte_event_timer_adapter_free(adapters[0]); + TEST_ASSERT(ret < 0, "Erroneously freed adapter that was previously " + "freed"); + + return TEST_SUCCESS; +} + static struct unit_test_suite adapter_tests = { .suite_name = "event timer adapter test suite", .setup = testsuite_setup, .teardown = testsuite_teardown, .unit_test_cases = { + TEST_CASE(adapter_create_free), TEST_CASES_END() /**< NULL terminate unit test array */ } }; -- 2.6.4