From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 1F24A1B21A for ; Thu, 11 Jan 2018 01:21:41 +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 fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Jan 2018 16:21:41 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,342,1511856000"; d="scan'208";a="192627455" 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:40 -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:21:02 -0600 Message-Id: <1515630074-29020-12-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 11/23] test: exercise event timer adapter start/stop 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:42 -0000 Signed-off-by: Erik Gabriel Carrillo --- test/test/test_event_timer_adapter.c | 77 +++++++++++++++++++++++++++++++++++- 1 file changed, 76 insertions(+), 1 deletion(-) diff --git a/test/test/test_event_timer_adapter.c b/test/test/test_event_timer_adapter.c index c8623aa..58cbaba 100644 --- a/test/test/test_event_timer_adapter.c +++ b/test/test/test_event_timer_adapter.c @@ -49,8 +49,11 @@ #define TEST_PORT_ID 0 #define TEST_QUEUE_ID 0 +#define NSECPERSEC 1E9 + static int evdev; struct rte_mempool *g_event_timer_pool; +struct rte_event_timer_adapter *g_adapter; static inline void devconf_set_test_values(struct rte_event_dev_config *dev_conf, @@ -158,7 +161,33 @@ testsuite_teardown(void) rte_mempool_free(g_event_timer_pool); } -#define NSECPERSEC 1E9 +static int +adapter_create(void) +{ + int adapter_id = 0; + + struct rte_event_timer_adapter_conf conf = { + .event_dev_id = 0, + .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, + }; + + g_adapter = rte_event_timer_adapter_create(&conf); + TEST_ASSERT(g_adapter != NULL, "Failed to create event timer adapter"); + + return TEST_SUCCESS; +} + +static void +adapter_free(void) +{ + (void) rte_event_timer_adapter_free(g_adapter); +} + static int adapter_create_free(void) { @@ -245,12 +274,58 @@ adapter_create_free(void) return TEST_SUCCESS; } +/* TODO: test multiple starts */ +static int +adapter_start_stop(void) +{ + int ret; + uint32_t service_id; + struct rte_event_timer_adapter *l_adapter = NULL; + + ret = rte_event_timer_adapter_start(l_adapter); + TEST_ASSERT(ret < 0, "Erroneously started null adapter, ret = %d", ret); + + /* Check that we fail when no service core is mapped */ + ret = rte_event_timer_adapter_start(g_adapter); + TEST_ASSERT(ret == -ENOENT, "Erroneously started adapter with no " + "service core mapped"); + + TEST_ASSERT_SUCCESS(rte_event_timer_adapter_service_id_get(g_adapter, + &service_id), + "Failed to get event timer adapter service id"); + + TEST_ASSERT(rte_service_lcore_count() > 0, "Need one or more service " + "cores to perform this test"); + + /* Could map using service_id, but just do default mapping */ + ret = rte_service_start_with_defaults(); + TEST_ASSERT(ret == 0, "Failed to start services"); + + ret = rte_event_timer_adapter_start(g_adapter); + TEST_ASSERT(ret == 0, "Failed to start adapter"); + + ret = rte_event_timer_adapter_start(g_adapter); + TEST_ASSERT(ret == 0, "Failed to repeatedly start adapter"); + + ret = rte_event_timer_adapter_stop(g_adapter); + TEST_ASSERT(ret == 0, "Failed to stop event adapter, ret = %d", ret); + + ret = rte_event_timer_adapter_stop(l_adapter); + TEST_ASSERT(ret < 0, "Erroneously stopped event adapter, ret = %d", + ret); + + rte_service_lcore_reset_all(); + + 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_CASE_ST(adapter_create, adapter_free, adapter_start_stop), TEST_CASES_END() /**< NULL terminate unit test array */ } }; -- 2.6.4