From patchwork Mon Aug 7 22:54:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 109600 Delivered-To: patch@linaro.org Received: by 10.182.109.195 with SMTP id hu3csp3317325obb; Mon, 7 Aug 2017 15:55:42 -0700 (PDT) X-Received: by 10.99.98.193 with SMTP id w184mr2033987pgb.358.1502146542392; Mon, 07 Aug 2017 15:55:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502146542; cv=none; d=google.com; s=arc-20160816; b=PGZUGa2m7eTEqMibwurGnScpqV12CW4zWDRpKM8GJK2XWXOjZESaKg6LlMBfkhbaKZ 7fJ+0n9pj2jMpXE8FONWoNzqMYs4BKx9auFr+oYS+5VeXgydngwEwjPTPaiFDrL4uPB6 2dXWbwq9teZBN/uLn+hQFqpi1jBx702cFM/6wPIipYjRH8HNp24Pw+b9/SIMfrXElMYH 5Q3eNaemUSIJTPb+7Wo8s0rFEi15iN0UsS1HlyWD4/ix8w+CgMAYFIDa3dm1xxf5nQ43 tm6DQQDnaDxMPFizGw1PXSW1cnQUMzSFL4zD1kHGv7UOO9bCbeqG8L4Ly/Iq4K1vSwk1 FvOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature:arc-authentication-results; bh=sifgOgbgX7P5d0QkI/qPLIjqIOJc9T6y+xZ3ImBCkT4=; b=aDrWOMTSevbUdzz1xsMHu1dNm0ek/rv6ECW0CagqK7u4EL+7bT+LtXN8Ia0rwrkzW5 KFUkcThxCUnJClCnulq0z2QJh55XwDOxlKnJxQb+JXov4sF41PiQY2HkdKvSwnxlc+/q 9p4IO9fhJ2Z1P1Et+FG00Bp6KmDwqVCs7ZDa208PVEYtbKg80CyEGE2RAGQCT1jYo9/I 1OfZC/gIFv9YmxtvH5YYg4Lub6m3W7SEf23h+UPDJDu9KT4S7rV2LH/b0VD//JjuTuj0 8GPm/EzWIifBA4JPN9et+vKvzKxwE1azFW1Xq6g/m5/PTHGPQrzKNLKHYWmPDeilFcw7 5NFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@CAVIUMNETWORKS.onmicrosoft.com header.b=NU+KisAd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q14si5135046pli.588.2017.08.07.15.55.42; Mon, 07 Aug 2017 15:55:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@CAVIUMNETWORKS.onmicrosoft.com header.b=NU+KisAd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752062AbdHGWzk (ORCPT + 25 others); Mon, 7 Aug 2017 18:55:40 -0400 Received: from mail-sn1nam02on0062.outbound.protection.outlook.com ([104.47.36.62]:52821 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751761AbdHGWzi (ORCPT ); Mon, 7 Aug 2017 18:55:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=sifgOgbgX7P5d0QkI/qPLIjqIOJc9T6y+xZ3ImBCkT4=; b=NU+KisAdvI9i2GBcOT609vLGnor6v+8sJ5sMnVlut4g0gDJDzZ6F3mJWZrvRttdb2lozSvzjknFELe+vTuEj+JoN45pHaxxtabCjQiSpFa3vG/QQr3P7SMOe17b8vC6FK0BsmPFLIrJtcstMbjDnQ+UhhiO8hAHOOnRDv2/RA0g= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Yuri.Norov@cavium.com; Received: from localhost (41.141.196.40) by DM3PR07MB2121.namprd07.prod.outlook.com (10.164.4.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1320.16; Mon, 7 Aug 2017 22:55:23 +0000 From: Yury Norov To: Andrew Morton , Noam Camus , Rasmus Villemoes Cc: Matthew Wilcox , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org, Yury Norov Subject: [PATCH 2/2] lib: add test for bitmap_parselist() Date: Tue, 8 Aug 2017 01:54:38 +0300 Message-Id: <20170807225438.16161-2-ynorov@caviumnetworks.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170807225438.16161-1-ynorov@caviumnetworks.com> References: <20170807225438.16161-1-ynorov@caviumnetworks.com> MIME-Version: 1.0 X-Originating-IP: [41.141.196.40] X-ClientProxiedBy: DB6PR02CA0004.eurprd02.prod.outlook.com (10.170.218.145) To DM3PR07MB2121.namprd07.prod.outlook.com (10.164.4.139) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 800b077d-5f42-4580-681b-08d4dde76a90 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(300000503095)(300135400095)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:DM3PR07MB2121; X-Microsoft-Exchange-Diagnostics: 1; DM3PR07MB2121; 3:6p9R1psix1wN6WUtJTHrGRlXq954Uu9QYQ80ZNOa3gbg1olu4iBOGw3zb7G4bEd3AvOsptqJFreA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QtI+rab9TGQC1bGVl3YbcekQ528jhVeaBvSe/Uw3lQ7ubXXnVA76xL/YjxsLHl2mc+gUf6wsvsqRNpEncNBgz6FUAxPBjojwXjZkpPhTAP7YSzMnenmr0d/FZHG5UftA0gTCZyO0MHa+zp/e+LGMRSF6RIn5Ge3yjWGHFbS9oOEEd3Wt1CuOQH1UBXysduPh1HDS0PlS6ydnN2mpP4oFfmcjq0ErHe/qFMuOvzibPUFea9F2fPGkYM50+tHuveuc1Y7kNpc9q9ve0QJEqfJJTqBCGGtyN1H3l3m98vt32yJ4APMZolwkZhXd2pdrKxEuN8oS+afaX3EH5a6LpDrIBCXXoWixjZgCATFXqmaxRuTXxLsAvapZFpbbmwYF+bcDTQ=; 4:VRY+TfGIqU26OGgFGk5QF/a8zTtUd4AcGRT89ZpsBnf7DZMj2XSaNQcHzqpU0Rd8L+8pLh1PTLvNDZCv8wXtg4+PnLPpj+VSKiEsduWfMpvEKN3JwAvpvNpAVoJl35cqAy/M6Dd7ggNrq+DXbhtSZq1x5KWONtstQkODA0k3iLPgcQZiImoZGMFsa+4nqcMjrUK5WL0ZzLeRo56/ek4XhBcHuMpfv10ALN1wj9snHh41SLWiDD96GeFNVku0326y X-Exchange-Antispam-Report-Test: UriScan:; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(93006095)(100000703101)(100105400095)(6041248)(20161123562025)(20161123560025)(20161123564025)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(6072148)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:DM3PR07MB2121; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:DM3PR07MB2121; X-Forefront-PRVS: 0392679D18 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(7370300001)(6009001)(6069001)(39400400002)(39850400002)(39410400002)(39840400002)(39450400003)(189002)(199003)(305945005)(3846002)(8676002)(76506005)(105586002)(478600001)(81166006)(25786009)(106356001)(50226002)(97736004)(5001810100001)(42186005)(38730400002)(5003940100001)(7350300001)(72206003)(81156014)(6486002)(10646004)(66066001)(47776003)(68736007)(101416001)(76176999)(2906002)(5660300001)(50986999)(189998001)(10916006)(2950100002)(42882006)(6116002)(36756003)(8666007)(33646002)(107886003)(7736002)(53936002)(4326008)(6496005)(6666003)(1076002)(54906002)(50466002)(48376002)(3486003); DIR:OUT; SFP:1101; SCL:1; SRVR:DM3PR07MB2121; H:localhost; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: 1; DM3PR07MB2121; 23:7FxcUiLJuhQtU9Ktcda5gxtjwHLJ6bmOAPqnwYivN5VTFhNHDVI5uTWHSOeIviRdOgf06zy7bQTAj8Nk8by/+hA4ELJiEFqC28FWSfhXE6u+YYhhMFPrY8gl2RNWI04j+i0doZgigmXWDHxn0Vp40npfwabTQDe/iFUSy9QC9PqaN0H65GjegX8eU7it6hhHEALmEDUk5PF6VKRwqjFGlV+6UgdvWkcTLCZODMHvfuhrtRp6LAKDWCmxzoDcfTRxRlVAbytxG1SN0QJLvVw+i2hiMJommM/iPktS82z+B11AxbpPgeyVr0ubkRzxVmYda7G+8ByvSjyVbMvwAa9rZaRtwtm7znVozn4GfULNSlAK8p+L6PY19XLgtVCgp1z1q1fLes3zFD894fgh19ImjYHTUidZnam2lDpDv8obsivTzJAvODBz8kNW9t6eJU1QAiYAmWYg0CmWjs2QrH/8U4AbJ73Vhtm9knlRh7puszMVd8Rpvvi7dbxL3RFY+QPaHvzG/848/uECGD58nTT1Ftgfbg/vOWPJypr64Tzq+XGwYPmnu+StkkEulQ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guWQwMsiRopI5v4EFKRjnudwb/HTMJBxDMOZ/nUi1ODYyXXIjVYZichcu8zZm/SS4sYf/KsmI9o2nHp62TKxv3bjVpJxwqXjJGLhrqLlByLICH2aGjbKf4caYNLtsdSjG14e5ZraW61Uw+fMFA/Ws6ec43htN9ApPEdsyRWeEEBoLMEWXyrTUBg==; 5:JzuLP9atL8SGg5XAcdHZZA95RarGGV/Dnez4SOBFnkTI4ariDUizvXWAiiZq4CyUqKr+8GfAQLfKCjkZoM8YXN+UmisuzMCevKNbLv92lvsTA1a8CwUnZiuD+nmozRPGOFIKWWOl5xzqaR8RPASCaA==; 24:TwGSoKz9OPDfhxsLF4jgHvkdrpDVu2v3gfptOBzPWWL+9giAwg6uPrScsU7UJnANZp6NzcK9/ZXg2IH/wO2z6rLo0OBb/scRsVMp+a+D5LY=; 7:1UzOKp5onYEQkuUUfcOJxQfcsXRycSetYo+IVcLSJZP5jnKVqnMAbive21QlqdG0DNrtJLnmWo6woGzYHmF4zahjwssSihvwcTUaZMqEsv18UWQq5B8zB78iZXajFKwvKF3gQBTqpi+Lz592fXDhSE63VuUgVRInxBgzMNB4r4OwKhwzY6qR9SJgnLn7plqRw5HIVGSmpDpmk7+81VwnG0urytmQo9YBhRTHGxzFyB0= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Aug 2017 22:55:23.3922 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM3PR07MB2121 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Do some basic checks for the bitmap_parselist(). Signed-off-by: Yury Norov --- lib/test_bitmap.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) -- 2.11.0 Signed-off-by: Yury Norov diff --git a/lib/test_bitmap.c b/lib/test_bitmap.c index 2526a2975c51..5b80dd94e4d1 100644 --- a/lib/test_bitmap.c +++ b/lib/test_bitmap.c @@ -165,6 +165,78 @@ static void __init test_zero_fill_copy(void) expect_eq_pbl("128-1023", bmap2, 1024); } +#define PARSE_TIME 0x1 + +struct test_bitmap_parselist{ + const int errno; + const char *in; + const unsigned long *expected; + const int nbits; + const int flags; +}; + +static const unsigned long exp[] = {1, 2, 0x0000ffff, 0xffff0000, 0x55555555, + 0xaaaaaaaa, 0x11111111, 0x22222222, 0xffffffff, + 0xfffffffe, 0x3333333311111111, 0xffffffff77777777}; +static const unsigned long exp2[] = {0x3333333311111111, 0xffffffff77777777}; + +static const struct test_bitmap_parselist parselist_tests[] __initconst = { + {0, "0", &exp[0], 8, 0}, + {0, "1", &exp[1], 8, 0}, + {0, "0-15", &exp[2], 32, 0}, + {0, "16-31", &exp[3], 32, 0}, + {0, "0-31:1/2", &exp[4], 32, 0}, + {0, "1-31:1/2", &exp[5], 32, 0}, + {0, "0-31:1/4", &exp[6], 32, 0}, + {0, "1-31:1/4", &exp[7], 32, 0}, + {0, "0-31:4/4", &exp[8], 32, 0}, + {0, "1-31:4/4", &exp[9], 32, 0}, + {0, "0-31:1/4,32-63:2/4", &exp[10], 64, 0}, + {0, "0-31:3/4,32-63:4/4", &exp[11], 64, 0}, + + {0, "0-31:1/4,32-63:2/4,64-95:3/4,96-127:4/4", exp2, 128, 0}, + + {0, "0-2047:128/256", NULL, 2048, PARSE_TIME}, + + {-EINVAL, "-1", NULL, 8, 0}, + {-EINVAL, "-0", NULL, 8, 0}, + {-EINVAL, "10-1", NULL, 8, 0}, + {-EINVAL, "0-31:10/1", NULL, 8, 0}, +}; + +static void __init test_bitmap_parselist(void) +{ + int i; + int err; + cycles_t cycles; + DECLARE_BITMAP(bmap, 2048); + + for (i = 0; i < ARRAY_SIZE(parselist_tests); i++) { +#define ptest parselist_tests[i] + + cycles = get_cycles(); + err = bitmap_parselist(ptest.in, bmap, ptest.nbits); + cycles = get_cycles() - cycles; + + if (err != ptest.errno) { + pr_err("test %d: input is %s, errno is %d, expected %d\n", + i, ptest.in, err, ptest.errno); + continue; + } + + if (!err && ptest.expected + && !__bitmap_equal(bmap, ptest.expected, ptest.nbits)) { + pr_err("test %d: input is %s, result is 0x%lx, expected 0x%lx\n", + i, ptest.in, bmap[0], *ptest.expected); + continue; + } + + if (ptest.flags & PARSE_TIME) + pr_err("test %d: input is '%s' OK, Time: %lu\n", + i, ptest.in, cycles); + } +} + static void __init test_bitmap_u32_array_conversions(void) { DECLARE_BITMAP(bmap1, 1024); @@ -365,6 +437,7 @@ static int __init test_bitmap_init(void) { test_zero_fill_copy(); test_bitmap_u32_array_conversions(); + test_bitmap_parselist(); test_mem_optimisations(); if (failed_tests == 0)