btrfs-progs: tests: make sure mkfs.btrfs cleans up temporary chunks

Since current "btrfs filesystem df" command will warn if there are
multiple profiles of the same type, it's a good way to detect left-over
temporary chunks.

Enhance the existing mkfs-tests/001-basic-profiles test case to also
check for the warning messages, to make sure mkfs.btrfs has properly
cleaned up all temporary chunks.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Qu Wenruo 2021-10-11 17:43:00 +08:00 committed by David Sterba
parent 0befc6dce2
commit 6e888a7a6c

View file

@ -11,10 +11,23 @@ setup_root_helper
test_get_info()
{
local tmp_out
tmp_out=$(mktemp --tmpdir btrfs-progs-mkfs-tests-get-info.XXXXXX)
run_check $SUDO_HELPER "$TOP/btrfs" inspect-internal dump-super "$dev1"
run_check $SUDO_HELPER "$TOP/btrfs" check "$dev1"
run_check $SUDO_HELPER mount "$dev1" "$TEST_MNT"
run_check "$TOP/btrfs" filesystem df "$TEST_MNT"
# Work around for kernel bug that will treat SINGLE and single
# device RAID0 as the same.
# Thus kernel may create new SINGLE chunks, causing extra warning
# when testing single device RAID0.
run_check $SUDO_HELPER mount -o ro "$dev1" "$TEST_MNT"
run_check_stdout "$TOP/btrfs" filesystem df "$TEST_MNT" > "$tmp_out"
if grep -q "Multiple block group profiles detected" "$tmp_out"; then
rm -- "$tmp_out"
_fail "temporary chunks are not properly cleaned up"
fi
rm -- "$tmp_out"
run_check $SUDO_HELPER "$TOP/btrfs" filesystem usage "$TEST_MNT"
run_check $SUDO_HELPER "$TOP/btrfs" device usage "$TEST_MNT"
run_check $SUDO_HELPER umount "$TEST_MNT"