From patchwork Tue Sep 5 05:49:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Misono Tomohiro X-Patchwork-Id: 9937855 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D4DBE600CB for ; Tue, 5 Sep 2017 05:49:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B8D732881E for ; Tue, 5 Sep 2017 05:49:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ABA3E28886; Tue, 5 Sep 2017 05:49:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 297CB2881E for ; Tue, 5 Sep 2017 05:49:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751328AbdIEFtR (ORCPT ); Tue, 5 Sep 2017 01:49:17 -0400 Received: from mgwym04.jp.fujitsu.com ([211.128.242.43]:15551 "EHLO mgwym04.jp.fujitsu.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750807AbdIEFtR (ORCPT ); Tue, 5 Sep 2017 01:49:17 -0400 Received: from yt-mxoi2.gw.nic.fujitsu.com (unknown [192.168.229.69]) by mgwym04.jp.fujitsu.com with smtp id 03cb_1eac_5daea94c_60ac_489b_8c3d_a8b7bdedc402; Tue, 05 Sep 2017 14:49:09 +0900 Received: from g01jpfmpwyt03.exch.g01.fujitsu.local (g01jpfmpwyt03.exch.g01.fujitsu.local [10.128.193.57]) by yt-mxoi2.gw.nic.fujitsu.com (Postfix) with ESMTP id 0F41EAC00C9 for ; Tue, 5 Sep 2017 14:49:09 +0900 (JST) Received: from g01jpexchyt37.g01.fujitsu.local (unknown [10.128.193.4]) by g01jpfmpwyt03.exch.g01.fujitsu.local (Postfix) with ESMTP id 61D4D46E77D for ; Tue, 5 Sep 2017 14:49:08 +0900 (JST) X-SecurityPolicyCheck: OK by SHieldMailChecker v2.5.2 X-SHieldMailCheckerPolicyVersion: FJ-ISEC-20170217-enc X-SHieldMailCheckerMailID: 2701d74a92bb4b00b692d030d6f42a69 To: From: "Misono, Tomohiro" Subject: [PATCH 1/2] btrfs-progs: test: fix run_check_stdout() call _fail() Message-ID: <64ab304a-6b5f-d2ac-3b74-90952371404e@jp.fujitsu.com> Date: Tue, 5 Sep 2017 14:49:02 +0900 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 Content-Language: en-US X-SecurityPolicyCheck-GC: OK by FENCE-Mail X-TM-AS-MML: disable Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- tests/common | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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 }