MCPcopy Create free account
hub / github.com/F-Stack/f-stack / test_mempool_basic_ex

Function test_mempool_basic_ex

dpdk/app/test/test_mempool.c:380–436  ·  view source on GitHub ↗

* it tests some more basic of mempool */

Source from the content-addressed store, hash-verified

378 * it tests some more basic of mempool
379 */
380static int
381test_mempool_basic_ex(struct rte_mempool *mp)
382{
383 unsigned i;
384 void **obj;
385 void *err_obj;
386 int ret = -1;
387
388 if (mp == NULL)
389 return ret;
390
391 obj = rte_calloc("test_mempool_basic_ex", MEMPOOL_SIZE,
392 sizeof(void *), 0);
393 if (obj == NULL) {
394 printf("test_mempool_basic_ex fail to rte_malloc\n");
395 return ret;
396 }
397 printf("test_mempool_basic_ex now mempool (%s) has %u free entries\n",
398 mp->name, rte_mempool_in_use_count(mp));
399 if (rte_mempool_full(mp) != 1) {
400 printf("test_mempool_basic_ex the mempool should be full\n");
401 goto fail_mp_basic_ex;
402 }
403
404 for (i = 0; i < MEMPOOL_SIZE; i ++) {
405 if (rte_mempool_get(mp, &obj[i]) < 0) {
406 printf("test_mp_basic_ex fail to get object for [%u]\n",
407 i);
408 goto fail_mp_basic_ex;
409 }
410 }
411 if (rte_mempool_get(mp, &err_obj) == 0) {
412 printf("test_mempool_basic_ex get an impossible obj\n");
413 goto fail_mp_basic_ex;
414 }
415 printf("number: %u\n", i);
416 if (rte_mempool_empty(mp) != 1) {
417 printf("test_mempool_basic_ex the mempool should be empty\n");
418 goto fail_mp_basic_ex;
419 }
420
421 for (i = 0; i < MEMPOOL_SIZE; i++)
422 rte_mempool_put(mp, obj[i]);
423
424 if (rte_mempool_full(mp) != 1) {
425 printf("test_mempool_basic_ex the mempool should be full\n");
426 goto fail_mp_basic_ex;
427 }
428
429 ret = 0;
430
431fail_mp_basic_ex:
432 if (obj != NULL)
433 rte_free((void *)obj);
434
435 return ret;
436}
437

Callers 1

test_mempoolFunction · 0.85

Calls 8

rte_callocFunction · 0.85
rte_mempool_in_use_countFunction · 0.85
rte_mempool_fullFunction · 0.85
rte_mempool_getFunction · 0.85
rte_mempool_emptyFunction · 0.85
rte_mempool_putFunction · 0.85
rte_freeFunction · 0.85
printfFunction · 0.50

Tested by

no test coverage detected