btrfs-progs: tests: enhance TEST_LOG features

Add new keyword to dump the log file after any test fails. Can be useful
for remote analysis of test failures.

Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2016-11-18 15:18:02 +01:00
parent 7cd40e125b
commit 4884ae2f5e
8 changed files with 30 additions and 3 deletions

View File

@ -25,6 +25,11 @@
# EXTRA_CFLAGS additional compiler flags # EXTRA_CFLAGS additional compiler flags
# EXTRA_LDFLAGS additional linker flags # EXTRA_LDFLAGS additional linker flags
# #
# Testing-specific options (see also tests/README.md):
# TEST=GLOB run test(s) from directories matching GLOB
# TEST_LOG=tty print name of a command run via the execution helpers
# TEST_LOG=dump dump testing log file when a test fails
#
# Static checkers: # Static checkers:
# CHECKER static checker binary to be called (default: sparse) # CHECKER static checker binary to be called (default: sparse)
# CHECKER_FLAGS flags to pass to CHECKER, can override CFLAGS # CHECKER_FLAGS flags to pass to CHECKER, can override CFLAGS

View File

@ -108,9 +108,13 @@ the root helper).
### Verbosity ### Verbosity
Setting the variable `TEST_LOG=tty` will print all commands executed by some of * `TEST_LOG=tty` -- setting the variable will print all commands executed by
the wrappers (`run_check` etc), other commands are not printed to the terminal some of the wrappers (`run_check` etc), other commands are not printed to the
(but the full output is in the log). terminal (but the full output is in the log)
* `TEST_LOG=dump` -- dump the entire testing log when a test fails
Multiple values can be separated by `,`.
### Permissions ### Permissions

View File

@ -34,6 +34,9 @@ do
echo " [TEST/cli] $name" echo " [TEST/cli] $name"
./test.sh ./test.sh
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
if [[ $TEST_LOG =~ dump ]]; then
cat "$RESULTS"
fi
_fail "test failed for case $(basename $i)" _fail "test failed for case $(basename $i)"
fi fi
fi fi

View File

@ -37,6 +37,9 @@ run_one_test() {
./test.sh ./test.sh
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
_fail "test failed for case $testname" _fail "test failed for case $testname"
if [[ $TEST_LOG =~ dump ]]; then
cat "$RESULTS"
fi
fi fi
else else
_fail "custom test script not found" _fail "custom test script not found"

View File

@ -36,6 +36,9 @@ run_one_test() {
# Type 2 # Type 2
./test.sh ./test.sh
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
if [[ $TEST_LOG =~ dump ]]; then
cat "$RESULTS"
fi
_fail "test failed for case $(basename $testname)" _fail "test failed for case $(basename $testname)"
fi fi
else else

View File

@ -33,6 +33,9 @@ do
echo " [TEST/fuzz] $name" echo " [TEST/fuzz] $name"
./test.sh ./test.sh
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
if [[ $TEST_LOG =~ dump ]]; then
cat "$RESULTS"
fi
_fail "test failed for case $(basename $i)" _fail "test failed for case $(basename $i)"
fi fi
fi fi

View File

@ -37,6 +37,9 @@ do
if [ -x test.sh ]; then if [ -x test.sh ]; then
./test.sh ./test.sh
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
if [[ $TEST_LOG =~ dump ]]; then
cat "$RESULTS"
fi
_fail "test failed for case $(basename $i)" _fail "test failed for case $(basename $i)"
fi fi
fi fi

View File

@ -34,6 +34,9 @@ do
if [ -x test.sh ]; then if [ -x test.sh ]; then
./test.sh ./test.sh
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
if [[ $TEST_LOG =~ dump ]]; then
cat "$RESULTS"
fi
_fail "test failed for case $(basename $i)" _fail "test failed for case $(basename $i)"
fi fi
fi fi