[1/2] btrfs-progs: test: fix run_check_stdout() call _fail()
diff mbox

Message ID 64ab304a-6b5f-d2ac-3b74-90952371404e@jp.fujitsu.com
State New
Headers show

Commit Message

Misono Tomohiro Sept. 5, 2017, 5:49 a.m. UTC
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>
---
 tests/common | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Patch
diff mbox

diff --git a/tests/common b/tests/common
index d0324a6..b7d3436 100644
--- a/tests/common
+++ b/tests/common
@@ -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
 }