xfs/{263,106}: erase max warnings printout
[xfstests-dev.git] / tests / generic / 516
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2018, Oracle and/or its affiliates.  All Rights Reserved.
4 #
5 # FS QA Test No. 516
6 #
7 # Ensuring that we cannot dedupe non-matching parts of files:
8 #   - Fail to dedupe non-identical parts of two different files
9 #   - Check that nothing changes in either file
10 #
11 seq=`basename $0`
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
14
15 here=`pwd`
16 tmp=/tmp/$$
17 status=1    # failure is the default!
18 trap "_cleanup; exit \$status" 0 1 2 3 15
19
20 _cleanup()
21 {
22     cd /
23     rm -rf $tmp.* $testdir
24 }
25
26 # get standard environment, filters and checks
27 . ./common/rc
28 . ./common/filter
29 . ./common/reflink
30
31 # real QA test starts here
32 _supported_os Linux
33 _require_test_dedupe
34
35 rm -f $seqres.full
36
37 testdir=$TEST_DIR/test-$seq
38 rm -rf $testdir
39 mkdir $testdir
40
41 echo "Create the original files"
42 blksz=65536
43 _pwrite_byte 0x61 $((blksz * 2)) $((blksz * 6)) $testdir/file1 >> $seqres.full
44 _pwrite_byte 0x61 $((blksz * 2)) $((blksz * 6)) $testdir/file2 >> $seqres.full
45 _pwrite_byte 0x62 $(((blksz * 6) - 33)) 1 $testdir/file2 >> $seqres.full
46 _test_cycle_mount
47
48 md5sum $testdir/file1 | _filter_test_dir
49 md5sum $testdir/file2 | _filter_test_dir
50
51 _compare_range $testdir/file1 0 $testdir/file2 0 "$((blksz * 8))" \
52        || echo "Files 1-2 do not match (intentional)"
53
54 echo "(partial) dedupe the middle blocks together"
55 free_before=$(stat -f -c '%a' $testdir)
56 _dedupe_range $testdir/file1 $((blksz * 4)) $testdir/file2 \
57                 $((blksz * 4)) $((blksz * 2)) 2>&1 | _filter_xfs_io_numbers | _filter_dedupe_error
58 _test_cycle_mount
59 ${FILEFRAG_PROG} -v $testdir/file1 >> $seqres.full
60 ${FILEFRAG_PROG} -v $testdir/file2 >> $seqres.full
61 free_after=$(stat -f -c '%a' $testdir)
62 echo "freesp changed by $free_before -> $free_after" >> $seqres.full
63
64 echo "Compare sections"
65 md5sum $testdir/file1 | _filter_test_dir
66 md5sum $testdir/file2 | _filter_test_dir
67
68 _compare_range $testdir/file1 0 $testdir/file2 0 $((blksz * 4)) \
69        || echo "Start sections do not match (error)"
70
71 _compare_range $testdir/file1 $((blksz * 4)) $testdir/file2 \
72                 $((blksz * 4)) $((blksz * 2)) \
73        || echo "Middle sections do not match (intentional)"
74
75 _compare_range $testdir/file1 $((blksz * 6)) $testdir/file2 \
76                 $((blksz * 6)) $((blksz * 2)) \
77        || echo "End sections do not match (error)"
78
79 # success, all done
80 status=0
81 exit