generic: test MADV_POPULATE_READ with IO errors
[xfstests-dev.git] / tests / generic / 430
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 Netapp, Inc. All rights reserved.
4 #
5 # FS QA Test No. 430
6 #
7 # Tests vfs_copy_file_range():
8 #   - Copy a file
9 #   - Copy beginning of original to new file
10 #   - Copy middle of original to a new file
11 #   - Copy end of original to new file
12 #   - Copy middle of original to a new file, creating a hole
13 . ./common/preamble
14 _begin_fstest auto quick copy_range
15
16 # get standard environment
17 . common/filter
18
19 # real QA test starts here
20 _supported_fs generic
21
22 _require_xfs_io_command "copy_range"
23 _require_test
24
25 testdir=$TEST_DIR/test-$seq
26 rm -rf $testdir
27 mkdir $testdir
28
29 echo "Create the original file and then copy"
30 $XFS_IO_PROG -f -c 'pwrite -S 0x61 0    1000' $testdir/file >> $seqres.full 2>&1
31 $XFS_IO_PROG -f -c 'pwrite -S 0x62 1000 1000' $testdir/file >> $seqres.full 2>&1
32 $XFS_IO_PROG -f -c 'pwrite -S 0x63 2000 1000' $testdir/file >> $seqres.full 2>&1
33 $XFS_IO_PROG -f -c 'pwrite -S 0x64 3000 1000' $testdir/file >> $seqres.full 2>&1
34 $XFS_IO_PROG -f -c 'pwrite -S 0x65 4000 1000' $testdir/file >> $seqres.full 2>&1
35 $XFS_IO_PROG -f -c "copy_range $testdir/file" "$testdir/copy"
36 cmp $testdir/file $testdir/copy
37 echo "Original md5sums:"
38 md5sum $testdir/{file,copy} | _filter_test_dir
39
40 echo "Copy beginning of original file"
41 $XFS_IO_PROG -f -c "copy_range -l 1000 $testdir/file" "$testdir/beginning"
42 cmp -n 1000 $testdir/file $testdir/beginning
43 echo "md5sums after copying beginning:"
44 md5sum $testdir/{file,beginning} | _filter_test_dir
45
46 echo "Copy middle of original file"
47 $XFS_IO_PROG -f -c "copy_range -s 1000 -l 3000 $testdir/file" "$testdir/middle"
48 cmp -n 3000 $testdir/file $testdir/middle 1000
49 echo "md5sums after copying middle:"
50 md5sum $testdir/{file,middle} | _filter_test_dir
51
52 echo "Copy end of original file"
53 $XFS_IO_PROG -f -c "copy_range -s 4000 -l 1000 $testdir/file" "$testdir/end"
54 cmp -n 1000 $testdir/file $testdir/end 4000
55 echo "md5sums after copying end:"
56 md5sum $testdir/{file,end} | _filter_test_dir
57
58 echo "Copy beyond end of original file"
59 $XFS_IO_PROG -f -c "copy_range -s 4000 -l 2000 $testdir/file" "$testdir/beyond"
60 cmp -n 1000 $testdir/file $testdir/beyond 4000
61 echo "md5sums after copying beyond:"
62 md5sum $testdir/{file,beyond} | _filter_test_dir
63
64 echo "Copy creates hole in target file"
65 $XFS_IO_PROG -f -c "copy_range -s 1000 -l 3000 -d 1000 $testdir/file" "$testdir/hole"
66 cmp -n 3000 $testdir/file $testdir/hole 1000 1000
67 echo "md5sums after creating hole:"
68 md5sum $testdir/{file,hole} | _filter_test_dir
69
70 #success, all done
71 status=0
72 exit