From patchwork Sun Mar 20 18:15:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 64102 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp1016652lbc; Sun, 20 Mar 2016 11:16:08 -0700 (PDT) X-Received: by 10.140.219.134 with SMTP id p128mr37737700qhb.80.1458497767913; Sun, 20 Mar 2016 11:16:07 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id q141si6628236qha.77.2016.03.20.11.16.07; Sun, 20 Mar 2016 11:16:07 -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; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 910726177E; Sun, 20 Mar 2016 18:16:07 +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_H2, 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 4AEE061782; Sun, 20 Mar 2016 18:15:24 +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 11CF06177D; Sun, 20 Mar 2016 18:15:22 +0000 (UTC) Received: from mail-pf0-f179.google.com (mail-pf0-f179.google.com [209.85.192.179]) by lists.linaro.org (Postfix) with ESMTPS id 2F90B61748 for ; Sun, 20 Mar 2016 18:15:21 +0000 (UTC) Received: by mail-pf0-f179.google.com with SMTP id n5so236981397pfn.2 for ; Sun, 20 Mar 2016 11:15:21 -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=5hngKnUG+p2w3X6MpA/M5SQXWu1sNvhDcX+mW94J1pk=; b=D2DbzlHf1Lh0t8Gsawod7oySsg0G+geUhtWExgm0NPOkjSmrjeU3KVs01IKX36fKll R4wZFLHwtSXWfHjO2hc7HxeMHfX2b7DnyNWI5miv98Zl1f4KfDe8UQNLRmTw2dK08paB HeYoGacWpgI2Nl0lNtyzGnuVo+8KVMaJWoFx1yolCwEAnyrzhLCxT3yjQ3IvvmHciZ7p JJ6ip/FbudgaPlx3LiHjg/VskxQ1GvRYDJ+i1gafkyyX3cjqCjnrB3jVEcczTbg4Oykx G2/H5mudRlzEjB2VsfXiCCfLUSDc6Zh226o8tZjDXpkEMbKLq6vVHthh67feZfb9yA6t uTPA== X-Gm-Message-State: AD7BkJKry3GMGQTPAi1kayxanjkmJeM70PGmAztLDXJ7WnhShmRMg5/zPP3W0zXRdGVyudaAZA0= X-Received: by 10.66.90.163 with SMTP id bx3mr39594840pab.59.1458497720512; Sun, 20 Mar 2016 11:15:20 -0700 (PDT) Received: from Ubuntu15.localdomain ([216.9.110.2]) by smtp.gmail.com with ESMTPSA id to9sm34891374pab.27.2016.03.20.11.15.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 20 Mar 2016 11:15:19 -0700 (PDT) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Mon, 21 Mar 2016 01:15:16 +0700 Message-Id: <1458497716-12483-2-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1458497716-12483-1-git-send-email-bill.fischofer@linaro.org> References: <1458497716-12483-1-git-send-email-bill.fischofer@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCH 2/2] validation: packet: add multi-segment head/tail push/pull tests X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" 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" Signed-off-by: Bill Fischofer --- test/validation/packet/packet.c | 62 ++++++++++++++++++++++++++++++----------- 1 file changed, 46 insertions(+), 16 deletions(-) diff --git a/test/validation/packet/packet.c b/test/validation/packet/packet.c index a764ed9..cebb295 100644 --- a/test/validation/packet/packet.c +++ b/test/validation/packet/packet.c @@ -366,19 +366,26 @@ static void _verify_headroom_shift(odp_packet_t packet, void *data; char *data_orig = odp_packet_data(packet); char *head_orig = odp_packet_head(packet); + uint32_t seg_count_before = odp_packet_num_segs(packet); + uint32_t seg_count_after; if (shift >= 0) data = odp_packet_push_head(packet, shift); else data = odp_packet_pull_head(packet, -shift); + seg_count_after = odp_packet_num_segs(packet); CU_ASSERT_PTR_NOT_NULL(data); - CU_ASSERT(odp_packet_headroom(packet) == room - shift); - CU_ASSERT(odp_packet_seg_len(packet) == seg_data_len + shift); - CU_ASSERT(odp_packet_len(packet) == pkt_data_len + shift); - CU_ASSERT(odp_packet_data(packet) == data); - CU_ASSERT(odp_packet_head(packet) == head_orig); - CU_ASSERT(data == data_orig - shift); + if (seg_count_before == seg_count_after) { + CU_ASSERT(odp_packet_headroom(packet) == room - shift); + CU_ASSERT(odp_packet_seg_len(packet) == seg_data_len + shift); + CU_ASSERT(odp_packet_len(packet) == pkt_data_len + shift); + CU_ASSERT(odp_packet_data(packet) == data); + CU_ASSERT(odp_packet_head(packet) == head_orig); + CU_ASSERT(data == data_orig - shift); + } else { + CU_ASSERT(data != NULL); + } } void packet_test_headroom(void) @@ -403,6 +410,13 @@ void packet_test_headroom(void) _verify_headroom_shift(pkt, push_val + pull_val); _verify_headroom_shift(pkt, -push_val); _verify_headroom_shift(pkt, 0); + + if (segmentation_supported) { + push_val = room * 2; + _verify_headroom_shift(pkt, push_val); + _verify_headroom_shift(pkt, 0); + _verify_headroom_shift(pkt, -push_val); + } } static void _verify_tailroom_shift(odp_packet_t pkt, @@ -413,6 +427,8 @@ static void _verify_tailroom_shift(odp_packet_t pkt, uint32_t seg_data_len, pkt_data_len; void *tail; char *tail_orig; + uint32_t seg_count_before = odp_packet_num_segs(pkt); + uint32_t seg_count_after; room = odp_packet_tailroom(pkt); pkt_data_len = odp_packet_len(pkt); @@ -437,19 +453,26 @@ static void _verify_tailroom_shift(odp_packet_t pkt, } else { tail = odp_packet_pull_tail(pkt, -shift); } + seg_count_after = odp_packet_num_segs(pkt); CU_ASSERT_PTR_NOT_NULL(tail); - CU_ASSERT(odp_packet_seg_data_len(pkt, seg) == seg_data_len + shift); - CU_ASSERT(odp_packet_len(pkt) == pkt_data_len + shift); - CU_ASSERT(odp_packet_tailroom(pkt) == room - shift); - if (room == 0 || (room - shift) == 0) - return; - if (shift >= 0) { - CU_ASSERT(odp_packet_tail(pkt) == tail_orig + shift); - CU_ASSERT(tail == tail_orig); + + if (seg_count_before == seg_count_after) { + CU_ASSERT(odp_packet_seg_data_len(pkt, seg) == + seg_data_len + shift); + CU_ASSERT(odp_packet_len(pkt) == pkt_data_len + shift); + CU_ASSERT(odp_packet_tailroom(pkt) == room - shift); + if (room == 0 || (room - shift) == 0) + return; + if (shift >= 0) { + CU_ASSERT(odp_packet_tail(pkt) == tail_orig + shift); + CU_ASSERT(tail == tail_orig); + } else { + CU_ASSERT(odp_packet_tail(pkt) == tail); + CU_ASSERT(tail == tail_orig + shift); + } } else { - CU_ASSERT(odp_packet_tail(pkt) == tail); - CU_ASSERT(tail == tail_orig + shift); + CU_ASSERT(odp_packet_data(pkt) != NULL); } } @@ -478,6 +501,13 @@ void packet_test_tailroom(void) _verify_tailroom_shift(pkt, push_val + pull_val); _verify_tailroom_shift(pkt, -push_val); _verify_tailroom_shift(pkt, 0); + + if (segmentation_supported) { + push_val = room * 2; + _verify_tailroom_shift(pkt, push_val); + _verify_tailroom_shift(pkt, 0); + _verify_tailroom_shift(pkt, -push_val); + } } void packet_test_segments(void)