X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=test%2Ftest%2Ftest_ring.c;h=aaf1e70ad84150331e47acb83be7734701498ca8;hb=ca33590b6af032bff57d9cc70455660466a654b2;hp=d664b04b714ad4f44ba3c958e90f9d0abea2998d;hpb=f239aed5e674965691846e8ce3f187dd47523689;p=deb_dpdk.git diff --git a/test/test/test_ring.c b/test/test/test_ring.c index d664b04b..aaf1e70a 100644 --- a/test/test/test_ring.c +++ b/test/test/test_ring.c @@ -1,34 +1,5 @@ -/*- - * BSD LICENSE - * - * Copyright(c) 2010-2014 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2010-2014 Intel Corporation */ #include @@ -43,7 +14,6 @@ #include #include #include -#include #include #include #include @@ -87,8 +57,6 @@ static rte_atomic32_t synchro; -static struct rte_ring *r; - #define TEST_RING_VERIFY(exp) \ if (!(exp)) { \ printf("error at %s:%d\tcondition " #exp " failed\n", \ @@ -103,7 +71,7 @@ static struct rte_ring *r; * helper routine for test_ring_basic */ static int -test_ring_basic_full_empty(void * const src[], void *dst[]) +test_ring_basic_full_empty(struct rte_ring *r, void * const src[], void *dst[]) { unsigned i, rand; const unsigned rsz = RING_SIZE - 1; @@ -144,7 +112,7 @@ test_ring_basic_full_empty(void * const src[], void *dst[]) } static int -test_ring_basic(void) +test_ring_basic(struct rte_ring *r) { void **src = NULL, **cur_src = NULL, **dst = NULL, **cur_dst = NULL; int ret; @@ -280,7 +248,7 @@ test_ring_basic(void) goto fail; } - if (test_ring_basic_full_empty(src, dst) != 0) + if (test_ring_basic_full_empty(r, src, dst) != 0) goto fail; cur_src = src; @@ -347,7 +315,7 @@ test_ring_basic(void) } static int -test_ring_burst_basic(void) +test_ring_burst_basic(struct rte_ring *r) { void **src = NULL, **cur_src = NULL, **dst = NULL, **cur_dst = NULL; int ret; @@ -375,37 +343,37 @@ test_ring_burst_basic(void) printf("enqueue 1 obj\n"); ret = rte_ring_sp_enqueue_burst(r, cur_src, 1, NULL); cur_src += 1; - if ((ret & RTE_RING_SZ_MASK) != 1) + if (ret != 1) goto fail; printf("enqueue 2 objs\n"); ret = rte_ring_sp_enqueue_burst(r, cur_src, 2, NULL); cur_src += 2; - if ((ret & RTE_RING_SZ_MASK) != 2) + if (ret != 2) goto fail; printf("enqueue MAX_BULK objs\n"); ret = rte_ring_sp_enqueue_burst(r, cur_src, MAX_BULK, NULL); cur_src += MAX_BULK; - if ((ret & RTE_RING_SZ_MASK) != MAX_BULK) + if (ret != MAX_BULK) goto fail; printf("dequeue 1 obj\n"); ret = rte_ring_sc_dequeue_burst(r, cur_dst, 1, NULL); cur_dst += 1; - if ((ret & RTE_RING_SZ_MASK) != 1) + if (ret != 1) goto fail; printf("dequeue 2 objs\n"); ret = rte_ring_sc_dequeue_burst(r, cur_dst, 2, NULL); cur_dst += 2; - if ((ret & RTE_RING_SZ_MASK) != 2) + if (ret != 2) goto fail; printf("dequeue MAX_BULK objs\n"); ret = rte_ring_sc_dequeue_burst(r, cur_dst, MAX_BULK, NULL); cur_dst += MAX_BULK; - if ((ret & RTE_RING_SZ_MASK) != MAX_BULK) + if (ret != MAX_BULK) goto fail; /* check data */ @@ -423,22 +391,21 @@ test_ring_burst_basic(void) for (i = 0; i< (RING_SIZE/MAX_BULK - 1); i++) { ret = rte_ring_sp_enqueue_burst(r, cur_src, MAX_BULK, NULL); cur_src += MAX_BULK; - if ((ret & RTE_RING_SZ_MASK) != MAX_BULK) { + if (ret != MAX_BULK) goto fail; - } } printf("Enqueue 2 objects, free entries = MAX_BULK - 2 \n"); ret = rte_ring_sp_enqueue_burst(r, cur_src, 2, NULL); cur_src += 2; - if ((ret & RTE_RING_SZ_MASK) != 2) + if (ret != 2) goto fail; printf("Enqueue the remaining entries = MAX_BULK - 2 \n"); /* Always one free entry left */ ret = rte_ring_sp_enqueue_burst(r, cur_src, MAX_BULK, NULL); cur_src += MAX_BULK - 3; - if ((ret & RTE_RING_SZ_MASK) != MAX_BULK - 3) + if (ret != MAX_BULK - 3) goto fail; printf("Test if ring is full \n"); @@ -447,26 +414,26 @@ test_ring_burst_basic(void) printf("Test enqueue for a full entry \n"); ret = rte_ring_sp_enqueue_burst(r, cur_src, MAX_BULK, NULL); - if ((ret & RTE_RING_SZ_MASK) != 0) + if (ret != 0) goto fail; printf("Test dequeue without enough objects \n"); for (i = 0; i