Rename _test_mount to _test_cycle_mount
[xfstests-dev.git] / tests / generic / 182
1 #! /bin/bash
2 # FS QA Test No. 182
3 #
4 # Test the convention that dedupe with length == 0 means "to the end of fileA"
5 #   - Create a file.
6 #   - Try to dedupe "zero" bytes (which means dedupe to EOF).
7 #   - Check that the dedupe happened.
8 #
9 #-----------------------------------------------------------------------
10 # Copyright (c) 2015, Oracle and/or its affiliates.  All Rights Reserved.
11 #
12 # This program is free software; you can redistribute it and/or
13 # modify it under the terms of the GNU General Public License as
14 # published by the Free Software Foundation.
15 #
16 # This program is distributed in the hope that it would be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 # GNU General Public License for more details.
20 #
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write the Free Software Foundation,
23 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
24 #-----------------------------------------------------------------------
25
26 seq=`basename $0`
27 seqres=$RESULT_DIR/$seq
28 echo "QA output created by $seq"
29
30 here=`pwd`
31 tmp=/tmp/$$
32 status=1    # failure is the default!
33 trap "_cleanup; exit \$status" 0 1 2 3 15
34
35 _cleanup()
36 {
37     cd /
38     rm -rf $tmp.* $testdir
39 }
40
41 # get standard environment, filters and checks
42 . ./common/rc
43 . ./common/filter
44 . ./common/reflink
45
46 # real QA test starts here
47 _supported_os Linux
48 _require_test_dedupe
49
50 rm -f $seqres.full
51
52 testdir=$TEST_DIR/test-$seq
53 rm -rf $testdir
54 mkdir $testdir
55
56 echo "Create the original files"
57 blksz=65536
58 _pwrite_byte 0x61 0 $((blksz * 256)) $testdir/file1 >> $seqres.full
59 _pwrite_byte 0x62 0 $((blksz * 257)) $testdir/file2 >> $seqres.full
60 _pwrite_byte 0x62 0 $((blksz * 257)) $testdir/file2.chk >> $seqres.full
61 _dedupe_range $testdir/file1 $blksz $testdir/file2 $((blksz * 2)) 0 >> $seqres.full
62 _test_cycle_mount
63
64 md5sum $testdir/file1 | _filter_test_dir
65 md5sum $testdir/file2 | _filter_test_dir
66 md5sum $testdir/file2.chk | _filter_test_dir
67
68 c1=$(_md5_checksum $testdir/file1)
69 c2=$(_md5_checksum $testdir/file2)
70
71 test ${c1} != ${c2} || echo "file1 and file2 should not match"
72
73 echo "Compare against check files"
74 cmp -s $testdir/file2 $testdir/file2.chk || echo "file2 and file2.chk do not match"
75
76 echo "Make the original file almost dedup-able"
77 _pwrite_byte 0x61 0 $((blksz * 256)) $testdir/file1 >> $seqres.full
78 _pwrite_byte 0x61 0 $((blksz * 256)) $testdir/file2 >> $seqres.full
79 _pwrite_byte 0x61 0 $((blksz * 256)) $testdir/file2.chk >> $seqres.full
80 _dedupe_range $testdir/file1 $blksz $testdir/file2 $((blksz * 2)) 0 >> $seqres.full
81 _test_cycle_mount
82
83 md5sum $testdir/file1 | _filter_test_dir
84 md5sum $testdir/file2 | _filter_test_dir
85 md5sum $testdir/file2.chk | _filter_test_dir
86
87 c1=$(_md5_checksum $testdir/file1)
88 c2=$(_md5_checksum $testdir/file2)
89
90 test ${c1} != ${c2} || echo "file1 and file2 should not match"
91
92 echo "Compare against check files"
93 cmp -s $testdir/file2 $testdir/file2.chk || echo "file2 and file2.chk do not match"
94
95 echo "Make the original file dedup-able"
96 _pwrite_byte 0x61 0 $((blksz * 256)) $testdir/file1 >> $seqres.full
97 _pwrite_byte 0x61 0 $((blksz * 257)) $testdir/file2 >> $seqres.full
98 _pwrite_byte 0x61 0 $((blksz * 257)) $testdir/file2.chk >> $seqres.full
99 _dedupe_range $testdir/file1 $blksz $testdir/file2 $((blksz * 2)) 0 >> $seqres.full
100 _test_cycle_mount
101
102 md5sum $testdir/file1 | _filter_test_dir
103 md5sum $testdir/file2 | _filter_test_dir
104 md5sum $testdir/file2.chk | _filter_test_dir
105
106 c1=$(_md5_checksum $testdir/file1)
107 c2=$(_md5_checksum $testdir/file2)
108
109 test ${c1} = ${c2} || echo "file1 and file2 should match"
110
111 echo "Compare against check files"
112 cmp -s $testdir/file2 $testdir/file2.chk || echo "file2 and file2.chk do not match"
113
114 # success, all done
115 status=0
116 exit