[dpdk-dev] [RFC PATCH] test/test: support default mempool autotest

Shreyansh Jain shreyansh.jain at nxp.com
Fri Mar 31 12:17:49 CEST 2017


Mempool test currently supports:
 * ring_mp_mc
 * stack

In case a new mempool handler is added, there are multiple options
for supporting that in the mempool autotest:
1. Like the patch below, 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)

2. Removing stack handler as standard, and moving only to one specified
   by RTE_MBUF_DEFAULT_MEMPOOL_OPS (+ existing ring*)
 * It still leaves space for duplication of ring_mp_mc in case that is
   set to default (as in case of master tree)

3. Iterating over the list of mempool handlers and performing a set
   or predefined tests
 * reqiures quite a lot of rewrite of mempool autotest
 * specially, allowing some special tests (cache/no-cache) cases when
   a set of variables in loop are being used, would be tricky

4. only checking the default pool set by RTE_* macro
 * In case a user has build DPDK using a configured value, probably it
   expected that application (or custom applications) would use that
   default handler.
 * would also mean that non-default (non RTE_* value) would not be tested
   even though they are being used.

The decision above would impact how new mempool handlers are added and
how their testing (API verification) can be done without impacting the
mempool_autotest file everytime.

Signed-off-by: Shreyansh Jain <shreyansh.jain at nxp.com>

---
 test/test/test_mempool.c | 35 +++++++++++++++++++++++++++++++++--
 1 file changed, 33 insertions(+), 2 deletions(-)

diff --git a/test/test/test_mempool.c b/test/test/test_mempool.c
index b9880b3..aefbf80 100644
--- a/test/test/test_mempool.c
+++ b/test/test/test_mempool.c
@@ -509,9 +509,11 @@ walk_cb(struct rte_mempool *mp, void *userdata __rte_unused)
 static int
 test_mempool(void)
 {
+	int ret = -1;
 	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);
 
@@ -561,6 +563,30 @@ test_mempool(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");
@@ -605,15 +631,20 @@ test_mempool(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);
 
-	return 0;
+	ret = 0;
 
 err:
 	rte_mempool_free(mp_nocache);
 	rte_mempool_free(mp_cache);
 	rte_mempool_free(mp_stack);
-	return -1;
+	rte_mempool_free(default_pool);
+
+	return ret;
 }
 
 REGISTER_TEST_COMMAND(mempool_autotest, test_mempool);
-- 
2.7.4



More information about the dev mailing list