generic: test for file loss after mix of rename, fsync and inode eviction
[xfstests-dev.git] / tests / generic / 431
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. 431
6 #
7 # Tests vfs_copy_file_range():
8 #   - Copy a small file
9 #   - Small copies from various points in the original file
10 . ./common/preamble
11 _begin_fstest auto quick copy_range
12
13 # get standard environment
14 . common/filter
15
16 # real QA test starts here
17 _supported_fs generic
18
19 _require_xfs_io_command "copy_range"
20 _require_test
21
22 testdir=$TEST_DIR/test-$seq
23 rm -rf $testdir
24 mkdir $testdir
25
26 echo "Create the original file and then copy"
27 echo -n "abcde" > $testdir/file
28 $XFS_IO_PROG -f -c "copy_range $testdir/file" "$testdir/copy"
29 echo -n "abcde" | cmp $testdir/copy
30 echo "Original md5sums:"
31 md5sum $testdir/{file,copy} | _filter_test_dir
32
33 echo "Small copies from various points in the original file"
34 $XFS_IO_PROG -f -c "copy_range -s 0 -l 1      $testdir/file" "$testdir/a"
35 $XFS_IO_PROG -f -c "copy_range -s 1 -l 1      $testdir/file" "$testdir/b"
36 $XFS_IO_PROG -f -c "copy_range -s 2 -l 1      $testdir/file" "$testdir/c"
37 $XFS_IO_PROG -f -c "copy_range -s 3 -l 1      $testdir/file" "$testdir/d"
38 $XFS_IO_PROG -f -c "copy_range -s 4 -l 1      $testdir/file" "$testdir/e"
39 $XFS_IO_PROG -f -c "copy_range -s 4 -l 1 -d 1 $testdir/file" "$testdir/f"
40 $XFS_IO_PROG -f -c "copy_range -s 5 -l 1      $testdir/file" "$testdir/g"
41 echo -n "a"    | cmp $testdir/a
42 echo -n "b"    | cmp $testdir/b
43 echo -n "c"    | cmp $testdir/c
44 echo -n "d"    | cmp $testdir/d
45 echo -n "e"    | cmp $testdir/e
46 echo -en "\0e" | cmp $testdir/f
47 echo -n ""     | cmp $testdir/g
48 echo "md5sums after small copies"
49 md5sum $testdir/{file,a,b,c,d,e,f,g} | _filter_test_dir
50
51 #success, all done
52 status=0
53 exit