common: kill _supported_os
[xfstests-dev.git] / tests / generic / 111
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2014, Oracle and/or its affiliates.  All Rights Reserved.
4 #
5 # FS QA Test No. 111
6 #
7 # Tests file clone functionality of btrfs ("reflinks") on directory
8 # trees.
9 #   - Create directory and subdirectory, each having one file
10 #   - Create 2 recursive reflinked copies of the tree
11 #   - Modify the original files
12 #   - Modify one of the copies
13 #
14 seq=`basename $0`
15 seqres=$RESULT_DIR/$seq
16 echo "QA output created by $seq"
17
18 here=`pwd`
19 tmp=/tmp/$$
20 status=1    # failure is the default!
21 trap "_cleanup; exit \$status" 0 1 2 3 15
22
23 _cleanup()
24 {
25     cd /
26     rm -f $tmp.* $testdir
27 }
28
29 # get standard environment, filters and checks
30 . common/rc
31 . common/filter
32 . common/reflink
33
34 # real QA test starts here
35 _require_test_reflink
36
37 _require_xfs_io_command "fiemap"
38 _require_cp_reflink
39 _require_test
40
41 testdir1=$TEST_DIR/test-$seq
42 rm -rf $testdir1
43 mkdir $testdir1
44
45 _checksum_files() {
46     for F in original/file1 original/subdir/file2 \
47                  copy1/file1 copy1/subdir/file2 \
48                  copy2/file1 copy2/subdir/file2
49         do
50             md5sum $testdir1/$F | _filter_test_dir
51         done
52 }
53
54 rm -f $seqres.full
55
56 mkdir $testdir1/original
57 mkdir $testdir1/original/subdir
58
59 echo "Create the original files and reflink dirs"
60 $XFS_IO_PROG -f -c 'pwrite -S 0x61 0 9000' $testdir1/original/file1 \
61     >> $seqres.full 2>&1
62 $XFS_IO_PROG -f -c 'pwrite -S 0x62 0 11000' \
63     $testdir1/original/subdir/file2 >> $seqres.full 2>&1
64 cp --recursive --reflink $testdir1/original $testdir1/copy1
65 cp --recursive --reflink $testdir1/copy1 $testdir1/copy2
66
67 _verify_reflink $testdir1/original/file1 $testdir1/copy1/file1
68 _verify_reflink $testdir1/original/subdir/file2 \
69     $testdir1/copy1/subdir/file2
70 _verify_reflink $testdir1/original/file1 $testdir1/copy2/file1
71 _verify_reflink $testdir1/original/subdir/file2 \
72     $testdir1/copy2/subdir/file2
73
74 echo "Original md5sums:"
75 _checksum_files
76
77 echo "Overwrite original/file1 and original/subdir/file2 with new data"
78 $XFS_IO_PROG -c 'pwrite -S 0x63 0 13000' $testdir1/original/file1 \
79     >> $seqres.full 2>&1
80 $XFS_IO_PROG -c 'pwrite -S 0x64 5000 1000' \
81     $testdir1/original/subdir/file2 >> $seqres.full 2>&1
82 echo "md5sums now:"
83 _checksum_files
84
85 echo "Overwrite copy1/file1 and copy1/subdir/file2 with new data"
86 $XFS_IO_PROG -c 'pwrite -S 0x65 0 9000' $testdir1/copy1/file1 \
87     >> $seqres.full 2>&1
88 $XFS_IO_PROG -c 'pwrite -S 0x66 5000 25000' \
89     $testdir1/copy1/subdir/file2 >> $seqres.full 2>&1
90 echo "md5sums now:"
91 _checksum_files
92
93 # success, all done
94 status=0
95 exit