btrfs-progs: tests: enhance TEST_LOG features
authorDavid Sterba <dsterba@suse.com>
Fri, 18 Nov 2016 14:18:02 +0000 (15:18 +0100)
committerDavid Sterba <dsterba@suse.com>
Wed, 23 Nov 2016 09:51:43 +0000 (10:51 +0100)
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>
Makefile.in
tests/README.md
tests/cli-tests.sh
tests/convert-tests.sh
tests/fsck-tests.sh
tests/fuzz-tests.sh
tests/misc-tests.sh
tests/mkfs-tests.sh

index 4bd3e63..cba8f36 100644 (file)
 #   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
index ca45cf6..f0d54d5 100644 (file)
@@ -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
 
index bc1a1e2..16d6afc 100755 (executable)
@@ -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
index 5fa88a1..c566336 100755 (executable)
@@ -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"
index e71b711..d5fc3d1 100755 (executable)
@@ -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
index 9b88aa1..f72385e 100755 (executable)
@@ -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
index 40e1cba..1c645c9 100755 (executable)
@@ -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
index c130520..c8ff8c8 100755 (executable)
@@ -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