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

Function test_ring_basic_ex

dpdk/app/test/test_ring.c:961–1077  ·  view source on GitHub ↗

* Test default, single element, bulk and burst APIs */

Source from the content-addressed store, hash-verified

959 * Test default, single element, bulk and burst APIs
960 */
961static int
962test_ring_basic_ex(void)
963{
964 int ret = -1;
965 unsigned int i, j;
966 struct rte_ring *rp = NULL;
967 void **src = NULL, **cur_src = NULL, **dst = NULL, **cur_dst = NULL;
968
969 for (i = 0; i < RTE_DIM(esize); i++) {
970 rp = test_ring_create("test_ring_basic_ex", esize[i], RING_SIZE,
971 SOCKET_ID_ANY,
972 RING_F_SP_ENQ | RING_F_SC_DEQ);
973 if (rp == NULL) {
974 printf("%s: failed to create ring\n", __func__);
975 goto fail_test;
976 }
977
978 /* alloc dummy object pointers */
979 src = test_ring_calloc(RING_SIZE, esize[i]);
980 if (src == NULL) {
981 printf("%s: failed to alloc src memory\n", __func__);
982 goto fail_test;
983 }
984 test_ring_mem_init(src, RING_SIZE, esize[i]);
985 cur_src = src;
986
987 /* alloc some room for copied objects */
988 dst = test_ring_calloc(RING_SIZE, esize[i]);
989 if (dst == NULL) {
990 printf("%s: failed to alloc dst memory\n", __func__);
991 goto fail_test;
992 }
993 cur_dst = dst;
994
995 TEST_RING_VERIFY(rte_ring_lookup("test_ring_basic_ex") == rp,
996 rp, goto fail_test);
997
998 TEST_RING_VERIFY(rte_ring_empty(rp) == 1, rp, goto fail_test);
999
1000 printf("%u ring entries are now free\n",
1001 rte_ring_free_count(rp));
1002
1003 for (j = 0; j < RING_SIZE - 1; j++) {
1004 ret = test_ring_enqueue(rp, cur_src, esize[i], 1,
1005 TEST_RING_THREAD_DEF | TEST_RING_ELEM_SINGLE);
1006 TEST_RING_VERIFY(ret == 0, rp, goto fail_test);
1007 cur_src = test_ring_inc_ptr(cur_src, esize[i], 1);
1008 }
1009
1010 TEST_RING_VERIFY(rte_ring_full(rp) == 1, rp, goto fail_test);
1011
1012 for (j = 0; j < RING_SIZE - 1; j++) {
1013 ret = test_ring_dequeue(rp, cur_dst, esize[i], 1,
1014 TEST_RING_THREAD_DEF | TEST_RING_ELEM_SINGLE);
1015 TEST_RING_VERIFY(ret == 0, rp, goto fail_test);
1016 cur_dst = test_ring_inc_ptr(cur_dst, esize[i], 1);
1017 }
1018

Callers 1

test_ringFunction · 0.85

Calls 15

test_ring_createFunction · 0.85
test_ring_callocFunction · 0.85
test_ring_mem_initFunction · 0.85
rte_ring_lookupFunction · 0.85
rte_ring_emptyFunction · 0.85
rte_ring_free_countFunction · 0.85
test_ring_enqueueFunction · 0.85
test_ring_inc_ptrFunction · 0.85
rte_ring_fullFunction · 0.85
test_ring_dequeueFunction · 0.85
test_ring_mem_cmpFunction · 0.85
memsetFunction · 0.85

Tested by

no test coverage detected