From 421e41df492f838b9b78db7bfae1315f1f7c7336 Mon Sep 17 00:00:00 2001 From: Zhao Lei Date: Tue, 1 Sep 2015 14:45:22 +0200 Subject: [PATCH] btrfs-progs: tests: introduce test dev mount helpers mount command in old system can not add "-o loop" option automatically for a loop device, and make following test 013-extent-tree-rebuild fail. Considering that $TEST_DEV can be block or loop device, we need to determine our mount option in a condition for both case. Introduce a wrapper that will add the loop options if needed. Signed-off-by: Zhao Lei Signed-off-by: David Sterba --- tests/common | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/common b/tests/common index c597915..63b0d9f 100644 --- a/tests/common +++ b/tests/common @@ -171,6 +171,32 @@ prepare_test_dev() truncate -s "$size" "$TEST_DEV" || _not_run "create file for loop device failed" } +run_check_mount_test_dev() +{ + setup_root_helper + + local loop_opt + if [[ -b "$TEST_DEV" ]]; then + loop_opt="" + elif [[ -f "$TEST_DEV" ]]; then + loop_opt="-o loop" + else + _fail "Invalid \$TEST_DEV: $TEST_DEV" + fi + + [[ -d "$TEST_MNT" ]] || { + _fail "Invalid \$TEST_MNT: $TEST_MNT" + } + + run_check $SUDO_HELPER mount $loop_opt "$@" "$TEST_DEV" "$TEST_MNT" +} + +run_check_umount_test_dev() +{ + setup_root_helper + run_check $SUDO_HELPER umount "$@" "$TEST_DEV" +} + init_env() { TEST_MNT="${TEST_MNT:-$TOP/tests/mnt}" -- 2.7.4