From patchwork Tue Jul 21 13:32:20 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stuart Haslam X-Patchwork-Id: 51319 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by patches.linaro.org (Postfix) with ESMTPS id 8F1BC20323 for ; Tue, 21 Jul 2015 13:42:33 +0000 (UTC) Received: by lbvb1 with SMTP id b1sf47583792lbv.3 for ; Tue, 21 Jul 2015 06:42:32 -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=1bbVCFxlK23lhxL9wTY4TKxrf/gQ0hUldMdzcQbSlRU=; b=XKtZx42Zd3+JgsPzP0ql5Dcvgkl+IhSH0ExYsmrNQZM82TDidDYG06R9qlGXFkmBqd milGAEfcOEcgZhBDtu9mpXbqmnmoMp2FmF8cOXKRSnUB2L94+yynJlAOy0QZPJ5YirJm tdkzN/+gTqgy5qDtH0RfxDxOtJDrwjgTTQjdl1pLk1soyXVLTPA2ctgPB8ese8HI7MDz JatVkALBsuYxOER4pnRAnz7NGs8B13cSBnrVwc+mFovUtO7O13SvANRuq7n5ZV07PfoG V4boKaNk4UxHrlJ9S7cCSHLUTQOMSO/6DUdraVYw1mEnd4CP36/95eccY9zUG3qmhIby DHRA== X-Gm-Message-State: ALoCoQn7n3wcASw9aH/OsMMHiQmSZPrtoa55u6AclZfveLbnzUrLtnA5zqkD+lxKH/iMPDlgJLZy X-Received: by 10.112.26.5 with SMTP id h5mr17534271lbg.4.1437486152313; Tue, 21 Jul 2015 06:42:32 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.129 with SMTP id s1ls1003577las.89.gmail; Tue, 21 Jul 2015 06:42:32 -0700 (PDT) X-Received: by 10.152.22.4 with SMTP id z4mr33248480lae.81.1437486152125; Tue, 21 Jul 2015 06:42:32 -0700 (PDT) Received: from mail-lb0-f179.google.com (mail-lb0-f179.google.com. [209.85.217.179]) by mx.google.com with ESMTPS id f1si9570574lab.6.2015.07.21.06.42.32 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Jul 2015 06:42:32 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.179 as permitted sender) client-ip=209.85.217.179; Received: by lbbqi7 with SMTP id qi7so35728940lbb.3 for ; Tue, 21 Jul 2015 06:42:32 -0700 (PDT) X-Received: by 10.152.5.228 with SMTP id v4mr33000995lav.36.1437486152026; Tue, 21 Jul 2015 06:42:32 -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 l6csp1458909lba; Tue, 21 Jul 2015 06:42:30 -0700 (PDT) X-Received: by 10.140.19.203 with SMTP id 69mr54324096qgh.33.1437486150349; Tue, 21 Jul 2015 06:42:30 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id q64si28237520qha.36.2015.07.21.06.42.29; Tue, 21 Jul 2015 06:42:30 -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 8480061EE5; Tue, 21 Jul 2015 13:42:29 +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 D33C761EFD; Tue, 21 Jul 2015 13:33:44 +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 B8A9661EDA; Tue, 21 Jul 2015 13:33:06 +0000 (UTC) Received: from mail-wi0-f178.google.com (mail-wi0-f178.google.com [209.85.212.178]) by lists.linaro.org (Postfix) with ESMTPS id D5C8461E84 for ; Tue, 21 Jul 2015 13:32:54 +0000 (UTC) Received: by wibxm9 with SMTP id xm9so120928134wib.0 for ; Tue, 21 Jul 2015 06:32:54 -0700 (PDT) X-Received: by 10.180.87.168 with SMTP id az8mr32643107wib.53.1437485574155; Tue, 21 Jul 2015 06:32:54 -0700 (PDT) Received: from e106441.cambridge.arm.com ([2001:41d0:a:3cb4::abcd]) by smtp.gmail.com with ESMTPSA id jy6sm37121913wjc.4.2015.07.21.06.32.53 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 21 Jul 2015 06:32:53 -0700 (PDT) From: Stuart Haslam To: lng-odp@lists.linaro.org Date: Tue, 21 Jul 2015 14:32:20 +0100 Message-Id: <1437485540-4862-10-git-send-email-stuart.haslam@linaro.org> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1437485540-4862-1-git-send-email-stuart.haslam@linaro.org> References: <1437485540-4862-1-git-send-email-stuart.haslam@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCHv3 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.217.179 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, };