Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756951AbeAIRZG (ORCPT + 1 other); Tue, 9 Jan 2018 12:25:06 -0500 Received: from mga06.intel.com ([134.134.136.31]:12531 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752582AbeAIRZE (ORCPT ); Tue, 9 Jan 2018 12:25:04 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,336,1511856000"; d="scan'208";a="22669382" From: Andy Shevchenko To: Andrew Morton , linux-kernel@vger.kernel.org, Rasmus Villemoes , Randy Dunlap , Yury Norov Cc: Andy Shevchenko Subject: [PATCH v1 1/4] bitmap: Add bitmap_zero()/bitmap_clear() test cases Date: Tue, 9 Jan 2018 19:24:27 +0200 Message-Id: <20180109172430.87452-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.15.1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: Explicitly test bitmap_zero() and bitmap_clear() functions. Signed-off-by: Andy Shevchenko --- lib/test_bitmap.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/lib/test_bitmap.c b/lib/test_bitmap.c index de7ef2996a07..9734af711816 100644 --- a/lib/test_bitmap.c +++ b/lib/test_bitmap.c @@ -105,6 +105,35 @@ __check_eq_u32_array(const char *srcfile, unsigned int line, #define expect_eq_pbl(...) __expect_eq(pbl, ##__VA_ARGS__) #define expect_eq_u32_array(...) __expect_eq(u32_array, ##__VA_ARGS__) +static void __init test_zero_clear(void) +{ + DECLARE_BITMAP(bmap, 1024); + + /* Known way to set all bits */ + memset(bmap, 0xff, 128); + + expect_eq_pbl("0-22", bmap, 23); + expect_eq_pbl("0-1023", bmap, 1024); + + /* single-word bitmaps */ + bitmap_clear(bmap, 0, 9); + expect_eq_pbl("9-1023", bmap, 1024); + + bitmap_zero(bmap, 35); + expect_eq_pbl("64-1023", bmap, 1024); + + /* cross boundaries operations */ + bitmap_clear(bmap, 79, 19); + expect_eq_pbl("64-78,98-1023", bmap, 1024); + + bitmap_zero(bmap, 115); + expect_eq_pbl("128-1023", bmap, 1024); + + /* Zeroing entire area */ + bitmap_zero(bmap, 1024); + expect_eq_pbl("", bmap, 1024); +} + static void __init test_zero_fill_copy(void) { DECLARE_BITMAP(bmap1, 1024); @@ -309,6 +338,7 @@ static void noinline __init test_mem_optimisations(void) static int __init test_bitmap_init(void) { + test_zero_clear(); test_zero_fill_copy(); test_bitmap_arr32(); test_bitmap_parselist(); -- 2.15.1