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

Function test_pktmbuf_read

dpdk/app/test/test_mbuf.c:1903–1944  ·  view source on GitHub ↗

* Test to read mbuf packet using rte_pktmbuf_read */

Source from the content-addressed store, hash-verified

1901 * Test to read mbuf packet using rte_pktmbuf_read
1902 */
1903static int
1904test_pktmbuf_read(struct rte_mempool *pktmbuf_pool)
1905{
1906 struct rte_mbuf *m = NULL;
1907 char *data = NULL;
1908 const char *data_copy = NULL;
1909 int off;
1910
1911 /* alloc a mbuf */
1912 m = rte_pktmbuf_alloc(pktmbuf_pool);
1913 if (m == NULL)
1914 GOTO_FAIL("%s: mbuf allocation failed!\n", __func__);
1915 if (rte_pktmbuf_pkt_len(m) != 0)
1916 GOTO_FAIL("%s: Bad packet length\n", __func__);
1917 rte_mbuf_sanity_check(m, 0);
1918
1919 data = rte_pktmbuf_append(m, MBUF_TEST_DATA_LEN2);
1920 if (data == NULL)
1921 GOTO_FAIL("%s: Cannot append data\n", __func__);
1922 if (rte_pktmbuf_pkt_len(m) != MBUF_TEST_DATA_LEN2)
1923 GOTO_FAIL("%s: Bad packet length\n", __func__);
1924 memset(data, 0xfe, MBUF_TEST_DATA_LEN2);
1925
1926 /* read the data from mbuf */
1927 data_copy = rte_pktmbuf_read(m, 0, MBUF_TEST_DATA_LEN2, NULL);
1928 if (data_copy == NULL)
1929 GOTO_FAIL("%s: Error in reading data!\n", __func__);
1930 for (off = 0; off < MBUF_TEST_DATA_LEN2; off++) {
1931 if (data_copy[off] != (char)0xfe)
1932 GOTO_FAIL("Data corrupted at offset %u", off);
1933 }
1934 rte_pktmbuf_free(m);
1935 m = NULL;
1936
1937 return 0;
1938fail:
1939 if (m) {
1940 rte_pktmbuf_free(m);
1941 m = NULL;
1942 }
1943 return -1;
1944}
1945
1946/*
1947 * Test to read mbuf packet data from offset

Callers 2

test_mbufFunction · 0.85

Calls 6

rte_pktmbuf_allocFunction · 0.85
rte_mbuf_sanity_checkFunction · 0.85
rte_pktmbuf_appendFunction · 0.85
memsetFunction · 0.85
rte_pktmbuf_readFunction · 0.85
rte_pktmbuf_freeFunction · 0.85

Tested by

no test coverage detected