From patchwork Tue Jul 21 13:32:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stuart Haslam X-Patchwork-Id: 51313 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 patches.linaro.org (Postfix) with ESMTPS id 6CCC120323 for ; Tue, 21 Jul 2015 13:35:00 +0000 (UTC) Received: by wilm20 with SMTP id m20sf26903359wil.2 for ; Tue, 21 Jul 2015 06:34:59 -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=M5IyVWjDCAOvmweAOUVfHI+ElkhVcwm29zAqNf4RMUc=; b=KRCJ3AXF3upLbeQqbKIFWP61l/nG6F/M1BTdt5wpYRlxG8qzVeYRyQhE63m3wL9ifi cUodfuoeqoMtlIm6kf583HZSfu/NpNFuZqzlOtEIIV3AEMT0RdGRWyNcWbqfsBcOnR91 AgTqh6+RJW54u+lYCHJYV1SRP8dle20TFsw7+smrFISFKtu5T5JK3Dm8jjANKTzNKDjb ipVR8B05nhwmgoyzQZCP2TJAag24Xug+we7X+LbiwW4qKhuyTirPPuivQPc4OaPg5WcC N4wvqgMOz0IQNM1zDbYJsLBscKnhzGA0qP3TCBOHWkULL/JFSNC+HbWEg06ifySjiBBr nlaQ== X-Gm-Message-State: ALoCoQmmNveJievz+uqaCnhWpNjBpLUXvm1v3hCvMcnO/BRhbKC0SPlkXzf6ehDLvjnfecHzl6xl X-Received: by 10.194.179.42 with SMTP id dd10mr17732549wjc.7.1437485699661; Tue, 21 Jul 2015 06:34:59 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.36.227 with SMTP id t3ls910612laj.72.gmail; Tue, 21 Jul 2015 06:34:59 -0700 (PDT) X-Received: by 10.112.205.161 with SMTP id lh1mr22647767lbc.43.1437485699364; Tue, 21 Jul 2015 06:34:59 -0700 (PDT) Received: from mail-la0-f41.google.com (mail-la0-f41.google.com. [209.85.215.41]) by mx.google.com with ESMTPS id ay8si7717367lab.9.2015.07.21.06.34.59 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Jul 2015 06:34:59 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.41 as permitted sender) client-ip=209.85.215.41; Received: by laem6 with SMTP id m6so117882290lae.0 for ; Tue, 21 Jul 2015 06:34:59 -0700 (PDT) X-Received: by 10.112.139.103 with SMTP id qx7mr32979528lbb.73.1437485699102; Tue, 21 Jul 2015 06:34:59 -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 l6csp1454643lba; Tue, 21 Jul 2015 06:34:57 -0700 (PDT) X-Received: by 10.50.43.196 with SMTP id y4mr24892568igl.14.1437485697327; Tue, 21 Jul 2015 06:34:57 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id ci10si9486909igb.28.2015.07.21.06.34.55; Tue, 21 Jul 2015 06:34:57 -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 6793A61E60; Tue, 21 Jul 2015 13:34:55 +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 E51CD61EDC; Tue, 21 Jul 2015 13:33:02 +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 80A5061E87; Tue, 21 Jul 2015 13:32:50 +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 9546D61E74 for ; Tue, 21 Jul 2015 13:32:49 +0000 (UTC) Received: by wibxm9 with SMTP id xm9so120925629wib.0 for ; Tue, 21 Jul 2015 06:32:48 -0700 (PDT) X-Received: by 10.180.24.40 with SMTP id r8mr32706751wif.13.1437485568695; Tue, 21 Jul 2015 06:32:48 -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.47 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 21 Jul 2015 06:32:48 -0700 (PDT) From: Stuart Haslam To: lng-odp@lists.linaro.org Date: Tue, 21 Jul 2015 14:32:15 +0100 Message-Id: <1437485540-4862-5-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 4/9] validation: cpumask: def_worker and def_control fixes 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.41 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 The odp_cpumask_def_worker() and odp_cpumask_def_control() APIs are used to populate a mask with the CPUs available for running threads of the same type. This does not necessarily mean those CPUs are dedicated to running threads of that type, on a particular platform the same CPU may appear in both the control and worker set. The test now verifies that the APIs; - populate the mask with at least 1 CPU - return a value that matches the number of CPUs set in the mask - don't return a value greater than the total available CPUsa - don't return a value greater than the requested number of CPUs Signed-off-by: Stuart Haslam Reviewed-by: Christophe Milard --- test/validation/cpumask/cpumask.c | 44 +++++++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 11 deletions(-) diff --git a/test/validation/cpumask/cpumask.c b/test/validation/cpumask/cpumask.c index 933ee97..d72569e 100644 --- a/test/validation/cpumask/cpumask.c +++ b/test/validation/cpumask/cpumask.c @@ -476,39 +476,61 @@ static void cpumask_test_odp_cpumask_setall(void) static void cpumask_test_odp_cpumask_def_control(void) { - int num; - int max_cpus = mask_capacity(); + unsigned num; + unsigned mask_count; + unsigned max_cpus = mask_capacity(); odp_cpumask_t mask; num = odp_cpumask_def_control(&mask, ALL_AVAILABLE); + mask_count = odp_cpumask_count(&mask); - CU_ASSERT(num >= 0); + CU_ASSERT(mask_count == num); + CU_ASSERT(num > 0); CU_ASSERT(num <= max_cpus); } static void cpumask_test_odp_cpumask_def_worker(void) { - int num; - int max_cpus = mask_capacity(); + unsigned num; + unsigned mask_count; + unsigned max_cpus = mask_capacity(); odp_cpumask_t mask; num = odp_cpumask_def_worker(&mask, ALL_AVAILABLE); + mask_count = odp_cpumask_count(&mask); - CU_ASSERT(num >= 0); + CU_ASSERT(mask_count == num); + CU_ASSERT(num > 0); CU_ASSERT(num <= max_cpus); } static void cpumask_test_odp_cpumask_def(void) { - int num_worker; - int num_control; - int max_cpus = mask_capacity(); + unsigned mask_count; + unsigned num_worker; + unsigned num_control; + unsigned max_cpus = mask_capacity(); + unsigned available_cpus = odp_cpu_count(); + unsigned requested_cpus; odp_cpumask_t mask; - num_worker = odp_cpumask_def_worker(&mask, max_cpus - 1); + CU_ASSERT(available_cpus <= max_cpus); + + if (available_cpus > 1) + requested_cpus = available_cpus - 1; + else + requested_cpus = available_cpus; + num_worker = odp_cpumask_def_worker(&mask, requested_cpus); + mask_count = odp_cpumask_count(&mask); + CU_ASSERT(mask_count == num_worker); + num_control = odp_cpumask_def_control(&mask, 1); + mask_count = odp_cpumask_count(&mask); + CU_ASSERT(mask_count == num_control); - CU_ASSERT((num_control + num_worker) <= max_cpus); + CU_ASSERT(num_control == 1); + CU_ASSERT(num_worker <= available_cpus); + CU_ASSERT(num_worker > 0); } static CU_TestInfo cpumask_suite[] = {