Skip to content

Commit c4c14c2

Browse files
committed
lib/test_bitmap: increment failure counter properly
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 <[email protected]> Link: https://lore.kernel.org/lkml/[email protected]/ Signed-off-by: Yury Norov <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Reviewed-by: Alexander Lobakin <[email protected]>
1 parent dad9774 commit c4c14c2

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

lib/test_bitmap.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,7 @@ static void __init test_bitmap_parselist(void)
470470
if (err != ptest.errno) {
471471
pr_err("parselist: %d: input is %s, errno is %d, expected %d\n",
472472
i, ptest.in, err, ptest.errno);
473+
failed_tests++;
473474
continue;
474475
}
475476

@@ -478,6 +479,7 @@ static void __init test_bitmap_parselist(void)
478479
pr_err("parselist: %d: input is %s, result is 0x%lx, expected 0x%lx\n",
479480
i, ptest.in, bmap[0],
480481
*ptest.expected);
482+
failed_tests++;
481483
continue;
482484
}
483485

@@ -511,11 +513,13 @@ static void __init test_bitmap_printlist(void)
511513

512514
if (ret != slen + 1) {
513515
pr_err("bitmap_print_to_pagebuf: result is %d, expected %d\n", ret, slen);
516+
failed_tests++;
514517
goto out;
515518
}
516519

517520
if (strncmp(buf, expected, slen)) {
518521
pr_err("bitmap_print_to_pagebuf: result is %s, expected %s\n", buf, expected);
522+
failed_tests++;
519523
goto out;
520524
}
521525

@@ -583,6 +587,7 @@ static void __init test_bitmap_parse(void)
583587
if (err != test.errno) {
584588
pr_err("parse: %d: input is %s, errno is %d, expected %d\n",
585589
i, test.in, err, test.errno);
590+
failed_tests++;
586591
continue;
587592
}
588593

@@ -591,6 +596,7 @@ static void __init test_bitmap_parse(void)
591596
pr_err("parse: %d: input is %s, result is 0x%lx, expected 0x%lx\n",
592597
i, test.in, bmap[0],
593598
*test.expected);
599+
failed_tests++;
594600
continue;
595601
}
596602

@@ -615,10 +621,12 @@ static void __init test_bitmap_arr32(void)
615621

616622
next_bit = find_next_bit(bmap2,
617623
round_up(nbits, BITS_PER_LONG), nbits);
618-
if (next_bit < round_up(nbits, BITS_PER_LONG))
624+
if (next_bit < round_up(nbits, BITS_PER_LONG)) {
619625
pr_err("bitmap_copy_arr32(nbits == %d:"
620626
" tail is not safely cleared: %d\n",
621627
nbits, next_bit);
628+
failed_tests++;
629+
}
622630

623631
if (nbits < EXP1_IN_BITS - 32)
624632
expect_eq_uint(arr[DIV_ROUND_UP(nbits, 32)],
@@ -641,15 +649,19 @@ static void __init test_bitmap_arr64(void)
641649
expect_eq_bitmap(bmap2, exp1, nbits);
642650

643651
next_bit = find_next_bit(bmap2, round_up(nbits, BITS_PER_LONG), nbits);
644-
if (next_bit < round_up(nbits, BITS_PER_LONG))
652+
if (next_bit < round_up(nbits, BITS_PER_LONG)) {
645653
pr_err("bitmap_copy_arr64(nbits == %d:"
646654
" tail is not safely cleared: %d\n", nbits, next_bit);
655+
failed_tests++;
656+
}
647657

648658
if ((nbits % 64) &&
649-
(arr[(nbits - 1) / 64] & ~GENMASK_ULL((nbits - 1) % 64, 0)))
659+
(arr[(nbits - 1) / 64] & ~GENMASK_ULL((nbits - 1) % 64, 0))) {
650660
pr_err("bitmap_to_arr64(nbits == %d): tail is not safely cleared: 0x%016llx (must be 0x%016llx)\n",
651661
nbits, arr[(nbits - 1) / 64],
652662
GENMASK_ULL((nbits - 1) % 64, 0));
663+
failed_tests++;
664+
}
653665

654666
if (nbits < EXP1_IN_BITS - 64)
655667
expect_eq_uint(arr[DIV_ROUND_UP(nbits, 64)], 0xa5a5a5a5);

0 commit comments

Comments
 (0)