common/rc: add _scratch_{u}mount_idmapped() helpers
[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_fs generic
33
34 rm -f $seqres.full
35
36 _require_test
37 _require_scratch
38 _require_xfs_io_command "copy_range"
39
40 _scratch_mkfs >>$seqres.full 2>&1
41 _scratch_mount
42
43
44 testdir=$TEST_DIR/test-$seq
45 rm -rf $testdir
46 mkdir $testdir
47 rm -f $seqres.full
48
49 $XFS_IO_PROG -f -c "pwrite -S 0x61 0 128k" $testdir/file >> $seqres.full 2>&1
50
51 # expect success or EXDEV on filesystem/kernel that do not support
52 # cross-device copy_range
53 testio=`$XFS_IO_PROG -f -c "copy_range -l 128k $testdir/file" $SCRATCH_MNT/copy 2>&1`
54 echo $testio | grep -q "cross-device" && \
55         _notrun "$FSTYP does not support cross-device copy_file_range"
56 echo -n $testio
57 cmp $testdir/file $SCRATCH_MNT/copy
58 echo "md5sums after xdev copy:"
59 md5sum $testdir/file $SCRATCH_MNT/copy | _filter_testdir_and_scratch
60
61 # success, all done
62 status=0
63 exit