common/rc: Add _require_{chown,chmod}()
[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 seq=`basename $0`
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
13
14 here=`pwd`
15 tmp=/tmp/$$
16 status=1    # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
18
19 _cleanup()
20 {
21         cd /
22         rm -rf $tmp.*
23 }
24
25 # get standard environment
26 . common/rc
27 . common/filter
28
29 # real QA test starts here
30 _supported_fs generic
31
32 _require_xfs_io_command "copy_range"
33 _require_test
34
35 testdir=$TEST_DIR/test-$seq
36 rm -rf $testdir
37 mkdir $testdir
38 rm -f $seqres.full
39
40 echo "Create the original file and then copy"
41 echo -n "abcde" > $testdir/file
42 $XFS_IO_PROG -f -c "copy_range $testdir/file" "$testdir/copy"
43 echo -n "abcde" | cmp $testdir/copy
44 echo "Original md5sums:"
45 md5sum $testdir/{file,copy} | _filter_test_dir
46
47 echo "Small copies from various points in the original file"
48 $XFS_IO_PROG -f -c "copy_range -s 0 -l 1      $testdir/file" "$testdir/a"
49 $XFS_IO_PROG -f -c "copy_range -s 1 -l 1      $testdir/file" "$testdir/b"
50 $XFS_IO_PROG -f -c "copy_range -s 2 -l 1      $testdir/file" "$testdir/c"
51 $XFS_IO_PROG -f -c "copy_range -s 3 -l 1      $testdir/file" "$testdir/d"
52 $XFS_IO_PROG -f -c "copy_range -s 4 -l 1      $testdir/file" "$testdir/e"
53 $XFS_IO_PROG -f -c "copy_range -s 4 -l 1 -d 1 $testdir/file" "$testdir/f"
54 $XFS_IO_PROG -f -c "copy_range -s 5 -l 1      $testdir/file" "$testdir/g"
55 echo -n "a"    | cmp $testdir/a
56 echo -n "b"    | cmp $testdir/b
57 echo -n "c"    | cmp $testdir/c
58 echo -n "d"    | cmp $testdir/d
59 echo -n "e"    | cmp $testdir/e
60 echo -en "\0e" | cmp $testdir/f
61 echo -n ""     | cmp $testdir/g
62 echo "md5sums after small copies"
63 md5sum $testdir/{file,a,b,c,d,e,f,g} | _filter_test_dir
64
65 #success, all done
66 status=0
67 exit