generic: test MADV_POPULATE_READ with IO errors
[xfstests-dev.git] / tests / generic / 178
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015, Oracle and/or its affiliates.  All Rights Reserved.
4 #
5 # FS QA Test No. 178
6 #
7 # Ensure that punch-hole doesn't clobber CoW.
8 #
9 . ./common/preamble
10 _begin_fstest auto quick clone punch
11
12 # Override the default cleanup function.
13 _cleanup()
14 {
15     cd /
16     rm -rf $tmp.* $testdir
17 }
18
19 # Import common functions.
20 . ./common/filter
21 . ./common/reflink
22
23 # real QA test starts here
24 _require_test_reflink
25 _require_cp_reflink
26 _require_xfs_io_command "fpunch"
27
28 testdir=$TEST_DIR/test-$seq
29 rm -rf $testdir
30 mkdir $testdir
31
32 echo "Create the original files"
33 blksz=65536
34 nr=512
35 filesize=$((blksz * nr))
36 _pwrite_byte 0x61 0 $filesize $testdir/file1 >> $seqres.full
37
38 _cp_reflink $testdir/file1 $testdir/file2
39 _test_cycle_mount
40
41 md5sum $testdir/file1 | _filter_test_dir
42 md5sum $testdir/file2 | _filter_test_dir
43
44 echo "Write and punch"
45 _pwrite_byte 0x62 0 $((blksz * 256)) $testdir/file2 >> $seqres.full
46 $XFS_IO_PROG -f -c "fpunch $blksz $((blksz * 254))" $testdir/file2
47 _test_cycle_mount
48
49 echo "Compare results"
50 md5sum $testdir/file1 | _filter_test_dir
51 md5sum $testdir/file2 | _filter_test_dir
52
53 # success, all done
54 status=0
55 exit