* test allocation and free of mbufs */
| 682 | * test allocation and free of mbufs |
| 683 | */ |
| 684 | static int |
| 685 | test_pktmbuf_pool(struct rte_mempool *pktmbuf_pool) |
| 686 | { |
| 687 | unsigned i; |
| 688 | struct rte_mbuf *m[NB_MBUF]; |
| 689 | int ret = 0; |
| 690 | |
| 691 | for (i=0; i<NB_MBUF; i++) |
| 692 | m[i] = NULL; |
| 693 | |
| 694 | /* alloc NB_MBUF mbufs */ |
| 695 | for (i=0; i<NB_MBUF; i++) { |
| 696 | m[i] = rte_pktmbuf_alloc(pktmbuf_pool); |
| 697 | if (m[i] == NULL) { |
| 698 | printf("rte_pktmbuf_alloc() failed (%u)\n", i); |
| 699 | ret = -1; |
| 700 | } |
| 701 | } |
| 702 | struct rte_mbuf *extra = NULL; |
| 703 | extra = rte_pktmbuf_alloc(pktmbuf_pool); |
| 704 | if(extra != NULL) { |
| 705 | printf("Error pool not empty"); |
| 706 | ret = -1; |
| 707 | } |
| 708 | extra = rte_pktmbuf_clone(m[0], pktmbuf_pool); |
| 709 | if(extra != NULL) { |
| 710 | printf("Error pool not empty"); |
| 711 | ret = -1; |
| 712 | } |
| 713 | /* free them */ |
| 714 | for (i=0; i<NB_MBUF; i++) { |
| 715 | rte_pktmbuf_free(m[i]); |
| 716 | } |
| 717 | |
| 718 | return ret; |
| 719 | } |
| 720 | |
| 721 | /* |
| 722 | * test bulk allocation and bulk free of mbufs |
no test coverage detected