btrfs-progs: tests: don't treat segfault as ignorable error
authorDavid Sterba <dsterba@suse.com>
Mon, 3 Oct 2016 15:55:49 +0000 (17:55 +0200)
committerDavid Sterba <dsterba@suse.com>
Wed, 5 Oct 2016 10:39:01 +0000 (12:39 +0200)
Some fuzzed images cause various tools to crash but the mayfail helper
would not recognize that. We don't mind if the utility failes but it
must not crash.

Signed-off-by: David Sterba <dsterba@suse.com>
tests/common

index c50b661..d965c12 100644 (file)
@@ -48,6 +48,8 @@ run_check_stdout()
 # same as run_check but does not fail the test, output is logged
 run_mayfail()
 {
+       local ret
+
        echo "############### $@" >> $RESULTS 2>&1
        if [ "$TEST_LOG" = 'tty' ]; then echo "CMD(mayfail): $@" > /dev/tty; fi
        if [ "$1" = 'root_helper' ]; then
@@ -55,9 +57,13 @@ run_mayfail()
        else
                $INSTRUMENT "$@" >> $RESULTS 2>&1
        fi
-       if [ $? != 0 ]; then
-               echo "failed (ignored): $@" >> $RESULTS
-               return 1
+       ret=$?
+       if [ $ret != 0 ]; then
+               echo "failed (ignored, ret=$ret): $@" >> $RESULTS
+               if [ $ret == 139 ]; then
+                       _fail "mayfail: returned code 139 (SEGFAULT), not ignored"
+               fi
+               return $ret
        fi
 }