Skip to content

Commit 4bdba81

Browse files
ryota-sakamototytso
authored andcommitted
ext4: replace KUnit tests for memcmp() with KUNIT_ASSERT_MEMEQ()
Replace KUnit tests for memcmp() with KUNIT_ASSERT_MEMEQ() to improve debugging that prints the hex dump of the buffers when the assertion fails, whereas memcmp() only returns an integer difference. Signed-off-by: Ryota Sakamoto <sakamo.ryota@gmail.com> Link: https://patch.msgid.link/20260127-fix-fs_ext4-memcmp-v1-1-5c269ae906b6@gmail.com Signed-off-by: Theodore Ts'o <tytso@mit.edu>
1 parent 5200f5f commit 4bdba81

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

fs/ext4/mballoc-test.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -714,8 +714,7 @@ do_test_generate_buddy(struct kunit *test, struct super_block *sb, void *bitmap,
714714
ext4_mb_generate_buddy_test(sb, ext4_buddy, bitmap, TEST_GOAL_GROUP,
715715
ext4_grp);
716716

717-
KUNIT_ASSERT_EQ(test, memcmp(mbt_buddy, ext4_buddy, sb->s_blocksize),
718-
0);
717+
KUNIT_ASSERT_MEMEQ(test, mbt_buddy, ext4_buddy, sb->s_blocksize);
719718
mbt_validate_group_info(test, mbt_grp, ext4_grp);
720719
}
721720

@@ -776,8 +775,7 @@ test_mb_mark_used_range(struct kunit *test, struct ext4_buddy *e4b,
776775
grp->bb_counters[i] = 0;
777776
ext4_mb_generate_buddy_test(sb, buddy, bitmap, 0, grp);
778777

779-
KUNIT_ASSERT_EQ(test, memcmp(buddy, e4b->bd_buddy, sb->s_blocksize),
780-
0);
778+
KUNIT_ASSERT_MEMEQ(test, buddy, e4b->bd_buddy, sb->s_blocksize);
781779
mbt_validate_group_info(test, grp, e4b->bd_info);
782780
}
783781

@@ -841,8 +839,7 @@ test_mb_free_blocks_range(struct kunit *test, struct ext4_buddy *e4b,
841839
grp->bb_counters[i] = 0;
842840
ext4_mb_generate_buddy_test(sb, buddy, bitmap, 0, grp);
843841

844-
KUNIT_ASSERT_EQ(test, memcmp(buddy, e4b->bd_buddy, sb->s_blocksize),
845-
0);
842+
KUNIT_ASSERT_MEMEQ(test, buddy, e4b->bd_buddy, sb->s_blocksize);
846843
mbt_validate_group_info(test, grp, e4b->bd_info);
847844

848845
}

0 commit comments

Comments
 (0)