X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=test%2Ftest%2Ftest_ring.c;h=858ebc1da39771ff2cf4c5dd1ca6f8d4f8e747c9;hb=f1ae15bac8aaa75aeb4fa886fd4d74d34c373193;hp=3891f5dc8c3ea3ec416582c6e688433599465eee;hpb=8c82198978a1b47553e47a8caeced22f325ad573;p=dpdk.git diff --git a/test/test/test_ring.c b/test/test/test_ring.c index 3891f5dc8c..858ebc1da3 100644 --- a/test/test/test_ring.c +++ b/test/test/test_ring.c @@ -78,21 +78,6 @@ * - Dequeue one object, two objects, MAX_BULK objects * - Check that dequeued pointers are correct * - * - Test watermark and default bulk enqueue/dequeue: - * - * - Set watermark - * - Set default bulk value - * - Enqueue objects, check that -EDQUOT is returned when - * watermark is exceeded - * - Check that dequeued pointers are correct - * - * #. Check live watermark change - * - * - Start a loop on another lcore that will enqueue and dequeue - * objects in a ring. It will monitor the value of watermark. - * - At the same time, change the watermark on the master lcore. - * - The slave lcore will check that watermark changes from 16 to 32. - * * #. Performance tests. * * Tests done in test_ring_perf.c @@ -115,123 +100,6 @@ static struct rte_ring *r; #define TEST_RING_FULL_EMTPY_ITER 8 -static int -check_live_watermark_change(__attribute__((unused)) void *dummy) -{ - uint64_t hz = rte_get_timer_hz(); - void *obj_table[MAX_BULK]; - unsigned watermark, watermark_old = 16; - uint64_t cur_time, end_time; - int64_t diff = 0; - int i, ret; - unsigned count = 4; - - /* init the object table */ - memset(obj_table, 0, sizeof(obj_table)); - end_time = rte_get_timer_cycles() + (hz / 4); - - /* check that bulk and watermark are 4 and 32 (respectively) */ - while (diff >= 0) { - - /* add in ring until we reach watermark */ - ret = 0; - for (i = 0; i < 16; i ++) { - if (ret != 0) - break; - ret = rte_ring_enqueue_bulk(r, obj_table, count); - } - - if (ret != -EDQUOT) { - printf("Cannot enqueue objects, or watermark not " - "reached (ret=%d)\n", ret); - return -1; - } - - /* read watermark, the only change allowed is from 16 to 32 */ - watermark = r->watermark; - if (watermark != watermark_old && - (watermark_old != 16 || watermark != 32)) { - printf("Bad watermark change %u -> %u\n", watermark_old, - watermark); - return -1; - } - watermark_old = watermark; - - /* dequeue objects from ring */ - while (i--) { - ret = rte_ring_dequeue_bulk(r, obj_table, count); - if (ret != 0) { - printf("Cannot dequeue (ret=%d)\n", ret); - return -1; - } - } - - cur_time = rte_get_timer_cycles(); - diff = end_time - cur_time; - } - - if (watermark_old != 32 ) { - printf(" watermark was not updated (wm=%u)\n", - watermark_old); - return -1; - } - - return 0; -} - -static int -test_live_watermark_change(void) -{ - unsigned lcore_id = rte_lcore_id(); - unsigned lcore_id2 = rte_get_next_lcore(lcore_id, 0, 1); - - printf("Test watermark live modification\n"); - rte_ring_set_water_mark(r, 16); - - /* launch a thread that will enqueue and dequeue, checking - * watermark and quota */ - rte_eal_remote_launch(check_live_watermark_change, NULL, lcore_id2); - - rte_delay_ms(100); - rte_ring_set_water_mark(r, 32); - rte_delay_ms(100); - - if (rte_eal_wait_lcore(lcore_id2) < 0) - return -1; - - return 0; -} - -/* Test for catch on invalid watermark values */ -static int -test_set_watermark( void ){ - unsigned count; - int setwm; - - struct rte_ring *r = rte_ring_lookup("test_ring_basic_ex"); - if(r == NULL){ - printf( " ring lookup failed\n" ); - goto error; - } - count = r->size * 2; - setwm = rte_ring_set_water_mark(r, count); - if (setwm != -EINVAL){ - printf("Test failed to detect invalid watermark count value\n"); - goto error; - } - - count = 0; - rte_ring_set_water_mark(r, count); - if (r->watermark != r->size) { - printf("Test failed to detect invalid watermark count value\n"); - goto error; - } - return 0; - -error: - return -1; -} - /* * helper routine for test_ring_basic */ @@ -249,20 +117,21 @@ test_ring_basic_full_empty(void * const src[], void *dst[]) rand = RTE_MAX(rte_rand() % RING_SIZE, 1UL); printf("%s: iteration %u, random shift: %u;\n", __func__, i, rand); - TEST_RING_VERIFY(-ENOBUFS != rte_ring_enqueue_bulk(r, src, - rand)); - TEST_RING_VERIFY(0 == rte_ring_dequeue_bulk(r, dst, rand)); + TEST_RING_VERIFY(rte_ring_enqueue_bulk(r, src, rand, + NULL) != 0); + TEST_RING_VERIFY(rte_ring_dequeue_bulk(r, dst, rand, + NULL) == rand); /* fill the ring */ - TEST_RING_VERIFY(-ENOBUFS != rte_ring_enqueue_bulk(r, src, - rsz)); + TEST_RING_VERIFY(rte_ring_enqueue_bulk(r, src, rsz, NULL) != 0); TEST_RING_VERIFY(0 == rte_ring_free_count(r)); TEST_RING_VERIFY(rsz == rte_ring_count(r)); TEST_RING_VERIFY(rte_ring_full(r)); TEST_RING_VERIFY(0 == rte_ring_empty(r)); /* empty the ring */ - TEST_RING_VERIFY(0 == rte_ring_dequeue_bulk(r, dst, rsz)); + TEST_RING_VERIFY(rte_ring_dequeue_bulk(r, dst, rsz, + NULL) == rsz); TEST_RING_VERIFY(rsz == rte_ring_free_count(r)); TEST_RING_VERIFY(0 == rte_ring_count(r)); TEST_RING_VERIFY(0 == rte_ring_full(r)); @@ -301,39 +170,39 @@ test_ring_basic(void) cur_dst = dst; printf("enqueue 1 obj\n"); - ret = rte_ring_sp_enqueue_bulk(r, cur_src, 1); + ret = rte_ring_sp_enqueue_bulk(r, cur_src, 1, NULL); cur_src += 1; - if (ret != 0) + if (ret == 0) goto fail; printf("enqueue 2 objs\n"); - ret = rte_ring_sp_enqueue_bulk(r, cur_src, 2); + ret = rte_ring_sp_enqueue_bulk(r, cur_src, 2, NULL); cur_src += 2; - if (ret != 0) + if (ret == 0) goto fail; printf("enqueue MAX_BULK objs\n"); - ret = rte_ring_sp_enqueue_bulk(r, cur_src, MAX_BULK); + ret = rte_ring_sp_enqueue_bulk(r, cur_src, MAX_BULK, NULL); cur_src += MAX_BULK; - if (ret != 0) + if (ret == 0) goto fail; printf("dequeue 1 obj\n"); - ret = rte_ring_sc_dequeue_bulk(r, cur_dst, 1); + ret = rte_ring_sc_dequeue_bulk(r, cur_dst, 1, NULL); cur_dst += 1; - if (ret != 0) + if (ret == 0) goto fail; printf("dequeue 2 objs\n"); - ret = rte_ring_sc_dequeue_bulk(r, cur_dst, 2); + ret = rte_ring_sc_dequeue_bulk(r, cur_dst, 2, NULL); cur_dst += 2; - if (ret != 0) + if (ret == 0) goto fail; printf("dequeue MAX_BULK objs\n"); - ret = rte_ring_sc_dequeue_bulk(r, cur_dst, MAX_BULK); + ret = rte_ring_sc_dequeue_bulk(r, cur_dst, MAX_BULK, NULL); cur_dst += MAX_BULK; - if (ret != 0) + if (ret == 0) goto fail; /* check data */ @@ -347,39 +216,39 @@ test_ring_basic(void) cur_dst = dst; printf("enqueue 1 obj\n"); - ret = rte_ring_mp_enqueue_bulk(r, cur_src, 1); + ret = rte_ring_mp_enqueue_bulk(r, cur_src, 1, NULL); cur_src += 1; - if (ret != 0) + if (ret == 0) goto fail; printf("enqueue 2 objs\n"); - ret = rte_ring_mp_enqueue_bulk(r, cur_src, 2); + ret = rte_ring_mp_enqueue_bulk(r, cur_src, 2, NULL); cur_src += 2; - if (ret != 0) + if (ret == 0) goto fail; printf("enqueue MAX_BULK objs\n"); - ret = rte_ring_mp_enqueue_bulk(r, cur_src, MAX_BULK); + ret = rte_ring_mp_enqueue_bulk(r, cur_src, MAX_BULK, NULL); cur_src += MAX_BULK; - if (ret != 0) + if (ret == 0) goto fail; printf("dequeue 1 obj\n"); - ret = rte_ring_mc_dequeue_bulk(r, cur_dst, 1); + ret = rte_ring_mc_dequeue_bulk(r, cur_dst, 1, NULL); cur_dst += 1; - if (ret != 0) + if (ret == 0) goto fail; printf("dequeue 2 objs\n"); - ret = rte_ring_mc_dequeue_bulk(r, cur_dst, 2); + ret = rte_ring_mc_dequeue_bulk(r, cur_dst, 2, NULL); cur_dst += 2; - if (ret != 0) + if (ret == 0) goto fail; printf("dequeue MAX_BULK objs\n"); - ret = rte_ring_mc_dequeue_bulk(r, cur_dst, MAX_BULK); + ret = rte_ring_mc_dequeue_bulk(r, cur_dst, MAX_BULK, NULL); cur_dst += MAX_BULK; - if (ret != 0) + if (ret == 0) goto fail; /* check data */ @@ -394,13 +263,13 @@ test_ring_basic(void) printf("fill and empty the ring\n"); for (i = 0; i