From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6DA5FC4360C for ; Fri, 27 Sep 2019 10:08:14 +0000 (UTC) Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3D91C217D7; Fri, 27 Sep 2019 10:08:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=sourceforge.net header.i=@sourceforge.net header.b="QnU+VnhX"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=sf.net header.i=@sf.net header.b="lWVSZV3f" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3D91C217D7 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linux-f2fs-devel-bounces@lists.sourceforge.net Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1iDnAb-0006I1-U8; Fri, 27 Sep 2019 10:08:13 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1iDnAa-0006Hu-R8 for linux-f2fs-devel@lists.sourceforge.net; Fri, 27 Sep 2019 10:08:12 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Type:MIME-Version:Message-ID:Date:Subject: CC:To:From:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=A565AxJDYLIT6qXe6YO90IwXPt5qhsiZOrHJnxQOCpU=; b=QnU+VnhXu6mA9kVY370LmZ61ne mJ0XD8sdaVbPPrRqEZyRnM+oYrt2epMiZzLY8lwmvKdFxlqBWJUjP7igC0iL448LTT/UALxXqb2AZ ZivoBk9EdBILQzV8SONEU5fQWsP5E3MxxB0afmVvAlb156xCVIcC7cEIfKcRyV15GXno=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From:Sender: Reply-To:Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date :Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=A565AxJDYLIT6qXe6YO90IwXPt5qhsiZOrHJnxQOCpU=; b=l WVSZV3f+9+VHMtXOPM+ZDFO7vU0XBm1hXBxpSfjTxLMK2ICvGjh0XErpRwgOr+RjQdJU62vonq+a+ HVWSxKCpgSkPUan+zFHIxn8U5nsf/pC7a+qern9jaPY7MhvSllvTbdQO8bBLDD9pHHDH4F9uDpYlI 0xwDFAKYBpo4AvRw=; Received: from szxga07-in.huawei.com ([45.249.212.35] helo=huawei.com) by sfi-mx-3.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.2) id 1iDnAZ-008BtW-4F for linux-f2fs-devel@lists.sourceforge.net; Fri, 27 Sep 2019 10:08:12 +0000 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id DD07883C419AF77F4883; Fri, 27 Sep 2019 18:08:01 +0800 (CST) Received: from szvp000203569.huawei.com (10.120.216.130) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.439.0; Fri, 27 Sep 2019 18:07:48 +0800 From: Chao Yu To: Date: Fri, 27 Sep 2019 18:07:42 +0800 Message-ID: <20190927100742.9266-1-yuchao0@huawei.com> X-Mailer: git-send-email 2.18.0.rc1 MIME-Version: 1.0 X-Originating-IP: [10.120.216.130] X-CFilter-Loop: Reflected X-Headers-End: 1iDnAZ-008BtW-4F Subject: [f2fs-dev] [PATCH] common/rc: generalize _get_filesize() X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: fstests@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net There are some testcases use below command to get file size, generalize it as global function _get_filesize() ls -l $1 | $AWK_PROG '{print $5}' - adjust common/defrag, generic/275 and generic/315 to use it - remove unused _filesize in generic/013 Signed-off-by: Chao Yu --- common/defrag | 2 +- common/rc | 5 +++++ tests/generic/013 | 5 ----- tests/generic/275 | 2 +- tests/generic/315 | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/common/defrag b/common/defrag index 9866d3da..50596f70 100644 --- a/common/defrag +++ b/common/defrag @@ -145,7 +145,7 @@ _defrag() STAT_BEFORE=`stat -c "a: %x m: %y c: %z" $1` if [ $FSTYP == "f2fs" ]; then - _filesize=`ls -l $1 | $AWK_PROG '{print $5}'` + _filesize=`_get_filesize $1` $DEFRAG_PROG 0 $_filesize $1 >> $seqres.full 2>&1 else $DEFRAG_PROG -v $1 >> $seqres.full 2>&1 diff --git a/common/rc b/common/rc index 66c7fd4d..69735ae6 100644 --- a/common/rc +++ b/common/rc @@ -165,6 +165,11 @@ if [ ! -z "$REPORT_LIST" ]; then _assert_report_list fi +_get_filesize() +{ + echo `ls -l $1 | $AWK_PROG '{print $5}'` +} + _mount() { $MOUNT_PROG `_mount_ops_filter $*` diff --git a/tests/generic/013 b/tests/generic/013 index 9e533ee8..bc596102 100755 --- a/tests/generic/013 +++ b/tests/generic/013 @@ -24,11 +24,6 @@ _cleanup() rm -rf $TEST_DIR/fsstress.$$.* } -_filesize() -{ - ls -l $1 | $AWK_PROG '{print " filesize = " $5}' -} - # get standard environment, filters and checks . ./common/rc . ./common/filter diff --git a/tests/generic/275 b/tests/generic/275 index a934c19c..adc82856 100755 --- a/tests/generic/275 +++ b/tests/generic/275 @@ -73,7 +73,7 @@ echo "Bytes written until ENOSPC:" >>$seqres.full du $SCRATCH_MNT/tmp1 >>$seqres.full # And at least some of it should succeed. -_filesize=`ls -l $SCRATCH_MNT/tmp1 | awk '{print $5}'` +_filesize=`_get_filesize $SCRATCH_MNT/tmp1` [ $_filesize -lt $((128 * 1024)) ] && \ _fail "Partial write until enospc failed; wrote $_filesize bytes." diff --git a/tests/generic/315 b/tests/generic/315 index fd49b579..808d7d74 100755 --- a/tests/generic/315 +++ b/tests/generic/315 @@ -52,7 +52,7 @@ $XFS_IO_PROG -f -c 'falloc -k 0 $(($avail_begin/2))' \ $TEST_DIR/testfile.$seq >>$seqres.full 2>&1 # Verify the file size, it should keep unchanged as 0 in this case -fsize=`ls -l $TEST_DIR/testfile.$seq | awk '{print $5}'` +fsize=`_get_filesize $TEST_DIR/testfile.$seq` [ "$fsize" -eq 0 ] || _fail "File size is changed to ($fsize Bytes)" # Truncate the file size back to 0 -- 2.18.0.rc1 _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel