common/rc: generalize _get_filesize()

There are some testcases use below two kind of commands to get file
size, generalize the second way as global function _get_filesize()
to simply codes.

1. ls -l $1 | $AWK_PROG '{print $5}'
2. stat -c %s $1

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
This commit is contained in:
Chao Yu
2019-11-01 18:28:21 +08:00
committed by Eryu Guan
parent eff343fb5d
commit 11d3da6a7f
18 changed files with 29 additions and 29 deletions
+4 -4
View File
@@ -60,9 +60,9 @@ swapfile_cycle() {
# Create a swap file with a large discontiguous range(?)
echo "large discontig swap" | tee -a $seqres.full
_pwrite_byte 0x58 0 $((len * 2)) $swapfile >> $seqres.full
old_sz="$(stat -c '%s' $swapfile)"
old_sz="$(_get_filesize $swapfile)"
$XFS_IO_PROG -c "fcollapse $((len / 2)) $len" $swapfile >> $seqres.full 2>&1
new_sz="$(stat -c '%s' $swapfile)"
new_sz="$(_get_filesize $swapfile)"
if [ $old_sz -gt $new_sz ]; then
swapfile_cycle $swapfile
fi
@@ -71,9 +71,9 @@ rm -f $swapfile
# Create a swap file with a small discontiguous range(?)
echo "small discontig swap" | tee -a $seqres.full
_pwrite_byte 0x58 0 $((len + 1024)) $swapfile >> $seqres.full
old_sz="$(stat -c '%s' $swapfile)"
old_sz="$(_get_filesize $swapfile)"
$XFS_IO_PROG -c "fcollapse 66560 1024" $swapfile >> $seqres.full 2>&1
new_sz="$(stat -c '%s' $swapfile)"
new_sz="$(_get_filesize $swapfile)"
if [ $old_sz -gt $new_sz ]; then
swapfile_cycle $swapfile
fi