From patchwork Thu Jul 16 16:25:44 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stuart Haslam X-Patchwork-Id: 51188 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f72.google.com (mail-wg0-f72.google.com [74.125.82.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 73D7422A8A for ; Thu, 16 Jul 2015 16:29:24 +0000 (UTC) Received: by wgbbj7 with SMTP id bj7sf20017044wgb.2 for ; Thu, 16 Jul 2015 09:29: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=M5IyVWjDCAOvmweAOUVfHI+ElkhVcwm29zAqNf4RMUc=; b=Nas9LNWx0O+VD5jSg4xFBQ1FOGwCxBIopoM81C18pmPtbuDDr397z+2mag9BEChppM jiE602r5DN4KpWDRwlZsfuxL1JE3kj30nlV0XQcJpeT2VzVMZM4RqFr//fxl7sq7+Mk1 N5zec5rpOmsktgtEfKu4SnzNZ8W9MXMsvB+czGd9fdNCt7EVhXzCTol+NVBODGSYN+G4 7Zg0MVha9f8oG4lgz/7sgLsFKjzqCLRLOD0ZTkxFvlNKMBjExFX18LZ+RpfTTajpvVWv JjEJrHihqU1eI8i+BQUzRKXZDGIGSyajaRP9RjvpHPcHYQEUDpPO7Lxm2W4k/NtqCYun j9Tw== X-Gm-Message-State: ALoCoQmpdDv/0Se/WZBUcEfZnhudtaNreCaqniUE7bUbcKIlHy/hYhT+LSqhMf34Uz5bUatE8Pjh X-Received: by 10.152.237.36 with SMTP id uz4mr5244344lac.1.1437064163764; Thu, 16 Jul 2015 09:29:23 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.204.168 with SMTP id kz8ls327644lac.105.gmail; Thu, 16 Jul 2015 09:29:23 -0700 (PDT) X-Received: by 10.112.159.162 with SMTP id xd2mr9929029lbb.67.1437064163486; Thu, 16 Jul 2015 09:29:23 -0700 (PDT) Received: from mail-la0-f43.google.com (mail-la0-f43.google.com. [209.85.215.43]) by mx.google.com with ESMTPS id mq4si7394349lbb.11.2015.07.16.09.29.23 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Jul 2015 09:29:23 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) client-ip=209.85.215.43; Received: by lahh5 with SMTP id h5so46683713lah.2 for ; Thu, 16 Jul 2015 09:29:23 -0700 (PDT) X-Received: by 10.152.88.42 with SMTP id bd10mr6074677lab.112.1437064163386; Thu, 16 Jul 2015 09:29: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.108.230 with SMTP id hn6csp363649lbb; Thu, 16 Jul 2015 09:29:22 -0700 (PDT) X-Received: by 10.140.20.115 with SMTP id 106mr18322984qgi.87.1437064162013; Thu, 16 Jul 2015 09:29:22 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id i106si10191453qgi.6.2015.07.16.09.29.20; Thu, 16 Jul 2015 09:29: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 DABD661E37; Thu, 16 Jul 2015 16:29:20 +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 4A84B620D1; Thu, 16 Jul 2015 16:26:40 +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 4926D620D4; Thu, 16 Jul 2015 16:26:35 +0000 (UTC) Received: from mail-wi0-f170.google.com (mail-wi0-f170.google.com [209.85.212.170]) by lists.linaro.org (Postfix) with ESMTPS id BBE696208E for ; Thu, 16 Jul 2015 16:26:11 +0000 (UTC) Received: by wibud3 with SMTP id ud3so21165794wib.0 for ; Thu, 16 Jul 2015 09:26:11 -0700 (PDT) X-Received: by 10.194.133.73 with SMTP id pa9mr20279300wjb.148.1437063970920; Thu, 16 Jul 2015 09:26:10 -0700 (PDT) Received: from e106441.cambridge.arm.com ([2001:41d0:a:3cb4::abcd]) by smtp.gmail.com with ESMTPSA id be9sm13889153wjb.26.2015.07.16.09.26.09 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 16 Jul 2015 09:26:10 -0700 (PDT) From: Stuart Haslam To: lng-odp@lists.linaro.org Date: Thu, 16 Jul 2015 17:25:44 +0100 Message-Id: <1437063949-24456-5-git-send-email-stuart.haslam@linaro.org> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1437063949-24456-1-git-send-email-stuart.haslam@linaro.org> References: <1437063949-24456-1-git-send-email-stuart.haslam@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCHv2 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.43 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 --- 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[] = {