generic: test for creating duplicate filenames in encrypted dir
[xfstests-dev.git] / tests / generic / 433
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. 433
6 #
7 # Tests vfs_copy_file_range():
8 #   - Copy a small file
9 #   - Use copy to swap data at beginning and end
10 #   - Use copy to swap data in the middle
11 #   - Use copy to swap data in a small file
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 15
20
21 _cleanup()
22 {
23         cd /
24         rm -rf $tmp.*
25 }
26
27 # get standard environment
28 . common/rc
29 . common/filter
30
31 # real QA test starts here
32 _supported_fs generic
33
34 _require_xfs_io_command "copy_range"
35 _require_test
36
37 testdir=$TEST_DIR/test-$seq
38 rm -rf $testdir
39 mkdir $testdir
40 rm -f $seqres.full
41
42 echo "Create the original file and then copy"
43 echo -n "abcde" > $testdir/file
44 $XFS_IO_PROG -f -c "copy_range $testdir/file" "$testdir/copy"
45 cmp $testdir/file $testdir/copy
46 echo "Original md5sums:"
47 md5sum $testdir/{file,copy} | _filter_test_dir
48
49 echo "Swap beginning and end of original file"
50 $XFS_IO_PROG -f -c "copy_range -s 0 -d 4 -l 1 $testdir/file" "$testdir/copy"
51 $XFS_IO_PROG -f -c "copy_range -s 4 -d 0 -l 1 $testdir/file" "$testdir/copy"
52 echo -n "ebcda" | cmp $testdir/copy
53 echo "md5sums after swapping beginning and end:"
54 md5sum $testdir/{file,copy} | _filter_test_dir
55
56 echo "Swap middle parts of original file"
57 $XFS_IO_PROG -f -c "copy_range -s 1 -d 3 -l 1 $testdir/file" "$testdir/copy"
58 $XFS_IO_PROG -f -c "copy_range -s 3 -d 1 -l 1 $testdir/file" "$testdir/copy"
59 echo -n "edcba" | cmp $testdir/copy
60 echo "md5sums after swapping middle:"
61 md5sum $testdir/{file,copy} | _filter_test_dir
62
63 echo "Copy tail of original file onto copy"
64 $XFS_IO_PROG -f -c "copy_range -s 1 -d 3 -l 4 $testdir/file" "$testdir/copy"
65 echo -n "edcbcde" | cmp $testdir/copy
66 echo "md5sums after copying tail:"
67 md5sum $testdir/{file,copy} | _filter_test_dir
68
69 #success, all done
70 status=0
71 exit