diff options
author | Zhao Lei <zhaolei@cn.fujitsu.com> | 2015-09-01 14:45:22 +0200 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2015-09-01 14:53:16 +0200 |
commit | 421e41df492f838b9b78db7bfae1315f1f7c7336 (patch) | |
tree | 86866d1df3ba74f51a22bd7ce033201bcd0f0175 | |
parent | 3ca185850bca6e227adf584851343dd69c2aaf05 (diff) | |
download | btrfs-progs-421e41df492f838b9b78db7bfae1315f1f7c7336.tar.gz |
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 <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r-- | tests/common | 26 |
1 files changed, 26 insertions, 0 deletions
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}" |