#!/bin/bash
# remove all intermediate files from tests
-SCRIPT_DIR=$(dirname $(readlink -f $0))
-TOP=$(readlink -f $SCRIPT_DIR/../)
-source $TOP/tests/common
+SCRIPT_DIR=$(dirname $(readlink -f "$0"))
+TOP=$(readlink -f "$SCRIPT_DIR/../")
+source "$TOP/tests/common"
setup_root_helper
$SUDO_HELPER umount "$TEST_MNT" &>/dev/null
-if ! cd $TOP/tests; then
+if ! cd "$TOP/tests"; then
echo "ERROR: cannot cd to $TOP/tests"
exit 1
fi
# command line interface coverage tests
LANG=C
-SCRIPT_DIR=$(dirname $(readlink -f $0))
-TOP=$(readlink -f $SCRIPT_DIR/../)
+SCRIPT_DIR=$(dirname $(readlink -f "$0"))
+TOP=$(readlink -f "$SCRIPT_DIR/../")
TEST_DEV=${TEST_DEV:-}
RESULTS="$TOP/tests/cli-tests-results.txt"
IMAGE="$TOP/tests/test.img"
-source $TOP/tests/common
+source "$TOP/tests/common"
export TOP
export RESULTS
export IMAGE
export TEST_DEV
-rm -f $RESULTS
+rm -f "$RESULTS"
check_prereq btrfs
check_kernel_support
# The tests are driven by their custom script called 'test.sh'
-for i in $(find $TOP/tests/cli-tests -maxdepth 1 -mindepth 1 -type d \
+for i in $(find "$TOP/tests/cli-tests" -maxdepth 1 -mindepth 1 -type d \
${TEST:+-name "$TEST"} | sort)
do
- name=$(basename $i)
- cd $i
+ name=$(basename "$i")
+ cd "$i"
if [ -x test.sh ]; then
- echo "=== Entering $i" >> $RESULTS
+ echo "=== Entering $i" >> "$RESULTS"
echo " [TEST/cli] $name"
./test.sh
if [ $? -ne 0 ]; then
_fail "test failed for case $(basename $i)"
fi
fi
- cd $TOP
+ cd "$TOP"
done
# clean.
LANG=C
-SCRIPT_DIR=$(dirname $(readlink -f $0))
-TOP=$(readlink -f $SCRIPT_DIR/../)
+SCRIPT_DIR=$(dirname $(readlink -f "$0"))
+TOP=$(readlink -f "$SCRIPT_DIR/../")
TEST_DEV=${TEST_DEV:-}
RESULTS="$TOP/tests/convert-tests-results.txt"
IMAGE="$TOP/tests/test.img"
-source $TOP/tests/common
-source $TOP/tests/common.convert
+source "$TOP/tests/common"
+source "$TOP/tests/common.convert"
export TOP
export RESULTS
export IMAGE
export TEST_DEV
-rm -f $RESULTS
+rm -f "$RESULTS"
check_kernel_support
testname=$(basename "$testdir")
echo " [TEST/conv] $testname"
cd "$testdir"
- echo "=== Entering $testname" >> $RESULTS
+ echo "=== Entering $testname" >> "$RESULTS"
if [ -x test.sh ]; then
# Only support custom test scripts
./test.sh
}
# Test special images
-for i in $(find $TOP/tests/convert-tests -maxdepth 1 -mindepth 1 -type d \
+for i in $(find "$TOP/tests/convert-tests" -maxdepth 1 -mindepth 1 -type d \
${TEST:+-name "$TEST"} | sort)
do
run_one_test "$i"
# loop through all of our bad images and make sure fsck repairs them properly
LANG=C
-SCRIPT_DIR=$(dirname $(readlink -f $0))
-TOP=$(readlink -f $SCRIPT_DIR/../)
+SCRIPT_DIR=$(dirname $(readlink -f "$0"))
+TOP=$(readlink -f "$SCRIPT_DIR/../")
TEST_DEV=${TEST_DEV:-}
RESULTS="$TOP/tests/fsck-tests-results.txt"
IMAGE="$TOP/tests/test.img"
-source $TOP/tests/common
+source "$TOP/tests/common"
export TOP
export RESULTS
export IMAGE
export TEST_DEV
-rm -f $RESULTS
+rm -f "$RESULTS"
# test rely on corrupting blocks tool
check_prereq btrfs-corrupt-block
testname="$1"
echo " [TEST/fsck] $(basename $testname)"
- cd $testname
- echo "=== Entering $testname" >> $RESULTS
+ cd "$testname"
+ echo "=== Entering $testname" >> "$RESULTS"
if [ -x test.sh ]; then
# Type 2
./test.sh
# Type 1
check_all_images `pwd`
fi
- cd $TOP
+ cd "$TOP"
}
# Each dir contains one type of error for btrfsck test.
# This is for case btrfs-image can't dump or case needs extra
# check/verify
-for i in $(find $TOP/tests/fsck-tests -maxdepth 1 -mindepth 1 -type d \
+for i in $(find "$TOP/tests/fsck-tests" -maxdepth 1 -mindepth 1 -type d \
${TEST:+-name "$TEST"} | sort)
do
run_one_test "$i"
# misc tests on fuzzed or crafted images
LANG=C
-SCRIPT_DIR=$(dirname $(readlink -f $0))
-TOP=$(readlink -f $SCRIPT_DIR/../)
+SCRIPT_DIR=$(dirname $(readlink -f "$0"))
+TOP=$(readlink -f "$SCRIPT_DIR/../")
TEST_DEV=${TEST_DEV:-}
RESULTS="$TOP/tests/fuzz-tests-results.txt"
IMAGE="$TOP/tests/test.img"
-source $TOP/tests/common
+source "$TOP/tests/common"
export TOP
export RESULTS
export IMAGE
export TEST_DEV
-rm -f $RESULTS
+rm -f "$RESULTS"
check_prereq btrfs
# The tests are driven by their custom script called 'test.sh'
-for i in $(find $TOP/tests/fuzz-tests -maxdepth 1 -mindepth 1 -type d \
+for i in $(find "$TOP/tests/fuzz-tests" -maxdepth 1 -mindepth 1 -type d \
${TEST:+-name "$TEST"} | sort)
do
- name=$(basename $i)
+ name=$(basename "$i")
cd $i
if [ -x test.sh ]; then
- echo "=== Entering $i" >> $RESULTS
+ echo "=== Entering $i" >> "$RESULTS"
echo " [TEST/fuzz] $name"
./test.sh
if [ $? -ne 0 ]; then
_fail "test failed for case $(basename $i)"
fi
fi
- cd $TOP
+ cd "$TOP"
done
# Misc tests
LANG=C
-SCRIPT_DIR=$(dirname $(readlink -f $0))
-TOP=$(readlink -f $SCRIPT_DIR/../)
+SCRIPT_DIR=$(dirname $(readlink -f "$0"))
+TOP=$(readlink -f "$SCRIPT_DIR/../")
TEST_DEV=${TEST_DEV:-}
RESULTS="$TOP/tests/misc-tests-results.txt"
IMAGE="$TOP/tests/test.img"
-source $TOP/tests/common
+source "$TOP/tests/common"
export TOP
export RESULTS
export TEST_DEV
export IMAGE
-rm -f $RESULTS
+rm -f "$RESULTS"
# test rely on corrupting blocks tool
check_prereq btrfs-corrupt-block
# The tests are driven by their custom script called 'test.sh'
-for i in $(find $TOP/tests/misc-tests -maxdepth 1 -mindepth 1 -type d \
+for i in $(find "$TOP/tests/misc-tests" -maxdepth 1 -mindepth 1 -type d \
${TEST:+-name "$TEST"} | sort)
do
echo " [TEST/misc] $(basename $i)"
- cd $i
- echo "=== Entering $i" >> $RESULTS
+ cd "$i"
+ echo "=== Entering $i" >> "$RESULTS"
if [ -x test.sh ]; then
./test.sh
if [ $? -ne 0 ]; then
_fail "test failed for case $(basename $i)"
fi
fi
- cd $TOP
+ cd "$TOP"
done
# mkfs.btrfs tests
LANG=C
-SCRIPT_DIR=$(dirname $(readlink -f $0))
-TOP=$(readlink -f $SCRIPT_DIR/../)
+SCRIPT_DIR=$(dirname $(readlink -f "$0"))
+TOP=$(readlink -f "$SCRIPT_DIR/../")
TEST_DEV=${TEST_DEV:-}
RESULTS="$TOP/tests/mkfs-tests-results.txt"
IMAGE="$TOP/tests/test.img"
-source $TOP/tests/common
+source "$TOP/tests/common"
export TOP
export RESULTS
export IMAGE
export TEST_DEV
-rm -f $RESULTS
+rm -f "$RESULTS"
check_prereq mkfs.btrfs
check_prereq btrfs
# The tests are driven by their custom script called 'test.sh'
-for i in $(find $TOP/tests/mkfs-tests -maxdepth 1 -mindepth 1 -type d \
+for i in $(find "$TOP/tests/mkfs-tests" -maxdepth 1 -mindepth 1 -type d \
${TEST:+-name "$TEST"} | sort)
do
echo " [TEST/mkfs] $(basename $i)"
- cd $i
- echo "=== Entering $i" >> $RESULTS
+ cd "$i"
+ echo "=== Entering $i" >> "$RESULTS"
if [ -x test.sh ]; then
./test.sh
if [ $? -ne 0 ]; then
_fail "test failed for case $(basename $i)"
fi
fi
- cd $TOP
+ cd "$TOP"
done
# a shell with test environment set up, logged commands and output
LANG=C
-SCRIPT_DIR=$(dirname $(readlink -f $0))
-TOP=$(readlink -f $SCRIPT_DIR/../)
+SCRIPT_DIR=$(dirname $(readlink -f "$0"))
+TOP=$(readlink -f "$SCRIPT_DIR/../")
TEST_DEV=${TEST_DEV:-}
RESULTS="$TOP/tests/test-console.txt"
IMAGE="$TOP/tests/test.img"