diff mbox series

[1/2] lib/test_bitmap: increment failure counter properly

Message ID 20230227214524.914050-1-yury.norov@gmail.com (mailing list archive)
State New, archived
Headers show
Series [1/2] lib/test_bitmap: increment failure counter properly | expand

Commit Message

Yury Norov Feb. 27, 2023, 9:45 p.m. UTC
The tests that don't use expect_eq() macro to determine that a test is
failured must increment failed_tests explicitly.

Reported-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/lkml/20230225184702.GA3587246@roeck-us.net/
Signed-off-by: Yury Norov <yury.norov@gmail.com>
---
 lib/test_bitmap.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

Comments

Andy Shevchenko Feb. 27, 2023, 10:55 p.m. UTC | #1
On Mon, Feb 27, 2023 at 01:45:23PM -0800, Yury Norov wrote:
> The tests that don't use expect_eq() macro to determine that a test is
> failured must increment failed_tests explicitly.

...

>  			pr_err("bitmap_copy_arr32(nbits == %d:"
>  				" tail is not safely cleared: %d\n",

Usually we don't split string literals (since checkpatch doesn't complain on a
looong lines with them at the end of the line),

...

>  			pr_err("bitmap_copy_arr64(nbits == %d:"
>  				" tail is not safely cleared: %d\n", nbits, next_bit);

Ditto.

P.S. Seems a material for another patch.
Yury Norov Feb. 28, 2023, 2:49 a.m. UTC | #2
On Tue, Feb 28, 2023 at 12:55:05AM +0200, Andy Shevchenko wrote:
> On Mon, Feb 27, 2023 at 01:45:23PM -0800, Yury Norov wrote:
> > The tests that don't use expect_eq() macro to determine that a test is
> > failured must increment failed_tests explicitly.
> 
> ...
> 
> >  			pr_err("bitmap_copy_arr32(nbits == %d:"
> >  				" tail is not safely cleared: %d\n",
> 
> Usually we don't split string literals (since checkpatch doesn't complain on a
> looong lines with them at the end of the line),
> 
> ...
> 
> >  			pr_err("bitmap_copy_arr64(nbits == %d:"
> >  				" tail is not safely cleared: %d\n", nbits, next_bit);
> 
> Ditto.
> 
> P.S. Seems a material for another patch.

If you're OK with this patch, can you give your review tag please?

Thanks,
Yury
Andy Shevchenko March 1, 2023, 3:11 p.m. UTC | #3
On Mon, Feb 27, 2023 at 06:49:29PM -0800, Yury Norov wrote:
> On Tue, Feb 28, 2023 at 12:55:05AM +0200, Andy Shevchenko wrote:
> > On Mon, Feb 27, 2023 at 01:45:23PM -0800, Yury Norov wrote:
> > > The tests that don't use expect_eq() macro to determine that a test is
> > > failured must increment failed_tests explicitly.
> > 
> > ...
> > 
> > >  			pr_err("bitmap_copy_arr32(nbits == %d:"
> > >  				" tail is not safely cleared: %d\n",
> > 
> > Usually we don't split string literals (since checkpatch doesn't complain on a
> > looong lines with them at the end of the line),
> > 
> > ...
> > 
> > >  			pr_err("bitmap_copy_arr64(nbits == %d:"
> > >  				" tail is not safely cleared: %d\n", nbits, next_bit);
> > 
> > Ditto.
> > 
> > P.S. Seems a material for another patch.
> 
> If you're OK with this patch, can you give your review tag please?

I'm fine with the series,
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
diff mbox series

Patch

diff --git a/lib/test_bitmap.c b/lib/test_bitmap.c
index 8954610ec683..c4b90d145398 100644
--- a/lib/test_bitmap.c
+++ b/lib/test_bitmap.c
@@ -471,6 +471,7 @@  static void __init test_bitmap_parselist(void)
 		if (err != ptest.errno) {
 			pr_err("parselist: %d: input is %s, errno is %d, expected %d\n",
 					i, ptest.in, err, ptest.errno);
+			failed_tests++;
 			continue;
 		}
 
@@ -479,6 +480,7 @@  static void __init test_bitmap_parselist(void)
 			pr_err("parselist: %d: input is %s, result is 0x%lx, expected 0x%lx\n",
 					i, ptest.in, bmap[0],
 					*ptest.expected);
+			failed_tests++;
 			continue;
 		}
 
@@ -512,11 +514,13 @@  static void __init test_bitmap_printlist(void)
 
 	if (ret != slen + 1) {
 		pr_err("bitmap_print_to_pagebuf: result is %d, expected %d\n", ret, slen);
+		failed_tests++;
 		goto out;
 	}
 
 	if (strncmp(buf, expected, slen)) {
 		pr_err("bitmap_print_to_pagebuf: result is %s, expected %s\n", buf, expected);
+		failed_tests++;
 		goto out;
 	}
 
@@ -584,6 +588,7 @@  static void __init test_bitmap_parse(void)
 		if (err != test.errno) {
 			pr_err("parse: %d: input is %s, errno is %d, expected %d\n",
 					i, test.in, err, test.errno);
+			failed_tests++;
 			continue;
 		}
 
@@ -592,6 +597,7 @@  static void __init test_bitmap_parse(void)
 			pr_err("parse: %d: input is %s, result is 0x%lx, expected 0x%lx\n",
 					i, test.in, bmap[0],
 					*test.expected);
+			failed_tests++;
 			continue;
 		}
 
@@ -616,10 +622,12 @@  static void __init test_bitmap_arr32(void)
 
 		next_bit = find_next_bit(bmap2,
 				round_up(nbits, BITS_PER_LONG), nbits);
-		if (next_bit < round_up(nbits, BITS_PER_LONG))
+		if (next_bit < round_up(nbits, BITS_PER_LONG)) {
 			pr_err("bitmap_copy_arr32(nbits == %d:"
 				" tail is not safely cleared: %d\n",
 				nbits, next_bit);
+			failed_tests++;
+		}
 
 		if (nbits < EXP1_IN_BITS - 32)
 			expect_eq_uint(arr[DIV_ROUND_UP(nbits, 32)],
@@ -642,15 +650,19 @@  static void __init test_bitmap_arr64(void)
 		expect_eq_bitmap(bmap2, exp1, nbits);
 
 		next_bit = find_next_bit(bmap2, round_up(nbits, BITS_PER_LONG), nbits);
-		if (next_bit < round_up(nbits, BITS_PER_LONG))
+		if (next_bit < round_up(nbits, BITS_PER_LONG)) {
 			pr_err("bitmap_copy_arr64(nbits == %d:"
 				" tail is not safely cleared: %d\n", nbits, next_bit);
+			failed_tests++;
+		}
 
 		if ((nbits % 64) &&
-		    (arr[(nbits - 1) / 64] & ~GENMASK_ULL((nbits - 1) % 64, 0)))
+		    (arr[(nbits - 1) / 64] & ~GENMASK_ULL((nbits - 1) % 64, 0))) {
 			pr_err("bitmap_to_arr64(nbits == %d): tail is not safely cleared: 0x%016llx (must be 0x%016llx)\n",
 			       nbits, arr[(nbits - 1) / 64],
 			       GENMASK_ULL((nbits - 1) % 64, 0));
+			failed_tests++;
+		}
 
 		if (nbits < EXP1_IN_BITS - 64)
 			expect_eq_uint(arr[DIV_ROUND_UP(nbits, 64)], 0xa5a5a5a5);