From patchwork Fri Apr 10 15:52:18 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 47061 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E574E21416 for ; Fri, 10 Apr 2015 15:56:09 +0000 (UTC) Received: by laat2 with SMTP id t2sf5417836laa.2 for ; Fri, 10 Apr 2015 08:56:08 -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=aqHErPwXP6ageyn41JxszgVX55uhe7JEUmatZIq9beQ=; b=X0kdb0OowzXpfNlsBJ9We8YpGHmoJZBKs74oV0GMbW1m7qbgP2TOMk5tQ+B6rQ6WqP D7Y9I2JmUSuvU11i8r4sOPNfoBnsPNWvM23XED2Hpl85tfZ2TJScURZ7uBlF1A8AveX/ ZtTt54MD7ZhgUXguj81QxFTsJTpFUo1JGZLpJ2HZV4BQfrBjYezODYkQGJQqPsJVDzHv tsijZ3ZZza+1dfMLEcTzAAUWGAN5FPByr581SE7X7pLj8lV68N6UVCl86CDdoL1LvMsv REyPrPcAQEP/7Dc28uQGgtwb0teBQnO1bEDqla0VZH+x70UngzaPcFQQea02qPtwJw+m 6pkQ== X-Gm-Message-State: ALoCoQmGtOo4CmiYrKcx9DSh+BNbQLSoIXhlNXAREoiwHc4PVFemWIg1MxUyDh9m/QZm00l4E9Az X-Received: by 10.152.37.101 with SMTP id x5mr446220laj.5.1428681368947; Fri, 10 Apr 2015 08:56:08 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.205.33 with SMTP id ld1ls482094lac.11.gmail; Fri, 10 Apr 2015 08:56:08 -0700 (PDT) X-Received: by 10.152.5.39 with SMTP id p7mr2036459lap.18.1428681368732; Fri, 10 Apr 2015 08:56:08 -0700 (PDT) Received: from mail-la0-f48.google.com (mail-la0-f48.google.com. [209.85.215.48]) by mx.google.com with ESMTPS id ba7si1794291lab.50.2015.04.10.08.56.08 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Apr 2015 08:56:08 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.48 as permitted sender) client-ip=209.85.215.48; Received: by lagv1 with SMTP id v1so16362220lag.3 for ; Fri, 10 Apr 2015 08:56:08 -0700 (PDT) X-Received: by 10.112.162.232 with SMTP id yd8mr1980500lbb.41.1428681368561; Fri, 10 Apr 2015 08:56:08 -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.67.65 with SMTP id l1csp1190423lbt; Fri, 10 Apr 2015 08:56:07 -0700 (PDT) X-Received: by 10.140.235.73 with SMTP id g70mr2557122qhc.73.1428681367365; Fri, 10 Apr 2015 08:56:07 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id g83si2178768qhc.58.2015.04.10.08.56.05; Fri, 10 Apr 2015 08:56: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; Received: by lists.linaro.org (Postfix, from userid 109) id F1D4C650F9; Fri, 10 Apr 2015 15:56:04 +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=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, URIBL_BLOCKED autolearn=unavailable autolearn_force=no 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 9F8D065105; Fri, 10 Apr 2015 15:53:52 +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 EA757650F4; Fri, 10 Apr 2015 15:53:31 +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 4368D650FF for ; Fri, 10 Apr 2015 15:52:36 +0000 (UTC) Received: by obbfy7 with SMTP id fy7so20295858obb.2 for ; Fri, 10 Apr 2015 08:52:35 -0700 (PDT) X-Received: by 10.182.248.161 with SMTP id yn1mr2699790obc.25.1428681154086; Fri, 10 Apr 2015 08:52:34 -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 ke9sm1895845obb.9.2015.04.10.08.52.33 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 10 Apr 2015 08:52:33 -0700 (PDT) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Fri, 10 Apr 2015 10:52:18 -0500 Message-Id: <1428681138-24954-7-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1428681138-24954-1-git-send-email-bill.fischofer@linaro.org> References: <1428681138-24954-1-git-send-email-bill.fischofer@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCHv4 6/6] validation: packet: add user metadata 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.48 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 --- test/validation/odp_packet.c | 54 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/test/validation/odp_packet.c b/test/validation/odp_packet.c index 0c1d069..e9395b6 100644 --- a/test/validation/odp_packet.c +++ b/test/validation/odp_packet.c @@ -24,6 +24,16 @@ static const uint32_t packet_len = PACKET_BUF_LEN - odp_packet_t test_packet; +static struct udata_struct { + uint64_t u64; + uint32_t u32; + char str[10]; +} test_packet_udata = { + 123456, + 789912, + "abcdefg", +}; + static int packet_testsuite_init(void) { odp_pool_param_t params = { @@ -31,18 +41,31 @@ static int packet_testsuite_init(void) .seg_len = PACKET_BUF_LEN, .len = PACKET_BUF_LEN, .num = 100, + .udata_size = sizeof(struct udata_struct), }, .type = ODP_POOL_PACKET, }; + struct udata_struct *udat; + uint32_t udat_size; packet_pool = odp_pool_create("packet_pool", ODP_SHM_INVALID, ¶ms); if (packet_pool == ODP_POOL_INVALID) return -1; test_packet = odp_packet_alloc(packet_pool, packet_len); + if (odp_packet_is_valid(test_packet) == 0) return -1; + udat = odp_packet_user_data(test_packet); + udat_size = odp_packet_user_data_size(test_packet); + if (udat == NULL || udat_size != sizeof(struct udata_struct)) + return -1; + odp_pool_print(packet_pool); + printf("about to init udata at addr %p size %d\n", udat, udat_size); + memcpy(udat, &test_packet_udata, sizeof(struct udata_struct)); + printf("udata set in test_packet\n"); + return 0; } @@ -162,6 +185,7 @@ static void packet_context(void) odp_packet_t pkt = test_packet; char ptr_test_value = 2; uint64_t u64_test_value = 0x0123456789abcdf; + struct udata_struct *udat; void *prev_ptr; uint64_t prev_u64; @@ -176,6 +200,13 @@ static void packet_context(void) CU_ASSERT(odp_packet_user_u64(pkt) == u64_test_value); odp_packet_user_u64_set(pkt, prev_u64); + udat = odp_packet_user_data(pkt); + CU_ASSERT(udat != NULL); + CU_ASSERT(odp_packet_user_data_size(pkt) == + sizeof(struct udata_struct)); + CU_ASSERT(memcmp(udat, &test_packet_udata, sizeof(struct udata_struct)) + == 0); + odp_packet_reset(pkt, packet_len); } @@ -479,6 +510,7 @@ static void packet_add_rem_data(void) uint32_t pkt_len, offset, add_len; void *usr_ptr; uint64_t usr_u64; + struct udata_struct *udat, *new_udat; pkt = odp_packet_alloc(packet_pool, PACKET_BUF_LEN); CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID); @@ -486,6 +518,11 @@ static void packet_add_rem_data(void) pkt_len = odp_packet_len(pkt); usr_ptr = odp_packet_user_ptr(pkt); usr_u64 = odp_packet_user_u64(pkt); + udat = odp_packet_user_data(pkt); + CU_ASSERT(odp_packet_user_data_size(pkt) == + sizeof(struct udata_struct)); + memcpy(udat, &test_packet_udata, sizeof(struct udata_struct)); + /* Insert one more packet length in the middle of a packet */ offset = pkt_len / 2; add_len = pkt_len; @@ -499,6 +536,14 @@ static void packet_add_rem_data(void) CU_ASSERT(odp_packet_user_ptr(new_pkt) == usr_ptr); CU_ASSERT(odp_packet_user_u64(new_pkt) == usr_u64); + /* Verify that user metadata has been preserved */ + new_udat = odp_packet_user_data(new_pkt); + CU_ASSERT(new_udat != NULL); + CU_ASSERT(odp_packet_user_data_size(new_pkt) == + sizeof(struct udata_struct)); + CU_ASSERT(memcmp(new_udat, &test_packet_udata, + sizeof(struct udata_struct)) == 0); + pkt = new_pkt; pkt_len = odp_packet_len(pkt); @@ -511,6 +556,15 @@ static void packet_add_rem_data(void) CU_ASSERT(odp_packet_len(new_pkt) == pkt_len - add_len); CU_ASSERT(odp_packet_user_ptr(new_pkt) == usr_ptr); CU_ASSERT(odp_packet_user_u64(new_pkt) == usr_u64); + + /* Verify that user metadata has been preserved */ + new_udat = odp_packet_user_data(new_pkt); + CU_ASSERT(new_udat != NULL); + CU_ASSERT(odp_packet_user_data_size(new_pkt) == + sizeof(struct udata_struct)); + CU_ASSERT(memcmp(new_udat, &test_packet_udata, + sizeof(struct udata_struct)) == 0); + pkt = new_pkt; free_packet: