From patchwork Thu May 4 22: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: 98586 Delivered-To: patch@linaro.org Received: by 10.140.89.200 with SMTP id v66csp831555qgd; Thu, 4 May 2017 15:00:59 -0700 (PDT) X-Received: by 10.55.119.5 with SMTP id s5mr10078091qkc.32.1493935259290; Thu, 04 May 2017 15:00:59 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id 46si2833879qte.210.2017.05.04.15.00.58; Thu, 04 May 2017 15:00:59 -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; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 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 D1F4260950; Thu, 4 May 2017 22:00:58 +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 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 A3EB360609; Thu, 4 May 2017 22:00:34 +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 B13AB6095E; Thu, 4 May 2017 22:00:28 +0000 (UTC) Received: from forward2m.cmail.yandex.net (forward2m.cmail.yandex.net [5.255.216.20]) by lists.linaro.org (Postfix) with ESMTPS id 430EF60880 for ; Thu, 4 May 2017 22:00:27 +0000 (UTC) Received: from smtp1o.mail.yandex.net (smtp1o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::25]) by forward2m.cmail.yandex.net (Yandex) with ESMTP id 8C65421699 for ; Fri, 5 May 2017 01:00:24 +0300 (MSK) Received: from smtp1o.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtp1o.mail.yandex.net (Yandex) with ESMTP id 298811300AAE for ; Fri, 5 May 2017 01:00:23 +0300 (MSK) Received: by smtp1o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id GWvRAGZNCj-0NHWufHK; Fri, 05 May 2017 01:00:23 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) X-Yandex-Suid-Status: 1 0 From: Github ODP bot To: lng-odp@lists.linaro.org Date: Fri, 5 May 2017 01:00:07 +0300 Message-Id: <1493935208-7891-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1493935208-7891-1-git-send-email-odpbot@yandex.ru> References: <1493935208-7891-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 19 Subject: [lng-odp] [PATCH v1 2/2] test: lock: expand rwlock tests 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: Dmitry Eremin-Solenikov Expand testsuite for rwlocks: - always verify _trylock return code - always unlock after successful _trylock return - try calling _trylock when holding write lock Signed-off-by: Dmitry Eremin-Solenikov --- /** Email created from pull request 19 (lumag:fix-rwlock) ** https://github.com/Linaro/odp/pull/19 ** Patch: https://github.com/Linaro/odp/pull/19.patch ** Base sha: 79ba737a404d2833ad33d8f84ed6ce82c9a8c18e ** Merge commit sha: 8448157882fac03287253bf54c19284b6d52246e **/ test/common_plat/validation/api/lock/lock.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/test/common_plat/validation/api/lock/lock.c b/test/common_plat/validation/api/lock/lock.c index bd9a2aa..f8a1d8c 100644 --- a/test/common_plat/validation/api/lock/lock.c +++ b/test/common_plat/validation/api/lock/lock.c @@ -257,7 +257,7 @@ static int ticketlock_api_tests(void *arg UNUSED) static void rwlock_api_test(odp_rwlock_t *rw_lock) { - int rc; + int rc = 0; odp_rwlock_init(rw_lock); /* CU_ASSERT(odp_rwlock_is_locked(rw_lock) == 0); */ @@ -265,23 +265,40 @@ static void rwlock_api_test(odp_rwlock_t *rw_lock) odp_rwlock_read_lock(rw_lock); rc = odp_rwlock_read_trylock(rw_lock); - CU_ASSERT(rc == 0); + CU_ASSERT(rc != 0); + if (rc == 1) + odp_rwlock_read_unlock(rw_lock); + rc = odp_rwlock_write_trylock(rw_lock); CU_ASSERT(rc == 0); + if (rc == 1) + odp_rwlock_write_unlock(rw_lock); odp_rwlock_read_unlock(rw_lock); rc = odp_rwlock_read_trylock(rw_lock); + CU_ASSERT(rc != 0); if (rc == 1) odp_rwlock_read_unlock(rw_lock); odp_rwlock_write_lock(rw_lock); /* CU_ASSERT(odp_rwlock_is_locked(rw_lock) == 1); */ + rc = odp_rwlock_read_trylock(rw_lock); + CU_ASSERT(rc == 0); + if (rc == 1) + odp_rwlock_read_unlock(rw_lock); + + rc = odp_rwlock_write_trylock(rw_lock); + CU_ASSERT(rc == 0); + if (rc == 1) + odp_rwlock_write_unlock(rw_lock); + odp_rwlock_write_unlock(rw_lock); /* CU_ASSERT(odp_rwlock_is_locked(rw_lock) == 0); */ rc = odp_rwlock_write_trylock(rw_lock); + CU_ASSERT(rc != 0); if (rc == 1) odp_rwlock_write_unlock(rw_lock); }