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 40914A051C; Fri, 17 Jan 2020 18:03:17 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 9CB612C28; Fri, 17 Jan 2020 18:03:16 +0100 (CET) Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by dpdk.org (Postfix) with ESMTP id C17FC2BB9 for ; Fri, 17 Jan 2020 18:03:14 +0100 (CET) Received: by mail-wr1-f66.google.com with SMTP id z3so23445372wru.3 for ; Fri, 17 Jan 2020 09:03:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=JNopFuyr7lmmKgfScpOboED1oqoH/SGomrvnbrCBCVk=; b=BHq6FxjbWVQUVNUQN4ObYYP3BPIudWobt6aAAGpoSanSyvurFcK7u75cDgnmgGMWT6 bX8OBRIDrJlBhLQEge0n99mkprVbp4TLxXg4x7qlUWhfhQu8N+s/uPyipUdc5wVAVrje Q8xUl25c12pAxWp/ibBzsVP6O14L6XTQGwZxLIdouzdFJwr4Y67DHOh9N/Icia0bhq14 pDmKxSfMbjzlG7AaeZPCrbsjJJutZIhbQIpWwANX/MUPtntBVCVx4f0LGPMrR3nJdHlR aQGsE7ly5gfHmtEnVGdL81H9WzDs1WDirkd43utBIQ2eK79Kt1wfeLRLoDkI1aOSPYpJ sAHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=JNopFuyr7lmmKgfScpOboED1oqoH/SGomrvnbrCBCVk=; b=gaTSIg3qqSS+XHctQhz2uAATFwIt1P2krzrMIbQHDEtl4UXaKrZmhxagYUQ7Zpsyk6 3yQuQA7mQh5dg2fZEGuOAc251hnepOkPl8RzkqPXhgNMHHEBK46i730r41FggoOu+OUF EdczO2N/HCXQQrE6H/yM/m27VUojHo7Jngh8J+sIOOq0hvAGtk0i8xVCkKG0GQc+xor8 4rVk39Zr9X+deEAhZ1QvCbB8OuoUQ2lIBpF+9vDOxy0eaLUaqhNI4MJlrzlV1lfv07h9 PgOlhsajsICeLtmKDGEWfcXbdXjzv39FQUMYAAUbh2B5bSj6oe1ZfbRXnUtiEcSoSHY4 Oj+g== X-Gm-Message-State: APjAAAWOTaQFVY9T6wMdWr4YGOadMIWV/CjcSe5KcWMfWxn5QGHdckje /lPGjsUl5KGmMfArsaoPhZv57Q== X-Google-Smtp-Source: APXvYqyE2DzfOdOoCkzOpz3vGNO4sLe4rTP9jTfKQYxY21v48NAxo5bHEwSkaIDV4/N7edVeuS9CzA== X-Received: by 2002:adf:f484:: with SMTP id l4mr4323829wro.207.1579280594354; Fri, 17 Jan 2020 09:03:14 -0800 (PST) Received: from 6wind.com (2a01cb0c0005a600345636f7e65ed1a0.ipv6.abo.wanadoo.fr. [2a01:cb0c:5:a600:3456:36f7:e65e:d1a0]) by smtp.gmail.com with ESMTPSA id u16sm8316361wmj.41.2020.01.17.09.03.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jan 2020 09:03:13 -0800 (PST) Date: Fri, 17 Jan 2020 18:03:12 +0100 From: Olivier Matz To: Honnappa Nagarahalli Cc: sthemmin@microsoft.com, jerinj@marvell.com, bruce.richardson@intel.com, david.marchand@redhat.com, pbhagavatula@marvell.com, konstantin.ananyev@intel.com, yipeng1.wang@intel.com, dev@dpdk.org, dharmik.thakkar@arm.com, ruifeng.wang@arm.com, gavin.hu@arm.com, nd@arm.com Message-ID: <20200117170312.GZ22738@platinum> References: <20190906190510.11146-1-honnappa.nagarahalli@arm.com> <20200116052511.8557-1-honnappa.nagarahalli@arm.com> <20200116052511.8557-4-honnappa.nagarahalli@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200116052511.8557-4-honnappa.nagarahalli@arm.com> User-Agent: Mutt/1.10.1 (2018-07-13) Subject: Re: [dpdk-dev] [PATCH v9 3/6] test/ring: add functional tests for rte_ring_xxx_elem APIs 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" On Wed, Jan 15, 2020 at 11:25:08PM -0600, Honnappa Nagarahalli wrote: > Add basic infrastructure to test rte_ring_xxx_elem APIs. > Adjust the existing test cases to test for various ring > element sizes. > > Signed-off-by: Honnappa Nagarahalli > Reviewed-by: Gavin Hu > --- > app/test/test_ring.c | 1342 +++++++++++++++++++++--------------------- > app/test/test_ring.h | 187 ++++++ > 2 files changed, 850 insertions(+), 679 deletions(-) > create mode 100644 app/test/test_ring.h > > diff --git a/app/test/test_ring.c b/app/test/test_ring.c > index aaf1e70ad..c08500eca 100644 > --- a/app/test/test_ring.c > +++ b/app/test/test_ring.c > @@ -23,11 +23,13 @@ > #include > #include > #include > +#include > #include > #include > #include > > #include "test.h" > +#include "test_ring.h" > > /* > * Ring As you are changing a lot of things, maybe it's an opportunity to update or remove the comment at the beginning of the file. > @@ -55,8 +57,6 @@ > #define RING_SIZE 4096 > #define MAX_BULK 32 > > -static rte_atomic32_t synchro; > - > #define TEST_RING_VERIFY(exp) \ > if (!(exp)) { \ > printf("error at %s:%d\tcondition " #exp " failed\n", \ > @@ -67,808 +67,792 @@ static rte_atomic32_t synchro; > > #define TEST_RING_FULL_EMTPY_ITER 8 > > -/* > - * helper routine for test_ring_basic > - */ > -static int > -test_ring_basic_full_empty(struct rte_ring *r, void * const src[], void *dst[]) > +static int esize[] = {-1, 4, 8, 16, 20}; it could be const [...] > +/* > + * Burst and bulk operations with sp/sc, mp/mc and default (during creation) > + * Random number of elements are enqueued and dequeued. > + */ > +static int > +test_ring_burst_bulk_tests1(unsigned int api_type) > +{ > + struct rte_ring *r; > + void **src = NULL, **cur_src = NULL, **dst = NULL, **cur_dst = NULL; > + int ret; > + unsigned int i, j; > + int rand; > + const unsigned int rsz = RING_SIZE - 1; > > - /* check data */ > - if (memcmp(src, dst, cur_dst - dst)) { > - rte_hexdump(stdout, "src", src, cur_src - src); > - rte_hexdump(stdout, "dst", dst, cur_dst - dst); > - printf("data after dequeue is not the same\n"); > - goto fail; > - } > + for (i = 0; i < RTE_DIM(esize); i++) { > + test_ring_print_test_string("Test standard ring", api_type, > + esize[i]); > > - cur_src = src; > - cur_dst = dst; > + /* Create the ring */ > + r = test_ring_create("test_ring_burst_bulk_tests", esize[i], > + RING_SIZE, SOCKET_ID_ANY, 0); > > - ret = rte_ring_mp_enqueue(r, cur_src); > - if (ret != 0) > - goto fail; > + /* alloc dummy object pointers */ > + src = test_ring_calloc(RING_SIZE * 2, esize[i]); > + if (src == NULL) > + goto fail; > + test_ring_mem_init(src, RING_SIZE * 2, esize[i]); > + cur_src = src; > > - ret = rte_ring_mc_dequeue(r, cur_dst); > - if (ret != 0) > - goto fail; > + /* alloc some room for copied objects */ > + dst = test_ring_calloc(RING_SIZE * 2, esize[i]); > + if (dst == NULL) > + goto fail; > + cur_dst = dst; > + > + printf("Random full/empty test\n"); > + > + 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); > + ret = test_ring_enqueue(r, cur_src, esize[i], rand, > + api_type); > + TEST_RING_VERIFY(ret != 0); > + > + ret = test_ring_dequeue(r, cur_dst, esize[i], rand, > + api_type); > + TEST_RING_VERIFY(ret == rand); > + > + /* fill the ring */ > + ret = test_ring_enqueue(r, cur_src, esize[i], rsz, > + 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 */ > + ret = test_ring_dequeue(r, cur_dst, esize[i], rsz, > + 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); > + } > + > + /* Free memory before test completed */ > + rte_ring_free(r); > + rte_free(src); > + rte_free(dst); I think they should be reset to NULL to avoid a double free if next iteration fails. There are several places like this, I think it can be done even if not really needed. [...] > diff --git a/app/test/test_ring.h b/app/test/test_ring.h > new file mode 100644 > index 000000000..26716e4f8 > --- /dev/null > +++ b/app/test/test_ring.h > @@ -0,0 +1,187 @@ > +/* SPDX-License-Identifier: BSD-3-Clause > + * Copyright(c) 2019 Arm Limited > + */ > + > +#include > +#include > +#include > + > +/* API type to call > + * rte_ring__enqueue_ > + * TEST_RING_THREAD_DEF - Uses configured SPSC/MPMC calls > + * TEST_RING_THREAD_SPSC - Calls SP or SC API > + * TEST_RING_THREAD_MPMC - Calls MP or MC API > + */ > +#define TEST_RING_THREAD_DEF 1 > +#define TEST_RING_THREAD_SPSC 2 > +#define TEST_RING_THREAD_MPMC 4 > + > +/* API type to call > + * SL - Calls single element APIs > + * BL - Calls bulk APIs > + * BR - Calls burst APIs > + */ The comment was not updated according to macro name.