From patchwork Wed Jul 22 15:46:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stuart Haslam X-Patchwork-Id: 51354 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f70.google.com (mail-la0-f70.google.com [209.85.215.70]) by patches.linaro.org (Postfix) with ESMTPS id 946AF20323 for ; Wed, 22 Jul 2015 15:52:09 +0000 (UTC) Received: by lagw2 with SMTP id w2sf59967443lag.3 for ; Wed, 22 Jul 2015 08:52:08 -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=rExJnGC83cKe1IROc8jYvBBuJatl9EKTdLNbEyKfqUE=; b=k1YCcRG+Mw1nZg1xnwrjtgiYas9Y6wIJ2nghShCbKRdD7RItw1APGbda8gffTy10GG AAYDY8THkxKaLitW9Sd1r7Taq0ezTyEOjHq1kRJFs68HA569/1FkVxj7+EW3IvFao/+I 90CmTFkz8dbBZeTLGQG5d4DraZBxJ9RYII8DkifHS7i5SyxSG6DZKqu24OkdIVdquVQp h31tnfpFZsKNncy24Nrxm9pejeOTb9FsbNJJOwUEvwiyiP+3LWitmO5KLT+1bvuUUXDG tm7NiPy8TTjUcMIDIoqZ+VVnzXLnrQ0B+h4rvGK2KtQKb2QwWdQOSmHaynj652n+XYaf eXAw== X-Gm-Message-State: ALoCoQmXNyQDXM1BuU3myUllKFDft2D7XpszGU3X1HVpTCQtJWkRtAEbK7a7n99d85UQhB0vg/jL X-Received: by 10.152.28.100 with SMTP id a4mr1492478lah.4.1437580328524; Wed, 22 Jul 2015 08:52:08 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.43.2 with SMTP id s2ls103008lal.86.gmail; Wed, 22 Jul 2015 08:52:08 -0700 (PDT) X-Received: by 10.112.147.201 with SMTP id tm9mr3050270lbb.40.1437580328373; Wed, 22 Jul 2015 08:52:08 -0700 (PDT) Received: from mail-lb0-f177.google.com (mail-lb0-f177.google.com. [209.85.217.177]) by mx.google.com with ESMTPS id ez3si1529794lbc.86.2015.07.22.08.52.08 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Jul 2015 08:52:08 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) client-ip=209.85.217.177; Received: by lblf12 with SMTP id f12so139533705lbl.2 for ; Wed, 22 Jul 2015 08:52:08 -0700 (PDT) X-Received: by 10.113.4.105 with SMTP id cd9mr3052571lbd.106.1437580328176; Wed, 22 Jul 2015 08:52:08 -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 l6csp19325lba; Wed, 22 Jul 2015 08:52:07 -0700 (PDT) X-Received: by 10.140.150.198 with SMTP id 189mr4964995qhw.88.1437580326295; Wed, 22 Jul 2015 08:52:06 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id d197si2110372qhc.108.2015.07.22.08.52.05; Wed, 22 Jul 2015 08:52: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 3065461D51; Wed, 22 Jul 2015 15:52: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 D0E2661CC5; Wed, 22 Jul 2015 15:49:26 +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 34F2761B68; Wed, 22 Jul 2015 15:47:08 +0000 (UTC) Received: from mail-wi0-f177.google.com (mail-wi0-f177.google.com [209.85.212.177]) by lists.linaro.org (Postfix) with ESMTPS id 3D659611F9 for ; Wed, 22 Jul 2015 15:47:05 +0000 (UTC) Received: by wicmv11 with SMTP id mv11so87248270wic.0 for ; Wed, 22 Jul 2015 08:47:04 -0700 (PDT) X-Received: by 10.180.96.170 with SMTP id dt10mr43611430wib.42.1437580024054; Wed, 22 Jul 2015 08:47:04 -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.02 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 22 Jul 2015 08:47:03 -0700 (PDT) From: Stuart Haslam To: lng-odp@lists.linaro.org Date: Wed, 22 Jul 2015 16:46:23 +0100 Message-Id: <1437579989-1241-5-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 04/10] 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.217.177 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[] = {