common/rc: generalize _get_filesize()
[xfstests-dev.git] / tests / overlay / 060
index 68b8776ea4755e53f81a417970e6b6ca26549340..34140e1256702bd813bbadcb14bebf81c8d2be19 100755 (executable)
@@ -24,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
@@ -35,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
@@ -58,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
@@ -86,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\""
@@ -97,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"
 }
@@ -169,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