Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <linux@roeck-us.net>
Link: https://lore.kernel.org/lkml/20230225184702.GA3587246@roeck-us.net/
Signed-off-by: Yury Norov <yury.norov@gmail.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Alexander Lobakin <aleksander.lobakin@intel.com>

+15 -3
+15 -3
lib/test_bitmap.c
··· 470 470 if (err != ptest.errno) { 471 471 pr_err("parselist: %d: input is %s, errno is %d, expected %d\n", 472 472 i, ptest.in, err, ptest.errno); 473 + failed_tests++; 473 474 continue; 474 475 } 475 476 ··· 479 478 pr_err("parselist: %d: input is %s, result is 0x%lx, expected 0x%lx\n", 480 479 i, ptest.in, bmap[0], 481 480 *ptest.expected); 481 + failed_tests++; 482 482 continue; 483 483 } 484 484 ··· 513 511 514 512 if (ret != slen + 1) { 515 513 pr_err("bitmap_print_to_pagebuf: result is %d, expected %d\n", ret, slen); 514 + failed_tests++; 516 515 goto out; 517 516 } 518 517 519 518 if (strncmp(buf, expected, slen)) { 520 519 pr_err("bitmap_print_to_pagebuf: result is %s, expected %s\n", buf, expected); 520 + failed_tests++; 521 521 goto out; 522 522 } 523 523 ··· 587 583 if (err != test.errno) { 588 584 pr_err("parse: %d: input is %s, errno is %d, expected %d\n", 589 585 i, test.in, err, test.errno); 586 + failed_tests++; 590 587 continue; 591 588 } 592 589 ··· 596 591 pr_err("parse: %d: input is %s, result is 0x%lx, expected 0x%lx\n", 597 592 i, test.in, bmap[0], 598 593 *test.expected); 594 + failed_tests++; 599 595 continue; 600 596 } 601 597 ··· 621 615 622 616 next_bit = find_next_bit(bmap2, 623 617 round_up(nbits, BITS_PER_LONG), nbits); 624 - if (next_bit < round_up(nbits, BITS_PER_LONG)) 618 + if (next_bit < round_up(nbits, BITS_PER_LONG)) { 625 619 pr_err("bitmap_copy_arr32(nbits == %d:" 626 620 " tail is not safely cleared: %d\n", 627 621 nbits, next_bit); 622 + failed_tests++; 623 + } 628 624 629 625 if (nbits < EXP1_IN_BITS - 32) 630 626 expect_eq_uint(arr[DIV_ROUND_UP(nbits, 32)], ··· 649 641 expect_eq_bitmap(bmap2, exp1, nbits); 650 642 651 643 next_bit = find_next_bit(bmap2, round_up(nbits, BITS_PER_LONG), nbits); 652 - if (next_bit < round_up(nbits, BITS_PER_LONG)) 644 + if (next_bit < round_up(nbits, BITS_PER_LONG)) { 653 645 pr_err("bitmap_copy_arr64(nbits == %d:" 654 646 " tail is not safely cleared: %d\n", nbits, next_bit); 647 + failed_tests++; 648 + } 655 649 656 650 if ((nbits % 64) && 657 - (arr[(nbits - 1) / 64] & ~GENMASK_ULL((nbits - 1) % 64, 0))) 651 + (arr[(nbits - 1) / 64] & ~GENMASK_ULL((nbits - 1) % 64, 0))) { 658 652 pr_err("bitmap_to_arr64(nbits == %d): tail is not safely cleared: 0x%016llx (must be 0x%016llx)\n", 659 653 nbits, arr[(nbits - 1) / 64], 660 654 GENMASK_ULL((nbits - 1) % 64, 0)); 655 + failed_tests++; 656 + } 661 657 662 658 if (nbits < EXP1_IN_BITS - 64) 663 659 expect_eq_uint(arr[DIV_ROUND_UP(nbits, 64)], 0xa5a5a5a5);