public inbox for fstests@vger.kernel.org
 help / color / mirror / Atom feed
From: Chao Yu <yuchao0@huawei.com>
To: Dave Chinner <david@fromorbit.com>
Cc: <guaneryu@gmail.com>, <darrick.wong@oracle.com>,
	<fstests@vger.kernel.org>,
	<linux-f2fs-devel@lists.sourceforge.net>
Subject: Re: [PATCH v3] common/rc: generalize _get_filesize()
Date: Wed, 16 Oct 2019 14:29:03 +0800	[thread overview]
Message-ID: <9774df2c-aa9d-df86-7d14-d67a41ae2e87@huawei.com> (raw)
In-Reply-To: <20191016034325.GI15134@dread.disaster.area>

On 2019/10/16 11:43, Dave Chinner wrote:
> On Wed, Oct 16, 2019 at 10:48:03AM +0800, Chao Yu wrote:
>> 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}'
>>
>> And in addition, using more simple command "stat -c %s" instead.
>>
>> - adjust common/defrag, generic/275 and generic/315 to use it
>> - remove unused _filesize in generic/013
>>
>> Signed-off-by: Chao Yu <yuchao0@huawei.com>
>> ---
>> v3:
>> - avoid unneeded echo command in _get_filesize() pointed out by Darrick.
>>  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 1381a4dd..1769013b 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
>> -		local filesize=`ls -l $1 | $AWK_PROG '{print $5}'`
>> +		local 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 cfaabf10..8cdb7a9b 100644
>> --- a/common/rc
>> +++ b/common/rc
>> @@ -165,6 +165,11 @@ if [ ! -z "$REPORT_LIST" ]; then
>>  	_assert_report_list
>>  fi
>>  
>> +_get_filesize()
>> +{
>> +    stat -c %s "$1"
>> +}
> 
> Also, all these should use _get_filesize():

Oh, correct, I forgot to research with the new command... let me send v4 to
cover below lines.

Thanks for your reminder.

Thanks,

> 
> $ git grep 'stat -c %s'
> tests/btrfs/086:echo "bar file size after clone operation: $(stat -c %s $SCRATCH_MNT/bar)"
> tests/generic/399:                      total_file_size=$((total_file_size + $(stat -c %s $file)))
> tests/generic/399:      total_file_size=$((total_file_size + $(stat -c %s $file)))
> tests/xfs/306:size=`stat -c %s $SCRATCH_MNT/file`
> $ git grep 'stat -c "%s"'
> tests/generic/286:      test $(stat -c "%s" $src) = $(stat -c "%s" $dest) ||
> tests/generic/286:      test $(stat -c "%s" $src) = $(stat -c "%s" $dest) ||
> tests/generic/286:      test $(stat -c "%s" $src) = $(stat -c "%s" $dest) ||
> tests/generic/286:      test $(stat -c "%s" $src) = $(stat -c "%s" $dest) ||
> tests/overlay/060:      actual_size=$(stat -c "%s" $target)
> tests/xfs/014:  size=`stat -c "%s" $file`
> tests/xfs/076:offset=`stat -c "%s" $SCRATCH_MNT/spc`
> 
> 
> Cheers,
> 
> Dave.
> 

      reply	other threads:[~2019-10-16  6:29 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-16  2:48 [PATCH v3] common/rc: generalize _get_filesize() Chao Yu
2019-10-16  3:43 ` Dave Chinner
2019-10-16  6:29   ` Chao Yu [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9774df2c-aa9d-df86-7d14-d67a41ae2e87@huawei.com \
    --to=yuchao0@huawei.com \
    --cc=darrick.wong@oracle.com \
    --cc=david@fromorbit.com \
    --cc=fstests@vger.kernel.org \
    --cc=guaneryu@gmail.com \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox