btrfs-progs: tests: add variable quotation to fsck-tests

Signed-off-by: Lakshmipathi.G <Lakshmipathi.G@giis.co.in>
Signed-off-by: David Sterba <dsterba@suse.com>
master
Lakshmipathi.G 2017-04-24 18:59:40 +05:30 committed by David Sterba
parent 3ab900a04e
commit 467b49ccbb
11 changed files with 49 additions and 49 deletions

View File

@ -1,15 +1,15 @@
#!/bin/bash
source $TOP/tests/common
source "$TOP/tests/common"
check_prereq btrfs
echo "extracting image default_case.tar.xz" >> $RESULTS
echo "extracting image default_case.tar.xz" >> "$RESULTS"
tar --no-same-owner -xJf default_case.tar.xz || \
_fail "failed to extract default_case.tar.xz"
check_image test.img
echo "extracting image skinny_case.tar.xz" >> $RESULTS
echo "extracting image skinny_case.tar.xz" >> "$RESULTS"
tar --no-same-owner -xJf skinny_case.tar.xz || \
_fail "failed to extract skinny_case.tar.xz"
check_image test.img

View File

@ -1,6 +1,6 @@
#!/bin/bash
source $TOP/tests/common
source "$TOP/tests/common"
check_prereq btrfs-image
@ -37,16 +37,16 @@ leaf_no_data_ext_list=(
generate_leaf_corrupt_no_data_ext()
{
dest=$1
echo "generating leaf_corrupt_no_data_ext.btrfs-image" >> $RESULTS
echo "generating leaf_corrupt_no_data_ext.btrfs-image" >> "$RESULTS"
tar --no-same-owner -xJf ./no_data_extent.tar.xz || \
_fail "failed to extract leaf_corrupt_no_data_ext.btrfs-image"
$TOP/btrfs-image -r test.img.btrfs-image $dest || \
"$TOP/btrfs-image" -r test.img.btrfs-image "$dest" || \
_fail "failed to extract leaf_corrupt_no_data_ext.btrfs-image"
# leaf at 4206592 and 20905984 contains no regular data
# extent, clear its csum to corrupt the leaf.
for x in 4206592 20905984; do
dd if=/dev/zero of=$dest bs=1 count=32 conv=notrunc seek=$x \
dd if=/dev/zero of="$dest" bs=1 count=32 conv=notrunc seek="$x" \
1>/dev/null 2>&1
done
}
@ -60,21 +60,21 @@ check_inode()
name=$5
# Check whether the inode exists
exists=$($SUDO_HELPER find $path -inum $ino)
exists=$($SUDO_HELPER find "$path" -inum "$ino")
if [ -z "$exists" ]; then
_fail "inode $ino not recovered correctly"
fi
# Check inode type
found_mode=$(printf "%o" 0x$($SUDO_HELPER stat $exists -c %f))
if [ $found_mode -ne $mode ]; then
found_mode=$(printf "%o" 0x$($SUDO_HELPER stat "$exists" -c %f))
if [ "$found_mode" -ne "$mode" ]; then
echo "$found_mode"
_fail "inode $ino modes not recovered"
fi
# Check inode size
found_size=$($SUDO_HELPER stat $exists -c %s)
if [ $mode -ne 41700 -a $found_size -ne $size ]; then
found_size=$($SUDO_HELPER stat "$exists" -c %s)
if [ $mode -ne 41700 -a "$found_size" -ne "$size" ]; then
_fail "inode $ino size not recovered correctly"
fi
@ -90,11 +90,11 @@ check_inode()
check_leaf_corrupt_no_data_ext()
{
image=$1
$SUDO_HELPER mount -o loop $image -o ro $TEST_MNT
$SUDO_HELPER mount -o loop "$image" -o ro "$TEST_MNT"
i=0
while [ $i -lt ${#leaf_no_data_ext_list[@]} ]; do
check_inode $TEST_MNT/lost+found \
check_inode "$TEST_MNT/lost+found" \
${leaf_no_data_ext_list[i]} \
${leaf_no_data_ext_list[i + 1]} \
${leaf_no_data_ext_list[i + 2]} \
@ -102,7 +102,7 @@ check_leaf_corrupt_no_data_ext()
${leaf_no_data_ext_list[i + 4]}
((i+=4))
done
$SUDO_HELPER umount $TEST_MNT
$SUDO_HELPER umount "$TEST_MNT"
}
setup_root_helper

View File

@ -1,6 +1,6 @@
#!/bin/bash
source $TOP/tests/common
source "$TOP/tests/common"
check_prereq btrfs-corrupt-block
check_prereq mkfs.btrfs
@ -12,32 +12,32 @@ prepare_test_dev 1G
# test whether fsck can rebuild a corrupted extent tree
test_extent_tree_rebuild()
{
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
generate_dataset small
for i in `seq 1 100`;do
run_check $SUDO_HELPER $TOP/btrfs sub snapshot $TEST_MNT \
$TEST_MNT/snapaaaaaaa_$i
run_check $SUDO_HELPER "$TOP/btrfs" sub snapshot "$TEST_MNT" \
"$TEST_MNT/snapaaaaaaa_$i"
done
run_check_umount_test_dev
# get extent root bytenr
extent_root_bytenr=`$SUDO_HELPER $TOP/btrfs inspect-internal dump-tree -r $TEST_DEV | \
extent_root_bytenr=`$SUDO_HELPER "$TOP/btrfs" inspect-internal dump-tree -r "$TEST_DEV" | \
grep extent | awk '{print $7}'`
if [ -z $extent_root_bytenr ];then
if [ -z "$extent_root_bytenr" ];then
_fail "fail to get extent root bytenr"
fi
# corrupt extent root node block
run_check $SUDO_HELPER $TOP/btrfs-corrupt-block -l $extent_root_bytenr \
-b 4096 $TEST_DEV
run_check $SUDO_HELPER "$TOP/btrfs-corrupt-block" -l "$extent_root_bytenr" \
-b 4096 "$TEST_DEV"
$SUDO_HELPER $TOP/btrfs check $TEST_DEV >& /dev/null && \
$SUDO_HELPER "$TOP/btrfs" check "$TEST_DEV" >& /dev/null && \
_fail "btrfs check should detect failure"
run_check $SUDO_HELPER $TOP/btrfs check --repair --init-extent-tree $TEST_DEV
run_check $SUDO_HELPER $TOP/btrfs check $TEST_DEV
run_check $SUDO_HELPER "$TOP/btrfs" check --repair --init-extent-tree "$TEST_DEV"
run_check $SUDO_HELPER "$TOP/btrfs" check "$TEST_DEV"
}
test_extent_tree_rebuild

View File

@ -1,11 +1,11 @@
#!/bin/bash
source $TOP/tests/common
source "$TOP/tests/common"
check_prereq btrfs
image=$(extract_image "./default_case.raw.xz")
run_check_stdout $TOP/btrfs check "$image" 2>&1 |
run_check_stdout "$TOP/btrfs" check "$image" 2>&1 |
grep -q "crossing stripe boundary" ||
_fail "no expected error message in the output"

View File

@ -11,12 +11,12 @@
#
# a buggy check leads to the above messages
source $TOP/tests/common
source "$TOP/tests/common"
check_prereq btrfs
image=$(extract_image "./default_case.img.xz")
run_check_stdout $TOP/btrfs check "$image" 2>&1 |
run_check_stdout "$TOP/btrfs" check "$image" 2>&1 |
grep -q "type mismatch with chunk" &&
_fail "unexpected error message in the output"

View File

@ -15,16 +15,16 @@
# the beginning of leaf.
# Which caused false alert for lowmem mode.
source $TOP/tests/common
source "$TOP/tests/common"
check_prereq btrfs
for img in *.img *.raw.xz
do
image=$(extract_image $img)
image=$(extract_image "$img")
# Since the return value bug is already fixed, we don't need
# the old grep hack to detect bug.
run_check $TOP/btrfs check "$image"
run_check "$TOP/btrfs" check "$image"
rm -f "$image"
done

View File

@ -1,14 +1,14 @@
#!/bin/bash
# confirm whether btrfsck supports to check a partially dropped snapshot
source $TOP/tests/common
source "$TOP/tests/common"
check_prereq btrfs
for img in *.img
do
image=$(extract_image $img)
run_check_stdout $TOP/btrfs check "$image" 2>&1 |
image=$(extract_image "$img")
run_check_stdout "$TOP/btrfs" check "$image" 2>&1 |
grep -q "Errors found in extent allocation tree or chunk allocation"
if [ $? -eq 0 ]; then
rm -f "$image"

View File

@ -1,7 +1,7 @@
#!/bin/bash
# check whether btrfsck can detect running qgroup rescan
source $TOP/tests/common
source "$TOP/tests/common"
check_prereq btrfs
@ -9,7 +9,7 @@ check_image() {
local image
image=$1
run_check_stdout $TOP/btrfs check "$image" 2>&1 | \
run_check_stdout "$TOP/btrfs" check "$image" 2>&1 | \
grep -q "Counts for qgroup id"
if [ $? -eq 0 ]; then
_fail "Btrfs check doesn't detect rescan correctly"

View File

@ -5,13 +5,13 @@
# Fixed by patch:
# btrfs-progs: Fix stack overflow for checking qgroup on tree reloc tree
source $TOP/tests/common
source "$TOP/tests/common"
check_prereq btrfs
check_image()
{
run_check $TOP/btrfs check "$1"
run_check "$TOP/btrfs" check "$1"
}
check_all_images

View File

@ -1,7 +1,7 @@
#!/bin/bash
# confirm that clearing space cache works
source $TOP/tests/common
source "$TOP/tests/common"
check_prereq btrfs
check_prereq mkfs.btrfs
@ -9,21 +9,21 @@ check_prereq mkfs.btrfs
setup_root_helper
prepare_test_dev 1G
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
# Create files that takes at least 3 data chunks, while
# can still be removed to create free space inside one chunk.
for i in $(seq 0 6); do
run_check $SUDO_HELPER dd if=/dev/zero of=$TEST_MNT/file_${i} bs=1M \
run_check $SUDO_HELPER dd if=/dev/zero of="$TEST_MNT/file_${i}" bs=1M \
count=64 > /dev/null 2>&1
done
sync
# Remove file 1 3 5 to create holes
for i in 1 3 5; do
run_check $SUDO_HELPER rm $TEST_MNT/file_${i}
run_check $SUDO_HELPER rm "$TEST_MNT/file_${i}"
done
sync
@ -31,17 +31,17 @@ sync
run_check_umount_test_dev
# Clear space cache and re-check fs
run_check $TOP/btrfs check --clear-space-cache v1 $TEST_DEV
run_check $TOP/btrfs check $TEST_DEV
run_check "$TOP/btrfs" check --clear-space-cache v1 "$TEST_DEV"
run_check "$TOP/btrfs" check "$TEST_DEV"
# Manually recheck space cache and super space cache generation
run_check_stdout $TOP/btrfs inspect-internal dump-tree -t root $TEST_DEV | \
run_check_stdout "$TOP/btrfs" inspect-internal dump-tree -t root "$TEST_DEV" | \
grep -q FREE_SPACE
if [ $? -eq 0 ]; then
_fail "clear space cache doesn't clear all space cache"
fi
run_check_stdout $TOP/btrfs inspect-internal dump-super $TEST_DEV |
run_check_stdout $TOP/btrfs inspect-internal dump-super "$TEST_DEV" |
grep -q 'cache_generation.*18446744073709551615'
if [ $? -ne 0 ]; then
_fail "clear space cache doesn't set cache_generation correctly"

View File

@ -1,7 +1,7 @@
#!/bin/bash
# Confirm btrfs check can check file extents without causing false alert
source $TOP/tests/common
source "$TOP/tests/common"
check_prereq btrfs
check_prereq mkfs.btrfs