From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 71DC1A04F3; Fri, 20 Dec 2019 05:46:35 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B2A6D1BF8E; Fri, 20 Dec 2019 05:46:09 +0100 (CET) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by dpdk.org (Postfix) with ESMTP id 4024C1BF75 for ; Fri, 20 Dec 2019 05:45:58 +0100 (CET) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 18CC711B3; Thu, 19 Dec 2019 20:45:57 -0800 (PST) Received: from qc2400f-1.austin.arm.com (qc2400f-1.austin.arm.com [10.118.14.48]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0E4CF3F718; Thu, 19 Dec 2019 20:45:57 -0800 (PST) From: Honnappa Nagarahalli To: olivier.matz@6wind.com, sthemmin@microsoft.com, jerinj@marvell.com, bruce.richardson@intel.com, david.marchand@redhat.com, pbhagavatula@marvell.com, konstantin.ananyev@intel.com, honnappa.nagarahalli@arm.com Cc: dev@dpdk.org, dharmik.thakkar@arm.com, ruifeng.wang@arm.com, gavin.hu@arm.com, nd@arm.com Date: Thu, 19 Dec 2019 22:45:11 -0600 Message-Id: <20191220044524.32910-5-honnappa.nagarahalli@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191220044524.32910-1-honnappa.nagarahalli@arm.com> References: <20190906190510.11146-1-honnappa.nagarahalli@arm.com> <20191220044524.32910-1-honnappa.nagarahalli@arm.com> Subject: [dpdk-dev] [PATCH v7 04/17] test/ring: test burst APIs with random empty-full test case X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The random empty-full test case should be tested with burst APIs as well. Hence the test case is consolidated in test_ring_burst_bulk_tests function. Signed-off-by: Honnappa Nagarahalli Reviewed-by: Gavin Hu --- app/test/test_ring.c | 91 +++++++++++++++++++++----------------------- 1 file changed, 43 insertions(+), 48 deletions(-) diff --git a/app/test/test_ring.c b/app/test/test_ring.c index e7a8b468b..d4f40ad20 100644 --- a/app/test/test_ring.c +++ b/app/test/test_ring.c @@ -113,50 +113,6 @@ test_ring_print_test_string(const char *istr, unsigned int api_type, int esize) printf("burst\n"); } -/* - * helper routine for test_ring_basic - */ -static int -test_ring_basic_full_empty(struct rte_ring *r, void * const src[], void *dst[]) -{ - unsigned i, rand; - const unsigned rsz = RING_SIZE - 1; - - printf("Basic full/empty test\n"); - - for (i = 0; TEST_RING_FULL_EMTPY_ITER != i; i++) { - - /* random shift in the ring */ - rand = RTE_MAX(rte_rand() % RING_SIZE, 1UL); - printf("%s: iteration %u, random shift: %u;\n", - __func__, i, 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(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(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)); - TEST_RING_VERIFY(rte_ring_empty(r)); - - /* check data */ - TEST_RING_VERIFY(0 == memcmp(src, dst, rsz)); - rte_ring_dump(stdout, r); - } - return 0; -} - static int test_ring_basic(struct rte_ring *r) { @@ -294,9 +250,6 @@ test_ring_basic(struct rte_ring *r) goto fail; } - if (test_ring_basic_full_empty(r, src, dst) != 0) - goto fail; - cur_src = src; cur_dst = dst; @@ -371,6 +324,8 @@ test_ring_burst_bulk_tests(unsigned int api_type) int ret; unsigned int i, j; unsigned int num_elems; + int rand; + const unsigned int rsz = RING_SIZE - 1; for (i = 0; i < RTE_DIM(esize); i++) { test_ring_print_test_string("Test standard ring", api_type, @@ -483,7 +438,6 @@ test_ring_burst_bulk_tests(unsigned int api_type) goto fail; TEST_RING_INCP(cur_src, esize[i], 2); - printf("Enqueue the remaining entries = MAX_BULK - 3\n"); /* Bulk APIs enqueue exact number of elements */ if ((api_type & TEST_RING_BL) == TEST_RING_BL) @@ -546,6 +500,47 @@ test_ring_burst_bulk_tests(unsigned int api_type) goto fail; } + printf("Random full/empty test\n"); + cur_src = src; + cur_dst = dst; + + for (j = 0; j != TEST_RING_FULL_EMTPY_ITER; j++) { + /* random shift in the ring */ + rand = RTE_MAX(rte_rand() % RING_SIZE, 1UL); + printf("%s: iteration %u, random shift: %u;\n", + __func__, i, rand); + TEST_RING_ENQUEUE(r, cur_src, esize[i], rand, + ret, api_type); + TEST_RING_VERIFY(ret != 0); + + TEST_RING_DEQUEUE(r, cur_dst, esize[i], rand, + ret, api_type); + TEST_RING_VERIFY(ret == rand); + + /* fill the ring */ + TEST_RING_ENQUEUE(r, cur_src, esize[i], rsz, + ret, api_type); + TEST_RING_VERIFY(ret != 0); + + TEST_RING_VERIFY(rte_ring_free_count(r) == 0); + TEST_RING_VERIFY(rsz == rte_ring_count(r)); + TEST_RING_VERIFY(rte_ring_full(r)); + TEST_RING_VERIFY(rte_ring_empty(r) == 0); + + /* empty the ring */ + TEST_RING_DEQUEUE(r, cur_dst, esize[i], rsz, + ret, api_type); + TEST_RING_VERIFY(ret == (int)rsz); + TEST_RING_VERIFY(rsz == rte_ring_free_count(r)); + TEST_RING_VERIFY(rte_ring_count(r) == 0); + TEST_RING_VERIFY(rte_ring_full(r) == 0); + TEST_RING_VERIFY(rte_ring_empty(r)); + + /* check data */ + TEST_RING_VERIFY(memcmp(src, dst, rsz) == 0); + rte_ring_dump(stdout, r); + } + /* Free memory before test completed */ rte_ring_free(r); rte_free(src); -- 2.17.1