btrfs-progs: test-frame: Update variant names

Use upper case variant name for the following variants:
1) top -> TOP
2) script_dir -> SCRIPT_DIR

And change the following variant name:
1) RESULT -> RESULTS

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
This commit is contained in:
Qu Wenruo 2015-04-03 15:01:12 +08:00 committed by David Sterba
parent ffe9554b78
commit 8720e15cd1
5 changed files with 35 additions and 35 deletions

View File

@ -5,7 +5,7 @@
_fail() _fail()
{ {
echo "$*" | tee -a $RESULT echo "$*" | tee -a $RESULTS
exit 1 exit 1
} }
@ -17,13 +17,13 @@ _not_run()
run_check() run_check()
{ {
echo "############### $@" >> $RESULT 2>&1 echo "############### $@" >> $RESULTS 2>&1
"$@" >> $RESULT 2>&1 || _fail "failed: $@" "$@" >> $RESULTS 2>&1 || _fail "failed: $@"
} }
check_prereq() check_prereq()
{ {
if ! [ -f $top/$1 ]; then if ! [ -f $TOP/$1 ]; then
_fail "Failed prerequisities: $1"; _fail "Failed prerequisities: $1";
fi fi
} }
@ -31,12 +31,12 @@ check_prereq()
check_image() check_image()
{ {
image=$1 image=$1
echo "testing image $(basename $image)" >> $RESULT echo "testing image $(basename $image)" >> $RESULTS
$top/btrfs check $image >> $RESULT 2>&1 $TOP/btrfs check $image >> $RESULTS 2>&1
[ $? -eq 0 ] && _fail "btrfs check should have detected corruption" [ $? -eq 0 ] && _fail "btrfs check should have detected corruption"
run_check $top/btrfs check --repair $image run_check $TOP/btrfs check --repair $image
run_check $top/btrfs check $image run_check $TOP/btrfs check $image
} }
check_all_images() check_all_images()
@ -44,8 +44,8 @@ check_all_images()
dir=$1 dir=$1
for i in $(find $dir -iname '*.img') for i in $(find $dir -iname '*.img')
do do
echo "extracting image $(basename $i)" >> $RESULT echo "extracting image $(basename $i)" >> $RESULTS
$top/btrfs-image -r $i $i.restored || \ $TOP/btrfs-image -r $i $i.restored || \
_fail "failed to extract image $i" _fail "failed to extract image $i"
check_image $i.restored check_image $i.restored

View File

@ -5,25 +5,25 @@
# It's GPL, same as everything else in this tree. # It's GPL, same as everything else in this tree.
# #
unset top unset TOP
unset LANG unset LANG
LANG=C LANG=C
script_dir=$(dirname $(realpath $0)) SCRIPT_DIR=$(dirname $(realpath $0))
top=$(realpath $script_dir/../) TOP=$(realpath $SCRIPT_DIR/../)
TEST_DEV=${TEST_DEV:-} TEST_DEV=${TEST_DEV:-}
TEST_MNT=${TEST_MNT:-$top/tests/mnt} TEST_MNT=${TEST_MNT:-$TOP/tests/mnt}
RESULT="$top/tests/fsck-tests-results.txt" RESULTS="$TOP/tests/fsck-tests-results.txt"
source $top/tests/common source $TOP/tests/common
# Allow child test to use $top and $RESULT # Allow child test to use $TOP and $RESULTS
export top export TOP
export RESULT export RESULTS
# For custom script needs to verfiy recovery # For custom script needs to verfiy recovery
export TEST_MNT export TEST_MNT
export LANG export LANG
rm -f $RESULT rm -f $RESULTS
mkdir -p $TEST_MNT || _fail "unable to create mount point on $TEST_MNT" mkdir -p $TEST_MNT || _fail "unable to create mount point on $TEST_MNT"
# test rely on corrupting blocks tool # test rely on corrupting blocks tool
@ -44,7 +44,7 @@ check_prereq btrfs
# This is for case btrfs-image can't dump or case needs extra # This is for case btrfs-image can't dump or case needs extra
# check/verify # check/verify
for i in $(find $top/tests/fsck-tests -maxdepth 1 -mindepth 1 -type d | sort) for i in $(find $TOP/tests/fsck-tests -maxdepth 1 -mindepth 1 -type d | sort)
do do
echo " [TEST] $(basename $i)" echo " [TEST] $(basename $i)"
cd $i cd $i
@ -58,5 +58,5 @@ do
# Type 1 # Type 1
check_all_images `pwd` check_all_images `pwd`
fi fi
cd $top cd $TOP
done done

View File

@ -1,13 +1,13 @@
#!/bin/bash #!/bin/bash
source $top/tests/common source $TOP/tests/common
echo "extracting image default_case.tar.xz" >> $RESULT echo "extracting image default_case.tar.xz" >> $RESULTS
tar xJf default_case.tar.xz || \ tar 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" >> $RESULT echo "extracting image skinny_case.tar.xz" >> $RESULTS
tar xJf skinny_case.tar.xz || \ tar 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

View File

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
source $top/tests/common source $TOP/tests/common
# Check file list for leaf corruption, no regular/preallocated # Check file list for leaf corruption, no regular/preallocated
# file extent case. # file extent case.
@ -34,7 +34,7 @@ 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" >> $RESULT echo "generating leaf_corrupt_no_data_ext.btrfs-image" >> $RESULTS
tar xJf ./no_data_extent.tar.xz || \ tar 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"
btrfs-image -r test.img.btrfs-image $dest || \ btrfs-image -r test.img.btrfs-image $dest || \

View File

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
source $top/tests/common source $TOP/tests/common
if [ -z $TEST_DEV ]; then if [ -z $TEST_DEV ]; then
echo " [NOTRUN] extent tree rebuild, need TEST_DEV variant" echo " [NOTRUN] extent tree rebuild, need TEST_DEV variant"
@ -16,32 +16,32 @@ fi
test_extent_tree_rebuild() test_extent_tree_rebuild()
{ {
echo " [TEST] extent tree rebuild" echo " [TEST] extent tree rebuild"
$top/mkfs.btrfs -f $TEST_DEV >> /dev/null 2>&1 || _fail "fail to mkfs" $TOP/mkfs.btrfs -f $TEST_DEV >> /dev/null 2>&1 || _fail "fail to mkfs"
run_check mount $TEST_DEV $TEST_MNT run_check mount $TEST_DEV $TEST_MNT
cp -aR /lib/modules/`uname -r`/ $TEST_MNT 2>&1 cp -aR /lib/modules/`uname -r`/ $TEST_MNT 2>&1
for i in `seq 1 100`;do for i in `seq 1 100`;do
$top/btrfs sub snapshot $TEST_MNT \ $TOP/btrfs sub snapshot $TEST_MNT \
$TEST_MNT/snapaaaaaaa_$i >& /dev/null $TEST_MNT/snapaaaaaaa_$i >& /dev/null
done done
run_check umount $TEST_DEV run_check umount $TEST_DEV
# get extent root bytenr # get extent root bytenr
extent_root_bytenr=`$top/btrfs-debug-tree -r $TEST_DEV | \ extent_root_bytenr=`$TOP/btrfs-debug-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 $top/btrfs-corrupt-block -l $extent_root_bytenr \ run_check $TOP/btrfs-corrupt-block -l $extent_root_bytenr \
-b 4096 $TEST_DEV -b 4096 $TEST_DEV
$top/btrfs check $TEST_DEV >& /dev/null && \ $TOP/btrfs check $TEST_DEV >& /dev/null && \
_fail "btrfs check should detect failure" _fail "btrfs check should detect failure"
run_check $top/btrfs check --init-extent-tree $TEST_DEV run_check $TOP/btrfs check --init-extent-tree $TEST_DEV
run_check $top/btrfs check $TEST_DEV run_check $TOP/btrfs check $TEST_DEV
} }
test_extent_tree_rebuild test_extent_tree_rebuild