From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wg0-f47.google.com (mail-wg0-f47.google.com [74.125.82.47]) by dpdk.org (Postfix) with ESMTP id 068326A94 for ; Tue, 31 Mar 2015 21:23:35 +0200 (CEST) Received: by wgra20 with SMTP id a20so30317901wgr.3 for ; Tue, 31 Mar 2015 12:23:34 -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=dqa4cYF1V5sTAXGVr280rAfPfczCD0TXJ2Fn5Uwn2iY=; b=PbCk5tDZXFo1LKB7+m2VnusylJPYLfgigniHIPN+pZmxWM+iev7vzZt+AGytHk9q6/ AvJmZwZi2YMkysOzN+SnGEyQUoNPerQJg/lOKJjzeHtRbRdc/hkI1sT6oTPP71eQ9TNC RlGgnLwNLzhYzJeAcRUaQWkUE5yAl8jOoQf0Va7siy3lXW+dxgPzIrHBmNjaVtpjjzCN QinY7BHcBykAMt/7yPzgKzmSWdCsPrvdTEY66O1TCvtnqX2HwRHJTMeOj4JxH6RLeERq y5ouOl6868MQ1+wyM/KuLTYZbh1DGzwffy27XkSHYdoi2rBgNvMxPRyxR4piFVZzYSPf GyjA== X-Gm-Message-State: ALoCoQkAtiR8qSA5yjG3WecUWFh9nUlsdEPct4TBtkPqVf/FxpsmEhuICXKc1huT6aWfphtpARsP X-Received: by 10.180.73.111 with SMTP id k15mr8208448wiv.34.1427829813906; Tue, 31 Mar 2015 12:23:33 -0700 (PDT) Received: from localhost.localdomain ([185.65.185.242]) by mx.google.com with ESMTPSA id g2sm25966892wib.1.2015.03.31.12.23.32 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 31 Mar 2015 12:23:33 -0700 (PDT) From: Olivier Matz X-Google-Original-From: Olivier Matz To: dev@dpdk.org Date: Tue, 31 Mar 2015 21:23:04 +0200 Message-Id: <1427829784-12323-6-git-send-email-zer0@droids-corp.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1427829784-12323-1-git-send-email-zer0@droids-corp.org> References: <1427385595-15011-1-git-send-email-olivier.matz@6wind.com> <1427829784-12323-1-git-send-email-zer0@droids-corp.org> Subject: [dpdk-dev] [PATCH v3 5/5] 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: Tue, 31 Mar 2015 19:23:35 -0000 From: Olivier Matz Signed-off-by: Olivier Matz --- app/test/test_mbuf.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/app/test/test_mbuf.c b/app/test/test_mbuf.c index 9d8ee4e..e59aedc 100644 --- a/app/test/test_mbuf.c +++ b/app/test/test_mbuf.c @@ -325,6 +325,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 */ @@ -382,11 +383,34 @@ 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; return 0; fail: @@ -394,6 +418,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