From patchwork Thu Jul 16 16:25:49 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stuart Haslam X-Patchwork-Id: 51193 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 294B622A8A for ; Thu, 16 Jul 2015 16:35:12 +0000 (UTC) Received: by widic2 with SMTP id ic2sf5859874wid.1 for ; Thu, 16 Jul 2015 09:35:11 -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=UQ9+x/BbcRhRBfLTcDLU3flFZRDb+QpaaAja/efmNrk=; b=iwOa7OTFa8UfY99Ly9Pc7kQYT7QoGZ0tNAKx+dfIdi5raUKOUN9oSQ127b/JYb9JjD 0KOon+lDQ88aSKhHydveWdqD1PsyIg1zy5EHfIDChz5szzslCe4+FvknekwDBQFC2fcI 01wlTzxC5kFfS3VPF+4I43aNnBBvBQdnj0cNjuu0QXpUxiEDxD5QC4SgHYVyB6/U5Asz GykK1KgWlrgn2lIKEm4SKBh1ZHOgiIBqh2mENdhq46+4Ml7F5emYdOScixE46AyRjD1Q M0MdpRiPdwguls2VQHWMC2ur+Dpk90nOsTyFkwYHLRBGLfjSZEK3gvLWEcebNH7AE/NV SKsw== X-Gm-Message-State: ALoCoQkpcz7O7NuoxCt5M7gSFYljvym9UAhdkYo68PWy9H9PLujP1wohBI9JvVn1BZycJRIsi6i3 X-Received: by 10.180.90.106 with SMTP id bv10mr2272953wib.6.1437064511401; Thu, 16 Jul 2015 09:35:11 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.180.135 with SMTP id do7ls399845lac.109.gmail; Thu, 16 Jul 2015 09:35:11 -0700 (PDT) X-Received: by 10.152.36.161 with SMTP id r1mr10150002laj.88.1437064511054; Thu, 16 Jul 2015 09:35:11 -0700 (PDT) Received: from mail-la0-f47.google.com (mail-la0-f47.google.com. [209.85.215.47]) by mx.google.com with ESMTPS id wn2si7375859lac.93.2015.07.16.09.35.11 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Jul 2015 09:35:11 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.47 as permitted sender) client-ip=209.85.215.47; Received: by lagw2 with SMTP id w2so46775326lag.3 for ; Thu, 16 Jul 2015 09:35:11 -0700 (PDT) X-Received: by 10.112.131.98 with SMTP id ol2mr10448386lbb.56.1437064510954; Thu, 16 Jul 2015 09:35:10 -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.108.230 with SMTP id hn6csp366962lbb; Thu, 16 Jul 2015 09:35:09 -0700 (PDT) X-Received: by 10.55.15.75 with SMTP id z72mr18215487qkg.58.1437064506285; Thu, 16 Jul 2015 09:35:06 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id i203si10168480qhc.66.2015.07.16.09.35.05; Thu, 16 Jul 2015 09:35:06 -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 723D9620B9; Thu, 16 Jul 2015 16:35:05 +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=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, URIBL_BLOCKED autolearn=disabled 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 9375C620EB; Thu, 16 Jul 2015 16:27:29 +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 D499D620EC; Thu, 16 Jul 2015 16:27:25 +0000 (UTC) Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com [209.85.212.181]) by lists.linaro.org (Postfix) with ESMTPS id 12DF9620B5 for ; Thu, 16 Jul 2015 16:26:19 +0000 (UTC) Received: by wicmv11 with SMTP id mv11so21099759wic.1 for ; Thu, 16 Jul 2015 09:26:18 -0700 (PDT) X-Received: by 10.194.178.99 with SMTP id cx3mr20048503wjc.33.1437063978230; Thu, 16 Jul 2015 09:26:18 -0700 (PDT) Received: from e106441.cambridge.arm.com ([2001:41d0:a:3cb4::abcd]) by smtp.gmail.com with ESMTPSA id be9sm13889153wjb.26.2015.07.16.09.26.15 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 16 Jul 2015 09:26:16 -0700 (PDT) From: Stuart Haslam To: lng-odp@lists.linaro.org Date: Thu, 16 Jul 2015 17:25:49 +0100 Message-Id: <1437063949-24456-10-git-send-email-stuart.haslam@linaro.org> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1437063949-24456-1-git-send-email-stuart.haslam@linaro.org> References: <1437063949-24456-1-git-send-email-stuart.haslam@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCHv2 9/9] validation: thrmask: test worker and control APIs 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: stuart.haslam@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.47 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 Add tests for odp_thrmask_worker() and odp_thrmask_control() Signed-off-by: Stuart Haslam --- test/validation/thrmask/thrmask.c | 72 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 67 insertions(+), 5 deletions(-) diff --git a/test/validation/thrmask/thrmask.c b/test/validation/thrmask/thrmask.c index 15d39c3..d07744e 100644 --- a/test/validation/thrmask/thrmask.c +++ b/test/validation/thrmask/thrmask.c @@ -7,9 +7,74 @@ #include #include "odp_cunit_common.h" +#include "test_debug.h" #include "thrmask.h" #include "mask_common.h" +odp_barrier_t bar_entry; +odp_barrier_t bar_exit; + +static void *thread_func(void *arg TEST_UNUSED) +{ + /* indicate that thread has started */ + odp_barrier_wait(&bar_entry); + + /* wait for indication that we can exit */ + odp_barrier_wait(&bar_exit); + + return NULL; +} + +static void thrmask_test_odp_thrmask_worker(void) +{ + odp_thrmask_t mask; + int ret; + pthrd_arg args = { .testcase = 0, .numthrds = 1 }; + + CU_ASSERT_FATAL(odp_thread_type() == ODP_THREAD_CONTROL); + + odp_barrier_init(&bar_entry, args.numthrds + 1); + odp_barrier_init(&bar_exit, args.numthrds + 1); + + /* should start out with 0 worker threads */ + ret = odp_thrmask_worker(&mask); + CU_ASSERT(ret == odp_thrmask_count(&mask)); + CU_ASSERT(ret == 0); + + /* start the test thread(s) */ + ret = odp_cunit_thread_create(thread_func, &args); + CU_ASSERT(ret == args.numthrds); + + if (ret != args.numthrds) + return; + + /* wait for thread(s) to start */ + odp_barrier_wait(&bar_entry); + + ret = odp_thrmask_worker(&mask); + CU_ASSERT(ret == odp_thrmask_count(&mask)); + CU_ASSERT(ret == args.numthrds); + CU_ASSERT(ret <= ODP_CONFIG_MAX_THREADS); + + /* allow thread(s) to exit */ + odp_barrier_wait(&bar_exit); + + odp_cunit_thread_exit(&args); +} + +static void thrmask_test_odp_thrmask_control(void) +{ + odp_thrmask_t mask; + int ret; + + CU_ASSERT(odp_thread_type() == ODP_THREAD_CONTROL); + + /* should start out with 1 worker thread */ + ret = odp_thrmask_control(&mask); + CU_ASSERT(ret == odp_thrmask_count(&mask)); + CU_ASSERT(ret == 1); +} + static CU_TestInfo thrmask_suite[] = { {"odp_thrmask_to/from_str()", thrmask_test_odp_thrmask_to_from_str}, {"odp_thrmask_equal()", thrmask_test_odp_thrmask_equal}, @@ -25,6 +90,8 @@ static CU_TestInfo thrmask_suite[] = { {"odp_thrmask_first()", thrmask_test_odp_thrmask_first}, {"odp_thrmask_last()", thrmask_test_odp_thrmask_last}, {"odp_thrmask_next()", thrmask_test_odp_thrmask_next}, + {"odp_thrmask_worker()", thrmask_test_odp_thrmask_worker}, + {"odp_thrmask_control()", thrmask_test_odp_thrmask_control}, CU_TEST_INFO_NULL, }; @@ -33,11 +100,6 @@ static CU_SuiteInfo thrmask_suites[] = { CU_SUITE_INFO_NULL, }; -unsigned max_supported_num_in_mask(void) -{ - return ODP_CONFIG_MAX_THREADS; -} - int thrmask_main(void) { return odp_cunit_run(thrmask_suites);