From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wi0-f173.google.com (mail-wi0-f173.google.com [209.85.212.173]) by dpdk.org (Postfix) with ESMTP id DC3D57F39 for ; Wed, 25 Mar 2015 18:00:46 +0100 (CET) Received: by wibg7 with SMTP id g7so79061216wib.1 for ; Wed, 25 Mar 2015 10:00:46 -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=DbAbbmHBYxUSNrZRf7JtjPvMww0oUuiOq6PsQ91Wxmo=; b=aOUQv4cF5mk1BKzq290H2X7lafRaGA/r65ssCWykPEGzq4qfxFpM/PExnJctHe+wsa JSrDTVpZCamZXdVs2GZypaSXsqwGEUQU+2tM2MxPZeSZ7f6oPEcCZ1PoEBQOIaceLbya r60hLaRyNQNvjTdTBn+8LJXgjZ0eE0Wkw3JJhO0EeaWj1lltNWAUWe3+os7dx1s0mtaq IRldnoRWSnJwrKInmXuK0hjico8dILqXgVukbLdaGgmQFt5u2TeUt7V5fG+bMTXi4RuP 8zBnyB2C/DahQEhIakzNCU86Ks9e1p4tHFZm4YjB8YrTzPj1/T5U2RTk2Ed1cOCvtZzU h2iQ== X-Gm-Message-State: ALoCoQlnUhMQy6cx/62A2jzJzDUIaQ7zTehXXfEeSztmFjRM+EO3tSMX0lMI3tUPzqi8MKDtFW1y X-Received: by 10.181.8.103 with SMTP id dj7mr39700814wid.75.1427302846729; Wed, 25 Mar 2015 10:00:46 -0700 (PDT) Received: from glumotte.dev.6wind.com (6wind.net2.nerim.net. [213.41.180.237]) by mx.google.com with ESMTPSA id wo10sm4513373wjb.35.2015.03.25.10.00.46 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 25 Mar 2015 10:00:46 -0700 (PDT) From: Olivier Matz To: dev@dpdk.org Date: Wed, 25 Mar 2015 18:00:38 +0100 Message-Id: <1427302838-8285-6-git-send-email-olivier.matz@6wind.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1427302838-8285-1-git-send-email-olivier.matz@6wind.com> References: <1427302838-8285-1-git-send-email-olivier.matz@6wind.com> Subject: [dpdk-dev] [PATCH 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: Wed, 25 Mar 2015 17:00:47 -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..68cd4de 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(clone); return -1; } #undef GOTO_FAIL -- 2.1.4