@@ -165,3 +165,27 @@ init_env()
mkdir -p "$TEST_MNT" || { echo "Failed mkdir -p $TEST_MNT"; exit 1; }
}
init_env
+
+mount_test_dev()
+{
+ 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"
+ }
+
+ mount "${loop_opt[@]}" "$TEST_DEV" "$TEST_MNT" || _fail "mount $TEST_DEV to $TEST_MNT failed"
+}
+
+umount_test_dev()
+{
+ umount "$TEST_DEV"
+}
+
@@ -12,14 +12,14 @@ test_extent_tree_rebuild()
{
run_check $SUDO_HELPER $TOP/mkfs.btrfs -f $TEST_DEV
- run_check $SUDO_HELPER mount $TEST_DEV $TEST_MNT
+ run_check $SUDO_HELPER mount_test_dev
run_check $SUDO_HELPER cp -aR /lib/modules/`uname -r`/ $TEST_MNT
for i in `seq 1 100`;do
run_check $SUDO_HELPER $TOP/btrfs sub snapshot $TEST_MNT \
$TEST_MNT/snapaaaaaaa_$i
done
- run_check $SUDO_HELPER umount $TEST_DEV
+ run_check $SUDO_HELPER umount_test_dev
# get extent root bytenr
extent_root_bytenr=`$SUDO_HELPER $TOP/btrfs-debug-tree -r $TEST_DEV | \