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

Function test_neg_pktmbuf_alloc_bulk

dpdk/app/test/test_mbuf.c:1872–1898  ·  view source on GitHub ↗

* Negative testing for allocating a bulk of mbufs */

Source from the content-addressed store, hash-verified

1870 * Negative testing for allocating a bulk of mbufs
1871 */
1872static int
1873test_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

Callers 2

test_mbufFunction · 0.85

Calls 3

rte_pktmbuf_alloc_bulkFunction · 0.85
rte_pktmbuf_freeFunction · 0.85
printfFunction · 0.50

Tested by

no test coverage detected