common/rc: generalize _get_filesize()
[xfstests-dev.git] / tests / generic / 286
old mode 100644 (file)
new mode 100755 (executable)
index 1bf0c87..00cb87b
@@ -1,28 +1,13 @@
 #! /bin/bash
-# FS QA Test No. 286
-#
-# SEEK_DATA/SEEK_HOLE copy tests.
-#
-#-----------------------------------------------------------------------
+# SPDX-License-Identifier: GPL-2.0
 # Copyright (c) 2011 Oracle 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.
-#
-# 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
+# FS QA Test No. 286
 #
-#-----------------------------------------------------------------------
+# SEEK_DATA/SEEK_HOLE copy tests.
 #
-
 seq=`basename $0`
+seqres=$RESULT_DIR/$seq
 echo "QA output created by $seq"
 
 here=`pwd`
@@ -30,17 +15,20 @@ status=1    # failure is the default!
 trap "_cleanup; exit \$status" 0 1 2 3 15
 
 # get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
 
 # real QA test starts here
 _supported_fs generic
 _supported_os Linux
 
+_require_test
+_require_seek_data_hole
+
 src=$TEST_DIR/seek_copy_testfile
 dest=$TEST_DIR/seek_copy_testfile.dest
 
-[ -x $here/src/seek_copy_test ] || _notrun "seek_copy_test not built"
+_require_test_program "seek_copy_test"
 
 _cleanup()
 {
@@ -61,15 +49,15 @@ test01()
                write_cmd="$write_cmd -c \"pwrite $offset 1m\""
        done
 
-       echo "*** test01() create sparse file ***" >>$seq.full
-       eval ${XFS_IO_PROG} -F -f "${write_cmd}" $src >>$seq.full 2>&1 ||
+       echo "*** test01() create sparse file ***" >>$seqres.full
+       eval ${XFS_IO_PROG} -f "${write_cmd}" $src >>$seqres.full 2>&1 ||
                _fail "create sparse file failed!"
-       echo "*** test01() create sparse file done ***" >>$seq.full
-       echo >>$seq.full
+       echo "*** test01() create sparse file done ***" >>$seqres.full
+       echo >>$seqres.full
 
        $here/src/seek_copy_test $src $dest
        
-       test $(stat --printf "%s" $src) = $(stat --printf "%s" $dest) ||
+       test $(_get_filesize $src) = $(_get_filesize $dest) ||
                _fail "TEST01: file size check failed"
 
        cmp $src $dest || _fail "TEST01: file bytes check failed"
@@ -89,15 +77,15 @@ test02()
                write_cmd="$write_cmd -c \"falloc $offset 3m\" -c \"pwrite $offset 1m\""
        done
 
-       echo "*** test02() create sparse file ***" >>$seq.full
-       eval ${XFS_IO_PROG} -F -f "${write_cmd}" $src >>$seq.full 2>&1 ||
+       echo "*** test02() create sparse file ***" >>$seqres.full
+       eval ${XFS_IO_PROG} -f "${write_cmd}" $src >>$seqres.full 2>&1 ||
                _fail "create sparse file failed!"
-       echo "*** test02() create sparse file done ***" >>$seq.full
-       echo >>$seq.full
+       echo "*** test02() create sparse file done ***" >>$seqres.full
+       echo >>$seqres.full
 
        $here/src/seek_copy_test $src $dest
 
-       test $(stat --printf "%s" $src) = $(stat --printf "%s" $dest) ||
+       test $(_get_filesize $src) = $(_get_filesize $dest) ||
                _fail "TEST02: file size check failed"
 
        cmp $src $dest || _fail "TEST02: file bytes check failed"
@@ -132,14 +120,14 @@ test03()
                write_cmd="$write_cmd -c \"pwrite $offset 10m\""
        done
 
-       echo "*** test03() create sparse file ***" >>$seq.full
-       eval ${XFS_IO_PROG} -F -f "${write_cmd}" $src >>$seq.full 2>&1 ||
+       echo "*** test03() create sparse file ***" >>$seqres.full
+       eval ${XFS_IO_PROG} -f "${write_cmd}" $src >>$seqres.full 2>&1 ||
                _fail "create sparse file failed!"
-       echo "*** test03() create sparse file done ***" >>$seq.full
-       echo >>$seq.full
+       echo "*** test03() create sparse file done ***" >>$seqres.full
+       echo >>$seqres.full
        $here/src/seek_copy_test $src $dest
 
-       test $(stat --printf "%s" $src) = $(stat --printf "%s" $dest) ||
+       test $(_get_filesize $src) = $(_get_filesize $dest) ||
                _fail "TEST03: file size check failed"
 
        cmp $src $dest || _fail "TEST03: file bytes check failed"
@@ -174,20 +162,20 @@ test04()
                write_cmd="$write_cmd -c \"pwrite $offset 2m\""
        done
 
-       echo "*** test04() create sparse file ***" >>$seq.full
-       eval ${XFS_IO_PROG} -F -f "${write_cmd}" $src >>$seq.full 2>&1 ||
+       echo "*** test04() create sparse file ***" >>$seqres.full
+       eval ${XFS_IO_PROG} -f "${write_cmd}" $src >>$seqres.full 2>&1 ||
                _fail "create sparse file failed!"
-       echo "*** test04() create sparse file done ***" >>$seq.full
-       echo >>$seq.full
+       echo "*** test04() create sparse file done ***" >>$seqres.full
+       echo >>$seqres.full
        $here/src/seek_copy_test $src $dest
 
-       test $(stat --printf "%s" $src) = $(stat --printf "%s" $dest) ||
+       test $(_get_filesize $src) = $(_get_filesize $dest) ||
                _fail "TEST04: file size check failed"
 
        cmp $src $dest || _fail "TEST04: file bytes check failed"
 }
 
-rm -f $seq.full
+rm -f $seqres.full
 test01
 test02
 test03