generic: cross-device copy_file_range test
[xfstests-dev.git] / tests / generic / 565
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2018 Red Hat, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 565
6 #
7 # Exercise copy_file_range() across devices supported by some
8 # filesystems since kernel commit:
9 #
10 # 5dae222a5ff0 vfs: allow copy_file_range to copy across devices
11 #
12 seq=`basename $0`
13 seqres=$RESULT_DIR/$seq
14 echo "QA output created by $seq"
15
16 here=`pwd`
17 tmp=/tmp/$$
18 status=1        # failure is the default!
19 trap "_cleanup; exit \$status" 0 1 2 3 7 15
20
21 _cleanup()
22 {
23         cd /
24         rm -rf $tmp.*
25 }
26
27 # get standard environment, filters and checks
28 . ./common/rc
29 . ./common/filter
30
31 # real QA test starts here
32 _supported_os Linux
33 _supported_fs generic
34
35 rm -f $seqres.full
36
37 _require_test
38 _require_scratch
39 _require_xfs_io_command "copy_range"
40
41 _scratch_mkfs 2>&1 >> $seqres.full
42 _scratch_mount
43
44
45 testdir=$TEST_DIR/test-$seq
46 rm -rf $testdir
47 mkdir $testdir
48 rm -f $seqres.full
49
50 $XFS_IO_PROG -f -c "pwrite -S 0x61 0 128k" $testdir/file >> $seqres.full 2>&1
51
52 # expect success or EXDEV on filesystem/kernel that do not support
53 # cross-device copy_range
54 testio=`$XFS_IO_PROG -f -c "copy_range -l 128k $testdir/file" $SCRATCH_MNT/copy 2>&1`
55 echo $testio | grep -q "cross-device" && \
56         _notrun "$FSTYP does not support cross-device copy_file_range"
57 echo -n $testio
58 cmp $testdir/file $SCRATCH_MNT/copy
59 echo "md5sums after xdev copy:"
60 md5sum $testdir/file $SCRATCH_MNT/copy | _filter_test_dir | _filter_scratch
61
62 # success, all done
63 status=0
64 exit