* Negative testing for allocating a bulk of mbufs */
| 1870 | * Negative testing for allocating a bulk of mbufs |
| 1871 | */ |
| 1872 | static int |
| 1873 | test_neg_pktmbuf_alloc_bulk(struct rte_mempool *pktmbuf_pool) |
| 1874 | { |
| 1875 | int ret = 0; |
| 1876 | unsigned int idx, loop; |
| 1877 | unsigned int neg_alloc_counts[] = { |
| 1878 | MEMPOOL_CACHE_SIZE - NB_MBUF, |
| 1879 | NB_MBUF + 1, |
| 1880 | NB_MBUF * 8, |
| 1881 | UINT_MAX |
| 1882 | }; |
| 1883 | struct rte_mbuf *mbufs[NB_MBUF * 8] = { 0 }; |
| 1884 | |
| 1885 | for (idx = 0; idx < RTE_DIM(neg_alloc_counts); idx++) { |
| 1886 | ret = rte_pktmbuf_alloc_bulk(pktmbuf_pool, mbufs, |
| 1887 | neg_alloc_counts[idx]); |
| 1888 | if (ret == 0) { |
| 1889 | printf("%s: Bulk alloc must fail! count(%u); ret(%d)\n", |
| 1890 | __func__, neg_alloc_counts[idx], ret); |
| 1891 | for (loop = 0; loop < neg_alloc_counts[idx] && |
| 1892 | mbufs[loop] != NULL; loop++) |
| 1893 | rte_pktmbuf_free(mbufs[loop]); |
| 1894 | return -1; |
| 1895 | } |
| 1896 | } |
| 1897 | return 0; |
| 1898 | } |
| 1899 | |
| 1900 | /* |
| 1901 | * Test to read mbuf packet using rte_pktmbuf_read |
no test coverage detected