diff mbox series

[06/16] lib/test_bitmap: delete meaningless test for bitmap_cut

Message ID 20220718192844.1805158-7-yury.norov@gmail.com (mailing list archive)
State New
Headers show
Series Introduce DEBUG_BITMAP config option and bitmap_check_params() | expand

Commit Message

Yury Norov July 18, 2022, 7:28 p.m. UTC
One of bitmap_cut() tests passed it with:
	nbits = BITS_PER_LONG;
	first = BITS_PER_LONG;
	cut = BITS_PER_LONG;

This test is useless because the range to cut is not inside the
bitmap. This should normally raise an error, but bitmap_cut() is
void and returns nothing.

To check if the test is passed, it just tests that the memory is
not touched by bitmap_cut(), which is probably not correct, because
if a function is passed with wrong parameters, it's too optimistic 
to expect a correct, or even sane behavior.

Now that we have bitmap_check_params(), there's a tool to detect such
things in real code, and we can drop the test.

Signed-off-by: Yury Norov <yury.norov@gmail.com>
---
 lib/test_bitmap.c | 4 ----
 1 file changed, 4 deletions(-)

Comments

Andy Shevchenko July 18, 2022, 9:11 p.m. UTC | #1
On Mon, Jul 18, 2022 at 12:28:34PM -0700, Yury Norov wrote:
> One of bitmap_cut() tests passed it with:
> 	nbits = BITS_PER_LONG;
> 	first = BITS_PER_LONG;
> 	cut = BITS_PER_LONG;
> 
> This test is useless because the range to cut is not inside the
> bitmap. This should normally raise an error, but bitmap_cut() is
> void and returns nothing.
> 
> To check if the test is passed, it just tests that the memory is
> not touched by bitmap_cut(), which is probably not correct, because
> if a function is passed with wrong parameters, it's too optimistic 
> to expect a correct, or even sane behavior.
> 
> Now that we have bitmap_check_params(), there's a tool to detect such
> things in real code, and we can drop the test.

There are no "useless" tests. Same comments as per a couple of previous
patches.
diff mbox series

Patch

diff --git a/lib/test_bitmap.c b/lib/test_bitmap.c
index 8bd279a7633f..c1ea449aae2d 100644
--- a/lib/test_bitmap.c
+++ b/lib/test_bitmap.c
@@ -707,10 +707,6 @@  static struct test_bitmap_cut test_cut[] = {
 	{ 15, 16, 32, { 0xa5a5a5a5UL, }, { 0x0000a5a5UL, }, },
 	{ 16, 15, 32, { 0xa5a5a5a5UL, }, { 0x0001a5a5UL, }, },
 
-	{ BITS_PER_LONG, BITS_PER_LONG, BITS_PER_LONG,
-		{ 0xa5a5a5a5UL, 0xa5a5a5a5UL, },
-		{ 0xa5a5a5a5UL, 0xa5a5a5a5UL, },
-	},
 	{ 1, BITS_PER_LONG - 1, BITS_PER_LONG,
 		{ 0xa5a5a5a5UL, 0xa5a5a5a5UL, },
 		{ 0x00000001UL, 0x00000001UL, },