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 9751CA04F3; Fri, 20 Dec 2019 05:46:27 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 49BA61BF87; Fri, 20 Dec 2019 05:46:07 +0100 (CET) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by dpdk.org (Postfix) with ESMTP id 456E11BF76 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 2C30C11D4; 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 187AA3F86C; 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:12 -0600 Message-Id: <20191220044524.32910-6-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 05/17] test/ring: add default, single element test cases 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" Add default, single element test cases for rte_ring_xxx_elem APIs. The burst APIs are kept as is since they are being tested with a ring created with SP/SC flags. They are further enhanced with bulk APIs. Signed-off-by: Honnappa Nagarahalli Reviewed-by: Gavin Hu --- app/test/test_ring.c | 129 +++++++++++++++++++++++++++---------------- 1 file changed, 81 insertions(+), 48 deletions(-) diff --git a/app/test/test_ring.c b/app/test/test_ring.c index d4f40ad20..1025097c8 100644 --- a/app/test/test_ring.c +++ b/app/test/test_ring.c @@ -620,78 +620,111 @@ test_lookup_null(void) } /* - * it tests some more basic ring operations + * Test default, single element, bulk and burst APIs */ static int test_ring_basic_ex(void) { int ret = -1; - unsigned i; + unsigned int i, j; struct rte_ring *rp = NULL; - void **obj = NULL; + void *obj = NULL; - obj = rte_calloc("test_ring_basic_ex_malloc", RING_SIZE, sizeof(void *), 0); - if (obj == NULL) { - printf("test_ring_basic_ex fail to rte_malloc\n"); - goto fail_test; - } + for (i = 0; i < RTE_DIM(esize); i++) { + obj = test_ring_calloc(RING_SIZE, esize[i]); + if (obj == NULL) { + printf("test_ring_basic_ex fail to rte_malloc\n"); + goto fail_test; + } - rp = rte_ring_create("test_ring_basic_ex", RING_SIZE, SOCKET_ID_ANY, - RING_F_SP_ENQ | RING_F_SC_DEQ); - if (rp == NULL) { - printf("test_ring_basic_ex fail to create ring\n"); - goto fail_test; - } + TEST_RING_CREATE("test_ring_basic_ex", esize[i], RING_SIZE, + SOCKET_ID_ANY, + RING_F_SP_ENQ | RING_F_SC_DEQ, rp); + if (rp == NULL) { + printf("test_ring_basic_ex fail to create ring\n"); + goto fail_test; + } - if (rte_ring_lookup("test_ring_basic_ex") != rp) { - goto fail_test; - } + if (rte_ring_lookup("test_ring_basic_ex") != rp) { + printf("test_ring_basic_ex ring is not found\n"); + goto fail_test; + } - if (rte_ring_empty(rp) != 1) { - printf("test_ring_basic_ex ring is not empty but it should be\n"); - goto fail_test; - } + if (rte_ring_empty(rp) != 1) { + printf("test_ring_basic_ex ring is not empty but it should be\n"); + goto fail_test; + } - printf("%u ring entries are now free\n", rte_ring_free_count(rp)); + printf("%u ring entries are now free\n", + rte_ring_free_count(rp)); - for (i = 0; i < RING_SIZE; i ++) { - rte_ring_enqueue(rp, obj[i]); - } + for (j = 0; j < RING_SIZE; j++) { + TEST_RING_ENQUEUE(rp, obj, esize[i], 1, ret, + TEST_RING_N | TEST_RING_SL); + } - if (rte_ring_full(rp) != 1) { - printf("test_ring_basic_ex ring is not full but it should be\n"); - goto fail_test; - } + if (rte_ring_full(rp) != 1) { + printf("test_ring_basic_ex ring is not full but it should be\n"); + goto fail_test; + } - for (i = 0; i < RING_SIZE; i ++) { - rte_ring_dequeue(rp, &obj[i]); - } + for (j = 0; j < RING_SIZE; j++) { + TEST_RING_DEQUEUE(rp, obj, esize[i], 1, ret, + TEST_RING_N | TEST_RING_SL); + } - if (rte_ring_empty(rp) != 1) { - printf("test_ring_basic_ex ring is not empty but it should be\n"); - goto fail_test; - } + if (rte_ring_empty(rp) != 1) { + printf("test_ring_basic_ex ring is not empty but it should be\n"); + goto fail_test; + } - /* Covering the ring burst operation */ - ret = rte_ring_enqueue_burst(rp, obj, 2, NULL); - if (ret != 2) { - printf("test_ring_basic_ex: rte_ring_enqueue_burst fails \n"); - goto fail_test; - } + /* Following tests use the configured flags to decide + * SP/SC or MP/MC. + */ + /* Covering the ring burst operation */ + TEST_RING_ENQUEUE(rp, obj, esize[i], 2, ret, + TEST_RING_N | TEST_RING_BR); + if (ret != 2) { + printf("test_ring_basic_ex: rte_ring_enqueue_burst fails\n"); + goto fail_test; + } + + TEST_RING_DEQUEUE(rp, obj, esize[i], 2, ret, + TEST_RING_N | TEST_RING_BR); + if (ret != 2) { + printf("test_ring_basic_ex: rte_ring_dequeue_burst fails\n"); + goto fail_test; + } + + /* Covering the ring bulk operation */ + TEST_RING_ENQUEUE(rp, obj, esize[i], 2, ret, + TEST_RING_N | TEST_RING_BL); + if (ret != 2) { + printf("test_ring_basic_ex: rte_ring_enqueue_bulk fails\n"); + goto fail_test; + } + + TEST_RING_DEQUEUE(rp, obj, esize[i], 2, ret, + TEST_RING_N | TEST_RING_BL); + if (ret != 2) { + printf("test_ring_basic_ex: rte_ring_dequeue_bulk fails\n"); + goto fail_test; + } - ret = rte_ring_dequeue_burst(rp, obj, 2, NULL); - if (ret != 2) { - printf("test_ring_basic_ex: rte_ring_dequeue_burst fails \n"); - goto fail_test; + rte_ring_free(rp); + rte_free(obj); + rp = NULL; + obj = NULL; } - ret = 0; + return 0; + fail_test: rte_ring_free(rp); if (obj != NULL) rte_free(obj); - return ret; + return -1; } static int -- 2.17.1