From: Anatoly Burakov <anatoly.burakov@intel.com>
To: dev@dpdk.org
Cc: Olivier Matz <olivier.matz@6wind.com>,
pablo.de.lara.guarch@intel.com, stable@dpdk.org
Subject: [dpdk-dev] [PATCH v4 3/6] test: fix memory leak in ring autotest
Date: Mon, 5 Feb 2018 13:03:09 +0000 [thread overview]
Message-ID: <c42e7a4506f3ee7e4b66094b3ec58a333a4a09c9.1517834482.git.anatoly.burakov@intel.com> (raw)
In-Reply-To: <409be7970a029d2d2cfffeafee43ea2645244eb2.1517834482.git.anatoly.burakov@intel.com>
In-Reply-To: <8ccde502aee6921dd4fc74718309d60b8c82f444.1516178976.git.anatoly.burakov@intel.com>
Get rid of global static ring variable and don't reuse rings
between test runs.
Fixes: 4e32101f9b01 ("ring: support freeing")
Cc: pablo.de.lara.guarch@intel.com
Cc: stable@dpdk.org
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: Olivier Matz <olivier.matz@6wind.com>
---
Notes:
v3: fix commit message to point to approriate commit being fixed
v2: remove static ring variable
test/test/test_ring.c | 61 ++++++++++++++++++++++++++++-----------------------
1 file changed, 33 insertions(+), 28 deletions(-)
diff --git a/test/test/test_ring.c b/test/test/test_ring.c
index 19d497a..b339f04 100644
--- a/test/test/test_ring.c
+++ b/test/test/test_ring.c
@@ -57,8 +57,6 @@
static rte_atomic32_t synchro;
-static struct rte_ring *r;
-
#define TEST_RING_VERIFY(exp) \
if (!(exp)) { \
printf("error at %s:%d\tcondition " #exp " failed\n", \
@@ -73,7 +71,7 @@ static struct rte_ring *r;
* helper routine for test_ring_basic
*/
static int
-test_ring_basic_full_empty(void * const src[], void *dst[])
+test_ring_basic_full_empty(struct rte_ring *r, void * const src[], void *dst[])
{
unsigned i, rand;
const unsigned rsz = RING_SIZE - 1;
@@ -114,7 +112,7 @@ test_ring_basic_full_empty(void * const src[], void *dst[])
}
static int
-test_ring_basic(void)
+test_ring_basic(struct rte_ring *r)
{
void **src = NULL, **cur_src = NULL, **dst = NULL, **cur_dst = NULL;
int ret;
@@ -250,7 +248,7 @@ test_ring_basic(void)
goto fail;
}
- if (test_ring_basic_full_empty(src, dst) != 0)
+ if (test_ring_basic_full_empty(r, src, dst) != 0)
goto fail;
cur_src = src;
@@ -317,7 +315,7 @@ test_ring_basic(void)
}
static int
-test_ring_burst_basic(void)
+test_ring_burst_basic(struct rte_ring *r)
{
void **src = NULL, **cur_src = NULL, **dst = NULL, **cur_dst = NULL;
int ret;
@@ -731,6 +729,7 @@ test_ring_basic_ex(void)
ret = 0;
fail_test:
+ rte_ring_free(rp);
if (obj != NULL)
rte_free(obj);
@@ -811,61 +810,67 @@ test_ring_with_exact_size(void)
static int
test_ring(void)
{
+ struct rte_ring *r = NULL;
+
/* some more basic operations */
if (test_ring_basic_ex() < 0)
- return -1;
+ goto test_fail;
rte_atomic32_init(&synchro);
+ r = rte_ring_create("test", RING_SIZE, SOCKET_ID_ANY, 0);
if (r == NULL)
- r = rte_ring_create("test", RING_SIZE, SOCKET_ID_ANY, 0);
- if (r == NULL)
- return -1;
+ goto test_fail;
/* retrieve the ring from its name */
if (rte_ring_lookup("test") != r) {
printf("Cannot lookup ring from its name\n");
- return -1;
+ goto test_fail;
}
/* burst operations */
- if (test_ring_burst_basic() < 0)
- return -1;
+ if (test_ring_burst_basic(r) < 0)
+ goto test_fail;
/* basic operations */
- if (test_ring_basic() < 0)
- return -1;
+ if (test_ring_basic(r) < 0)
+ goto test_fail;
/* basic operations */
if ( test_create_count_odd() < 0){
- printf ("Test failed to detect odd count\n");
- return -1;
- }
- else
- printf ( "Test detected odd count\n");
+ printf("Test failed to detect odd count\n");
+ goto test_fail;
+ } else
+ printf("Test detected odd count\n");
if ( test_lookup_null() < 0){
- printf ("Test failed to detect NULL ring lookup\n");
- return -1;
- }
- else
- printf ( "Test detected NULL ring lookup \n");
+ printf("Test failed to detect NULL ring lookup\n");
+ goto test_fail;
+ } else
+ printf("Test detected NULL ring lookup\n");
/* test of creating ring with wrong size */
if (test_ring_creation_with_wrong_size() < 0)
- return -1;
+ goto test_fail;
/* test of creation ring with an used name */
if (test_ring_creation_with_an_used_name() < 0)
- return -1;
+ goto test_fail;
if (test_ring_with_exact_size() < 0)
- return -1;
+ goto test_fail;
/* dump the ring status */
rte_ring_list_dump(stdout);
+ rte_ring_free(r);
+
return 0;
+
+test_fail:
+ rte_ring_free(r);
+
+ return -1;
}
REGISTER_TEST_COMMAND(ring_autotest, test_ring);
--
2.7.4
next prev parent reply other threads:[~2018-02-05 13:03 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-22 10:12 [dpdk-dev] [PATCH 1/6] test: fix memory leak in bitmap test Anatoly Burakov
2017-12-22 10:12 ` [dpdk-dev] [PATCH 2/6] test: fix memory leak in reorder autotest Anatoly Burakov
2017-12-22 10:12 ` [dpdk-dev] [PATCH 3/6] test: fix memory leak in ring autotest Anatoly Burakov
2017-12-22 16:26 ` Olivier MATZ
2017-12-23 11:49 ` Burakov, Anatoly
2017-12-22 10:12 ` [dpdk-dev] [PATCH 4/6] test: fix memory leak in ring perf autotest Anatoly Burakov
2017-12-22 16:28 ` Olivier MATZ
2017-12-22 10:12 ` [dpdk-dev] [PATCH 5/6] test: fix memory leak in table autotest Anatoly Burakov
2018-01-11 14:17 ` Dumitrescu, Cristian
2017-12-22 10:12 ` [dpdk-dev] [PATCH 6/6] test: fix memory leak in timer perf autotest Anatoly Burakov
2018-01-11 14:16 ` [dpdk-dev] [PATCH 1/6] test: fix memory leak in bitmap test Dumitrescu, Cristian
2018-01-17 8:36 ` [dpdk-dev] [PATCH v2 " Anatoly Burakov
2018-01-17 8:36 ` [dpdk-dev] [PATCH v2 2/6] test: fix memory leak in reorder autotest Anatoly Burakov
2018-01-17 8:36 ` [dpdk-dev] [PATCH v2 3/6] test: fix memory leak in ring autotest Anatoly Burakov
2018-01-17 8:42 ` Burakov, Anatoly
2018-01-17 8:36 ` [dpdk-dev] [PATCH v2 4/6] test: fix memory leak in ring perf autotest Anatoly Burakov
2018-01-17 8:36 ` [dpdk-dev] [PATCH v2 5/6] test: fix memory leak in table autotest Anatoly Burakov
2018-01-17 8:36 ` [dpdk-dev] [PATCH v2 6/6] test: fix memory leak in timer perf autotest Anatoly Burakov
2018-01-17 11:15 ` [dpdk-dev] [PATCH v3 1/6] test: fix memory leak in bitmap test Anatoly Burakov
2018-02-01 0:10 ` Thomas Monjalon
2018-02-01 17:04 ` Burakov, Anatoly
2018-02-02 9:08 ` Thomas Monjalon
2018-02-02 10:31 ` Burakov, Anatoly
2018-02-02 17:08 ` Thomas Monjalon
2018-02-05 10:06 ` Burakov, Anatoly
2018-02-05 10:25 ` Thomas Monjalon
2018-02-05 13:03 ` [dpdk-dev] [PATCH v4 " Anatoly Burakov
2018-02-06 13:35 ` [dpdk-dev] [PATCH v5 " Anatoly Burakov
2018-02-06 18:34 ` Thomas Monjalon
2018-02-06 13:35 ` [dpdk-dev] [PATCH v5 2/6] test: fix memory leak in reorder autotest Anatoly Burakov
2018-02-06 13:35 ` [dpdk-dev] [PATCH v5 3/6] test: fix memory leak in ring autotest Anatoly Burakov
2018-02-06 13:35 ` [dpdk-dev] [PATCH v5 4/6] test: fix memory leak in ring perf autotest Anatoly Burakov
2018-02-06 13:35 ` [dpdk-dev] [PATCH v5 5/6] test: fix memory leak in table autotest Anatoly Burakov
2018-02-06 13:35 ` [dpdk-dev] [PATCH v5 6/6] test: fix memory leak in timer perf autotest Anatoly Burakov
2018-02-05 13:03 ` [dpdk-dev] [PATCH v4 2/6] test: fix memory leak in reorder autotest Anatoly Burakov
2018-02-05 13:03 ` Anatoly Burakov [this message]
2018-02-06 0:36 ` [dpdk-dev] [PATCH v4 3/6] test: fix memory leak in ring autotest Thomas Monjalon
2018-02-05 13:03 ` [dpdk-dev] [PATCH v4 4/6] test: fix memory leak in ring perf autotest Anatoly Burakov
2018-02-05 13:03 ` [dpdk-dev] [PATCH v4 5/6] test: fix memory leak in table autotest Anatoly Burakov
2018-02-05 13:03 ` [dpdk-dev] [PATCH v4 6/6] test: fix memory leak in timer perf autotest Anatoly Burakov
2018-01-17 11:15 ` [dpdk-dev] [PATCH v3 2/6] test: fix memory leak in reorder autotest Anatoly Burakov
2018-01-17 11:15 ` [dpdk-dev] [PATCH v3 3/6] test: fix memory leak in ring autotest Anatoly Burakov
2018-01-19 8:33 ` Olivier Matz
2018-01-17 11:15 ` [dpdk-dev] [PATCH v3 4/6] test: fix memory leak in ring perf autotest Anatoly Burakov
2018-01-19 8:35 ` Olivier Matz
2018-01-17 11:15 ` [dpdk-dev] [PATCH v3 5/6] test: fix memory leak in table autotest Anatoly Burakov
2018-01-17 11:15 ` [dpdk-dev] [PATCH v3 6/6] test: fix memory leak in timer perf autotest Anatoly Burakov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c42e7a4506f3ee7e4b66094b3ec58a333a4a09c9.1517834482.git.anatoly.burakov@intel.com \
--to=anatoly.burakov@intel.com \
--cc=dev@dpdk.org \
--cc=olivier.matz@6wind.com \
--cc=pablo.de.lara.guarch@intel.com \
--cc=stable@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).