common/rc: generalize _get_filesize()
[xfstests-dev.git] / tests / overlay / 060
index f1a9d34658c41823b5f92dcf53601856b3dbd481..34140e1256702bd813bbadcb14bebf81c8d2be19 100755 (executable)
@@ -1,26 +1,11 @@
 #! /bin/bash
-# FS QA Test No. 060
-#
-# Test metadata only copy up functionality.
-#
-#-----------------------------------------------------------------------
+# SPDX-License-Identifier: GPL-2.0
 # Copyright (C) 2018 Red Hat, Inc. 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.
+# FS QA Test No. 060
 #
-# 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
-#-----------------------------------------------------------------------
+# Test metadata only copy up functionality.
 #
-
 seq=`basename $0`
 seqres=$RESULT_DIR/$seq
 echo "QA output created by $seq"
@@ -39,6 +24,7 @@ _cleanup()
 # get standard environment, filters and checks
 . ./common/rc
 . ./common/filter
+. ./common/attr
 
 # remove previous $seqres.full before test
 rm -f $seqres.full
@@ -50,6 +36,7 @@ _supported_os Linux
 # them explicity after test.
 _require_scratch_nocheck
 _require_scratch_overlay_features index redirect_dir metacopy
+_require_xfs_io_command "falloc"
 
 # remove all files from previous tests
 _scratch_mkfs
@@ -73,7 +60,7 @@ check_metacopy()
        local out_f target_f
        local msg
 
-        out_f=$($GETFATTR_PROG --absolute-names --only-values -n \
+        out_f=$(_getfattr --absolute-names --only-values -n \
                $OVL_XATTR_METACOPY $target 2>&1 | _filter_scratch)
 
        if [ "$exist" == "y" ];then
@@ -101,7 +88,7 @@ check_redirect()
        local target=$1
        local expect=$2
 
-       value=$($GETFATTR_PROG --absolute-names --only-values -n \
+       value=$(_getfattr --absolute-names --only-values -n \
                $OVL_XATTR_REDIRECT $target)
 
        [[ "$value" == "$expect" ]] || echo "Redirect xattr incorrect. Expected=\"$expect\", actual=\"$value\""
@@ -112,7 +99,7 @@ check_file_size()
 {
        local target=$1 expected_size=$2 actual_size
 
-       actual_size=$(stat -c "%s" $target)
+       actual_size=$(_get_filesize $target)
 
        [ "$actual_size" == "$expected_size" ] || echo "Expected file size $expected_size but actual size is $actual_size"
 }
@@ -184,7 +171,7 @@ test_common()
 
        # Trigger data copy up and check absence of metacopy xattr.
        mount_overlay $_lowerdir
-       $XFS_IO_PROG -c "open -a $SCRATCH_MNT/$_target"
+       $XFS_IO_PROG -c "falloc 0 1" $SCRATCH_MNT/$_target >> $seqres.full
        echo "check properties of data copied up file"
        check_file_size_contents $SCRATCH_MNT/$_target $_size "$_data"
        umount_overlay