btrfs-progs: tests: add shell quotes to misc test scripts

Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2018-03-23 16:34:30 +01:00
parent 3ccad2a644
commit dcb174ce2e
22 changed files with 208 additions and 207 deletions

View File

@ -21,21 +21,22 @@ test_feature()
local tuneopt
local sbflag
mkfsfeatures=${1:+-O ^$1}
mkfsfeatures=$1
tuneopt="$2"
sbflag="$3"
run_check $SUDO_HELPER $TOP/mkfs.btrfs -f $mkfsfeatures $TEST_DEV
if run_check_stdout $TOP/btrfs inspect-internal dump-super $TEST_DEV | \
run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f \
${mkfsfeatures:+-O ^"$mkfsfeatures"} "$TEST_DEV"
if run_check_stdout "$TOP/btrfs" inspect-internal dump-super "$TEST_DEV" | \
grep -q "$sbflag"; then
_fail "FAIL: feature $sbflag must not be set on the base image"
fi
run_check $TOP/btrfstune $tuneopt $TEST_DEV
if ! run_check_stdout $TOP/btrfs inspect-internal dump-super $TEST_DEV | \
run_check "$TOP/btrfstune" "$tuneopt" "$TEST_DEV"
if ! run_check_stdout "$TOP/btrfs" inspect-internal dump-super "$TEST_DEV" | \
grep -q "$sbflag"; then
_fail "FAIL: feature $sbflag not set"
fi
run_check $SUDO_HELPER $TOP/btrfs check $TEST_DEV
run_check $SUDO_HELPER "$TOP/btrfs" check "$TEST_DEV"
}
test_feature extref -r EXTENDED_IREF

View File

@ -10,7 +10,7 @@ check_prereq btrfs
prepare_test_dev
get_fs_uuid() {
run_check_stdout $TOP/btrfs inspect-internal dump-super "$1" | \
run_check_stdout "$TOP/btrfs" inspect-internal dump-super "$1" | \
grep '^fsid' | awk '{print $2}'
}
@ -20,18 +20,18 @@ test_uuid_random()
origuuid=11111111-a101-4031-b29a-379d4f8b7a2d
run_check $SUDO_HELPER $TOP/mkfs.btrfs -f \
--uuid $origuuid \
--rootdir $INTERNAL_BIN/Documentation \
$TEST_DEV
run_check $TOP/btrfs inspect-internal dump-super "$TEST_DEV"
currentfsid=$(run_check_stdout $TOP/btrfstune -f -u $TEST_DEV | \
run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f \
--uuid "$origuuid" \
--rootdir "$INTERNAL_BIN/Documentation" \
"$TEST_DEV"
run_check "$TOP/btrfs" inspect-internal dump-super "$TEST_DEV"
currentfsid=$(run_check_stdout "$TOP/btrfstune" -f -u "$TEST_DEV" | \
grep -i 'current fsid:' | awk '{print $3}')
if ! [ $currentfsid = $origuuid ]; then
if ! [ "$currentfsid" = "$origuuid" ]; then
_fail "FAIL: current UUID mismatch"
fi
run_check $TOP/btrfs inspect-internal dump-super "$TEST_DEV"
run_check $SUDO_HELPER $TOP/btrfs check $TEST_DEV
run_check "$TOP/btrfs" inspect-internal dump-super "$TEST_DEV"
run_check $SUDO_HELPER "$TOP/btrfs" check "$TEST_DEV"
}
test_uuid_user()
@ -42,19 +42,19 @@ test_uuid_user()
origuuid=22222222-d324-4f92-80e9-7658bf3b845f
newuuid=33333333-bfc9-4045-9399-a396dc6893b3
run_check $SUDO_HELPER $TOP/mkfs.btrfs -f \
--uuid $origuuid \
--rootdir $INTERNAL_BIN/Documentation \
$TEST_DEV
run_check $TOP/btrfs inspect-internal dump-super "$TEST_DEV"
run_check $TOP/btrfstune -f -U $newuuid \
$TEST_DEV
run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f \
--uuid "$origuuid" \
--rootdir "$INTERNAL_BIN/Documentation" \
"$TEST_DEV"
run_check "$TOP/btrfs" inspect-internal dump-super "$TEST_DEV"
run_check "$TOP/btrfstune" -f -U "$newuuid" \
"$TEST_DEV"
# btrfs inspect-internal dump-super is called within get_fs_uuid
fsid=$(get_fs_uuid $TEST_DEV)
if ! [ $fsid = $newuuid ]; then
fsid=$(get_fs_uuid "$TEST_DEV")
if ! [ "$fsid" = "$newuuid" ]; then
_fail "FAIL: UUID not rewritten"
fi
run_check $SUDO_HELPER $TOP/btrfs check $TEST_DEV
run_check $SUDO_HELPER "$TOP/btrfs" check "$TEST_DEV"
}
test_uuid_random

View File

@ -9,36 +9,36 @@ prepare_test_dev
get_log_root()
{
$TOP/btrfs inspect-internal dump-super "$1" | \
"$TOP/btrfs" inspect-internal dump-super "$1" | \
grep '^log_root\>' | awk '{print $2}'
}
get_log_root_level() {
$TOP/btrfs inspect-internal dump-super "$1" | \
"$TOP/btrfs" inspect-internal dump-super "$1" | \
grep '^log_root_level' | awk '{print $2}'
}
test_zero_log()
{
# FIXME: we need an image with existing log_root
run_check $SUDO_HELPER $TOP/mkfs.btrfs -f \
--rootdir $INTERNAL_BIN/Documentation \
$TEST_DEV
run_check $TOP/btrfs inspect-internal dump-super $TEST_DEV
run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f \
--rootdir "$INTERNAL_BIN/Documentation" \
"$TEST_DEV"
run_check "$TOP/btrfs" inspect-internal dump-super "$TEST_DEV"
if [ "$1" = 'standalone' ]; then
run_check $TOP/btrfs rescue zero-log $TEST_DEV
run_check "$TOP/btrfs" rescue zero-log "$TEST_DEV"
else
run_check $TOP/btrfs-zero-log $TEST_DEV
run_check "$TOP/btrfs-zero-log" "$TEST_DEV"
fi
log_root=$(get_log_root $TEST_DEV)
log_root_level=$(get_log_root $TEST_DEV)
log_root=$(get_log_root "$TEST_DEV")
log_root_level=$(get_log_root "$TEST_DEV")
if [ "$log_root" != 0 ]; then
_fail "FAIL: log_root not reset"
fi
if [ "$log_root_level" != 0 ]; then
_fail "FAIL: log_root_level not reset"
fi
run_check $TOP/btrfs inspect-internal dump-super $TEST_DEV
run_check $SUDO_HELPER $TOP/btrfs check $TEST_DEV
run_check "$TOP/btrfs" inspect-internal dump-super "$TEST_DEV"
run_check $SUDO_HELPER "$TOP/btrfs" check "$TEST_DEV"
}
test_zero_log standalone

View File

@ -14,45 +14,45 @@ setup_root_helper
# Optionally take id of the device to shrink
shrink_test()
{
min_size=$(run_check_stdout $SUDO_HELPER $TOP/btrfs inspect-internal min-dev-size ${1:+--id $1} $TEST_MNT)
min_size=$(echo $min_size | cut -d ' ' -f 1)
echo "min size = ${min_size}" >> $RESULTS
min_size=$(run_check_stdout $SUDO_HELPER "$TOP/btrfs" inspect-internal min-dev-size ${1:+--id "$1"} "$TEST_MNT")
min_size=$(echo "$min_size" | cut -d ' ' -f 1)
echo "min size = ${min_size}" >> "$RESULTS"
if [ -z "$min_size" ]; then
_fail "Failed to parse minimum size"
fi
run_check $SUDO_HELPER $TOP/btrfs filesystem resize $min_size $TEST_MNT
run_check $SUDO_HELPER "$TOP/btrfs" filesystem resize "$min_size" "$TEST_MNT"
}
run_check truncate -s 20G $IMAGE
run_check $TOP/mkfs.btrfs -f $IMAGE
run_check $SUDO_HELPER mount $IMAGE $TEST_MNT
run_check $SUDO_HELPER chmod a+rw $TEST_MNT
run_check truncate -s 20G "$IMAGE"
run_check "$TOP/mkfs.btrfs" -f "$IMAGE"
run_check $SUDO_HELPER mount "$IMAGE" "$TEST_MNT"
run_check $SUDO_HELPER chmod a+rw "$TEST_MNT"
# Create 7 data block groups, each with a size of 1Gb.
for ((i = 1; i <= 7; i++)); do
run_check fallocate -l 1G $TEST_MNT/foo$i
run_check fallocate -l 1G "$TEST_MNT/foo$i"
done
# Make sure they are persisted (all the chunk, device and block group items
# added to the chunk/dev/extent trees).
run_check $TOP/btrfs filesystem sync $TEST_MNT
run_check "$TOP/btrfs" filesystem sync "$TEST_MNT"
# Now remove 3 of those 1G files. This will result in 3 block groups becoming
# unused, which will be automatically deleted by the cleaner kthread, and this
# will result in 3 holes (unallocated space) in the device (each with a size
# of 1Gb).
run_check rm -f $TEST_MNT/foo2
run_check rm -f $TEST_MNT/foo4
run_check rm -f $TEST_MNT/foo6
run_check rm -f "$TEST_MNT/foo2"
run_check rm -f "$TEST_MNT/foo4"
run_check rm -f "$TEST_MNT/foo6"
# Sync once to wake up the cleaner kthread which will delete the unused block
# groups - it could have been sleeping when they became unused. Then wait a bit
# to allow the cleaner kthread to delete them and then finally ensure the
# transaction started by the cleaner kthread is committed.
run_check $TOP/btrfs filesystem sync $TEST_MNT
run_check "$TOP/btrfs" filesystem sync "$TEST_MNT"
sleep 3
run_check $TOP/btrfs filesystem sync $TEST_MNT
run_check "$TOP/btrfs" filesystem sync "$TEST_MNT"
# Now attempt to get the minimum size we can resize the filesystem to and verify
# the resize operation succeeds. This size closely matches the sum of the size
@ -63,10 +63,10 @@ done
# Now convert metadata and system chunks to the single profile and check we are
# still able to get a correct minimum size and shrink to that size.
run_check $SUDO_HELPER $TOP/btrfs balance start -mconvert=single \
-sconvert=single -f $TEST_MNT
run_check $SUDO_HELPER "$TOP/btrfs" balance start -mconvert=single \
-sconvert=single -f "$TEST_MNT"
for ((i = 1; i <= 3; i++)); do
shrink_test 1
done
run_check $SUDO_HELPER umount $TEST_MNT
run_check $SUDO_HELPER umount "$TEST_MNT"

View File

@ -9,7 +9,7 @@ mkfs.ext4 -V &>/dev/null || _not_run "mkfs.ext4 not found"
prepare_test_dev
for ((i = 0; i < 20; i++)); do
echo "loop $i" >>$RESULTS
mkfs.ext4 -F "$TEST_DEV" &>>$RESULTS || _not_run "mkfs.ext4 failed"
run_check $TOP/btrfs-convert "$TEST_DEV"
echo "loop $i" >> "$RESULTS"
mkfs.ext4 -F "$TEST_DEV" &>>"$RESULTS" || _not_run "mkfs.ext4 failed"
run_check "$TOP/btrfs-convert" "$TEST_DEV"
done

View File

@ -14,29 +14,29 @@ setup_root_helper
test_image_dump()
{
run_check $SUDO_HELPER $TOP/btrfs check $dev1
run_check $SUDO_HELPER "$TOP/btrfs" check "$dev1"
# the output file will be deleted
run_mayfail $SUDO_HELPER $TOP/btrfs-image $dev1 /tmp/test-img.dump
run_mayfail $SUDO_HELPER "$TOP/btrfs-image" "$dev1" /tmp/test-img.dump
}
test_run()
{
run_check $SUDO_HELPER $TOP/mkfs.btrfs -f -d raid1 -m raid1 $dev1 $dev2
run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f -d raid1 -m raid1 "$dev1" "$dev2"
# we need extents to trigger reading from all devices
run_check $SUDO_HELPER mount $dev1 $TEST_MNT
run_check $SUDO_HELPER dd if=/dev/zero of=$TEST_MNT/a bs=1M count=10
run_check $SUDO_HELPER dd if=/dev/zero of=$TEST_MNT/b bs=4k count=1000 conv=sync
run_check $SUDO_HELPER umount $TEST_MNT
run_check $SUDO_HELPER mount "$dev1" "$TEST_MNT"
run_check $SUDO_HELPER dd if=/dev/zero of="$TEST_MNT/a" bs=1M count=10
run_check $SUDO_HELPER dd if=/dev/zero of="$TEST_MNT/b" bs=4k count=1000 conv=sync
run_check $SUDO_HELPER umount "$TEST_MNT"
test_image_dump
run_check $SUDO_HELPER $TOP/btrfs filesystem show $dev1
run_check $SUDO_HELPER "$TOP/btrfs" filesystem show "$dev1"
# create a degraded raid1 filesystem, check must succeed
# btrfs-image must not loop
run_mayfail wipefs -a $dev2
run_check $SUDO_HELPER losetup -d $dev2
run_mayfail wipefs -a "$dev2"
run_check $SUDO_HELPER losetup -d "$dev2"
unset loopdevs[2]
run_check $SUDO_HELPER $TOP/btrfs filesystem show $dev1
run_check $SUDO_HELPER "$TOP/btrfs" filesystem show "$dev1"
test_image_dump
}

View File

@ -12,21 +12,21 @@ check_prereq btrfs
setup_root_helper
prepare_test_dev
run_check $SUDO_HELPER $TOP/mkfs.btrfs -f "$TEST_DEV"
run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f "$TEST_DEV"
run_check_mount_test_dev
# to check following thing in both 1 and multiple subvolume case:
# 1: is subvolume sync loop indefinitely
# 2: is return value right
#
run_check $SUDO_HELPER $TOP/btrfs subvolume create "$TEST_MNT"/mysubvol1
run_check $SUDO_HELPER $TOP/btrfs subvolume create "$TEST_MNT"/mysubvol2
run_check $SUDO_HELPER $TOP/btrfs subvolume delete "$TEST_MNT"/mysubvol1
run_check $SUDO_HELPER $TOP/btrfs subvolume delete "$TEST_MNT"/mysubvol2
run_check $SUDO_HELPER $TOP/btrfs subvolume sync "$TEST_MNT"
run_check $SUDO_HELPER "$TOP/btrfs" subvolume create "$TEST_MNT"/mysubvol1
run_check $SUDO_HELPER "$TOP/btrfs" subvolume create "$TEST_MNT"/mysubvol2
run_check $SUDO_HELPER "$TOP/btrfs" subvolume delete "$TEST_MNT"/mysubvol1
run_check $SUDO_HELPER "$TOP/btrfs" subvolume delete "$TEST_MNT"/mysubvol2
run_check $SUDO_HELPER "$TOP/btrfs" subvolume sync "$TEST_MNT"
run_check $SUDO_HELPER $TOP/btrfs subvolume create "$TEST_MNT"/mysubvol
run_check $SUDO_HELPER $TOP/btrfs subvolume delete "$TEST_MNT"/mysubvol
run_check $SUDO_HELPER $TOP/btrfs subvolume sync "$TEST_MNT"
run_check $SUDO_HELPER "$TOP/btrfs" subvolume create "$TEST_MNT"/mysubvol
run_check $SUDO_HELPER "$TOP/btrfs" subvolume delete "$TEST_MNT"/mysubvol
run_check $SUDO_HELPER "$TOP/btrfs" subvolume sync "$TEST_MNT"
run_check_umount_test_dev

View File

@ -15,8 +15,8 @@ A_PRIME_NUM=17
for ((size = SIZE_FROM; size <= SIZE_END; size += A_PRIME_NUM)); do
run_check truncate -s "$size"M "$IMAGE"
run_check mkfs.ext4 -F "$IMAGE"
run_check $TOP/btrfs-convert "$IMAGE"
run_check_stdout $TOP/btrfs check "$IMAGE" 2>&1 |
run_check "$TOP/btrfs-convert" "$IMAGE"
run_check_stdout "$TOP/btrfs" check "$IMAGE" 2>&1 |
grep -q "crossing stripe boundary" &&
_fail "leaf crossing stripes after btrfs-convert"
done

View File

@ -10,41 +10,41 @@ check_prereq btrfs
setup_root_helper
prepare_test_dev
run_check $TOP/mkfs.btrfs -f "$TEST_DEV"
run_check "$TOP/mkfs.btrfs" -f "$TEST_DEV"
run_check_mount_test_dev
run_check $SUDO_HELPER chmod a+rw $TEST_MNT
run_check $SUDO_HELPER chmod a+rw "$TEST_MNT"
cd $TEST_MNT
cd "$TEST_MNT"
for i in `seq 5`; do
run_check dd if=/dev/zero of=file$i bs=1M count=10
done
for sn in `seq 4`;do
run_check $SUDO_HELPER $TOP/btrfs subvolume snapshot . snap$sn
run_check $SUDO_HELPER "$TOP/btrfs" subvolume snapshot . snap$sn
for i in `seq 10`; do
run_check dd if=/dev/zero of=snap$sn/file$i bs=1M count=10
run_check dd if=/dev/zero of="snap$sn/file$i" bs=1M count=10
done
done
run_check $SUDO_HELPER $TOP/btrfs subvolume list .
run_check $SUDO_HELPER $TOP/btrfs subvolume list -d .
run_check $SUDO_HELPER "$TOP/btrfs" subvolume list .
run_check $SUDO_HELPER "$TOP/btrfs" subvolume list -d .
idtodel=`run_check_stdout $SUDO_HELPER $TOP/btrfs inspect-internal rootid snap3`
idtodel=`run_check_stdout $SUDO_HELPER "$TOP/btrfs" inspect-internal rootid snap3`
# delete, sync after some time
run_check $SUDO_HELPER $TOP/btrfs subvolume delete -c snap3
{ sleep 5; run_check $TOP/btrfs filesystem sync $TEST_MNT; } &
run_check $SUDO_HELPER "$TOP/btrfs" subvolume delete -c snap3
{ sleep 5; run_check "$TOP/btrfs" filesystem sync "$TEST_MNT"; } &
run_check $SUDO_HELPER $TOP/btrfs subvolume sync . $idtodel
run_check $SUDO_HELPER "$TOP/btrfs" subvolume sync . "$idtodel"
if run_check_stdout $SUDO_HELPER $TOP/btrfs subvolume list -d . |
if run_check_stdout $SUDO_HELPER "$TOP/btrfs" subvolume list -d . |
grep -q "ID $idtodel.*DELETED"; then
_fail "sync did not wait for the subvolume cleanup"
fi
run_check $TOP/btrfs filesystem sync $TEST_MNT
run_check $SUDO_HELPER $TOP/btrfs subvolume list -d .
run_check "$TOP/btrfs" filesystem sync "$TEST_MNT"
run_check $SUDO_HELPER "$TOP/btrfs" subvolume list -d .
wait
cd ..

View File

@ -13,13 +13,13 @@ prepare_test_dev
run_check truncate -s 2G "$TEST_DEV"
run_check mkfs.ext4 -F "$TEST_DEV"
run_check $TOP/btrfs-convert "$TEST_DEV"
run_check $SUDO_HELPER $TOP/btrfs inspect-internal dump-tree "$TEST_DEV"
run_check "$TOP/btrfs-convert" "$TEST_DEV"
run_check $SUDO_HELPER "$TOP/btrfs" inspect-internal dump-tree "$TEST_DEV"
run_check_mount_test_dev
run_check $SUDO_HELPER $TOP/btrfs subvolume delete -c "$TEST_MNT/ext2_saved"
run_check $SUDO_HELPER "$TOP/btrfs" subvolume delete -c "$TEST_MNT/ext2_saved"
run_check_umount_test_dev
run_check $SUDO_HELPER $TOP/btrfs inspect-internal dump-tree "$TEST_DEV"
run_check_stdout $TOP/btrfs-convert --rollback "$TEST_DEV" |
run_check $SUDO_HELPER "$TOP/btrfs" inspect-internal dump-tree "$TEST_DEV"
run_check_stdout "$TOP/btrfs-convert" --rollback "$TEST_DEV" |
grep -q 'is it deleted' || _fail "unexpected rollback"
exit 0

View File

@ -10,31 +10,31 @@ setup_root_helper
test_do_mkfs()
{
run_check $SUDO_HELPER $TOP/mkfs.btrfs -f $@ ${loopdevs[@]}
run_check $SUDO_HELPER $TOP/btrfs inspect-internal dump-super $dev1
run_check $SUDO_HELPER $TOP/btrfs check $dev1
run_check $SUDO_HELPER $TOP/btrfs filesystem show
run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f "$@" ${loopdevs[@]}
run_check $SUDO_HELPER "$TOP/btrfs" inspect-internal dump-super "$dev1"
run_check $SUDO_HELPER "$TOP/btrfs" check "$dev1"
run_check $SUDO_HELPER "$TOP/btrfs" filesystem show
}
test_wipefs()
{
run_check $SUDO_HELPER wipefs -a $devtodel
run_check $SUDO_HELPER losetup -d $devtodel
run_check $SUDO_HELPER wipefs -a "$devtodel"
run_check $SUDO_HELPER losetup -d "$devtodel"
unset loopdevs[3]
run_check $SUDO_HELPER losetup --all
run_check $TOP/btrfs filesystem show
run_check "$TOP/btrfs" filesystem show
}
test_delete_missing()
{
run_check_mount_test_dev -o degraded
run_check $SUDO_HELPER $TOP/btrfs filesystem show $TEST_MNT
run_check $SUDO_HELPER $TOP/btrfs device delete missing $TEST_MNT
run_check $SUDO_HELPER $TOP/btrfs filesystem show $TEST_MNT
run_check $SUDO_HELPER "$TOP/btrfs" filesystem show "$TEST_MNT"
run_check $SUDO_HELPER "$TOP/btrfs" device delete missing "$TEST_MNT"
run_check $SUDO_HELPER "$TOP/btrfs" filesystem show "$TEST_MNT"
run_check_umount_test_dev
run_check_mount_test_dev
local out
out="$(run_check_stdout $SUDO_HELPER $TOP/btrfs filesystem show $TEST_MNT)"
out=$(run_check_stdout $SUDO_HELPER "$TOP/btrfs" filesystem show "$TEST_MNT")
if echo "$out" | grep -q -- "$devtodel"; then
_fail "device $devtodel not deleted"
fi

View File

@ -8,10 +8,10 @@ source "$TEST_TOP/common"
check_prereq btrfs-find-root
check_prereq btrfs-image
run_check $TOP/btrfs-image -r first_meta_chunk.btrfs-image test.img || \
run_check "$TOP/btrfs-image" -r first_meta_chunk.btrfs-image test.img || \
_fail "failed to extract first_meta_chunk.btrfs-image"
result=$(run_check_stdout $TOP/btrfs-find-root test.img | sed '/^Superblock/d')
result=$(run_check_stdout "$TOP/btrfs-find-root" test.img | sed '/^Superblock/d')
if [ -z "$result" ]; then
_fail "btrfs-find-root failed to find tree root"

View File

@ -13,9 +13,9 @@ setup_root_helper
prepare_test_dev
run_check "$TOP/mkfs.btrfs" -f "$TEST_DEV"
run_check_mount_test_dev
run_check $SUDO_HELPER chmod a+rw $TEST_MNT
run_check $SUDO_HELPER chmod a+rw "$TEST_MNT"
cd $TEST_MNT
cd "$TEST_MNT"
for i in `seq 5`; do
run_check dd if=/dev/zero of=file$i bs=1M count=10
@ -23,25 +23,25 @@ done
# 128 is minimum
for sn in `seq 130`;do
run_check $SUDO_HELPER $TOP/btrfs subvolume snapshot . snap$sn
run_check $SUDO_HELPER "$TOP/btrfs" subvolume snapshot . snap$sn
for i in `seq 10`; do
run_check dd if=/dev/zero of=snap$sn/file$i bs=1M count=1
run_check dd if=/dev/zero of="snap$sn/file$i" bs=1M count=1
done
done
run_check $SUDO_HELPER $TOP/btrfs subvolume list .
run_check $SUDO_HELPER $TOP/btrfs subvolume list -d .
run_check $SUDO_HELPER "$TOP/btrfs" subvolume list .
run_check $SUDO_HELPER "$TOP/btrfs" subvolume list -d .
idtodel=`run_check_stdout $SUDO_HELPER $TOP/btrfs inspect-internal rootid snap3`
idtodel=`run_check_stdout $SUDO_HELPER "$TOP/btrfs" inspect-internal rootid snap3`
# delete, sync after some time
run_check $SUDO_HELPER $TOP/btrfs subvolume delete -c snap*
{ sleep 5; run_check $TOP/btrfs filesystem sync $TEST_MNT; } &
run_check $SUDO_HELPER "$TOP/btrfs" subvolume delete -c snap*
{ sleep 5; run_check "$TOP/btrfs" filesystem sync "$TEST_MNT"; } &
run_check $SUDO_HELPER $TOP/btrfs subvolume sync .
run_check $SUDO_HELPER "$TOP/btrfs" subvolume sync .
run_check $TOP/btrfs filesystem sync $TEST_MNT
run_check $SUDO_HELPER $TOP/btrfs subvolume list -d .
run_check "$TOP/btrfs" filesystem sync "$TEST_MNT"
run_check $SUDO_HELPER "$TOP/btrfs" subvolume list -d .
wait
cd ..

View File

@ -12,14 +12,14 @@ setup_root_helper
prepare_test_dev
run_check "$TOP/mkfs.btrfs" -L BTRFS-TEST-LABEL -f "$TEST_DEV"
run_check_mount_test_dev
run_check $SUDO_HELPER chmod a+rw $TEST_MNT
run_check $SUDO_HELPER chmod a+rw "$TEST_MNT"
cd $TEST_MNT
run_check $SUDO_HELPER $TOP/btrfs filesystem label $TEST_MNT
cd "$TEST_MNT"
run_check $SUDO_HELPER "$TOP/btrfs" filesystem label "$TEST_MNT"
# shortest label
run_check $SUDO_HELPER $TOP/btrfs filesystem label $TEST_MNT a
run_check $SUDO_HELPER $TOP/btrfs filesystem label $TEST_MNT
run_check $SUDO_HELPER $TOP/btrfs filesystem label $TEST_MNT ''
run_check $SUDO_HELPER "$TOP/btrfs" filesystem label "$TEST_MNT" a
run_check $SUDO_HELPER "$TOP/btrfs" filesystem label "$TEST_MNT"
run_check $SUDO_HELPER "$TOP/btrfs" filesystem label "$TEST_MNT" ''
longlabel=\
0123456789\
@ -54,15 +54,15 @@ longlabel=\
\
01234
run_check $SUDO_HELPER $TOP/btrfs filesystem label $TEST_MNT "$longlabel"
run_check $SUDO_HELPER $TOP/btrfs filesystem label $TEST_MNT
run_check $SUDO_HELPER "$TOP/btrfs" filesystem label "$TEST_MNT" "$longlabel"
run_check $SUDO_HELPER "$TOP/btrfs" filesystem label "$TEST_MNT"
# 256, must fail
run_mustfail "label 256 bytes long succeeded" \
$SUDO_HELPER $TOP/btrfs filesystem label $TEST_MNT "$longlabel"5
run_check $SUDO_HELPER $TOP/btrfs filesystem label $TEST_MNT
$SUDO_HELPER "$TOP/btrfs" filesystem label "$TEST_MNT" "$longlabel"5
run_check $SUDO_HELPER "$TOP/btrfs" filesystem label "$TEST_MNT"
run_mustfail "label 2 * 255 bytes long succeeded" \
$SUDO_HELPER $TOP/btrfs filesystem label $TEST_MNT "$longlabel$longlabel"
run_check $SUDO_HELPER $TOP/btrfs filesystem label $TEST_MNT
$SUDO_HELPER "$TOP/btrfs" filesystem label "$TEST_MNT" "$longlabel$longlabel"
run_check $SUDO_HELPER "$TOP/btrfs" filesystem label "$TEST_MNT"
cd ..

View File

@ -6,12 +6,12 @@ source "$TEST_TOP/common"
check_prereq btrfs
run_check $TOP/btrfs inspect-internal dump-super /dev/urandom
run_check $TOP/btrfs inspect-internal dump-super -a /dev/urandom
run_check $TOP/btrfs inspect-internal dump-super -fa /dev/urandom
run_check $TOP/btrfs inspect-internal dump-super -Ffa /dev/urandom
run_check $TOP/btrfs inspect-internal dump-super -Ffa /dev/urandom
run_check $TOP/btrfs inspect-internal dump-super -Ffa /dev/urandom
run_check $TOP/btrfs inspect-internal dump-super -Ffa /dev/urandom
run_check $TOP/btrfs inspect-internal dump-super -Ffa /dev/urandom
run_check $TOP/btrfs inspect-internal dump-super -Ffa /dev/urandom
run_check "$TOP/btrfs" inspect-internal dump-super /dev/urandom
run_check "$TOP/btrfs" inspect-internal dump-super -a /dev/urandom
run_check "$TOP/btrfs" inspect-internal dump-super -fa /dev/urandom
run_check "$TOP/btrfs" inspect-internal dump-super -Ffa /dev/urandom
run_check "$TOP/btrfs" inspect-internal dump-super -Ffa /dev/urandom
run_check "$TOP/btrfs" inspect-internal dump-super -Ffa /dev/urandom
run_check "$TOP/btrfs" inspect-internal dump-super -Ffa /dev/urandom
run_check "$TOP/btrfs" inspect-internal dump-super -Ffa /dev/urandom
run_check "$TOP/btrfs" inspect-internal dump-super -Ffa /dev/urandom

View File

@ -17,28 +17,28 @@ run_check_mount_test_dev
here=`pwd`
cd "$TEST_MNT" || _fail "cannot chdir to TEST_MNT"
run_check $SUDO_HELPER $TOP/btrfs subvolume create subv-parent1
run_check $SUDO_HELPER "$TOP/btrfs" subvolume create subv-parent1
for i in 1 2 3; do
run_check $SUDO_HELPER dd if=/dev/zero of=subv-parent1/file1_$i bs=1M count=1
run_check $SUDO_HELPER $TOP/btrfs subvolume snapshot -r subv-parent1 subv-snap1_$i
run_check $SUDO_HELPER "$TOP/btrfs" subvolume snapshot -r subv-parent1 subv-snap1_$i
done
run_check $SUDO_HELPER $TOP/btrfs subvolume create subv-parent2
run_check $SUDO_HELPER "$TOP/btrfs" subvolume create subv-parent2
for i in 1 2 3; do
run_check $SUDO_HELPER dd if=/dev/zero of=subv-parent2/file2_$i bs=1M count=1
run_check $SUDO_HELPER $TOP/btrfs subvolume snapshot -r subv-parent2 subv-snap2_$i
run_check $SUDO_HELPER "$TOP/btrfs" subvolume snapshot -r subv-parent2 subv-snap2_$i
done
truncate -s0 "$here"/send-stream.img
chmod a+w "$here"/send-stream.img
run_check $SUDO_HELPER $TOP/btrfs send -f "$here"/send-stream.img \
run_check $SUDO_HELPER "$TOP/btrfs" send -f "$here"/send-stream.img \
-c subv-snap1_1 -c subv-snap2_1 subv-snap1_[23] subv-snap2_[23]
image=$(extract_image "$here"/multi-clone-src-v4.8.2.stream.xz)
old_stream_size=`stat --format=%s "$image"`
stream_size=`stat --format=%s "$here"/send-stream.img`
if [ $old_stream_size -lt $stream_size ]; then
if [ "$old_stream_size" -lt "$stream_size" ]; then
run_check ls -l "$image" "$here"/send-stream.img
_fail "sending stream size is bigger than old stream"
fi

View File

@ -19,24 +19,24 @@ test_full_empty_stream() {
local str
str="$here/stream-full-empty.stream"
run_check $TOP/mkfs.btrfs -f $TEST_DEV
run_check "$TOP/mkfs.btrfs" -f "$TEST_DEV"
run_check_mount_test_dev
cd "$TEST_MNT" || _fail "cannot chdir to TEST_MNT"
run_check $SUDO_HELPER $TOP/btrfs subvolume create subv1
run_check $SUDO_HELPER $TOP/btrfs subvolume snapshot -r subv1 subv1-snap
run_check $SUDO_HELPER "$TOP/btrfs" subvolume create subv1
run_check $SUDO_HELPER "$TOP/btrfs" subvolume snapshot -r subv1 subv1-snap
truncate -s0 "$str"
chmod a+w "$str"
run_check $SUDO_HELPER $TOP/btrfs send -f "$str" subv1-snap
run_check $SUDO_HELPER "$TOP/btrfs" send -f "$str" subv1-snap
cd "$here" || _fail "cannot chdir back to test directory"
run_check_umount_test_dev
run_check $TOP/mkfs.btrfs -f $TEST_DEV
run_check "$TOP/mkfs.btrfs" -f "$TEST_DEV"
run_check_mount_test_dev
run_check $SUDO_HELPER $TOP/btrfs receive "$@" -v -f "$str" "$TEST_MNT"
run_check $SUDO_HELPER "$TOP/btrfs" receive "$@" -v -f "$str" "$TEST_MNT"
run_check_umount_test_dev
run_check rm -f -- "$str"
@ -46,28 +46,28 @@ test_full_simple_stream() {
local str
str="$here/stream-full-simple.stream"
run_check $TOP/mkfs.btrfs -f $TEST_DEV
run_check "$TOP/mkfs.btrfs" -f $TEST_DEV
run_check_mount_test_dev
cd "$TEST_MNT" || _fail "cannot chdir to TEST_MNT"
run_check $SUDO_HELPER $TOP/btrfs subvolume create subv1
run_check $SUDO_HELPER "$TOP/btrfs" subvolume create subv1
for i in 1 2 3; do
run_check $SUDO_HELPER dd if=/dev/zero of=subv1/file1_$i bs=1M count=1
done
run_check $SUDO_HELPER $TOP/btrfs subvolume snapshot -r subv1 subv1-snap
run_check $SUDO_HELPER "$TOP/btrfs" subvolume snapshot -r subv1 subv1-snap
truncate -s0 "$str"
chmod a+w "$str"
run_check $SUDO_HELPER $TOP/btrfs send -f "$str" subv1-snap
run_check $SUDO_HELPER "$TOP/btrfs" send -f "$str" subv1-snap
cd "$here" || _fail "cannot chdir back to test directory"
run_check_umount_test_dev
run_check $TOP/mkfs.btrfs -f $TEST_DEV
run_check "$TOP/mkfs.btrfs" -f "$TEST_DEV"
run_check_mount_test_dev
run_check $SUDO_HELPER $TOP/btrfs receive "$@" -v -f "$str" "$TEST_MNT"
run_check $SUDO_HELPER "$TOP/btrfs" receive "$@" -v -f "$str" "$TEST_MNT"
run_check_umount_test_dev
run_check rm -f -- "$str"
@ -79,27 +79,27 @@ test_incr_empty_stream() {
fstr="$here/stream-full-empty.stream"
istr="$here/stream-incr-empty.stream"
run_check $TOP/mkfs.btrfs -f $TEST_DEV
run_check "$TOP/mkfs.btrfs" -f "$TEST_DEV"
run_check_mount_test_dev
cd "$TEST_MNT" || _fail "cannot chdir to TEST_MNT"
run_check $SUDO_HELPER $TOP/btrfs subvolume create subv1
run_check $SUDO_HELPER $TOP/btrfs subvolume snapshot -r subv1 subv1-snap
run_check $SUDO_HELPER $TOP/btrfs subvolume snapshot -r subv1 subv2-snap
run_check $SUDO_HELPER "$TOP/btrfs" subvolume create subv1
run_check $SUDO_HELPER "$TOP/btrfs" subvolume snapshot -r subv1 subv1-snap
run_check $SUDO_HELPER "$TOP/btrfs" subvolume snapshot -r subv1 subv2-snap
truncate -s0 "$fstr" "$istr"
chmod a+w "$fstr" "$istr"
run_check $SUDO_HELPER $TOP/btrfs send -f "$fstr" subv1-snap
run_check $SUDO_HELPER $TOP/btrfs send -p subv1-snap -f "$istr" subv2-snap
run_check $SUDO_HELPER "$TOP/btrfs" send -f "$fstr" subv1-snap
run_check $SUDO_HELPER "$TOP/btrfs" send -p subv1-snap -f "$istr" subv2-snap
cd "$here" || _fail "cannot chdir back to test directory"
run_check_umount_test_dev
run_check $TOP/mkfs.btrfs -f $TEST_DEV
run_check "$TOP/mkfs.btrfs" -f "$TEST_DEV"
run_check_mount_test_dev
run_check $SUDO_HELPER $TOP/btrfs receive "$@" -v -f "$fstr" "$TEST_MNT"
run_check $SUDO_HELPER $TOP/btrfs receive "$@" -v -f "$istr" "$TEST_MNT"
run_check $SUDO_HELPER "$TOP/btrfs" receive "$@" -v -f "$fstr" "$TEST_MNT"
run_check $SUDO_HELPER "$TOP/btrfs" receive "$@" -v -f "$istr" "$TEST_MNT"
run_check_umount_test_dev
run_check rm -f -- "$fstr" "$istr"
@ -110,36 +110,36 @@ test_incr_simple_stream() {
fstr="$here/stream-full-simple.stream"
istr="$here/stream-incr-simple.stream"
run_check $TOP/mkfs.btrfs -f $TEST_DEV
run_check "$TOP/mkfs.btrfs" -f "$TEST_DEV"
run_check_mount_test_dev
cd "$TEST_MNT" || _fail "cannot chdir to TEST_MNT"
run_check $SUDO_HELPER $TOP/btrfs subvolume create subv1
run_check $SUDO_HELPER "$TOP/btrfs" subvolume create subv1
for i in 1 2 3; do
run_check $SUDO_HELPER dd if=/dev/zero of=subv1/file1_$i bs=1M count=1
done
run_check $SUDO_HELPER $TOP/btrfs subvolume snapshot -r subv1 subv1-snap
run_check $SUDO_HELPER "$TOP/btrfs" subvolume snapshot -r subv1 subv1-snap
for i in 1 2 3; do
run_check $SUDO_HELPER dd if=/dev/urandom of=subv1/file1_$i bs=1M count=1
done
run_check $SUDO_HELPER $TOP/btrfs subvolume snapshot -r subv1 subv2-snap
run_check $SUDO_HELPER "$TOP/btrfs" subvolume snapshot -r subv1 subv2-snap
truncate -s0 "$fstr" "$istr"
chmod a+w "$fstr" "$istr"
run_check $SUDO_HELPER $TOP/btrfs send -f "$fstr" subv1-snap
run_check $SUDO_HELPER $TOP/btrfs send -p subv1-snap -f "$istr" subv2-snap
run_check $SUDO_HELPER "$TOP/btrfs" send -f "$fstr" subv1-snap
run_check $SUDO_HELPER "$TOP/btrfs" send -p subv1-snap -f "$istr" subv2-snap
cd "$here" || _fail "cannot chdir back to test directory"
run_check_umount_test_dev
run_check $TOP/mkfs.btrfs -f $TEST_DEV
run_check "$TOP/mkfs.btrfs" -f "$TEST_DEV"
run_check_mount_test_dev
run_check $SUDO_HELPER $TOP/btrfs receive "$@" -v -f "$fstr" "$TEST_MNT"
run_check $SUDO_HELPER $TOP/btrfs receive "$@" -v -f "$istr" "$TEST_MNT"
run_check $SUDO_HELPER "$TOP/btrfs" receive "$@" -v -f "$fstr" "$TEST_MNT"
run_check $SUDO_HELPER "$TOP/btrfs" receive "$@" -v -f "$istr" "$TEST_MNT"
run_check_umount_test_dev
run_check rm -f -- "$fstr" "$istr"
@ -151,7 +151,7 @@ test_incr_empty_stream
test_incr_simple_stream
extra_opt=-e
test_full_empty_stream $extra_opt
test_full_simple_stream $extra_opt
test_incr_empty_stream $extra_opt
test_incr_simple_stream $extra_opt
test_full_empty_stream "$extra_opt"
test_full_simple_stream "$extra_opt"
test_incr_empty_stream "$extra_opt"
test_incr_simple_stream "$extra_opt"

View File

@ -31,9 +31,9 @@ run_check $SUDO_HELPER "$TOP/btrfs" subvolume create "$TEST_MNT/baz"
run_check $SUDO_HELPER "$TOP/btrfs" subvolume create "$TEST_MNT/snap"
tr '\000' 'A' < /dev/null |
run_check $SUDO_HELPER dd of=$TEST_MNT/foo/file_a bs=$BLOCK_SIZE count=32
run_check $SUDO_HELPER dd of="$TEST_MNT/foo/file_a" bs="$BLOCK_SIZE" count=32
tr '\000' 'B' < /dev/null |
run_check $SUDO_HELPER dd of=$TEST_MNT/bar/file_b bs=$BLOCK_SIZE count=32
run_check $SUDO_HELPER dd of="$TEST_MNT/bar/file_b" bs="$BLOCK_SIZE" count=32
run_check $SUDO_HELPER cp --reflink=always "$TEST_MNT/foo/file_a" "$TEST_MNT/baz/file_a"
run_check $SUDO_HELPER cp --reflink=always "$TEST_MNT/bar/file_b" "$TEST_MNT/baz/file_b"

View File

@ -20,31 +20,31 @@ loop2=$(run_check_stdout $SUDO_HELPER losetup --find --show dev2)
# Create the test file system.
run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f $loop1 $loop2
run_check $SUDO_HELPER mount $loop1 "$TEST_MNT"
run_check $SUDO_HELPER dd bs=1M count=1 if=/dev/zero "of=$TEST_MNT/foobar"
run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f "$loop1" "$loop2"
run_check $SUDO_HELPER mount "$loop1" "$TEST_MNT"
run_check $SUDO_HELPER dd bs=1M count=1 if=/dev/zero of="$TEST_MNT/foobar"
orig_md5=$(run_check_stdout md5sum "$TEST_MNT/foobar" | cut -d ' ' -f 1)
run_check $SUDO_HELPER umount "$TEST_MNT"
# Create the image to restore later.
run_check $SUDO_HELPER "$TOP/btrfs-image" $loop1 "$IMAGE"
run_check $SUDO_HELPER "$TOP/btrfs-image" "$loop1" "$IMAGE"
# Wipe out the filesystem from the devices, restore the image on a single
# device, check everything works and file foobar is there and with 1Mb of
# zeroes.
run_check $SUDO_HELPER wipefs -a $loop1
run_check $SUDO_HELPER wipefs -a $loop2
run_check $SUDO_HELPER wipefs -a "$loop1"
run_check $SUDO_HELPER wipefs -a "$loop2"
run_check $SUDO_HELPER $TOP/btrfs-image -r "$IMAGE" $loop1
run_check $SUDO_HELPER "$TOP/btrfs-image" -r "$IMAGE" "$loop1"
run_check $SUDO_HELPER mount $loop1 "$TEST_MNT"
run_check $SUDO_HELPER mount "$loop1" "$TEST_MNT"
new_md5=$(run_check_stdout md5sum "$TEST_MNT/foobar" | cut -d ' ' -f 1)
run_check $SUDO_HELPER umount "$TEST_MNT"
# Cleanup loop devices.
run_check $SUDO_HELPER losetup -d $loop1
run_check $SUDO_HELPER losetup -d $loop2
run_check $SUDO_HELPER losetup -d "$loop1"
run_check $SUDO_HELPER losetup -d "$loop2"
rm -f dev1 dev2
# Compare the file digests.
[ $orig_md5 == $new_md5 ] || _fail "File digests do not match"
[ "$orig_md5" == "$new_md5" ] || _fail "File digests do not match"

View File

@ -12,7 +12,7 @@ setup_root_helper
test_run()
{
# empty filesystem, with enough redundancy so degraded mount works
run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f -d raid1 -m raid1 $dev1 $dev2
run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f -d raid1 -m raid1 "$dev1" "$dev2"
TEST_DEV="$dev1"
run_check_mount_test_dev
@ -21,8 +21,8 @@ test_run()
grep -q "slack.*16\\.00EiB" && _fail
run_check_umount_test_dev
run_mayfail wipefs -a $dev2
run_check $SUDO_HELPER losetup -d $dev2
run_mayfail wipefs -a "$dev2"
run_check $SUDO_HELPER losetup -d "$dev2"
unset loopdevs[2]
run_check_mount_test_dev -o degraded,ro

View File

@ -36,15 +36,15 @@ id6=$(run_check_stdout "$TOP/btrfs" inspect-internal rootid dir/file2) \
id7=$(run_check_stdout "$TOP/btrfs" inspect-internal rootid sub/file3) \
|| { echo $id7; exit 1; }
if ! ([ $id1 -ne $id2 ] && [ $id1 -ne $id3 ] && [ $id2 -ne $id3 ]); then
if ! ([ "$id1" -ne "$id2" ] && [ "$id1" -ne "$id3" ] && [ "$id2" -ne "$id3" ]); then
_fail "inspect-internal rootid: each subvolume must have different id"
fi
if ! ([ $id1 -eq $id4 ] && [ $id1 -eq $id5 ] && [ $id1 -eq $id6 ]); then
if ! ([ "$id1" -eq "$id4" ] && [ "$id1" -eq "$id5" ] && [ "$id1" -eq "$id6" ]); then
_fail "inspect-internal rootid: rootid mismatch found"
fi
if ! ([ $id2 -eq $id7 ]); then
if ! ([ "$id2" -eq "$id7" ]); then
_fail "inspect-internal rootid: rootid mismatch found"
fi

View File

@ -25,9 +25,9 @@ function check_corruption {
run_check $SUDO_HELPER dd bs=1K count=1 seek=$(($sb_offset + 1)) if=/dev/zero of="$TEST_DEV" conv=notrunc
# if corrupting one of the sb copies, copy it over the initial superblock
if [ ! -z $source_sb ]; then
if [ ! -z "$source_sb" ]; then
local shift_val=$((16 << $source_sb * 12 ))
run_check $SUDO_HELPER dd bs=1K count=4 seek=64 skip=$shift_val if="$TEST_DEV" of="$TEST_DEV" conv=notrunc
run_check $SUDO_HELPER dd bs=1K count=4 seek=64 skip="$shift_val" if="$TEST_DEV" of="$TEST_DEV" conv=notrunc
fi
# we can't use our mount helper, the following works for file image and