From 2a24192454edce74837c745df09c46b6e7468d58 Mon Sep 17 00:00:00 2001 From: David Sterba Date: Wed, 5 Jun 2019 18:55:48 +0200 Subject: [PATCH] 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 --- tests/common | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/common b/tests/common index 1575ae38..b3f286a0 100644 --- a/tests/common +++ b/tests/common @@ -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