mirror of
https://github.com/kdave/btrfs-progs
synced 2025-01-11 08:19:32 +00:00
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>
This commit is contained in:
parent
3ab900a04e
commit
467b49ccbb
@ -1,15 +1,15 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
source $TOP/tests/common
|
source "$TOP/tests/common"
|
||||||
|
|
||||||
check_prereq btrfs
|
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 || \
|
tar --no-same-owner -xJf default_case.tar.xz || \
|
||||||
_fail "failed to extract default_case.tar.xz"
|
_fail "failed to extract default_case.tar.xz"
|
||||||
check_image test.img
|
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 || \
|
tar --no-same-owner -xJf skinny_case.tar.xz || \
|
||||||
_fail "failed to extract skinny_case.tar.xz"
|
_fail "failed to extract skinny_case.tar.xz"
|
||||||
check_image test.img
|
check_image test.img
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
source $TOP/tests/common
|
source "$TOP/tests/common"
|
||||||
|
|
||||||
check_prereq btrfs-image
|
check_prereq btrfs-image
|
||||||
|
|
||||||
@ -37,16 +37,16 @@ leaf_no_data_ext_list=(
|
|||||||
generate_leaf_corrupt_no_data_ext()
|
generate_leaf_corrupt_no_data_ext()
|
||||||
{
|
{
|
||||||
dest=$1
|
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 || \
|
tar --no-same-owner -xJf ./no_data_extent.tar.xz || \
|
||||||
_fail "failed to extract leaf_corrupt_no_data_ext.btrfs-image"
|
_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"
|
_fail "failed to extract leaf_corrupt_no_data_ext.btrfs-image"
|
||||||
|
|
||||||
# leaf at 4206592 and 20905984 contains no regular data
|
# leaf at 4206592 and 20905984 contains no regular data
|
||||||
# extent, clear its csum to corrupt the leaf.
|
# extent, clear its csum to corrupt the leaf.
|
||||||
for x in 4206592 20905984; do
|
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
|
1>/dev/null 2>&1
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
@ -60,21 +60,21 @@ check_inode()
|
|||||||
name=$5
|
name=$5
|
||||||
|
|
||||||
# Check whether the inode exists
|
# Check whether the inode exists
|
||||||
exists=$($SUDO_HELPER find $path -inum $ino)
|
exists=$($SUDO_HELPER find "$path" -inum "$ino")
|
||||||
if [ -z "$exists" ]; then
|
if [ -z "$exists" ]; then
|
||||||
_fail "inode $ino not recovered correctly"
|
_fail "inode $ino not recovered correctly"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check inode type
|
# Check inode type
|
||||||
found_mode=$(printf "%o" 0x$($SUDO_HELPER stat $exists -c %f))
|
found_mode=$(printf "%o" 0x$($SUDO_HELPER stat "$exists" -c %f))
|
||||||
if [ $found_mode -ne $mode ]; then
|
if [ "$found_mode" -ne "$mode" ]; then
|
||||||
echo "$found_mode"
|
echo "$found_mode"
|
||||||
_fail "inode $ino modes not recovered"
|
_fail "inode $ino modes not recovered"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check inode size
|
# Check inode size
|
||||||
found_size=$($SUDO_HELPER stat $exists -c %s)
|
found_size=$($SUDO_HELPER stat "$exists" -c %s)
|
||||||
if [ $mode -ne 41700 -a $found_size -ne $size ]; then
|
if [ $mode -ne 41700 -a "$found_size" -ne "$size" ]; then
|
||||||
_fail "inode $ino size not recovered correctly"
|
_fail "inode $ino size not recovered correctly"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -90,11 +90,11 @@ check_inode()
|
|||||||
check_leaf_corrupt_no_data_ext()
|
check_leaf_corrupt_no_data_ext()
|
||||||
{
|
{
|
||||||
image=$1
|
image=$1
|
||||||
$SUDO_HELPER mount -o loop $image -o ro $TEST_MNT
|
$SUDO_HELPER mount -o loop "$image" -o ro "$TEST_MNT"
|
||||||
|
|
||||||
i=0
|
i=0
|
||||||
while [ $i -lt ${#leaf_no_data_ext_list[@]} ]; do
|
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]} \
|
||||||
${leaf_no_data_ext_list[i + 1]} \
|
${leaf_no_data_ext_list[i + 1]} \
|
||||||
${leaf_no_data_ext_list[i + 2]} \
|
${leaf_no_data_ext_list[i + 2]} \
|
||||||
@ -102,7 +102,7 @@ check_leaf_corrupt_no_data_ext()
|
|||||||
${leaf_no_data_ext_list[i + 4]}
|
${leaf_no_data_ext_list[i + 4]}
|
||||||
((i+=4))
|
((i+=4))
|
||||||
done
|
done
|
||||||
$SUDO_HELPER umount $TEST_MNT
|
$SUDO_HELPER umount "$TEST_MNT"
|
||||||
}
|
}
|
||||||
|
|
||||||
setup_root_helper
|
setup_root_helper
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
source $TOP/tests/common
|
source "$TOP/tests/common"
|
||||||
|
|
||||||
check_prereq btrfs-corrupt-block
|
check_prereq btrfs-corrupt-block
|
||||||
check_prereq mkfs.btrfs
|
check_prereq mkfs.btrfs
|
||||||
@ -12,32 +12,32 @@ prepare_test_dev 1G
|
|||||||
# test whether fsck can rebuild a corrupted extent tree
|
# test whether fsck can rebuild a corrupted extent tree
|
||||||
test_extent_tree_rebuild()
|
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
|
run_check_mount_test_dev
|
||||||
generate_dataset small
|
generate_dataset small
|
||||||
|
|
||||||
for i in `seq 1 100`;do
|
for i in `seq 1 100`;do
|
||||||
run_check $SUDO_HELPER $TOP/btrfs sub snapshot $TEST_MNT \
|
run_check $SUDO_HELPER "$TOP/btrfs" sub snapshot "$TEST_MNT" \
|
||||||
$TEST_MNT/snapaaaaaaa_$i
|
"$TEST_MNT/snapaaaaaaa_$i"
|
||||||
done
|
done
|
||||||
run_check_umount_test_dev
|
run_check_umount_test_dev
|
||||||
|
|
||||||
# get extent root bytenr
|
# 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}'`
|
grep extent | awk '{print $7}'`
|
||||||
if [ -z $extent_root_bytenr ];then
|
if [ -z "$extent_root_bytenr" ];then
|
||||||
_fail "fail to get extent root bytenr"
|
_fail "fail to get extent root bytenr"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# corrupt extent root node block
|
# corrupt extent root node block
|
||||||
run_check $SUDO_HELPER $TOP/btrfs-corrupt-block -l $extent_root_bytenr \
|
run_check $SUDO_HELPER "$TOP/btrfs-corrupt-block" -l "$extent_root_bytenr" \
|
||||||
-b 4096 $TEST_DEV
|
-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"
|
_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 --repair --init-extent-tree "$TEST_DEV"
|
||||||
run_check $SUDO_HELPER $TOP/btrfs check $TEST_DEV
|
run_check $SUDO_HELPER "$TOP/btrfs" check "$TEST_DEV"
|
||||||
}
|
}
|
||||||
|
|
||||||
test_extent_tree_rebuild
|
test_extent_tree_rebuild
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
source $TOP/tests/common
|
source "$TOP/tests/common"
|
||||||
|
|
||||||
check_prereq btrfs
|
check_prereq btrfs
|
||||||
|
|
||||||
image=$(extract_image "./default_case.raw.xz")
|
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" ||
|
grep -q "crossing stripe boundary" ||
|
||||||
_fail "no expected error message in the output"
|
_fail "no expected error message in the output"
|
||||||
|
|
||||||
|
@ -11,12 +11,12 @@
|
|||||||
#
|
#
|
||||||
# a buggy check leads to the above messages
|
# a buggy check leads to the above messages
|
||||||
|
|
||||||
source $TOP/tests/common
|
source "$TOP/tests/common"
|
||||||
|
|
||||||
check_prereq btrfs
|
check_prereq btrfs
|
||||||
|
|
||||||
image=$(extract_image "./default_case.img.xz")
|
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" &&
|
grep -q "type mismatch with chunk" &&
|
||||||
_fail "unexpected error message in the output"
|
_fail "unexpected error message in the output"
|
||||||
|
|
||||||
|
@ -15,16 +15,16 @@
|
|||||||
# the beginning of leaf.
|
# the beginning of leaf.
|
||||||
# Which caused false alert for lowmem mode.
|
# Which caused false alert for lowmem mode.
|
||||||
|
|
||||||
source $TOP/tests/common
|
source "$TOP/tests/common"
|
||||||
|
|
||||||
check_prereq btrfs
|
check_prereq btrfs
|
||||||
|
|
||||||
for img in *.img *.raw.xz
|
for img in *.img *.raw.xz
|
||||||
do
|
do
|
||||||
image=$(extract_image $img)
|
image=$(extract_image "$img")
|
||||||
|
|
||||||
# Since the return value bug is already fixed, we don't need
|
# Since the return value bug is already fixed, we don't need
|
||||||
# the old grep hack to detect bug.
|
# the old grep hack to detect bug.
|
||||||
run_check $TOP/btrfs check "$image"
|
run_check "$TOP/btrfs" check "$image"
|
||||||
rm -f "$image"
|
rm -f "$image"
|
||||||
done
|
done
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# confirm whether btrfsck supports to check a partially dropped snapshot
|
# confirm whether btrfsck supports to check a partially dropped snapshot
|
||||||
|
|
||||||
source $TOP/tests/common
|
source "$TOP/tests/common"
|
||||||
|
|
||||||
check_prereq btrfs
|
check_prereq btrfs
|
||||||
|
|
||||||
for img in *.img
|
for img in *.img
|
||||||
do
|
do
|
||||||
image=$(extract_image $img)
|
image=$(extract_image "$img")
|
||||||
run_check_stdout $TOP/btrfs check "$image" 2>&1 |
|
run_check_stdout "$TOP/btrfs" check "$image" 2>&1 |
|
||||||
grep -q "Errors found in extent allocation tree or chunk allocation"
|
grep -q "Errors found in extent allocation tree or chunk allocation"
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
rm -f "$image"
|
rm -f "$image"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# check whether btrfsck can detect running qgroup rescan
|
# check whether btrfsck can detect running qgroup rescan
|
||||||
|
|
||||||
source $TOP/tests/common
|
source "$TOP/tests/common"
|
||||||
|
|
||||||
check_prereq btrfs
|
check_prereq btrfs
|
||||||
|
|
||||||
@ -9,7 +9,7 @@ check_image() {
|
|||||||
local image
|
local image
|
||||||
|
|
||||||
image=$1
|
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"
|
grep -q "Counts for qgroup id"
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
_fail "Btrfs check doesn't detect rescan correctly"
|
_fail "Btrfs check doesn't detect rescan correctly"
|
||||||
|
@ -5,13 +5,13 @@
|
|||||||
# Fixed by patch:
|
# Fixed by patch:
|
||||||
# btrfs-progs: Fix stack overflow for checking qgroup on tree reloc tree
|
# btrfs-progs: Fix stack overflow for checking qgroup on tree reloc tree
|
||||||
|
|
||||||
source $TOP/tests/common
|
source "$TOP/tests/common"
|
||||||
|
|
||||||
check_prereq btrfs
|
check_prereq btrfs
|
||||||
|
|
||||||
check_image()
|
check_image()
|
||||||
{
|
{
|
||||||
run_check $TOP/btrfs check "$1"
|
run_check "$TOP/btrfs" check "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
check_all_images
|
check_all_images
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# confirm that clearing space cache works
|
# confirm that clearing space cache works
|
||||||
|
|
||||||
source $TOP/tests/common
|
source "$TOP/tests/common"
|
||||||
|
|
||||||
check_prereq btrfs
|
check_prereq btrfs
|
||||||
check_prereq mkfs.btrfs
|
check_prereq mkfs.btrfs
|
||||||
@ -9,21 +9,21 @@ check_prereq mkfs.btrfs
|
|||||||
setup_root_helper
|
setup_root_helper
|
||||||
prepare_test_dev 1G
|
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
|
run_check_mount_test_dev
|
||||||
|
|
||||||
# Create files that takes at least 3 data chunks, while
|
# Create files that takes at least 3 data chunks, while
|
||||||
# can still be removed to create free space inside one chunk.
|
# can still be removed to create free space inside one chunk.
|
||||||
|
|
||||||
for i in $(seq 0 6); do
|
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
|
count=64 > /dev/null 2>&1
|
||||||
done
|
done
|
||||||
sync
|
sync
|
||||||
|
|
||||||
# Remove file 1 3 5 to create holes
|
# Remove file 1 3 5 to create holes
|
||||||
for i in 1 3 5; do
|
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
|
done
|
||||||
|
|
||||||
sync
|
sync
|
||||||
@ -31,17 +31,17 @@ sync
|
|||||||
run_check_umount_test_dev
|
run_check_umount_test_dev
|
||||||
|
|
||||||
# Clear space cache and re-check fs
|
# Clear space cache and re-check fs
|
||||||
run_check $TOP/btrfs check --clear-space-cache v1 $TEST_DEV
|
run_check "$TOP/btrfs" check --clear-space-cache v1 "$TEST_DEV"
|
||||||
run_check $TOP/btrfs check $TEST_DEV
|
run_check "$TOP/btrfs" check "$TEST_DEV"
|
||||||
|
|
||||||
# Manually recheck space cache and super space cache generation
|
# 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
|
grep -q FREE_SPACE
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
_fail "clear space cache doesn't clear all space cache"
|
_fail "clear space cache doesn't clear all space cache"
|
||||||
fi
|
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'
|
grep -q 'cache_generation.*18446744073709551615'
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
_fail "clear space cache doesn't set cache_generation correctly"
|
_fail "clear space cache doesn't set cache_generation correctly"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Confirm btrfs check can check file extents without causing false alert
|
# Confirm btrfs check can check file extents without causing false alert
|
||||||
|
|
||||||
source $TOP/tests/common
|
source "$TOP/tests/common"
|
||||||
|
|
||||||
check_prereq btrfs
|
check_prereq btrfs
|
||||||
check_prereq mkfs.btrfs
|
check_prereq mkfs.btrfs
|
||||||
|
Loading…
Reference in New Issue
Block a user