From: Qu Wenruo Date: Wed, 29 Nov 2017 08:58:43 +0000 (+0800) Subject: btrfs-progs: tests/mkfs: verify that mkfs.btrfs rootdir+shrink behaves correctly X-Git-Tag: upstream/4.16.1~218 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0ba347f315435f8dd6d3158ac82ec104cff443a2;p=platform%2Fupstream%2Fbtrfs-progs.git btrfs-progs: tests/mkfs: verify that mkfs.btrfs rootdir+shrink behaves correctly Signed-off-by: Qu Wenruo Signed-off-by: David Sterba --- diff --git a/tests/mkfs-tests/012-rootdir-no-shrink/test.sh b/tests/mkfs-tests/012-rootdir-no-shrink/test.sh new file mode 100755 index 0000000..c1cb04f --- /dev/null +++ b/tests/mkfs-tests/012-rootdir-no-shrink/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Test if mkfs.btrfs --rootdir will skip shrinking correctly + +source "$TOP/tests/common" + +check_prereq mkfs.btrfs + +setup_root_helper + +fs_size=$((512 * 1024 * 1024)) +bs=$((1024 * 1024)) +tmp=$(mktemp -d --tmpdir btrfs-progs-mkfs.rootdirXXXXXXX) + +prepare_test_dev $fs_size + +# No shrink case + +run_check "$TOP/mkfs.btrfs" -f --rootdir "$tmp" "$TEST_DEV" +run_check_mount_test_dev + +# We should be able to write at least half of the fs size data since the fs is +# not shrunk +run_check $SUDO_HELPER dd if=/dev/zero bs=$bs count=$(($fs_size / $bs / 2)) \ + of="$TEST_MNT/file" + +run_check_umount_test_dev + +# Shrink case + +run_check "$TOP/mkfs.btrfs" -f --rootdir "$tmp" --shrink "$TEST_DEV" +run_check_mount_test_dev + +run_mustfail "mkfs.btrfs for shrink rootdir" \ + $SUDO_HELPER dd if=/dev/zero bs=$bs count=$(($fs_size / $bs / 2)) \ + of="$TEST_MNT/file" + +run_check_umount_test_dev + +rm -rf -- "$tmp"