btrfs-progs: test: fix run_check_stdout() call _fail()
authorMisono, Tomohiro <misono.tomohiro@jp.fujitsu.com>
Tue, 5 Sep 2017 05:49:02 +0000 (14:49 +0900)
committerDavid Sterba <dsterba@suse.com>
Fri, 8 Sep 2017 14:15:05 +0000 (16:15 +0200)
run_check_stdout() uses "... | tee ... || _fail".  However, since tee
won't fail, _fail() is not called even if first command fails.

Fix this by checking PIPESTATUS in the end.

Signed-off-by: Tomohiro Misono <misono.tomohiro@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
tests/common

index ebd41ba..d450c2c 100644 (file)
@@ -154,9 +154,12 @@ run_check_stdout()
        echo "############### $@" >> "$RESULTS" 2>&1
        if [[ $TEST_LOG =~ tty ]]; then echo "CMD(stdout): $@" > /dev/tty; fi
        if [ "$1" = 'root_helper' ]; then
-               "$@" 2>&1 | tee -a "$RESULTS" || _fail "failed: $@"
+               "$@" 2>&1 | tee -a "$RESULTS"
        else
-               $INSTRUMENT "$@" 2>&1 | tee -a "$RESULTS" || _fail "failed: $@"
+               $INSTRUMENT "$@" 2>&1 | tee -a "$RESULTS"
+       fi
+       if [ ${PIPESTATUS[0]} -ne 0 ]; then
+               _fail "failed: $@"
        fi
 }