From patchwork Wed Jul 22 15:46:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stuart Haslam X-Patchwork-Id: 51360 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by patches.linaro.org (Postfix) with ESMTPS id 941B220323 for ; Wed, 22 Jul 2015 16:01:24 +0000 (UTC) Received: by wixh2 with SMTP id h2sf28328394wix.0 for ; Wed, 22 Jul 2015 09:01:23 -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=Qy0oYkZznuzyf8u/FiB85kAoJIAngyucJ7XOj4CoWRo=; b=UBPFk6A61spvDOU6APfp0Jiykh+eL4oDDsb77d1axsB5AgrF7gcYvjLF6tuZbviOSX 3Wp7+3510JtAs7Rg1RfkzuV0B06Di6r7jtZeQtMvfdDTqDDtzQ4YQEzjFRLD39ySeryP os+EebmbhARSK3RjJVIb/DGxz3IVpMg+gBS+4Cz6Er8vfzPlgWvV+Oh0jCK2w/SvAY/5 +SyD+YSXl2k+P6FNGYy1AxILHxm23Rf2TBmVk2rZII9p7ZC3HSAWh80DhWrFuhHy7qNB aKPERNsc11IH5vQ6rZ8cNdojXprLqJhj0B+lBfHPkBWhoNnoU7RvuIvAqaceqBbAuko3 L2yw== X-Gm-Message-State: ALoCoQkbdTMYA4EkcXdwQw0/GU1GiueIcpE6Jn2gl8areQcar4/m9uyE8Sds+h41/Ziw7Ee3eQVW X-Received: by 10.180.35.162 with SMTP id i2mr11835342wij.6.1437580883933; Wed, 22 Jul 2015 09:01:23 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.1.73 with SMTP id 9ls100098lak.17.gmail; Wed, 22 Jul 2015 09:01:23 -0700 (PDT) X-Received: by 10.112.219.200 with SMTP id pq8mr3079382lbc.110.1437580883766; Wed, 22 Jul 2015 09:01:23 -0700 (PDT) Received: from mail-lb0-f174.google.com (mail-lb0-f174.google.com. [209.85.217.174]) by mx.google.com with ESMTPS id dz8si1570874lac.4.2015.07.22.09.01.23 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Jul 2015 09:01:23 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.174 as permitted sender) client-ip=209.85.217.174; Received: by lblf12 with SMTP id f12so139713594lbl.2 for ; Wed, 22 Jul 2015 09:01:23 -0700 (PDT) X-Received: by 10.112.166.2 with SMTP id zc2mr3051359lbb.29.1437580883600; Wed, 22 Jul 2015 09:01:23 -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.7.198 with SMTP id l6csp23970lba; Wed, 22 Jul 2015 09:01:22 -0700 (PDT) X-Received: by 10.140.102.101 with SMTP id v92mr4635151qge.19.1437580882168; Wed, 22 Jul 2015 09:01:22 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id c50si2135138qge.121.2015.07.22.09.00.52; Wed, 22 Jul 2015 09:01:22 -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 EA55961D15; Wed, 22 Jul 2015 16:00:51 +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 13CAA61808; Wed, 22 Jul 2015 15:50:33 +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 BC4E061B68; Wed, 22 Jul 2015 15:47:22 +0000 (UTC) Received: from mail-wi0-f172.google.com (mail-wi0-f172.google.com [209.85.212.172]) by lists.linaro.org (Postfix) with ESMTPS id 1880A61B64 for ; Wed, 22 Jul 2015 15:47:14 +0000 (UTC) Received: by wicmv11 with SMTP id mv11so87253799wic.0 for ; Wed, 22 Jul 2015 08:47:13 -0700 (PDT) X-Received: by 10.194.192.166 with SMTP id hh6mr6071049wjc.127.1437580032981; Wed, 22 Jul 2015 08:47:12 -0700 (PDT) Received: from e106441.cambridge.arm.com ([2001:41d0:a:3cb4::abcd]) by smtp.gmail.com with ESMTPSA id ju2sm3994834wid.12.2015.07.22.08.47.12 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 22 Jul 2015 08:47:12 -0700 (PDT) From: Stuart Haslam To: lng-odp@lists.linaro.org Date: Wed, 22 Jul 2015 16:46:29 +0100 Message-Id: <1437579989-1241-11-git-send-email-stuart.haslam@linaro.org> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1437579989-1241-1-git-send-email-stuart.haslam@linaro.org> References: <1437579989-1241-1-git-send-email-stuart.haslam@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCHv4 10/10] 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.217.174 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 Reviewed-by: Christophe Milard --- test/validation/thread/thread.c | 70 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/test/validation/thread/thread.c b/test/validation/thread/thread.c index d8ea8b0..6fbdaef 100644 --- a/test/validation/thread/thread.c +++ b/test/validation/thread/thread.c @@ -7,11 +7,16 @@ #include #include #include +#include #include "thread.h" /* Helper macro for CU_TestInfo initialization */ #define _CU_TEST_INFO(test_func) {#test_func, test_func} +/* Test thread entry and exit synchronization barriers */ +odp_barrier_t bar_entry; +odp_barrier_t bar_exit; + static void thread_test_odp_cpu_id(void) { (void)odp_cpu_id(); @@ -30,6 +35,69 @@ static void thread_test_odp_thread_count(void) CU_PASS(); } +static void *thread_func(void *arg TEST_UNUSED) +{ + /* indicate that thread has started */ + odp_barrier_wait(&bar_entry); + + CU_ASSERT(odp_thread_type() == ODP_THREAD_WORKER); + + /* wait for indication that we can exit */ + odp_barrier_wait(&bar_exit); + + return NULL; +} + +static void thread_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 thread_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 thread_suite[] = { _CU_TEST_INFO(thread_test_odp_cpu_id), _CU_TEST_INFO(thread_test_odp_thread_id), @@ -48,6 +116,8 @@ static CU_TestInfo thread_suite[] = { _CU_TEST_INFO(thread_test_odp_thrmask_first), _CU_TEST_INFO(thread_test_odp_thrmask_last), _CU_TEST_INFO(thread_test_odp_thrmask_next), + _CU_TEST_INFO(thread_test_odp_thrmask_worker), + _CU_TEST_INFO(thread_test_odp_thrmask_control), CU_TEST_INFO_NULL, };