From 4884ae2f5e87e1cfbf7cc1d5624e0600b1fa46b3 Mon Sep 17 00:00:00 2001 From: David Sterba Date: Fri, 18 Nov 2016 15:18:02 +0100 Subject: [PATCH] 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 --- Makefile.in | 5 +++++ tests/README.md | 10 +++++++--- tests/cli-tests.sh | 3 +++ tests/convert-tests.sh | 3 +++ tests/fsck-tests.sh | 3 +++ tests/fuzz-tests.sh | 3 +++ tests/misc-tests.sh | 3 +++ tests/mkfs-tests.sh | 3 +++ 8 files changed, 30 insertions(+), 3 deletions(-) diff --git a/Makefile.in b/Makefile.in index 4bd3e63d..cba8f362 100644 --- a/Makefile.in +++ b/Makefile.in @@ -25,6 +25,11 @@ # EXTRA_CFLAGS additional compiler 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: # CHECKER static checker binary to be called (default: sparse) # CHECKER_FLAGS flags to pass to CHECKER, can override CFLAGS diff --git a/tests/README.md b/tests/README.md index ca45cf6f..f0d54d5e 100644 --- a/tests/README.md +++ b/tests/README.md @@ -108,9 +108,13 @@ the root helper). ### Verbosity -Setting the variable `TEST_LOG=tty` will print all commands executed by some of -the wrappers (`run_check` etc), other commands are not printed to the terminal -(but the full output is in the log). +* `TEST_LOG=tty` -- setting the variable will print all commands executed by + some of the wrappers (`run_check` etc), other commands are not printed to the + 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 diff --git a/tests/cli-tests.sh b/tests/cli-tests.sh index bc1a1e2c..16d6afcf 100755 --- a/tests/cli-tests.sh +++ b/tests/cli-tests.sh @@ -34,6 +34,9 @@ do echo " [TEST/cli] $name" ./test.sh if [ $? -ne 0 ]; then + if [[ $TEST_LOG =~ dump ]]; then + cat "$RESULTS" + fi _fail "test failed for case $(basename $i)" fi fi diff --git a/tests/convert-tests.sh b/tests/convert-tests.sh index 5fa88a12..c5663367 100755 --- a/tests/convert-tests.sh +++ b/tests/convert-tests.sh @@ -37,6 +37,9 @@ run_one_test() { ./test.sh if [ $? -ne 0 ]; then _fail "test failed for case $testname" + if [[ $TEST_LOG =~ dump ]]; then + cat "$RESULTS" + fi fi else _fail "custom test script not found" diff --git a/tests/fsck-tests.sh b/tests/fsck-tests.sh index e71b7119..d5fc3d14 100755 --- a/tests/fsck-tests.sh +++ b/tests/fsck-tests.sh @@ -36,6 +36,9 @@ run_one_test() { # Type 2 ./test.sh if [ $? -ne 0 ]; then + if [[ $TEST_LOG =~ dump ]]; then + cat "$RESULTS" + fi _fail "test failed for case $(basename $testname)" fi else diff --git a/tests/fuzz-tests.sh b/tests/fuzz-tests.sh index 9b88aa10..f72385e5 100755 --- a/tests/fuzz-tests.sh +++ b/tests/fuzz-tests.sh @@ -33,6 +33,9 @@ do echo " [TEST/fuzz] $name" ./test.sh if [ $? -ne 0 ]; then + if [[ $TEST_LOG =~ dump ]]; then + cat "$RESULTS" + fi _fail "test failed for case $(basename $i)" fi fi diff --git a/tests/misc-tests.sh b/tests/misc-tests.sh index 40e1cba1..1c645c9b 100755 --- a/tests/misc-tests.sh +++ b/tests/misc-tests.sh @@ -37,6 +37,9 @@ do if [ -x test.sh ]; then ./test.sh if [ $? -ne 0 ]; then + if [[ $TEST_LOG =~ dump ]]; then + cat "$RESULTS" + fi _fail "test failed for case $(basename $i)" fi fi diff --git a/tests/mkfs-tests.sh b/tests/mkfs-tests.sh index c130520d..c8ff8c83 100755 --- a/tests/mkfs-tests.sh +++ b/tests/mkfs-tests.sh @@ -34,6 +34,9 @@ do if [ -x test.sh ]; then ./test.sh if [ $? -ne 0 ]; then + if [[ $TEST_LOG =~ dump ]]; then + cat "$RESULTS" + fi _fail "test failed for case $(basename $i)" fi fi