From patchwork Fri Dec 1 15:00:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 120340 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp1253083qgn; Fri, 1 Dec 2017 07:05:25 -0800 (PST) X-Google-Smtp-Source: AGs4zMY3vjRHNy9pmoqqzgDb8f9yVdeT5n6fLGH+Fvy8BK1cYLGrFMODJJB5gdWgOjyhrq5Dpl5r X-Received: by 10.55.149.196 with SMTP id x187mr7534151qkd.51.1512140725459; Fri, 01 Dec 2017 07:05:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512140725; cv=none; d=google.com; s=arc-20160816; b=bkVHAtl/+28HXyKKpQa0EP2vRihXJ5Y/4iTG03FoXEL/y9DxXmH0Oq3Aj6aYE9K2Pb 0HGkMVvr4EpX/M36krCi2gKaUvg86Wc8/duIkLtwhr4rnwY+xOY2FddQZH7H9jfH4tB4 JUyAjOhtBjik37pNy94NaVkzWxwQwCrxLmK6VVi1ny2tzE6tj9xOzJ4Zt6OVz4mLmt8f JZAagDlmwOvURi/zdGjk0zkygxw785P7J+6mhlUe3lWz3SE3x/X65CA0xyTeGo9LQ0vh 5PMx6/6xLSXatUhofEwP0/DrzkAJZzmax1b8jzMRCsigiR5X1JJ9ChIQYe9Ir/1S0KdB ZkwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=jiiooJagx77z7auSS0Xkr0u88g/4Y6gnyKV1ehiioxY=; b=zatM5i/cjSn3gak8WcWF4ydbrfzntyqBw9S7z42HEQbGL2duNCvuGY4+IgjHrhu1Gg o1wmi6M2H2D++/GK3OwOHuFzt5pD2hie/LkocnH7+L1jzVuMeaTlFiJ5JWiMx8dYze5B N2FvKOAgasRUzpDThntIq3B+LsS1FooK+xqrTOqQPyZOEQH2N4ru8YkDmFOZZtwCq8L9 TlVC5SCYPKu9fOsL1sSFysMkDhpdXmA0dUaaW5WyPiTe3YgEIUhjx9bTRF+ZMa9QfNEt YkdDsSbMgOxa6LY/5xcpxiS1QdK2eJVw1v0viTVsiBvGE8vESGsG7NKVKeysDc8Oqol3 YbaQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id g35si7025876qtc.110.2017.12.01.07.05.23; Fri, 01 Dec 2017 07:05:25 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 89A2160988; Fri, 1 Dec 2017 15:05:23 +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=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, 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 EB5F060999; Fri, 1 Dec 2017 15:00:55 +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 05DBE60973; Fri, 1 Dec 2017 15:00:25 +0000 (UTC) Received: from forward104j.mail.yandex.net (forward104j.mail.yandex.net [5.45.198.247]) by lists.linaro.org (Postfix) with ESMTPS id 4922260974 for ; Fri, 1 Dec 2017 15:00:19 +0000 (UTC) Received: from mxback1o.mail.yandex.net (mxback1o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::1b]) by forward104j.mail.yandex.net (Yandex) with ESMTP id 3FF1C46177 for ; Fri, 1 Dec 2017 18:00:18 +0300 (MSK) Received: from smtp1j.mail.yandex.net (smtp1j.mail.yandex.net [2a02:6b8:0:801::ab]) by mxback1o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id wolaXanFOn-0ICiMr3K; Fri, 01 Dec 2017 18:00:18 +0300 Received: by smtp1j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id I6qrBsStkX-0HeiwI3u; Fri, 01 Dec 2017 18:00:17 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Fri, 1 Dec 2017 18:00:01 +0300 Message-Id: <1512140407-13534-7-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1512140407-13534-1-git-send-email-odpbot@yandex.ru> References: <1512140407-13534-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 318 Subject: [lng-odp] [PATCH API-NEXT v1 6/12] validation: packet: multi converts and single pool free 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: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Petri Savolainen Added tests for the new multi convert and single pool free functions. Signed-off-by: Petri Savolainen --- /** Email created from pull request 318 (psavol:next-multi-apis) ** https://github.com/Linaro/odp/pull/318 ** Patch: https://github.com/Linaro/odp/pull/318.patch ** Base sha: bdb7cbf620ada8682c89b5ae5a97cb84f16c0ed0 ** Merge commit sha: aee2bcc574d2a8efdfcecc3b8e681ce391119798 **/ test/validation/api/packet/packet.c | 85 ++++++++++++++++++++++++++++++++----- test/validation/api/packet/packet.h | 1 + 2 files changed, 75 insertions(+), 11 deletions(-) diff --git a/test/validation/api/packet/packet.c b/test/validation/api/packet/packet.c index ce4d66c0b..e8e664e4a 100644 --- a/test/validation/api/packet/packet.c +++ b/test/validation/api/packet/packet.c @@ -396,6 +396,50 @@ void packet_test_alloc_free_multi(void) CU_ASSERT(odp_pool_destroy(pool[1]) == 0); } +void packet_test_free_sp(void) +{ + const int num_pkt = 10; + odp_pool_t pool; + int i, ret; + odp_packet_t packet[num_pkt]; + odp_pool_param_t params; + odp_pool_capability_t capa; + uint32_t len = packet_len; + + CU_ASSERT_FATAL(odp_pool_capability(&capa) == 0); + + if (capa.pkt.max_len < len) + len = capa.pkt.max_len; + + odp_pool_param_init(¶ms); + + params.type = ODP_POOL_PACKET; + params.pkt.len = len; + params.pkt.num = num_pkt; + + pool = odp_pool_create("packet_pool_free_sp", ¶ms); + CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); + + ret = packet_alloc_multi(pool, len, packet, num_pkt); + CU_ASSERT_FATAL(ret == num_pkt); + for (i = 0; i < num_pkt; i++) { + CU_ASSERT_FATAL(packet[i] != ODP_PACKET_INVALID); + CU_ASSERT(odp_packet_len(packet[i]) == len); + } + odp_packet_free_sp(packet, num_pkt); + + /* Check that all the packets were returned back to the pool */ + ret = packet_alloc_multi(pool, len, packet, num_pkt); + CU_ASSERT_FATAL(ret == num_pkt); + for (i = 0; i < num_pkt; i++) { + CU_ASSERT_FATAL(packet[i] != ODP_PACKET_INVALID); + CU_ASSERT(odp_packet_len(packet[i]) == len); + } + odp_packet_free_sp(packet, num_pkt); + + CU_ASSERT(odp_pool_destroy(pool) == 0); +} + void packet_test_alloc_segmented(void) { const int num = 5; @@ -481,23 +525,41 @@ void packet_test_alloc_segmented(void) void packet_test_event_conversion(void) { - odp_packet_t pkt = test_packet; + odp_packet_t pkt0 = test_packet; + odp_packet_t pkt1 = segmented_test_packet; odp_packet_t tmp_pkt; - odp_event_t ev; + odp_event_t event; odp_event_subtype_t subtype; - - ev = odp_packet_to_event(pkt); - CU_ASSERT_FATAL(ev != ODP_EVENT_INVALID); - CU_ASSERT(odp_event_type(ev) == ODP_EVENT_PACKET); - CU_ASSERT(odp_event_subtype(ev) == ODP_EVENT_PACKET_BASIC); - CU_ASSERT(odp_event_types(ev, &subtype) == + odp_packet_t pkt[2] = {pkt0, pkt1}; + odp_event_t ev[2]; + int i; + + event = odp_packet_to_event(pkt0); + CU_ASSERT_FATAL(event != ODP_EVENT_INVALID); + CU_ASSERT(odp_event_type(event) == ODP_EVENT_PACKET); + CU_ASSERT(odp_event_subtype(event) == ODP_EVENT_PACKET_BASIC); + CU_ASSERT(odp_event_types(event, &subtype) == ODP_EVENT_PACKET); CU_ASSERT(subtype == ODP_EVENT_PACKET_BASIC); - tmp_pkt = odp_packet_from_event(ev); + tmp_pkt = odp_packet_from_event(event); CU_ASSERT_FATAL(tmp_pkt != ODP_PACKET_INVALID); - CU_ASSERT(tmp_pkt == pkt); - packet_compare_data(tmp_pkt, pkt); + CU_ASSERT(tmp_pkt == pkt0); + packet_compare_data(tmp_pkt, pkt0); + + odp_packet_to_event_multi(pkt, ev, 2); + + for (i = 0; i < 2; i++) { + CU_ASSERT_FATAL(ev[i] != ODP_EVENT_INVALID); + CU_ASSERT(odp_event_type(ev[i]) == ODP_EVENT_PACKET); + CU_ASSERT(odp_event_subtype(ev[i]) == ODP_EVENT_PACKET_BASIC); + } + + odp_packet_from_event_multi(pkt, ev, 2); + CU_ASSERT(pkt[0] == pkt0); + CU_ASSERT(pkt[1] == pkt1); + packet_compare_data(pkt[0], pkt0); + packet_compare_data(pkt[1], pkt1); } void packet_test_basic_metadata(void) @@ -2595,6 +2657,7 @@ void packet_test_parse(void) odp_testinfo_t packet_suite[] = { ODP_TEST_INFO(packet_test_alloc_free), ODP_TEST_INFO(packet_test_alloc_free_multi), + ODP_TEST_INFO(packet_test_free_sp), ODP_TEST_INFO(packet_test_alloc_segmented), ODP_TEST_INFO(packet_test_basic_metadata), ODP_TEST_INFO(packet_test_debug), diff --git a/test/validation/api/packet/packet.h b/test/validation/api/packet/packet.h index 4e99679ed..1d9947afa 100644 --- a/test/validation/api/packet/packet.h +++ b/test/validation/api/packet/packet.h @@ -12,6 +12,7 @@ /* test functions: */ void packet_test_alloc_free(void); void packet_test_alloc_free_multi(void); +void packet_test_free_sp(void); void packet_test_alloc_segmented(void); void packet_test_event_conversion(void); void packet_test_basic_metadata(void);