From patchwork Thu Jul 16 16:25:42 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stuart Haslam X-Patchwork-Id: 51187 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 ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E18A822A8A for ; Thu, 16 Jul 2015 16:28:36 +0000 (UTC) Received: by widic2 with SMTP id ic2sf5825174wid.1 for ; Thu, 16 Jul 2015 09:28:36 -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=loxuCqJYoTym1H2ZGBM0TmtV6ZutG1gek5TQWLZ1GN8=; b=GMMMUieKH+8mUcCmfjj+LHXgEWG5wdIATFycFKTmLhiWlw8mdzl2cGILSa8OGqOq+6 JSDZRhNO9/4HssHQ6Ndfj6YoEI8tpL3aB9X88JAtqAtykunA0TVp0vwPx1MdMdg6CHCV mZ6EfNJjQHMyCSNMd5b07JxHC7njTwy7d6v+/+Lw6ODEyqw6vAkvQJcGJ4XDKUbIZvlQ 9rGYSwKRb0Z6/06Iw1+7FlHzs+8CEjiDXdsOERx10ABHQlE2hNUugpH2bAvHUsRYLZjB gdF8nLPlrWjzKcJeRuCzP5xzMJO00un6sRa3GR7mTIf2gCCeFMYBwINV98LkFd8fN7D3 JYng== X-Gm-Message-State: ALoCoQk9aupKvLVljAFTeoUAw93IkUdXbrEPbOPmN7XLPXVB89sVe/CNp6GfkPs5bdbGpP1ToR96 X-Received: by 10.112.139.137 with SMTP id qy9mr5304574lbb.17.1437064116195; Thu, 16 Jul 2015 09:28:36 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.37.105 with SMTP id x9ls403925laj.11.gmail; Thu, 16 Jul 2015 09:28:36 -0700 (PDT) X-Received: by 10.112.27.138 with SMTP id t10mr10169923lbg.42.1437064116044; Thu, 16 Jul 2015 09:28:36 -0700 (PDT) Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com. [209.85.217.182]) by mx.google.com with ESMTPS id k3si7343865laf.146.2015.07.16.09.28.35 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Jul 2015 09:28:35 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.182 as permitted sender) client-ip=209.85.217.182; Received: by lbbpo10 with SMTP id po10so46768339lbb.3 for ; Thu, 16 Jul 2015 09:28:35 -0700 (PDT) X-Received: by 10.152.6.69 with SMTP id y5mr10042859lay.72.1437064115716; Thu, 16 Jul 2015 09:28:35 -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 hn6csp363196lbb; Thu, 16 Jul 2015 09:28:34 -0700 (PDT) X-Received: by 10.140.201.4 with SMTP id w4mr12383882qha.11.1437064114180; Thu, 16 Jul 2015 09:28:34 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id 22si10148223qht.56.2015.07.16.09.28.33; Thu, 16 Jul 2015 09:28:34 -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 05C21620B3; Thu, 16 Jul 2015 16:28:33 +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 DBAFC620CF; Thu, 16 Jul 2015 16:26: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 0C9A0620B1; Thu, 16 Jul 2015 16:26:15 +0000 (UTC) Received: from mail-wi0-f180.google.com (mail-wi0-f180.google.com [209.85.212.180]) by lists.linaro.org (Postfix) with ESMTPS id 8D9B961DA5 for ; Thu, 16 Jul 2015 16:26:09 +0000 (UTC) Received: by widjy10 with SMTP id jy10so20432850wid.1 for ; Thu, 16 Jul 2015 09:26:08 -0700 (PDT) X-Received: by 10.180.24.198 with SMTP id w6mr7896616wif.49.1437063968843; Thu, 16 Jul 2015 09:26:08 -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.07 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 16 Jul 2015 09:26:08 -0700 (PDT) From: Stuart Haslam To: lng-odp@lists.linaro.org Date: Thu, 16 Jul 2015 17:25:42 +0100 Message-Id: <1437063949-24456-3-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 2/9] validation: cpumask: use odp_cpumask_setall() to determine mask capacity 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.182 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 existing test uses odp_cpu_count() to attempt to determine the capacity of odp_cpumask_t. This was a workaround as there was previously no reliable method to determine this but the odp_cpumask_setall() API was added to address this, so use it. Signed-off-by: Stuart Haslam --- test/validation/cpumask/cpumask.c | 52 ++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/test/validation/cpumask/cpumask.c b/test/validation/cpumask/cpumask.c index d4daa61..933ee97 100644 --- a/test/validation/cpumask/cpumask.c +++ b/test/validation/cpumask/cpumask.c @@ -73,13 +73,15 @@ static void cpu_to_str(char *buff, int cpu) } /* - * returns the mask size to be tested... - * There is a bit of confusion right now about how to get this, - * so this is centralized here... in case of change... + * Returns the maximum number of CPUs that a mask can contain. */ -static unsigned int get_max_number_of_cpus_in_a_mask(void) +static unsigned mask_capacity(void) { - return odp_cpu_count(); + odp_cpumask_t mask; + + odp_cpumask_setall(&mask); + + return odp_cpumask_count(&mask); } static void cpumask_test_odp_cpumask_to_from_str(void) @@ -93,17 +95,17 @@ static void cpumask_test_odp_cpumask_to_from_str(void) unsigned int i; /* makes sure the mask has room for at least 1 CPU...: */ - CU_ASSERT_FATAL(get_max_number_of_cpus_in_a_mask() > 0); + CU_ASSERT_FATAL(mask_capacity() > 0); /* allocate memory for the buffers containing the mask strings: 1 char per nibble, i.e. 1 char per 4 cpus +extra for "0x" and null:*/ - buf_sz = (get_max_number_of_cpus_in_a_mask() >> 2) + 20; + buf_sz = (mask_capacity() >> 2) + 20; buf_in = malloc(buf_sz); buf_out = malloc(buf_sz); CU_ASSERT_FATAL(buf_in && buf_out); /* test 1 CPU at a time for all possible cpu positions in the mask */ - for (cpu = 0; cpu < get_max_number_of_cpus_in_a_mask(); cpu++) { + for (cpu = 0; cpu < mask_capacity(); cpu++) { /* init buffer for overwrite check: */ for (i = 0; i < buf_sz; i++) buf_out[i] = FILLING_PATTERN; @@ -166,7 +168,7 @@ static void cpumask_test_odp_cpumask_equal(void) CU_ASSERT(odp_cpumask_equal(&mask1, &mask2)); CU_ASSERT_FALSE(odp_cpumask_equal(&mask1, &mask3)); - if (get_max_number_of_cpus_in_a_mask() < 4) + if (mask_capacity() < 4) return; odp_cpumask_from_str(&mask1, TEST_MASK_CPU_0_2); @@ -175,7 +177,7 @@ static void cpumask_test_odp_cpumask_equal(void) CU_ASSERT(odp_cpumask_equal(&mask1, &mask2)); CU_ASSERT_FALSE(odp_cpumask_equal(&mask1, &mask3)); - if (get_max_number_of_cpus_in_a_mask() < 8) + if (mask_capacity() < 8) return; odp_cpumask_from_str(&mask1, TEST_MASK_CPU_0_2_4_6); @@ -206,7 +208,7 @@ static void cpumask_test_odp_cpumask_set(void) odp_cpumask_set(&mask1, 0); CU_ASSERT(odp_cpumask_equal(&mask1, &mask2)); - if (get_max_number_of_cpus_in_a_mask() < 4) + if (mask_capacity() < 4) return; odp_cpumask_from_str(&mask2, TEST_MASK_CPU_0_3); @@ -228,7 +230,7 @@ static void cpumask_test_odp_cpumask_clr(void) odp_cpumask_clr(&mask1, 0); CU_ASSERT(odp_cpumask_equal(&mask1, &mask2)); - if (get_max_number_of_cpus_in_a_mask() < 4) + if (mask_capacity() < 4) return; odp_cpumask_from_str(&mask1, TEST_MASK_CPU_0_2); @@ -255,7 +257,7 @@ static void cpumask_test_odp_cpumask_isset(void) odp_cpumask_from_str(&mask1, TEST_MASK_NO_CPU); CU_ASSERT_FALSE(odp_cpumask_isset(&mask1, 0)); - if (get_max_number_of_cpus_in_a_mask() < 4) + if (mask_capacity() < 4) return; odp_cpumask_from_str(&mask1, TEST_MASK_CPU_0_2); @@ -275,7 +277,7 @@ static void cpumask_test_odp_cpumask_count(void) odp_cpumask_from_str(&mask1, TEST_MASK_NO_CPU); CU_ASSERT(odp_cpumask_count(&mask1) == 0); - if (get_max_number_of_cpus_in_a_mask() < 4) + if (mask_capacity() < 4) return; odp_cpumask_from_str(&mask1, TEST_MASK_CPU_0_2); @@ -307,7 +309,7 @@ static void cpumask_test_odp_cpumask_and(void) odp_cpumask_and(&mask3, &mask1, &mask2); CU_ASSERT(odp_cpumask_equal(&mask3, &mask4)); - if (get_max_number_of_cpus_in_a_mask() < 4) + if (mask_capacity() < 4) return; odp_cpumask_from_str(&mask1, TEST_MASK_CPU_0_2); @@ -342,7 +344,7 @@ static void cpumask_test_odp_cpumask_or(void) odp_cpumask_or(&mask3, &mask1, &mask2); CU_ASSERT(odp_cpumask_equal(&mask3, &mask4)); - if (get_max_number_of_cpus_in_a_mask() < 4) + if (mask_capacity() < 4) return; odp_cpumask_from_str(&mask1, TEST_MASK_CPU_0_2); @@ -377,7 +379,7 @@ static void cpumask_test_odp_cpumask_xor(void) odp_cpumask_xor(&mask3, &mask1, &mask2); CU_ASSERT(odp_cpumask_equal(&mask3, &mask4)); - if (get_max_number_of_cpus_in_a_mask() < 4) + if (mask_capacity() < 4) return; odp_cpumask_from_str(&mask1, TEST_MASK_CPU_2); @@ -409,7 +411,7 @@ static void cpumask_test_odp_cpumask_first(void) odp_cpumask_from_str(&mask1, TEST_MASK_CPU_0); CU_ASSERT(odp_cpumask_first(&mask1) == 0); - if (get_max_number_of_cpus_in_a_mask() < 4) + if (mask_capacity() < 4) return; odp_cpumask_from_str(&mask1, TEST_MASK_CPU_1_3); @@ -428,7 +430,7 @@ static void cpumask_test_odp_cpumask_last(void) odp_cpumask_from_str(&mask1, TEST_MASK_CPU_0); CU_ASSERT(odp_cpumask_last(&mask1) == 0); - if (get_max_number_of_cpus_in_a_mask() < 4) + if (mask_capacity() < 4) return; odp_cpumask_from_str(&mask1, TEST_MASK_CPU_1_3); @@ -450,7 +452,7 @@ static void cpumask_test_odp_cpumask_next(void) CU_ASSERT(odp_cpumask_next(&mask1, -1) == 0); CU_ASSERT(odp_cpumask_next(&mask1, 0) == -1); - if (get_max_number_of_cpus_in_a_mask() < 4) + if (mask_capacity() < 4) return; odp_cpumask_from_str(&mask1, TEST_MASK_CPU_1_3); @@ -462,7 +464,7 @@ static void cpumask_test_odp_cpumask_next(void) static void cpumask_test_odp_cpumask_setall(void) { int num_cpus; - int max_cpus = get_max_number_of_cpus_in_a_mask(); + int max_cpus = mask_capacity(); odp_cpumask_t mask; odp_cpumask_setall(&mask); @@ -475,7 +477,7 @@ static void cpumask_test_odp_cpumask_setall(void) static void cpumask_test_odp_cpumask_def_control(void) { int num; - int max_cpus = get_max_number_of_cpus_in_a_mask(); + int max_cpus = mask_capacity(); odp_cpumask_t mask; num = odp_cpumask_def_control(&mask, ALL_AVAILABLE); @@ -487,7 +489,7 @@ static void cpumask_test_odp_cpumask_def_control(void) static void cpumask_test_odp_cpumask_def_worker(void) { int num; - int max_cpus = get_max_number_of_cpus_in_a_mask(); + int max_cpus = mask_capacity(); odp_cpumask_t mask; num = odp_cpumask_def_worker(&mask, ALL_AVAILABLE); @@ -500,13 +502,13 @@ static void cpumask_test_odp_cpumask_def(void) { int num_worker; int num_control; - int max_cpus = get_max_number_of_cpus_in_a_mask(); + int max_cpus = mask_capacity(); odp_cpumask_t mask; num_worker = odp_cpumask_def_worker(&mask, max_cpus - 1); num_control = odp_cpumask_def_control(&mask, 1); - CU_ASSERT((num_control + num_worker) == max_cpus); + CU_ASSERT((num_control + num_worker) <= max_cpus); } static CU_TestInfo cpumask_suite[] = {