From patchwork Thu Feb 1 16:00:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 126544 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp1837638ljc; Thu, 1 Feb 2018 08:01:13 -0800 (PST) X-Google-Smtp-Source: AH8x225g+fmwxS89snEaNx5VhtN24igkyBEDGoeviAbOBdjmbmWDVtrK0fM3dQtS5nfDnaF9bump X-Received: by 10.237.38.229 with SMTP id q92mr59794940qtd.160.1517500873505; Thu, 01 Feb 2018 08:01:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517500873; cv=none; d=google.com; s=arc-20160816; b=v8OeTEWEJ/KpDl/1TlXgaFW+ruWOW2jCNM59w+K7vMLp1HQ+7ptSAKNQZwAHIPd7Bo qBiQAWaxaQDaANhGBb0V5hDle+Baj/Cnb3ZoOcpgo2gZa+M6iuXq398wkMPuclYmbZUx bBrVMt3W+yQCYEfZRZwSLrVts00p9RmFEMji2ciN58frRYvPAgYcN0DjVL5uJwmjCqFt 45sxCaHetlKm6ea/05zTuFQy3/q1Yw5r8pNpuK3TQbhdT3GYp6CGUdwZsNgBAWIoVi5t sLtsmV5DhmCWBE8EmOaG5038LQp0SPKiFsGsiDwg0v/4j0mUBQtLa2gsKRLud681tOX/ bdwA== 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=3mRQhSO9PuN1OL7eom4i+xK+Vb9GDwEZN16nvw5tnqM=; b=Ol5V0GTRDyiQ/A+cBr8a/pRoOxgFwGt79K93njUFGCmGqrNHDu8JTjBTqPOQJY+kDa 2jMF5DwTkL5rwU9z573SG2hdQiIyy5N/egu/Dtw4aqVmOBd35qumlMd84sMyCMKNfmGK 820+vep1S6AcFJkLilfgZ3Mqi/AtSTDWVr8vZeriozr1g4sCRzylraZQ/6t/cJgzJQTQ h25yD440GGv/WL41D5Chr7mGGtATzECPhWI2pcXRnfK8GwWs3z6Tnu00Yi+UJdgMTSbq /kSGV4zcfU5wSgJsV8QxPasXwiozhOkuQ5JtgtnCfw9DAH4BRE+No8NDi80EehYhTriH YLBg== 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 95si2228805qkr.17.2018.02.01.08.01.13; Thu, 01 Feb 2018 08:01:13 -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 1888B61737; Thu, 1 Feb 2018 16:01:13 +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,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2 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 3E0516176F; Thu, 1 Feb 2018 16:00:31 +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 2A0E5617A2; Thu, 1 Feb 2018 16:00:18 +0000 (UTC) Received: from forward105p.mail.yandex.net (forward105p.mail.yandex.net [77.88.28.108]) by lists.linaro.org (Postfix) with ESMTPS id AFB3660813 for ; Thu, 1 Feb 2018 16:00:12 +0000 (UTC) Received: from mxback13j.mail.yandex.net (mxback13j.mail.yandex.net [IPv6:2a02:6b8:0:1619::88]) by forward105p.mail.yandex.net (Yandex) with ESMTP id 284F24082CA9 for ; Thu, 1 Feb 2018 19:00:11 +0300 (MSK) Received: from smtp3o.mail.yandex.net (smtp3o.mail.yandex.net [2a02:6b8:0:1a2d::27]) by mxback13j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id DB7XBYl0ss-0B5qmdFd; Thu, 01 Feb 2018 19:00:11 +0300 Received: by smtp3o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id IQBTIJTeEr-0Ad4tcR5; Thu, 01 Feb 2018 19:00:10 +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: Thu, 1 Feb 2018 19:00:07 +0300 Message-Id: <1517500809-452-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1517500809-452-1-git-send-email-odpbot@yandex.ru> References: <1517500809-452-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 446 Subject: [lng-odp] [PATCH API-NEXT v1 1/3] validation: shm: test capa and maximum reservation 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 test which uses capability API, and tries to reserve and use maximum sized block. 100 MB shm memory is assumed to be available to ODP validation tests. Signed-off-by: Petri Savolainen --- /** Email created from pull request 446 (psavol:next-global-init-shm-size-2) ** https://github.com/Linaro/odp/pull/446 ** Patch: https://github.com/Linaro/odp/pull/446.patch ** Base sha: 5718327018debbb02aacb464493504c95fbe57a3 ** Merge commit sha: 5beffee2f03442764ec79a301dd6608c8e82c8b4 **/ test/validation/api/shmem/shmem.c | 52 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/test/validation/api/shmem/shmem.c b/test/validation/api/shmem/shmem.c index bda07011c..feef34c54 100644 --- a/test/validation/api/shmem/shmem.c +++ b/test/validation/api/shmem/shmem.c @@ -22,6 +22,8 @@ #define STRESS_SIZE 32 /* power of 2 and <=256 */ #define STRESS_RANDOM_SZ 5 #define STRESS_ITERATION 5000 +#define MEGA 1000000UL +#define MAX_MEMORY_USED (100 * MEGA) typedef enum { STRESS_FREE, /* entry is free and can be allocated */ @@ -212,6 +214,55 @@ void shmem_test_basic(void) CU_ASSERT(0 == odp_shm_free(shm)); } +/* + * maximum size reservation + */ +static void shmem_test_max_reserve(void) +{ + odp_shm_capability_t capa; + odp_shm_t shm; + uint64_t size, align; + uint8_t *data; + uint64_t i; + + memset(&capa, 0, sizeof(odp_shm_capability_t)); + CU_ASSERT_FATAL(odp_shm_capability(&capa) == 0); + + CU_ASSERT(capa.max_blocks > 0); + + size = capa.max_size; + align = capa.max_align; + + /* Assuming that system has at least MAX_MEMORY_USED bytes available */ + if (capa.max_size == 0 || capa.max_size > MAX_MEMORY_USED) + size = MAX_MEMORY_USED; + + if (capa.max_align == 0 || capa.max_align > MEGA) + align = MEGA; + + printf("\n size: %" PRIu64 "\n", size); + printf(" align: %" PRIu64 "\n", align); + + shm = odp_shm_reserve("test_max_reserve", size, align, 0); + CU_ASSERT(shm != ODP_SHM_INVALID); + + data = odp_shm_addr(shm); + CU_ASSERT(data != NULL); + + if (data) { + memset(data, 0xde, size); + for (i = 0; i < size; i++) { + if (data[i] != 0xde) { + CU_FAIL("Data error"); + break; + } + } + } + + if (shm != ODP_SHM_INVALID) + CU_ASSERT(odp_shm_free(shm) == 0); +} + /* * thread part for the shmem_test_reserve_after_fork */ @@ -769,6 +820,7 @@ void shmem_test_stress(void) odp_testinfo_t shmem_suite[] = { ODP_TEST_INFO(shmem_test_basic), + ODP_TEST_INFO(shmem_test_max_reserve), ODP_TEST_INFO(shmem_test_reserve_after_fork), ODP_TEST_INFO(shmem_test_singleva_after_fork), ODP_TEST_INFO(shmem_test_stress),