From patchwork Fri Oct 27 08:00:07 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: 117296 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp472972qgn; Fri, 27 Oct 2017 01:01:08 -0700 (PDT) X-Google-Smtp-Source: ABhQp+RIhsGe1jLyT6stTPFwSfLXE/QBgOxL5uskn+XFI7XgDdl7LP2xi0RJE3YoJ80DcMvA5i2r X-Received: by 10.55.3.130 with SMTP id 124mr12555837qkd.42.1509091268124; Fri, 27 Oct 2017 01:01:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509091268; cv=none; d=google.com; s=arc-20160816; b=ADM7U0UDvSTyP7VfCBttm2Ptc3usXHuW6x7o4trXlzpAa4CEOZDtTRMlQ5YcYycMND oBuhvulktyR+y5hTrQPlAWVux7S43sYOAKjrOG6rAwzXhMi7aYyVrQ7qbxdJGkLNosbt /WEyCrT54V2iw9bRiSPtUci9iujxV42waIvSuMG8v3zYzAgD3WCKoHFsLrBX30ukK3wT lLAs/u4eLjTL8A90czO3GhODl+LH9o5OPt79d0fFw8sqhYDmnKq+HbNivImdG8Xyo+qd /VXESjSvFiezs3p+CCZbG4GUIei4EaT5lf7+ooYAzWhz+Dc01qPjAm0SfbZEOgqHirRZ 80vQ== 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=AnhVqdd5WphAdKb/PJTcJa68c92liFReGrKa2XCH9i0=; b=hli6C5qqlm436ENaCa0joH3avFurlBFZ13zBMi7rXN6ui9WecFhIopTXdxYcV6ZfeL 7GPIDm95ETJJwLVMhI2E5QwJXiY2AgbQ5mHsTHSwi86tOM1fxFJK4WRCfhHOZ8NC6xcL 9q2tu21mibpb/h/6yQqnJkmr0cYTIzAhzG1VXVg6Hbng/IC4sGEb6dOWMa92QZmv+r6J kHUq8Hb5habLInTHX8mx9sy2Jnjj8M1cwunACEPDpZenFzW6F6zKXnnDp3EWwGUMJLLc VedswyS9NsNiQCqXhkI3aGCaOvrBs4CU47YQaCnlzE1N9DAM6Hi+bLDUvzl7a2ttfTgW twmw== 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 r74si3489744qka.105.2017.10.27.01.01.07; Fri, 27 Oct 2017 01:01:08 -0700 (PDT) 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 C65C76227A; Fri, 27 Oct 2017 08:01: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=-5.4 required=5.0 tests=BAYES_00,FREEMAIL_FROM, 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 558DB608BE; Fri, 27 Oct 2017 08:00:57 +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 42438618C8; Fri, 27 Oct 2017 08:00:52 +0000 (UTC) Received: from forward102o.mail.yandex.net (forward102o.mail.yandex.net [37.140.190.182]) by lists.linaro.org (Postfix) with ESMTPS id C6CDF60996 for ; Fri, 27 Oct 2017 08:00:50 +0000 (UTC) Received: from mxback8j.mail.yandex.net (mxback8j.mail.yandex.net [IPv6:2a02:6b8:0:1619::111]) by forward102o.mail.yandex.net (Yandex) with ESMTP id 570895A04168 for ; Fri, 27 Oct 2017 11:00:49 +0300 (MSK) Received: from smtp4o.mail.yandex.net (smtp4o.mail.yandex.net [2a02:6b8:0:1a2d::28]) by mxback8j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id f9Xvm1KOUE-0n4aVIhO; Fri, 27 Oct 2017 11:00:49 +0300 Received: by smtp4o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 5leQ09wrpf-0mJuYTxB; Fri, 27 Oct 2017 11:00:48 +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, 27 Oct 2017 11:00:07 +0300 Message-Id: <1509091212-14398-4-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1509091212-14398-1-git-send-email-odpbot@yandex.ru> References: <1509091212-14398-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 234 Subject: [lng-odp] [PATCH API-NEXT v4 3/8] validation: pool: add subparam test 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 Test packet pool subparameters when those are supported. Signed-off-by: Petri Savolainen --- /** Email created from pull request 234 (psavol:next-pool-param) ** https://github.com/Linaro/odp/pull/234 ** Patch: https://github.com/Linaro/odp/pull/234.patch ** Base sha: d61d32590d1772b70b8dcd0d0ec44d29029d7443 ** Merge commit sha: 436021e0a0bff8bda38fa420ebbc4545c97a7fc8 **/ test/validation/api/pool/pool.c | 98 +++++++++++++++++++++++++++++++++++++++++ test/validation/api/pool/pool.h | 3 +- 2 files changed, 100 insertions(+), 1 deletion(-) diff --git a/test/validation/api/pool/pool.c b/test/validation/api/pool/pool.c index e633137ab..c38a336ce 100644 --- a/test/validation/api/pool/pool.c +++ b/test/validation/api/pool/pool.c @@ -10,6 +10,9 @@ #include "odp_cunit_common.h" #include "pool.h" +#define PKT_LEN 400 +#define PKT_NUM 500 + static const int default_buffer_size = 1500; static const int default_buffer_num = 1000; @@ -96,10 +99,105 @@ void pool_test_lookup_info_print(void) CU_ASSERT(odp_pool_destroy(pool) == 0); } +void pool_test_alloc_packet(void) +{ + odp_pool_t pool; + odp_pool_param_t param; + uint32_t i, num; + odp_packet_t pkt[PKT_NUM]; + + odp_pool_param_init(¶m); + + param.type = ODP_POOL_PACKET, + param.pkt.num = PKT_NUM; + param.pkt.len = PKT_LEN; + + pool = odp_pool_create(NULL, ¶m); + + CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); + + num = 0; + + for (i = 0; i < PKT_NUM; i++) { + pkt[num] = odp_packet_alloc(pool, PKT_LEN); + CU_ASSERT(pkt[num] != ODP_PACKET_INVALID); + + if (pkt[num] != ODP_PACKET_INVALID) + num++; + } + + for (i = 0; i < num; i++) + odp_packet_free(pkt[i]); + + CU_ASSERT(odp_pool_destroy(pool) == 0); +} + +void pool_test_alloc_packet_subparam(void) +{ + odp_pool_t pool; + odp_pool_capability_t capa; + odp_pool_param_t param; + uint32_t i, j, num, num_sub; + odp_packet_t pkt[PKT_NUM]; + + CU_ASSERT_FATAL(odp_pool_capability(&capa) == 0); + num_sub = capa.pkt.max_num_subparam; + + CU_ASSERT_FATAL(num_sub <= ODP_POOL_MAX_SUBPARAMS); + + odp_pool_param_init(¶m); + + param.type = ODP_POOL_PACKET, + param.pkt.num = PKT_NUM; + param.pkt.len = PKT_LEN; + param.pkt.num_subparam = num_sub; + + for (i = 0; i < num_sub; i++) { + param.pkt.sub[i].num = PKT_NUM; + param.pkt.sub[i].len = PKT_LEN + (i * 100); + } + + pool = odp_pool_create(NULL, ¶m); + + CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); + + num = 0; + + for (i = 0; i < PKT_NUM; i++) { + pkt[num] = odp_packet_alloc(pool, PKT_LEN); + CU_ASSERT(pkt[num] != ODP_PACKET_INVALID); + + if (pkt[num] != ODP_PACKET_INVALID) + num++; + } + + for (i = 0; i < num; i++) + odp_packet_free(pkt[i]); + + for (j = 0; j < num_sub; j++) { + num = 0; + + for (i = 0; i < param.pkt.sub[j].num; i++) { + pkt[num] = odp_packet_alloc(pool, param.pkt.sub[j].len); + CU_ASSERT(pkt[num] != ODP_PACKET_INVALID); + + if (pkt[num] != ODP_PACKET_INVALID) + num++; + } + + for (i = 0; i < num; i++) + odp_packet_free(pkt[i]); + } + + CU_ASSERT(odp_pool_destroy(pool) == 0); +} + odp_testinfo_t pool_suite[] = { ODP_TEST_INFO(pool_test_create_destroy_buffer), ODP_TEST_INFO(pool_test_create_destroy_packet), ODP_TEST_INFO(pool_test_create_destroy_timeout), + ODP_TEST_INFO(pool_test_alloc_packet), + ODP_TEST_INFO(pool_test_alloc_packet_subparam), ODP_TEST_INFO(pool_test_lookup_info_print), ODP_TEST_INFO_NULL, }; diff --git a/test/validation/api/pool/pool.h b/test/validation/api/pool/pool.h index 29e517633..3f8f5ebce 100644 --- a/test/validation/api/pool/pool.h +++ b/test/validation/api/pool/pool.h @@ -13,8 +13,9 @@ void pool_test_create_destroy_buffer(void); void pool_test_create_destroy_packet(void); void pool_test_create_destroy_timeout(void); -void pool_test_create_destroy_buffer_shm(void); void pool_test_lookup_info_print(void); +void pool_test_alloc_packet(void); +void pool_test_alloc_packet_subparam(void); /* test arrays: */ extern odp_testinfo_t pool_suite[];