From patchwork Tue Jul 21 13:32:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stuart Haslam X-Patchwork-Id: 51315 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by patches.linaro.org (Postfix) with ESMTPS id F17BB20323 for ; Tue, 21 Jul 2015 13:37:31 +0000 (UTC) Received: by lbbvz8 with SMTP id vz8sf47614857lbb.2 for ; Tue, 21 Jul 2015 06:37:30 -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=U6qmvocXmWCDZVO13xNa5yqcy2mMo3H3NuWV9TPZQ9b8FbwEH5mBCcV6esuYYjPw28 km+Ag/kANFQ/3FMT1WIcAU+mIr6pYRh8rcAQa1p+CzwstT1e7QMbS+LsX2M4VInW2tAG gnfwJ1mBJblpXG0Isb12O9a8c2m8EcATY1+4BXKKv+RyhAUAITUsc17LsXpfWVJQ0CyN ixUFtWBEwmbed0UuoyNudiquJQe2Fpz25T6d7hHb1fZ+7T7JnpEQVIVbNSUeOkR13NiR QDw0D9FkyBBqNTtREqfZko8VwQe6BrxNqV99SuoWXbEYXBrIfUXkA4LMX7fsfgBYr5ZE vcQA== X-Gm-Message-State: ALoCoQntSU1ROYUOyjAPBOiFl9glwBxz0pEUwkgEGc66mhtv7vk0tsdqZpcfNe6k/mTiM5r92Mlj X-Received: by 10.152.43.131 with SMTP id w3mr14762089lal.0.1437485850971; Tue, 21 Jul 2015 06:37:30 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.37.105 with SMTP id x9ls921973laj.11.gmail; Tue, 21 Jul 2015 06:37:30 -0700 (PDT) X-Received: by 10.152.180.134 with SMTP id do6mr45243lac.95.1437485850817; Tue, 21 Jul 2015 06:37:30 -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 m2si20779259laj.125.2015.07.21.06.37.30 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Jul 2015 06:37:30 -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 lbbqi7 with SMTP id qi7so35623891lbb.3 for ; Tue, 21 Jul 2015 06:37:30 -0700 (PDT) X-Received: by 10.152.4.163 with SMTP id l3mr33594637lal.35.1437485850661; Tue, 21 Jul 2015 06:37:30 -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 l6csp1456096lba; Tue, 21 Jul 2015 06:37:29 -0700 (PDT) X-Received: by 10.107.18.10 with SMTP id a10mr49528082ioj.98.1437485848627; Tue, 21 Jul 2015 06:37:28 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id z3si9507205igl.13.2015.07.21.06.37.27; Tue, 21 Jul 2015 06:37:28 -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 5E42261EDD; Tue, 21 Jul 2015 13:37:27 +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 9316B61EE1; Tue, 21 Jul 2015 13:33:11 +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 D451961E84; Tue, 21 Jul 2015 13:32:53 +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 635A761E84 for ; Tue, 21 Jul 2015 13:32:47 +0000 (UTC) Received: by wicmv11 with SMTP id mv11so41821957wic.0 for ; Tue, 21 Jul 2015 06:32:46 -0700 (PDT) X-Received: by 10.194.5.74 with SMTP id q10mr65582727wjq.27.1437485566683; Tue, 21 Jul 2015 06:32:46 -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.45 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 21 Jul 2015 06:32:46 -0700 (PDT) From: Stuart Haslam To: lng-odp@lists.linaro.org Date: Tue, 21 Jul 2015 14:32:13 +0100 Message-Id: <1437485540-4862-3-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 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 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[] = {