From mboxrd@z Thu Jan 1 00:00:00 1970 From: Hemant Agrawal Subject: [PATCH v2 2/2] test/test: support default mempool autotest Date: Mon, 3 Apr 2017 14:30:02 +0530 Message-ID: <1491210002-9519-2-git-send-email-hemant.agrawal@nxp.com> References: <1490955469-16216-1-git-send-email-shreyansh.jain@nxp.com> <1491210002-9519-1-git-send-email-hemant.agrawal@nxp.com> Mime-Version: 1.0 Content-Type: text/plain Cc: , , To: Return-path: Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0066.outbound.protection.outlook.com [104.47.40.66]) by dpdk.org (Postfix) with ESMTP id E97E3DE5 for ; Mon, 3 Apr 2017 11:00:16 +0200 (CEST) In-Reply-To: <1491210002-9519-1-git-send-email-hemant.agrawal@nxp.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" From: Shreyansh Jain Mempool test currently supports: * ring_mp_mc * stack Adding a new default pool options. So, ring* + stack + default (which can be 'stack' or 'ring') * This way, whatever the value of RTE_MBUF_DEFAULT_MEMPOOL_OPS is set, it would be verified. * even if that means duplicating some test (for example when "stack" is set as default and it already part of standard test) Signed-off-by: Shreyansh Jain --- test/test/test_mempool.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/test/test/test_mempool.c b/test/test/test_mempool.c index d863885..aefbf80 100644 --- a/test/test/test_mempool.c +++ b/test/test/test_mempool.c @@ -500,6 +500,12 @@ static int test_mempool_single_consumer(void) return 0; } +static void +walk_cb(struct rte_mempool *mp, void *userdata __rte_unused) +{ + printf("\t%s\n", mp->name); +} + static int test_mempool(void) { @@ -507,6 +513,7 @@ static int test_mempool_single_consumer(void) struct rte_mempool *mp_cache = NULL; struct rte_mempool *mp_nocache = NULL; struct rte_mempool *mp_stack = NULL; + struct rte_mempool *default_pool = NULL; rte_atomic32_init(&synchro); @@ -556,12 +563,39 @@ static int test_mempool_single_consumer(void) } rte_mempool_obj_iter(mp_stack, my_obj_init, NULL); + /* Create a mempool based on Default handler, if not "stack" */ + printf("Testing %s mempool handler\n", + RTE_MBUF_DEFAULT_MEMPOOL_OPS); + default_pool = rte_mempool_create_empty("default_pool", + MEMPOOL_SIZE, + MEMPOOL_ELT_SIZE, + RTE_MEMPOOL_CACHE_MAX_SIZE, 0, + SOCKET_ID_ANY, 0); + + if (default_pool == NULL) { + printf("cannot allocate default mempool\n"); + goto err; + } + if (rte_mempool_set_ops_byname(default_pool, + RTE_MBUF_DEFAULT_MEMPOOL_OPS, NULL) < 0) { + printf("cannot set default handler\n"); + goto err; + } + if (rte_mempool_populate_default(default_pool) < 0) { + printf("cannot populate default mempool\n"); + goto err; + } + rte_mempool_obj_iter(default_pool, my_obj_init, NULL); + /* retrieve the mempool from its name */ if (rte_mempool_lookup("test_nocache") != mp_nocache) { printf("Cannot lookup mempool from its name\n"); goto err; } + printf("Walk into mempools:\n"); + rte_mempool_walk(walk_cb, NULL); + rte_mempool_list_dump(stdout); /* basic tests without cache */ @@ -597,6 +631,9 @@ static int test_mempool_single_consumer(void) if (test_mempool_basic(mp_stack, 1) < 0) goto err; + if (test_mempool_basic(default_pool, 1) < 0) + goto err; + rte_mempool_list_dump(stdout); ret = 0; @@ -605,6 +642,7 @@ static int test_mempool_single_consumer(void) rte_mempool_free(mp_nocache); rte_mempool_free(mp_cache); rte_mempool_free(mp_stack); + rte_mempool_free(default_pool); return ret; } -- 1.9.1