From patchwork Wed Jul 22 15:46:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stuart Haslam X-Patchwork-Id: 51352 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by patches.linaro.org (Postfix) with ESMTPS id 49E3320323 for ; Wed, 22 Jul 2015 15:50:53 +0000 (UTC) Received: by wilm20 with SMTP id m20sf38224976wil.2 for ; Wed, 22 Jul 2015 08:50:52 -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=aAdPWYe9Iao0TYJpLyJN1ynK7qvbNf43IInDNAzonTA=; b=mdf3ssn35q+KzyulQU60JGyAcblZj7As2vXzCslKYo/ESeLXsMWj6J558wI3Q+Hq+Y mYqVCZAsheUaGpk/Zr5+/bkcvY80u4aFf2QO4k+o32ULUdAYWEpMG3GnCD7ze7kO+ix0 QQs0TAZ7zzFQLHywzh+UDHvm2an8P5txtiHqrnGOx0/alX5kxklwQlmRd496v/kqW78R 544HQHVn+uP8HZlTUDW1MUzN/FYJMeWjraMzjRmpdFAU4RIcuXmwBz+lvW9OgM+cuyNE 3aS3fnYgkCopEqhXXdG31UAtv7gE/V+aL6kqByd4HQ3ViF7llW/cr8lSXAkQMVXhAe7p RYUQ== X-Gm-Message-State: ALoCoQmz+ppWKURAaaoV2YrySh6uuDjb6BQicMOY5ew39oxh0LpVl29fsaE18IsoiHM/9YvYsB9u X-Received: by 10.112.85.69 with SMTP id f5mr1458249lbz.23.1437580252549; Wed, 22 Jul 2015 08:50:52 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.18.194 with SMTP id y2ls103261lad.16.gmail; Wed, 22 Jul 2015 08:50:52 -0700 (PDT) X-Received: by 10.152.1.4 with SMTP id 4mr3050952lai.25.1437580252383; Wed, 22 Jul 2015 08:50:52 -0700 (PDT) Received: from mail-lb0-f175.google.com (mail-lb0-f175.google.com. [209.85.217.175]) by mx.google.com with ESMTPS id eu8si1506737lbc.171.2015.07.22.08.50.52 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Jul 2015 08:50:52 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.175 as permitted sender) client-ip=209.85.217.175; Received: by lbbqi7 with SMTP id qi7so59208087lbb.3 for ; Wed, 22 Jul 2015 08:50:52 -0700 (PDT) X-Received: by 10.152.207.76 with SMTP id lu12mr3003187lac.29.1437580252025; Wed, 22 Jul 2015 08:50:52 -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 l6csp18693lba; Wed, 22 Jul 2015 08:50:50 -0700 (PDT) X-Received: by 10.55.15.147 with SMTP id 19mr4569562qkp.81.1437580250413; Wed, 22 Jul 2015 08:50:50 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id k200si2120123qhc.67.2015.07.22.08.50.49; Wed, 22 Jul 2015 08:50:50 -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 58C0E61CE3; Wed, 22 Jul 2015 15:50:49 +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 2B08661B64; Wed, 22 Jul 2015 15:49:20 +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 CF85161808; Wed, 22 Jul 2015 15:47:03 +0000 (UTC) Received: from mail-wi0-f179.google.com (mail-wi0-f179.google.com [209.85.212.179]) by lists.linaro.org (Postfix) with ESMTPS id 9AF7161808 for ; Wed, 22 Jul 2015 15:47:01 +0000 (UTC) Received: by wibxm9 with SMTP id xm9so169474998wib.0 for ; Wed, 22 Jul 2015 08:47:00 -0700 (PDT) X-Received: by 10.194.71.82 with SMTP id s18mr7004298wju.102.1437580020816; Wed, 22 Jul 2015 08:47:00 -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.46.59 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 22 Jul 2015 08:47:00 -0700 (PDT) From: Stuart Haslam To: lng-odp@lists.linaro.org Date: Wed, 22 Jul 2015 16:46:21 +0100 Message-Id: <1437579989-1241-3-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 02/10] 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.175 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 Reviewed-by: Christophe Milard --- 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[] = {