fstests: use _require_symlinks on all necessary tests
[xfstests-dev.git] / tests / generic / 179
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015, Oracle and/or its affiliates.  All Rights Reserved.
4 #
5 # FS QA Test No. 179
6 #
7 # Ensure that unaligned punch-hole steps around reflinked ranges:
8 #   - Create a reflink clone of a file
9 #   - Perform an unaligned punch in the middle of the file.
10 #   - Check that the reflinked areas are still there.
11 #
12 seq=`basename $0`
13 seqres=$RESULT_DIR/$seq
14 echo "QA output created by $seq"
15
16 here=`pwd`
17 tmp=/tmp/$$
18 status=1    # failure is the default!
19 trap "_cleanup; exit \$status" 0 1 2 3 15
20
21 _cleanup()
22 {
23     cd /
24     rm -rf $tmp.* $testdir
25 }
26
27 # get standard environment, filters and checks
28 . ./common/rc
29 . ./common/filter
30 . ./common/reflink
31
32 # real QA test starts here
33 _supported_os Linux
34 _require_test_reflink
35 _require_cp_reflink
36 _require_xfs_io_command "fpunch"
37
38 rm -f $seqres.full
39
40 testdir=$TEST_DIR/test-$seq
41 rm -rf $testdir
42 mkdir $testdir
43
44 echo "Create the original files"
45 blksz=65536
46 _pwrite_byte 0x61 0 $((blksz * 3)) $testdir/file1 >> $seqres.full
47
48 _cp_reflink $testdir/file1 $testdir/file2
49
50 _pwrite_byte 0x61 0 $((blksz * 3)) $testdir/file2.chk >> $seqres.full
51 _pwrite_byte 0x00 $((blksz - 17)) $((blksz + 17)) $testdir/file2.chk >> $seqres.full
52 _test_cycle_mount
53
54 md5sum $testdir/file1 | _filter_test_dir
55 md5sum $testdir/file2 | _filter_test_dir
56 md5sum $testdir/file2.chk | _filter_test_dir
57
58 c1=$(_md5_checksum $testdir/file1)
59 c2=$(_md5_checksum $testdir/file2)
60
61 test ${c1} = ${c2} || echo "file1 and file2 should match"
62
63 echo "fpunch files"
64 $XFS_IO_PROG -f -c "fpunch $((blksz - 17)) $((blksz + 17))" $testdir/file2
65 _test_cycle_mount
66
67 echo "Compare files"
68 md5sum $testdir/file1 | _filter_test_dir
69 md5sum $testdir/file2 | _filter_test_dir
70 md5sum $testdir/file2.chk | _filter_test_dir
71
72 c1=$(_md5_checksum $testdir/file1)
73 c2=$(_md5_checksum $testdir/file2)
74
75 test ${c1} != ${c2} || echo "file1 and file2 should not match"
76
77 echo "Compare against check files"
78 cmp -s $testdir/file2 $testdir/file2.chk || echo "file2 and file2.chk do not match"
79
80 # success, all done
81 status=0
82 exit