From mboxrd@z Thu Jan 1 00:00:00 1970 From: Olivier Matz Subject: [PATCH v6 12/13] test/mbuf: verify that cloning a clone works properly Date: Wed, 22 Apr 2015 11:57:29 +0200 Message-ID: <1429696650-9043-13-git-send-email-olivier.matz@6wind.com> References: <1429610122-30943-1-git-send-email-olivier.matz@6wind.com> <1429696650-9043-1-git-send-email-olivier.matz@6wind.com> To: dev-VfR2kkLFssw@public.gmane.org Return-path: In-Reply-To: <1429696650-9043-1-git-send-email-olivier.matz-pdR9zngts4EAvxtiuMwx3w@public.gmane.org> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces-VfR2kkLFssw@public.gmane.org Sender: "dev" Signed-off-by: Olivier Matz Acked-by: Neil Horman --- app/test/test_mbuf.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/app/test/test_mbuf.c b/app/test/test_mbuf.c index a16ec53..68564ee 100644 --- a/app/test/test_mbuf.c +++ b/app/test/test_mbuf.c @@ -126,6 +126,7 @@ static unsigned refcnt_lcore[RTE_MAX_LCORE]; * * #. Test packet cloning * - Clone a mbuf and verify the data + * - Clone the cloned mbuf and verify the data */ #define GOTO_FAIL(str, ...) do { \ @@ -326,6 +327,7 @@ testclone_testupdate_testdetach(void) { struct rte_mbuf *m = NULL; struct rte_mbuf *clone = NULL; + struct rte_mbuf *clone2 = NULL; uint32_t *data; /* alloc a mbuf */ @@ -383,11 +385,35 @@ testclone_testupdate_testdetach(void) if (rte_mbuf_refcnt_read(m->next) != 2) GOTO_FAIL("invalid refcnt in m->next\n"); + /* try to clone the clone */ + + clone2 = rte_pktmbuf_clone(clone, pktmbuf_pool); + if (clone2 == NULL) + GOTO_FAIL("cannot clone the clone\n"); + + data = rte_pktmbuf_mtod(clone2, uint32_t *); + if (*data != MAGIC_DATA) + GOTO_FAIL("invalid data in clone2\n"); + + data = rte_pktmbuf_mtod(clone2->next, uint32_t *); + if (*data != MAGIC_DATA) + GOTO_FAIL("invalid data in clone2->next\n"); + + if (rte_mbuf_refcnt_read(m) != 3) + GOTO_FAIL("invalid refcnt in m\n"); + + if (rte_mbuf_refcnt_read(m->next) != 3) + GOTO_FAIL("invalid refcnt in m->next\n"); + /* free mbuf */ rte_pktmbuf_free(m); rte_pktmbuf_free(clone); + rte_pktmbuf_free(clone2); + m = NULL; clone = NULL; + clone2 = NULL; + printf("%s ok\n", __func__); return 0; fail: @@ -395,6 +421,8 @@ fail: rte_pktmbuf_free(m); if (clone) rte_pktmbuf_free(clone); + if (clone2) + rte_pktmbuf_free(clone2); return -1; } #undef GOTO_FAIL -- 2.1.4