xfs/419: remove irrelevant swapfile test
[xfstests-dev.git] / common / reflink
index 2a7c7b848e2b0c6709ed1b53f1496a4eb95b151a..ee60398ed20ae9dab05037fbfc8024beea514cee 100644 (file)
@@ -1,25 +1,8 @@
 ##/bin/bash
-# Routines for reflinking, deduping, and comparing parts of files.
-#-----------------------------------------------------------------------
-#  Copyright (c) 2015 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; either version 2 of the License, or
-#  (at your option) any later version.
-#
-#  This program is distributed in the hope that it will 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 to the Free Software
-#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
-#  USA
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright (c) 2015 Oracle.  All Rights Reserved.
 #
-#  Contact information: Oracle Corporation, 500 Oracle Parkway,
-#  Redwood Shores, CA 94065, USA, or: http://www.oracle.com/
-#-----------------------------------------------------------------------
+# Routines for reflinking, deduping, and comparing parts of files.
 
 # Check that cp has a reflink argument
 _require_cp_reflink()
@@ -31,9 +14,14 @@ _require_cp_reflink()
 # Can we reflink between arbitrary file sets?
 # i.e. if we reflink a->b and c->d, can we later share
 # blocks between b & c?
+_supports_arbitrary_fileset_reflink()
+{
+       test "$FSTYP" != "ocfs2"
+}
+
 _require_arbitrary_fileset_reflink()
 {
-       test "$FSTYP" = "ocfs2" && \
+       _supports_arbitrary_fileset_reflink ||
                _notrun "reflink between arbitrary file groups not supported in $FSTYP"
 }
 
@@ -87,6 +75,24 @@ _require_scratch_reflink()
        _scratch_unmount
 }
 
+# this test requires duperemove working for the file system
+_require_scratch_duperemove()
+{
+       _require_scratch
+       _require_command "$DUPEREMOVE_PROG" duperemove
+
+       _scratch_mkfs > /dev/null
+       _scratch_mount
+       dd if=/dev/zero of="$SCRATCH_MNT/file1" bs=128k count=1 >& /dev/null
+       dd if=/dev/zero of="$SCRATCH_MNT/file2" bs=128k count=1 >& /dev/null
+       if ! "$DUPEREMOVE_PROG" -d "$SCRATCH_MNT/file1" \
+           "$SCRATCH_MNT/file2" >& /dev/null ; then
+               _scratch_unmount
+               _notrun "duperemove does not support file system type: $FSTYP"
+       fi
+       _scratch_unmount
+}
+
 # this test requires scratch fs to report explicit SHARED flag
 # e.g.
 #   0         4K         8K
@@ -162,11 +168,11 @@ _require_scratch_dedupe()
        $XFS_IO_PROG -f -c "pwrite -S 0x61 0 65536" "$SCRATCH_MNT/file2" > /dev/null
        testio="$($XFS_IO_PROG -f -c "dedupe $SCRATCH_MNT/file1 0 0 65536" "$SCRATCH_MNT/file2" 2>&1)"
        echo $testio | grep -q "Operation not supported" && \
-               _notrun "Dedupe not supported by test filesystem type: $FSTYP"
+               _notrun "Dedupe not supported by scratch filesystem type: $FSTYP"
        echo $testio | grep -q "Inappropriate ioctl for device" && \
-               _notrun "Dedupe not supported by test filesystem type: $FSTYP"
+               _notrun "Dedupe not supported by scratch filesystem type: $FSTYP"
        echo $testio | grep -q "Invalid argument" && \
-               _notrun "Dedupe not supported by test filesystem type: $FSTYP"
+               _notrun "Dedupe not supported by scratch filesystem type: $FSTYP"
        _scratch_unmount
 }