From patchwork Fri Jan 4 08:19:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hou Tao X-Patchwork-Id: 10748121 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 65C6317D2 for ; Fri, 4 Jan 2019 08:16:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 553AC27C2D for ; Fri, 4 Jan 2019 08:16:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3B4BA27F8C; Fri, 4 Jan 2019 08:16:04 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, 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 8A50227F4B for ; Fri, 4 Jan 2019 08:16:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725931AbfADIQD (ORCPT ); Fri, 4 Jan 2019 03:16:03 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:44278 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725919AbfADIQC (ORCPT ); Fri, 4 Jan 2019 03:16:02 -0500 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 35CB0A5A6A956 for ; Fri, 4 Jan 2019 16:15:59 +0800 (CST) Received: from huawei.com (10.90.53.225) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.408.0; Fri, 4 Jan 2019 16:15:53 +0800 From: Hou Tao To: CC: Subject: [PATCH v2 1/2] generic/131: wait until the server is ready or timeout Date: Fri, 4 Jan 2019 16:19:26 +0800 Message-ID: <20190104081927.112622-2-houtao1@huawei.com> X-Mailer: git-send-email 2.16.2.dirty In-Reply-To: <20190104081927.112622-1-houtao1@huawei.com> References: <20190104081927.112622-1-houtao1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.90.53.225] X-CFilter-Loop: Reflected Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When running xfstests under KVM VM and the load of host is high, only delaying 1s and checking the readiness of server are not enough, and the test case will fail early. Fix it by repeatedly checking the readiness signal until it's found, or timeout is triggered. Signed-off-by: Hou Tao --- v2: * add a timeout for the check of server readiness, else the test case may loop forever. --- tests/generic/131 | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tests/generic/131 b/tests/generic/131 index d7c146ae..80929c23 100755 --- a/tests/generic/131 +++ b/tests/generic/131 @@ -37,10 +37,19 @@ TESTFILE=$TEST_DIR/lock_file src/locktest $TESTFILE 2>&1 > $TEST_DIR/server.out & locktest_pid1=$! -sleep 1 +timeout=30 +while [ $timeout -gt 0 ]; do + sleep 1 -PORT=$(cat $TEST_DIR/server.out | grep "^server port: " | awk '{print $3}') -if [ -z $PORT ]; then + PORT=$(cat $TEST_DIR/server.out | grep "^server port: " | awk '{print $3}') + if [ -n "$PORT" ]; then + break + fi + + let timeout=timeout-1 +done + +if [ -z "$PORT" ]; then echo "Could not get server port" exit 1 fi