From patchwork Wed Sep 16 07:53:03 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 53720 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by patches.linaro.org (Postfix) with ESMTPS id 6E2F322A0D for ; Wed, 16 Sep 2015 07:55:40 +0000 (UTC) Received: by wicuu12 with SMTP id uu12sf17952229wic.2 for ; Wed, 16 Sep 2015 00:55:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:delivered-to:from:to:date :message-id:in-reply-to:references:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :mime-version:content-type:content-transfer-encoding:errors-to :sender:x-original-sender:x-original-authentication-results :mailing-list; bh=p8wQI9sqh5knz3IJsj8PW8uujlY6PYNGjcHT8wq8GBs=; b=kI5lmVcoUTcv423xWIaCvA9w8k+0hqMmqJrrtj6/GisQTFD37wEw14wA2HuPk6hyMy 9TOWCZKFKl41A/lDjQbefVRz2Nu+cCdigZZu6xwJzaqISbKEjHeJrIgHsnCoW+BwBzxZ is0rHXMSE94bbaUCep//a460LDhJ3tm1Q815sNiadjZrBmwQ7Cpw196IbhGz0s2hfv6F d4Ct438F3ngwcda+9hjsK9gG/jKHqw8VHnHkUAscvnDoxwLei04K3hZutRun8CfI0oo4 Cp2Itum0VzGxas+FUE/UND5hw9QOAEyJQ5BCghyRCOdkZhqQscLv14bf9YGwLn5R+3Jo hXGA== X-Gm-Message-State: ALoCoQnkh18PCKkm7CuqX2bIuju5x2usWfx+m0l50a52cKA7hBVlUoUBxUgGVQm7pQvvx6hPz0od X-Received: by 10.112.144.99 with SMTP id sl3mr5128539lbb.12.1442390139744; Wed, 16 Sep 2015 00:55:39 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.37.228 with SMTP id b4ls742306lak.28.gmail; Wed, 16 Sep 2015 00:55:39 -0700 (PDT) X-Received: by 10.112.130.97 with SMTP id od1mr26830469lbb.37.1442390139470; Wed, 16 Sep 2015 00:55:39 -0700 (PDT) Received: from mail-la0-f41.google.com (mail-la0-f41.google.com. [209.85.215.41]) by mx.google.com with ESMTPS id yp3si17374474lbb.43.2015.09.16.00.55.39 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Sep 2015 00:55:39 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.41 as permitted sender) client-ip=209.85.215.41; Received: by lahg1 with SMTP id g1so94184419lah.1 for ; Wed, 16 Sep 2015 00:55:39 -0700 (PDT) X-Received: by 10.112.130.70 with SMTP id oc6mr15280030lbb.32.1442390139025; Wed, 16 Sep 2015 00:55:39 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp2270498lbq; Wed, 16 Sep 2015 00:55:38 -0700 (PDT) X-Received: by 10.107.159.141 with SMTP id i135mr9970801ioe.96.1442390138144; Wed, 16 Sep 2015 00:55:38 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id k37si16503606iod.107.2015.09.16.00.55.37; Wed, 16 Sep 2015 00:55:38 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Received: by lists.linaro.org (Postfix, from userid 109) id 3199762D41; Wed, 16 Sep 2015 07:55:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 059D362D47; Wed, 16 Sep 2015 07:53:48 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 32EFE62D3D; Wed, 16 Sep 2015 07:53:36 +0000 (UTC) Received: from mail-la0-f43.google.com (mail-la0-f43.google.com [209.85.215.43]) by lists.linaro.org (Postfix) with ESMTPS id D0CAA62D2C for ; Wed, 16 Sep 2015 07:53:12 +0000 (UTC) Received: by lahg1 with SMTP id g1so94146881lah.1 for ; Wed, 16 Sep 2015 00:53:11 -0700 (PDT) X-Received: by 10.152.21.129 with SMTP id v1mr10623299lae.87.1442389991825; Wed, 16 Sep 2015 00:53:11 -0700 (PDT) Received: from localhost.localdomain (ppp91-76-161-180.pppoe.mtu-net.ru. [91.76.161.180]) by smtp.gmail.com with ESMTPSA id v3sm2330971lae.13.2015.09.16.00.53.11 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 16 Sep 2015 00:53:11 -0700 (PDT) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Wed, 16 Sep 2015 10:53:03 +0300 Message-Id: <1442389983-17007-5-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1442389983-17007-1-git-send-email-maxim.uvarov@linaro.org> References: <1442389983-17007-1-git-send-email-maxim.uvarov@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCHv3 4/4] validation: packet: test packet reference count X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: maxim.uvarov@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.41 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Signed-off-by: Maxim Uvarov --- test/validation/packet/packet.c | 36 ++++++++++++++++++++++++++++++++++++ test/validation/packet/packet.h | 1 + 2 files changed, 37 insertions(+) diff --git a/test/validation/packet/packet.c b/test/validation/packet/packet.c index 0c749c3..94d03e0 100644 --- a/test/validation/packet/packet.c +++ b/test/validation/packet/packet.c @@ -778,6 +778,41 @@ void packet_test_offset(void) CU_ASSERT_PTR_NOT_NULL(ptr); } +void packet_test_ref(void) +{ + odp_packet_t pkt = test_packet; + odp_packet_t pkt_ref; + uint32_t pkt_len = odp_packet_len(pkt); + uint8_t *data_buf1; + uint8_t *data_buf2; + + data_buf1 = malloc(pkt_len); + CU_ASSERT_PTR_NOT_NULL_FATAL(data_buf1); + data_buf2 = malloc(pkt_len); + CU_ASSERT_PTR_NOT_NULL_FATAL(data_buf2); + + pkt_ref = odp_packet_create_ref(pkt); + /* Handles should be different */ + CU_ASSERT(pkt != pkt_ref); + /* Debug print also should have refcount bits */ + CU_ASSERT(odp_packet_to_u64(pkt) != + odp_packet_to_u64(pkt_ref)); + + /* Check that packet data is the same for pkt and pkt_ref */ + CU_ASSERT(!odp_packet_copydata_out(pkt, 0, pkt_len, data_buf1)); + CU_ASSERT(!odp_packet_copydata_out(pkt_ref, 0, pkt_len, data_buf2)); + CU_ASSERT(!memcmp(data_buf1, data_buf2, pkt_len)); + + odp_packet_free(pkt_ref); + + /* Check original packet data after free reference. */ + CU_ASSERT(!odp_packet_copydata_out(pkt, 0, pkt_len, data_buf2)); + CU_ASSERT(!memcmp(data_buf1, data_buf2, pkt_len)); + + free(data_buf1); + free(data_buf2); +} + CU_TestInfo packet_suite[] = { _CU_TEST_INFO(packet_test_alloc_free), _CU_TEST_INFO(packet_test_alloc_segmented), @@ -797,6 +832,7 @@ CU_TestInfo packet_suite[] = { _CU_TEST_INFO(packet_test_copy), _CU_TEST_INFO(packet_test_copydata), _CU_TEST_INFO(packet_test_offset), + _CU_TEST_INFO(packet_test_ref), CU_TEST_INFO_NULL, }; diff --git a/test/validation/packet/packet.h b/test/validation/packet/packet.h index f8a16a8..d1feff8 100644 --- a/test/validation/packet/packet.h +++ b/test/validation/packet/packet.h @@ -28,6 +28,7 @@ void packet_test_add_rem_data(void); void packet_test_copy(void); void packet_test_copydata(void); void packet_test_offset(void); +void packet_test_ref(void); /* test arrays: */ extern CU_TestInfo packet_suite[];