btrfs-progs: tests: add helper for common mkfs on TEST_DEV

Lots of test opencode the mkfs phase with no special needs, add a helper
that forcibly creates fileystem on TEST_DEV. Any options can be added,
except devices.

Signed-off-by: David Sterba <dsterba@suse.com>
master
David Sterba 2019-06-05 18:55:48 +02:00
parent be08ddeb52
commit 2a24192454
1 changed files with 17 additions and 0 deletions

View File

@ -468,6 +468,23 @@ prepare_test_dev()
truncate -s "$size" "$TEST_DEV" || _not_run "create file for loop device failed"
}
# Create filesystem on $TEST_DEV with given options,
# do not use for multi-device filesystem
# $1-$n: optional, default is -f
run_check_mkfs_test_dev()
{
setup_root_helper
# check accidental files/devices passed
for opt in "$@"; do
if [ -f "$opt" -o -b "$opt" ]; then
_fail "ERROR: unexpected option for run_check_mkfs_test_dev: device"
fi
done
run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f "$@" "$TEST_DEV"
}
run_check_mount_test_dev()
{
setup_root_helper