common/rc: generalize _get_filesize()
[xfstests-dev.git] / tests / generic / 497
index 8dd1d32b8e5377fd8a945ae7105d65da0e473246..faeaa142c2593ece3d323ad54d028f441aa1f7c7 100755 (executable)
@@ -1,27 +1,12 @@
 #! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2018 Oracle.  All Rights Reserved.
+#
 # FS QA Test No. 497
 #
 # Test various swapfile activation oddities, having used fcollapse to
 # create discontiguous ranges in the file.
 #
-#-----------------------------------------------------------------------
-# Copyright (c) 2018 Oracle.  All Rights Reserved.
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License as
-# published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it would be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write the Free Software Foundation,
-# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-#
-#-----------------------------------------------------------------------
-
 seq=`basename $0`
 seqres=$RESULT_DIR/$seq
 echo "QA output created by $seq"
@@ -68,16 +53,16 @@ swapfile_cycle() {
        $CHATTR_PROG +C $swapfile >> $seqres.full 2>&1
        "$here/src/mkswap" $swapfile >> $seqres.full
        "$here/src/swapon" $swapfile 2>&1 | _filter_scratch
-       swapoff $swapfile 2>> $seeqres.full
+       swapoff $swapfile 2>> $seqres.full
        rm -f $swapfile
 }
 
 # 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
@@ -86,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