From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wg0-f49.google.com (mail-wg0-f49.google.com [74.125.82.49]) by dpdk.org (Postfix) with ESMTP id 65A9A5AA1 for ; Thu, 26 Mar 2015 17:00:05 +0100 (CET) Received: by wgdm6 with SMTP id m6so69568232wgd.2 for ; Thu, 26 Mar 2015 09:00:05 -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=evlpvdQ+wnDAmg0OAVw4qC6IDXvt69YMVYrsjw2OOpI=; b=RkleEmUr9AZVSL8H8qSfyQzzsWOomNncb3nJgH4IWCbcQ6R2wt6Iqd70czd0n2RNhI Z8sZGyNzABA7dP30fLK3vIWPEn5/Xz79xXHHkc0tGnvZXmqQ6WSmnXJRaNuWc9Y5fneU Qa3pJ7jmJAWjPE5Aeu0Y6mf22EhtixWutfhHVLlcW2TjrIwQ/DkCZeabFwD/LO4Ew12M QBj0gyVayd0oL9PjtNo74kRvLxodacGKoIZyBf4CGZzDNhSram/rybR/uSJLJQ+FJK8F BOWSiIm+hCt1LbQv45hHCDQxRxSqJoHAghfG1M1Q1GnpI8e7R3d6QEP/2p8RdpunOUy/ HjeQ== X-Gm-Message-State: ALoCoQm0v3CKsUxlXWEaJDrd7V4jF9mepmsKJ/GZdWtziXmCvf2cfE81D8rdb+VzwTRg7L5NgGMW X-Received: by 10.180.89.148 with SMTP id bo20mr47995424wib.91.1427385605164; Thu, 26 Mar 2015 09:00:05 -0700 (PDT) Received: from glumotte.dev.6wind.com (6wind.net2.nerim.net. [213.41.180.237]) by mx.google.com with ESMTPSA id i3sm2797619wiy.23.2015.03.26.09.00.04 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 26 Mar 2015 09:00:04 -0700 (PDT) From: Olivier Matz To: dev@dpdk.org Date: Thu, 26 Mar 2015 16:59:55 +0100 Message-Id: <1427385595-15011-6-git-send-email-olivier.matz@6wind.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1427385595-15011-1-git-send-email-olivier.matz@6wind.com> References: <1427302838-8285-1-git-send-email-olivier.matz@6wind.com> <1427385595-15011-1-git-send-email-olivier.matz@6wind.com> Cc: zoltan.kiss@linaro.org Subject: [dpdk-dev] [PATCH v2 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: Thu, 26 Mar 2015 16:00:05 -0000 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