fstests: move test group info to test files
[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 . ./common/preamble
12 _begin_fstest auto quick dedupe clone
13
14 # Override the default cleanup function.
15 _cleanup()
16 {
17     cd /
18     rm -rf $tmp.* $testdir
19 }
20
21 # Import common functions.
22 . ./common/filter
23 . ./common/reflink
24
25 # real QA test starts here
26 _require_test_dedupe
27
28 testdir=$TEST_DIR/test-$seq
29 rm -rf $testdir
30 mkdir $testdir
31
32 echo "Create the original files"
33 blksz=65536
34 _pwrite_byte 0x61 $((blksz * 2)) $((blksz * 6)) $testdir/file1 >> $seqres.full
35 _pwrite_byte 0x61 $((blksz * 2)) $((blksz * 6)) $testdir/file2 >> $seqres.full
36 _pwrite_byte 0x62 $(((blksz * 6) - 33)) 1 $testdir/file2 >> $seqres.full
37 _test_cycle_mount
38
39 md5sum $testdir/file1 | _filter_test_dir
40 md5sum $testdir/file2 | _filter_test_dir
41
42 _compare_range $testdir/file1 0 $testdir/file2 0 "$((blksz * 8))" \
43        || echo "Files 1-2 do not match (intentional)"
44
45 echo "(partial) dedupe the middle blocks together"
46 free_before=$(stat -f -c '%a' $testdir)
47 _dedupe_range $testdir/file1 $((blksz * 4)) $testdir/file2 \
48                 $((blksz * 4)) $((blksz * 2)) 2>&1 | _filter_xfs_io_numbers | _filter_dedupe_error
49 _test_cycle_mount
50 ${FILEFRAG_PROG} -v $testdir/file1 >> $seqres.full
51 ${FILEFRAG_PROG} -v $testdir/file2 >> $seqres.full
52 free_after=$(stat -f -c '%a' $testdir)
53 echo "freesp changed by $free_before -> $free_after" >> $seqres.full
54
55 echo "Compare sections"
56 md5sum $testdir/file1 | _filter_test_dir
57 md5sum $testdir/file2 | _filter_test_dir
58
59 _compare_range $testdir/file1 0 $testdir/file2 0 $((blksz * 4)) \
60        || echo "Start sections do not match (error)"
61
62 _compare_range $testdir/file1 $((blksz * 4)) $testdir/file2 \
63                 $((blksz * 4)) $((blksz * 2)) \
64        || echo "Middle sections do not match (intentional)"
65
66 _compare_range $testdir/file1 $((blksz * 6)) $testdir/file2 \
67                 $((blksz * 6)) $((blksz * 2)) \
68        || echo "End sections do not match (error)"
69
70 # success, all done
71 status=0
72 exit