From patchwork Mon Jul 13 17:53:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stuart Haslam X-Patchwork-Id: 51081 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f71.google.com (mail-wg0-f71.google.com [74.125.82.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4E5F320319 for ; Mon, 13 Jul 2015 18:00:23 +0000 (UTC) Received: by wgbbj7 with SMTP id bj7sf105930240wgb.2 for ; Mon, 13 Jul 2015 11:00:22 -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=MSGYP6QXEmztaJ48/1aBXnXX9rBHiySTXK5dnH7RYFc6feGcFK7TtFCcWacmZA3fb8 niv+KlpKi9ai4/3iGkJqBc2QUdOkQ6v01mbYV5DSFtTGyYAG2DILX00ZtX+mj6TQi3wR WseDR0+kCLC1fV1odeF0qsJEAWKx2Vbr0GeoCuv+32MJnOCMPhcdUZ6qMGpkU91886Ac 6G6mHcTpQZtR7P8YLgerIaUw/oeGfZjtieAgdkIrqyDASaPn6/pZbEP1TI0p6BS3AeEc U+J9IMSVriH/2A0qJ29hGEcrwSagxQkR8mz4wja+ce74iSJAqWcj2syM9XXzHJ9L1f0E hEDQ== X-Gm-Message-State: ALoCoQnZxIRMBXk699sLwASaGfz5SNArumIcjG+FnngJY6qosf20XcfEpcmxOkRo8WIkUkazNnO3 X-Received: by 10.152.179.136 with SMTP id dg8mr19102515lac.4.1436810422343; Mon, 13 Jul 2015 11:00:22 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.153.7.136 with SMTP id dc8ls993903lad.101.gmail; Mon, 13 Jul 2015 11:00:22 -0700 (PDT) X-Received: by 10.112.55.207 with SMTP id u15mr33499475lbp.88.1436810422194; Mon, 13 Jul 2015 11:00:22 -0700 (PDT) Received: from mail-la0-f49.google.com (mail-la0-f49.google.com. [209.85.215.49]) by mx.google.com with ESMTPS id jp7si2393540lab.155.2015.07.13.11.00.22 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 Jul 2015 11:00:22 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) client-ip=209.85.215.49; Received: by lagx9 with SMTP id x9so304986233lag.1 for ; Mon, 13 Jul 2015 11:00:22 -0700 (PDT) X-Received: by 10.152.36.161 with SMTP id r1mr33503546laj.88.1436810422049; Mon, 13 Jul 2015 11:00:22 -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 hn6csp1879644lbb; Mon, 13 Jul 2015 11:00:21 -0700 (PDT) X-Received: by 10.140.42.98 with SMTP id b89mr55659679qga.78.1436810420823; Mon, 13 Jul 2015 11:00:20 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id 47si21846070qgt.45.2015.07.13.11.00.20; Mon, 13 Jul 2015 11:00:20 -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 F056561D16; Mon, 13 Jul 2015 18:00:19 +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 C74A261E32; Mon, 13 Jul 2015 17:54:20 +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 4B66461E21; Mon, 13 Jul 2015 17:54:11 +0000 (UTC) Received: from mail-wi0-f176.google.com (mail-wi0-f176.google.com [209.85.212.176]) by lists.linaro.org (Postfix) with ESMTPS id 833D561E23 for ; Mon, 13 Jul 2015 17:53:34 +0000 (UTC) Received: by wicmv11 with SMTP id mv11so68564987wic.1 for ; Mon, 13 Jul 2015 10:53:33 -0700 (PDT) X-Received: by 10.194.5.74 with SMTP id q10mr67647749wjq.27.1436810013798; Mon, 13 Jul 2015 10:53:33 -0700 (PDT) Received: from e106441.cambridge.arm.com ([2001:41d0:a:3cb4::abcd]) by smtp.gmail.com with ESMTPSA id fm8sm15888662wib.9.2015.07.13.10.53.32 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 13 Jul 2015 10:53:33 -0700 (PDT) From: Stuart Haslam To: lng-odp@lists.linaro.org Date: Mon, 13 Jul 2015 18:53:09 +0100 Message-Id: <1436809989-9225-7-git-send-email-stuart.haslam@linaro.org> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1436809989-9225-1-git-send-email-stuart.haslam@linaro.org> References: <1436809989-9225-1-git-send-email-stuart.haslam@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCH 6/6] 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.49 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);