From patchwork Thu Jun 25 21:48:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 50333 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5ADCF228FD for ; Thu, 25 Jun 2015 21:48:54 +0000 (UTC) Received: by wiws10 with SMTP id s10sf491878wiw.2 for ; Thu, 25 Jun 2015 14:48:53 -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=Fjda9gOF3v8O3UMgDvFZv5PYylw7dbEqzZDoHLMSSK0=; b=aitxmhUdehP7zc6nABh0/yDyjw+NmKVrvmfuXNPlMD39kDCVe+2tZQo88Gq9CTzY0J 9n6RuHKkzoJON0lmkkCtZNB/tPr4JijNj8BUG5ddedVE2z3Y/edkJE/os1SU6wHMPQoi +RD2AiWpvnLVXJPpxG1TqU0lekaRKDtHis/Y4bIv4wdYssluVexSbwWoXH4H9/ewA+d1 FWDn4j/gRlQOYoZ3qowtN6W1thMU7przMuT8NbKBYWRrmB4PbsdC8c8fEQ/i1tu8UOdK xBPsb+LccsJ5LRK6JqgGW5KEYxNz6ghGAj1yIxXyofV7OovdAqJ4qpYmbwWEcHNY8ioh J+9g== X-Gm-Message-State: ALoCoQl8hsJ9ViZymg+NjHBV8i7PxWPuBIRVsJOympXnDSxNMkoCVgJ5EJhUFshDLN3MGtZUQD1A X-Received: by 10.112.171.41 with SMTP id ar9mr41002150lbc.24.1435268933571; Thu, 25 Jun 2015 14:48:53 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.19.137 with SMTP id f9ls432903lae.5.gmail; Thu, 25 Jun 2015 14:48:53 -0700 (PDT) X-Received: by 10.152.45.9 with SMTP id i9mr45935881lam.87.1435268933418; Thu, 25 Jun 2015 14:48:53 -0700 (PDT) Received: from mail-la0-f51.google.com (mail-la0-f51.google.com. [209.85.215.51]) by mx.google.com with ESMTPS id y6si25720432lbj.20.2015.06.25.14.48.53 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Jun 2015 14:48:53 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.51 as permitted sender) client-ip=209.85.215.51; Received: by lagx9 with SMTP id x9so53058047lag.1 for ; Thu, 25 Jun 2015 14:48:53 -0700 (PDT) X-Received: by 10.152.36.102 with SMTP id p6mr19382424laj.19.1435268932987; Thu, 25 Jun 2015 14:48:52 -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.108.230 with SMTP id hn6csp872942lbb; Thu, 25 Jun 2015 14:48:52 -0700 (PDT) X-Received: by 10.55.24.166 with SMTP id 38mr103855586qky.70.1435268931816; Thu, 25 Jun 2015 14:48:51 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id t18si30832549qgd.12.2015.06.25.14.48.50; Thu, 25 Jun 2015 14:48:51 -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 CE5BA61FB3; Thu, 25 Jun 2015 21:48:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252.ec2.internal 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 ip-10-142-244-252.ec2.internal (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id A46AA620D1; Thu, 25 Jun 2015 21:48:27 +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 E754B61D66; Thu, 25 Jun 2015 21:48:21 +0000 (UTC) Received: from mail-ob0-f180.google.com (mail-ob0-f180.google.com [209.85.214.180]) by lists.linaro.org (Postfix) with ESMTPS id 9DCD661D66 for ; Thu, 25 Jun 2015 21:48:20 +0000 (UTC) Received: by obctg8 with SMTP id tg8so55709952obc.3 for ; Thu, 25 Jun 2015 14:48:20 -0700 (PDT) X-Received: by 10.202.206.202 with SMTP id e193mr9852394oig.132.1435268900224; Thu, 25 Jun 2015 14:48:20 -0700 (PDT) Received: from localhost.localdomain (cpe-24-28-70-239.austin.res.rr.com. [24.28.70.239]) by mx.google.com with ESMTPSA id x77sm1491475oix.7.2015.06.25.14.48.19 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 25 Jun 2015 14:48:19 -0700 (PDT) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Thu, 25 Jun 2015 16:48:12 -0500 Message-Id: <1435268892-22935-2-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1435268892-22935-1-git-send-email-bill.fischofer@linaro.org> References: <1435268892-22935-1-git-send-email-bill.fischofer@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCH 2/2] validation: packet: add segmented packet segment tests 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: bill.fischofer@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.51 as permitted sender) smtp.mail=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: Bill Fischofer Extend segment tests to catch Bug https://bugs.linaro.org/show_bug.cgi?id=1661 --- test/validation/odp_packet.c | 61 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 59 insertions(+), 2 deletions(-) diff --git a/test/validation/odp_packet.c b/test/validation/odp_packet.c index 5915aba..a85eb8f 100644 --- a/test/validation/odp_packet.c +++ b/test/validation/odp_packet.c @@ -22,7 +22,11 @@ static const uint32_t packet_len = PACKET_BUF_LEN - ODP_CONFIG_PACKET_TAILROOM - PACKET_TAILROOM_RESERVE; -odp_packet_t test_packet; +static const uint32_t segmented_packet_len = PACKET_BUF_LEN * 5 - + ODP_CONFIG_PACKET_HEADROOM - ODP_CONFIG_PACKET_TAILROOM - + PACKET_TAILROOM_RESERVE; + +odp_packet_t test_packet, segmented_test_packet; static struct udata_struct { uint64_t u64; @@ -53,8 +57,11 @@ static int packet_testsuite_init(void) return -1; test_packet = odp_packet_alloc(packet_pool, packet_len); + segmented_test_packet = odp_packet_alloc(packet_pool, + segmented_packet_len); - if (odp_packet_is_valid(test_packet) == 0) + if (odp_packet_is_valid(test_packet) == 0 || + odp_packet_is_valid(segmented_test_packet) == 0) return -1; udat = odp_packet_user_area(test_packet); @@ -64,12 +71,19 @@ static int packet_testsuite_init(void) odp_pool_print(packet_pool); memcpy(udat, &test_packet_udata, sizeof(struct udata_struct)); + udat = odp_packet_user_area(segmented_test_packet); + udat_size = odp_packet_user_area_size(segmented_test_packet); + if (udat == NULL || udat_size != sizeof(struct udata_struct)) + return -1; + memcpy(udat, &test_packet_udata, sizeof(struct udata_struct)); + return 0; } static int packet_testsuite_finalize(void) { odp_packet_free(test_packet); + odp_packet_free(segmented_test_packet); if (odp_pool_destroy(packet_pool) != 0) return -1; return 0; @@ -378,6 +392,7 @@ static void packet_segments(void) uint32_t data_len, buf_len; odp_packet_seg_t seg; odp_packet_t pkt = test_packet; + odp_packet_t seg_pkt = segmented_test_packet; CU_ASSERT(odp_packet_is_valid(pkt) == 1); @@ -390,6 +405,8 @@ static void packet_segments(void) CU_ASSERT(num_segs == 1); } + CU_ASSERT(odp_packet_is_segmented(pkt) == 0); + CU_ASSERT(odp_packet_is_segmented(seg_pkt) == 1); seg = odp_packet_first_seg(pkt); buf_len = 0; @@ -427,6 +444,46 @@ static void packet_segments(void) if (seg_index == num_segs) CU_ASSERT(seg == ODP_PACKET_SEG_INVALID); + + seg = odp_packet_first_seg(seg_pkt); + num_segs = odp_packet_num_segs(seg_pkt); + + buf_len = 0; + data_len = 0; + seg_index = 0; + + while (seg_index < num_segs && seg != ODP_PACKET_SEG_INVALID) { + uint32_t seg_data_len, seg_buf_len; + void *seg_buf_addr, *seg_data; + + seg_buf_addr = odp_packet_seg_buf_addr(seg_pkt, seg); + seg_buf_len = odp_packet_seg_buf_len(seg_pkt, seg); + seg_data_len = odp_packet_seg_data_len(seg_pkt, seg); + seg_data = odp_packet_seg_data(seg_pkt, seg); + + CU_ASSERT(seg_buf_len > 0); + CU_ASSERT(seg_data_len > 0); + CU_ASSERT(seg_buf_len >= seg_data_len); + CU_ASSERT(seg_data != NULL); + CU_ASSERT(seg_buf_addr != NULL); + CU_ASSERT(seg_data >= seg_buf_addr); + CU_ASSERT(odp_packet_seg_to_u64(seg) != + odp_packet_seg_to_u64(ODP_PACKET_SEG_INVALID)); + + buf_len += seg_buf_len; + data_len += seg_data_len; + + /** @todo: touch memory in a segment */ + seg_index++; + seg = odp_packet_next_seg(seg_pkt, seg); + } + + CU_ASSERT(seg_index == num_segs); + CU_ASSERT(buf_len == odp_packet_buf_len(seg_pkt)); + CU_ASSERT(data_len == odp_packet_len(seg_pkt)); + + if (seg_index == num_segs) + CU_ASSERT(seg == ODP_PACKET_SEG_INVALID); } static void packet_segment_last(void)