From patchwork Fri Dec 20 04:45:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Honnappa Nagarahalli X-Patchwork-Id: 182205 Delivered-To: patch@linaro.org Received: by 2002:a92:1f98:0:0:0:0:0 with SMTP id f24csp58095ilf; Thu, 19 Dec 2019 20:46:53 -0800 (PST) X-Google-Smtp-Source: APXvYqx2fcAnn84MiXCVmJwqAAhd/RR4667k3wTnM78Y1h6p2K1bHUdvib87XjUv/rTL5MNXKF2x X-Received: by 2002:aa7:d3cb:: with SMTP id o11mr13931804edr.145.1576817213713; Thu, 19 Dec 2019 20:46:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576817213; cv=none; d=google.com; s=arc-20160816; b=UUWTKU6EwptYsw9K+eagr9fPonRTciZm9HaURhwYre5Q6g/H0D8XBgRl0uY+6nlN18 RxLtv6w7Mu0pG/RE0ShV0uR7WKWyjITj+1l+mUKnJsG/0Zd0gM/9Z8DIFybSsuq8e4qO IzgchZNjYbRmgeRAq8JV+YkefBARkCLMT0uG29AGT4IK494xdqh0rqT7yT3NXPaBH8cV ZxfYWxZZ3yBRfGdf/pyyUTKaa5attiC/xEjpxDSOa3pp7lJdDCmuzJ8ogJM8/NEeFAhi epM1A16HpSdmOnuKRMr5AIt57hFfb5BaU46zqO0N/ktR0aELe+KVrcjKax59rmH85keu YmGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:cc:to:from; bh=EWfM3OPU0M9/Ilk0RnjSDVB/qwaWguIjO6jFcrTI1TA=; b=AN5JBboAXK+pqYcY2TCBGwWuEKp2oArcUYlCr/2NdYUK2V0UQCW+TFjV7m8/4uqYaS rperYoXZoHA7exkACXf16sGruS+bLNtXf5fRnjt/dMdPYWQsUKhZPjsuTccyAouxftxv FuoZpf/LQVtDN6xbjUq919mo9oovUWfKMRtp+NxIU3tqRgRThn9nTiqy/5bITmVms4/H I+Ue6/6s6w9yp6b4fpbO0QBiyxhggNL/o/SmFN/26xwQOfduI3eiKliXoMqptM7Oeq/O FVSpfZVQTJoo16xC6Fjq76zyvU0+6TcnzKYhVodycwBRgrTmLVK2kUvDxjy5OMRIY/5w sh5w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org Return-Path: Received: from dpdk.org (dpdk.org. [92.243.14.124]) by mx.google.com with ESMTP id b5si6412980edf.359.2019.12.19.20.46.53; Thu, 19 Dec 2019 20:46:53 -0800 (PST) Received-SPF: pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) client-ip=92.243.14.124; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id AC6C11BF9D; Fri, 20 Dec 2019 05:46:13 +0100 (CET) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by dpdk.org (Postfix) with ESMTP id AAADD1BF73 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 386EC11FB; 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 2D4093F718; 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:13 -0600 Message-Id: <20191220044524.32910-7-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 06/17] test/ring: rte_ring_xxx_elem test cases for exact size ring 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" Test cases for the exact size ring are changed to test rte_ring_xxx_elem APIs. Signed-off-by: Honnappa Nagarahalli Reviewed-by: Gavin Hu --- app/test/test_ring.c | 147 ++++++++++++++++++++++++++----------------- 1 file changed, 89 insertions(+), 58 deletions(-) -- 2.17.1 diff --git a/app/test/test_ring.c b/app/test/test_ring.c index 1025097c8..294e3ee10 100644 --- a/app/test/test_ring.c +++ b/app/test/test_ring.c @@ -727,75 +727,106 @@ test_ring_basic_ex(void) return -1; } +/* + * Basic test cases with exact size ring. + */ static int test_ring_with_exact_size(void) { - struct rte_ring *std_ring = NULL, *exact_sz_ring = NULL; - void *ptr_array[16]; - static const unsigned int ring_sz = RTE_DIM(ptr_array); - unsigned int i; + struct rte_ring *std_r = NULL, *exact_sz_r = NULL; + void *obj; + const unsigned int ring_sz = 16; + unsigned int i, j; int ret = -1; - std_ring = rte_ring_create("std", ring_sz, rte_socket_id(), - RING_F_SP_ENQ | RING_F_SC_DEQ); - if (std_ring == NULL) { - printf("%s: error, can't create std ring\n", __func__); - goto end; - } - exact_sz_ring = rte_ring_create("exact sz", ring_sz, rte_socket_id(), - RING_F_SP_ENQ | RING_F_SC_DEQ | RING_F_EXACT_SZ); - if (exact_sz_ring == NULL) { - printf("%s: error, can't create exact size ring\n", __func__); - goto end; - } - - /* - * Check that the exact size ring is bigger than the standard ring - */ - if (rte_ring_get_size(std_ring) >= rte_ring_get_size(exact_sz_ring)) { - printf("%s: error, std ring (size: %u) is not smaller than exact size one (size %u)\n", - __func__, - rte_ring_get_size(std_ring), - rte_ring_get_size(exact_sz_ring)); - goto end; - } - /* - * check that the exact_sz_ring can hold one more element than the - * standard ring. (16 vs 15 elements) - */ - for (i = 0; i < ring_sz - 1; i++) { - rte_ring_enqueue(std_ring, NULL); - rte_ring_enqueue(exact_sz_ring, NULL); - } - if (rte_ring_enqueue(std_ring, NULL) != -ENOBUFS) { - printf("%s: error, unexpected successful enqueue\n", __func__); - goto end; - } - if (rte_ring_enqueue(exact_sz_ring, NULL) == -ENOBUFS) { - printf("%s: error, enqueue failed\n", __func__); - goto end; - } + for (i = 0; i < RTE_DIM(esize); i++) { + test_ring_print_test_string("Test exact size ring", + TEST_RING_IGNORE_API_TYPE, + esize[i]); + + /* alloc object pointers */ + obj = test_ring_calloc(16, esize[i]); + if (obj == NULL) + goto test_fail; + + TEST_RING_CREATE("std", esize[i], ring_sz, rte_socket_id(), + RING_F_SP_ENQ | RING_F_SC_DEQ, std_r); + if (std_r == NULL) { + printf("%s: error, can't create std ring\n", __func__); + goto test_fail; + } + TEST_RING_CREATE("exact sz", esize[i], ring_sz, rte_socket_id(), + RING_F_SP_ENQ | RING_F_SC_DEQ | RING_F_EXACT_SZ, + exact_sz_r); + if (exact_sz_r == NULL) { + printf("%s: error, can't create exact size ring\n", + __func__); + goto test_fail; + } - /* check that dequeue returns the expected number of elements */ - if (rte_ring_dequeue_burst(exact_sz_ring, ptr_array, - RTE_DIM(ptr_array), NULL) != ring_sz) { - printf("%s: error, failed to dequeue expected nb of elements\n", + /* + * Check that the exact size ring is bigger than the + * standard ring + */ + if (rte_ring_get_size(std_r) >= rte_ring_get_size(exact_sz_r)) { + printf("%s: error, std ring (size: %u) is not smaller than exact size one (size %u)\n", + __func__, + rte_ring_get_size(std_r), + rte_ring_get_size(exact_sz_r)); + goto test_fail; + } + /* + * check that the exact_sz_ring can hold one more element + * than the standard ring. (16 vs 15 elements) + */ + for (j = 0; j < ring_sz - 1; j++) { + TEST_RING_ENQUEUE(std_r, obj, esize[i], 1, ret, + TEST_RING_N | TEST_RING_SL); + TEST_RING_ENQUEUE(exact_sz_r, obj, esize[i], 1, + ret, TEST_RING_N | TEST_RING_SL); + } + TEST_RING_ENQUEUE(std_r, obj, esize[i], 1, ret, + TEST_RING_N | TEST_RING_SL); + if (ret != -ENOBUFS) { + printf("%s: error, unexpected successful enqueue\n", __func__); - goto end; - } + goto test_fail; + } + TEST_RING_ENQUEUE(exact_sz_r, obj, esize[i], 1, ret, + TEST_RING_N | TEST_RING_SL); + if (ret == -ENOBUFS) { + printf("%s: error, enqueue failed\n", __func__); + goto test_fail; + } - /* check that the capacity function returns expected value */ - if (rte_ring_get_capacity(exact_sz_ring) != ring_sz) { - printf("%s: error, incorrect ring capacity reported\n", + /* check that dequeue returns the expected number of elements */ + TEST_RING_DEQUEUE(exact_sz_r, obj, esize[i], ring_sz, + ret, TEST_RING_N | TEST_RING_BR); + if (ret != (int)ring_sz) { + printf("%s: error, failed to dequeue expected nb of elements\n", __func__); - goto end; + goto test_fail; + } + + /* check that the capacity function returns expected value */ + if (rte_ring_get_capacity(exact_sz_r) != ring_sz) { + printf("%s: error, incorrect ring capacity reported\n", + __func__); + goto test_fail; + } + + rte_free(obj); + rte_ring_free(std_r); + rte_ring_free(exact_sz_r); } - ret = 0; /* all ok if we get here */ -end: - rte_ring_free(std_ring); - rte_ring_free(exact_sz_ring); - return ret; + return 0; + +test_fail: + rte_free(obj); + rte_ring_free(std_r); + rte_ring_free(exact_sz_r); + return -1; } static int