From patchwork Fri Dec 20 04:45:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Honnappa Nagarahalli X-Patchwork-Id: 182202 Delivered-To: patch@linaro.org Received: by 2002:a92:1f98:0:0:0:0:0 with SMTP id f24csp57740ilf; Thu, 19 Dec 2019 20:46:28 -0800 (PST) X-Google-Smtp-Source: APXvYqyVemg2HLVHxkKtKkFS7LK1elDUiui66XYHVQCy5QcKHWavh6WlcPxvQB4Z/cpA3tmcx7pY X-Received: by 2002:a5d:4b88:: with SMTP id b8mr12863505wrt.343.1576817188205; Thu, 19 Dec 2019 20:46:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576817188; cv=none; d=google.com; s=arc-20160816; b=MXbE3EUEB0HNEdK/SKz02L5buVGXcyO/x1PXHW95xfl0z5ox33TMVkz2YQfmLriDnW ik93AyFcvPhu3DdYpdTiOnMOoW6nSaQQrodcInC93dYjIjYJIX+txQ5Kq/+TsdSULdUH glse8nydRpxJts4oXcxwSesSPfTzilRqDCaoAVJ9vlH++dm9IhlHgIV4/wWLOasbp70Z BXMNF5S7ZmCeD4ioIolNh0mUDraOLAC5dQRquMhL3hA/BKr12G1531cdVI6dlsUV6//S Ou0MG5nmVUwG+UsIm0+qFOzg65yrnPz/nX3K0MTxM2wWXamW5U/c29EFpzyRjPxa89OZ xZEw== 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=oM+/lK7YygW29i5bA8kdavZSbGyM9s5oLUdro0TFY+k=; b=WAgZ8BL27Two2vyf0G2UEgs3Rh8/XzZEtPM222zKt7kc+/N4W7FfBZZDHQA8eKejdb njiF19Cjob5C/ynxv14Jyrm+JNWYX/5uilPqq/0B0fMXxnLBDc40qHNFss16L1SnnXDx QmDP9ZtuX9NaIg96l/Aq6FpRypuNFypFCqMCDjQIYys1V7gS9zauKPNiJdwv8fEudc1V g2HIWEMFAJXUk1xfRn1d6uA2mZAT/FdbGBzNy+Ff0lSRFqxDgtu7rFgpxtmnI/jVKNTG vVakGVcmeAlVS6HxdJVYqerPYlqFzL8bWoZl7O0bR85PDLsE7450mEt9XW1Z5s2G/tKV SQFg== 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 h8si8137973wrv.151.2019.12.19.20.46.28; Thu, 19 Dec 2019 20:46:28 -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 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(-) -- 2.17.1 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