generic: test MADV_POPULATE_READ with IO errors
[xfstests-dev.git] / tests / generic / 373
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016 Oracle, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 373
6 #
7 # Check that cross-mountpoint reflink works.
8 #
9 . ./common/preamble
10 _begin_fstest auto quick clone
11
12 _register_cleanup "_cleanup" BUS
13
14 # Override the default cleanup function.
15 _cleanup()
16 {
17         cd /
18         rm -rf $tmp.*
19         wait
20 }
21
22 # Import common functions.
23 . ./common/filter
24 . ./common/reflink
25
26 # real QA test starts here
27 _supported_fs generic
28 _require_scratch_reflink
29 _require_cp_reflink
30
31 echo "Format and mount"
32 _scratch_mkfs > $seqres.full 2>&1
33 _scratch_mount >> $seqres.full 2>&1
34
35 testdir=$SCRATCH_MNT/test-$seq
36 mkdir $testdir
37 otherdir=/tmp/m.$seq
38 othertestdir=$otherdir/test-$seq
39 rm -rf $otherdir
40 mkdir $otherdir
41
42 blocks=1
43 blksz=65536
44 sz=$((blksz * blocks))
45
46 echo "Mount otherdir"
47 $MOUNT_PROG --bind $SCRATCH_MNT $otherdir
48
49 echo "Create file"
50 _pwrite_byte 0x61 0 $sz $testdir/file >> $seqres.full
51
52 filter_otherdir()
53 {
54         _filter_scratch | sed -e "s,$otherdir,OTHER_DIR,g"
55 }
56
57 echo "Reflink one file to another"
58 _cp_reflink $testdir/file $othertestdir/otherfile 2>&1 | filter_otherdir
59
60 echo "Check output"
61 md5sum $testdir/file | _filter_scratch
62 md5sum $othertestdir/otherfile | filter_otherdir
63
64 echo "Unmount otherdir"
65 $UMOUNT_PROG $otherdir
66 rm -rf $otherdir
67
68 # success, all done
69 status=0
70 exit