From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wg0-f42.google.com (mail-wg0-f42.google.com [74.125.82.42]) by dpdk.org (Postfix) with ESMTP id 86678C3C2 for ; Wed, 22 Apr 2015 11:57:55 +0200 (CEST) Received: by wgin8 with SMTP id n8so240385351wgi.0 for ; Wed, 22 Apr 2015 02:57:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=/fTfp/1jkbEoTgMezR6j8+ghO20XVNSFXT3jxmhGynE=; b=PGzqlsqG/AGaddHdjUJsW7PDSvPdeJsenJEPgqVP8x5yKrjpxZQVAk2miYNyZDoX8S hiXntmMTyrKQhwqY/0wp91JtGFxpklYqyCQIzLw3FCDfElAs/RidF4K3hPbeTkvtpiJw wp6PkXG10vuS+WDVo3d8LHgX37FsmbZUU0IAgcFk+oJglBfmG1tbPi+W7N5Ut+E1KV8u Ei3izjGlrQKcqYqmfLgTujyV7AosHth8LwhQWvfilhRs6AaaeaMeZJWs+xrYucafkCLk d971SubwfSejkYoj9dgF6n8w26sC2w0PMGwVU0i5SgFooqQDMDicLZQUSAQps8KeOXAA CErg== X-Gm-Message-State: ALoCoQliKpmyUFXfsRGxn53OPqWXLXezkbRQ4p5WuLd5QQFqKphnISQiRtWsj7BNFCuyssZW2ld2 X-Received: by 10.180.19.134 with SMTP id f6mr4338518wie.35.1429696675453; Wed, 22 Apr 2015 02:57:55 -0700 (PDT) Received: from glumotte.dev.6wind.com (6wind.net2.nerim.net. [213.41.180.237]) by mx.google.com with ESMTPSA id yr1sm6570006wjc.37.2015.04.22.02.57.54 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 22 Apr 2015 02:57:54 -0700 (PDT) From: Olivier Matz To: dev@dpdk.org Date: Wed, 22 Apr 2015 11:57:29 +0200 Message-Id: <1429696650-9043-13-git-send-email-olivier.matz@6wind.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1429696650-9043-1-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> Subject: [dpdk-dev] [PATCH v6 12/13] test/mbuf: verify that cloning a clone works properly X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Apr 2015 09:57:56 -0000 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