btrfs-progs: tests: also test --subvol modifiers in mkfs-tests/036-rootdir-subvol
Adds tests to mkfs-tests/036-rootdir-subvol for the modifiers to mkfs.btrfs --subvol: ro, rw, default, and default-ro. Signed-off-by: Mark Harmstone <maharmstone@fb.com>
This commit is contained in:
parent
6a1d4adad1
commit
bb1e8461ce
|
@ -18,12 +18,21 @@ basic()
|
|||
run_check mkdir "$tmp/dir/subvol"
|
||||
run_check touch "$tmp/dir/subvol/bar"
|
||||
|
||||
if [ "$1" != "" ]; then
|
||||
run_check_mkfs_test_dev --rootdir "$tmp" --subvol $1:dir/subvol
|
||||
else
|
||||
run_check_mkfs_test_dev --rootdir "$tmp" --subvol dir/subvol
|
||||
fi
|
||||
|
||||
run_check $SUDO_HELPER "$TOP/btrfs" check "$TEST_DEV"
|
||||
|
||||
run_check_mount_test_dev
|
||||
run_check_mount_test_dev -o subvolid=5
|
||||
run_check_stdout $SUDO_HELPER "$TOP/btrfs" subvolume list "$TEST_MNT" | \
|
||||
cut -d\ -f9 > "$tmp/output"
|
||||
run_check_stdout "$TOP/btrfs" property get "$TEST_MNT/dir/subvol" ro | \
|
||||
cut -d = -f2 > "$tmp/output2"
|
||||
run_check_stdout "$TOP/btrfs" subvolume get-default "$TEST_MNT" | \
|
||||
cut -d\ -f2 > "$tmp/output3"
|
||||
run_check_umount_test_dev
|
||||
|
||||
result=$(cat "$tmp/output")
|
||||
|
@ -31,6 +40,31 @@ basic()
|
|||
if [ "$result" != "dir/subvol" ]; then
|
||||
_fail "dir/subvol not in subvolume list"
|
||||
fi
|
||||
|
||||
result=$(cat "$tmp/output2")
|
||||
|
||||
if [ "$1" == "ro" -o "$1" == "default-ro" ]; then
|
||||
if [ "$result" != "true" ]; then
|
||||
_fail "dir/subvol was read-write, expected read-only"
|
||||
fi
|
||||
else
|
||||
if [ "$result" != "false" ]; then
|
||||
_fail "dir/subvol was read-only, expected read-write"
|
||||
fi
|
||||
fi
|
||||
|
||||
result=$(cat "$tmp/output3")
|
||||
|
||||
if [ "$1" == "default" -o "$1" == "default-ro" ]; then
|
||||
if [ "$result" != "256" ]; then
|
||||
_fail "default subvol was $result, expected 256"
|
||||
fi
|
||||
else
|
||||
if [ "$result" != "5" ]; then
|
||||
_fail "default subvol was $result, expected 5"
|
||||
fi
|
||||
fi
|
||||
|
||||
rm -rf -- "$tmp/foo" "$tmp/dir"
|
||||
}
|
||||
|
||||
|
@ -61,10 +95,15 @@ split_by_subvolume_hardlinks()
|
|||
run_check mkdir "$tmp/subv"
|
||||
run_check ln "$tmp/hl1" "$tmp/subv/hl3"
|
||||
|
||||
if [ "$1" != "" ]; then
|
||||
run_check_mkfs_test_dev --rootdir "$tmp" --subvol $1:subv
|
||||
else
|
||||
run_check_mkfs_test_dev --rootdir "$tmp" --subvol subv
|
||||
fi
|
||||
|
||||
run_check $SUDO_HELPER "$TOP/btrfs" check "$TEST_DEV"
|
||||
|
||||
run_check_mount_test_dev
|
||||
run_check_mount_test_dev -o subvolid=5
|
||||
nr_hardlink=$(run_check_stdout $SUDO_HELPER stat -c "%h" "$TEST_MNT/hl1")
|
||||
|
||||
if [ "$nr_hardlink" -ne 2 ]; then
|
||||
|
@ -76,10 +115,14 @@ split_by_subvolume_hardlinks()
|
|||
_fail "hard link number incorrect for subv/hl3, has ${nr_hardlink} expect 1"
|
||||
fi
|
||||
run_check_umount_test_dev
|
||||
rm -rf -- "$tmp/hl1" "$tmp/hl2" "$tmp/dir"
|
||||
rm -rf -- "$tmp/hl1" "$tmp/hl2" "$tmp/subv"
|
||||
}
|
||||
|
||||
basic
|
||||
for mod in "" ro rw default default-ro;
|
||||
do
|
||||
basic $mod
|
||||
split_by_subvolume_hardlinks $mod
|
||||
done
|
||||
|
||||
basic_hardlinks
|
||||
split_by_subvolume_hardlinks
|
||||
rm -rf -- "$tmp"
|
||||
|
|
Loading…
Reference in New Issue