generic: convert tests to SPDX license tags
[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 _supported_os Linux
32
33 _require_xfs_io_command "copy_range"
34 _require_test
35
36 testdir=$TEST_DIR/test-$seq
37 rm -rf $testdir
38 mkdir $testdir
39 rm -f $seqres.full
40
41 echo "Create the original file and then copy"
42 echo -n "abcde" > $testdir/file
43 $XFS_IO_PROG -f -c "copy_range $testdir/file" "$testdir/copy"
44 echo -n "abcde" | cmp $testdir/copy
45 echo "Original md5sums:"
46 md5sum $testdir/{file,copy} | _filter_test_dir
47
48 echo "Small copies from various points in the original file"
49 $XFS_IO_PROG -f -c "copy_range -s 0 -l 1      $testdir/file" "$testdir/a"
50 $XFS_IO_PROG -f -c "copy_range -s 1 -l 1      $testdir/file" "$testdir/b"
51 $XFS_IO_PROG -f -c "copy_range -s 2 -l 1      $testdir/file" "$testdir/c"
52 $XFS_IO_PROG -f -c "copy_range -s 3 -l 1      $testdir/file" "$testdir/d"
53 $XFS_IO_PROG -f -c "copy_range -s 4 -l 1      $testdir/file" "$testdir/e"
54 $XFS_IO_PROG -f -c "copy_range -s 4 -l 1 -d 1 $testdir/file" "$testdir/f"
55 $XFS_IO_PROG -f -c "copy_range -s 5 -l 1      $testdir/file" "$testdir/g"
56 echo -n "a"    | cmp $testdir/a
57 echo -n "b"    | cmp $testdir/b
58 echo -n "c"    | cmp $testdir/c
59 echo -n "d"    | cmp $testdir/d
60 echo -n "e"    | cmp $testdir/e
61 echo -en "\0e" | cmp $testdir/f
62 echo -n ""     | cmp $testdir/g
63 echo "md5sums after small copies"
64 md5sum $testdir/{file,a,b,c,d,e,f,g} | _filter_test_dir
65
66 #success, all done
67 status=0
68 exit