lib/: spdx license conversion
[xfstests-dev.git] / tests / generic / 178
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. 178
6 #
7 # Ensure that punch-hole doesn't clobber CoW.
8 #
9 seq=`basename $0`
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
12
13 here=`pwd`
14 tmp=/tmp/$$
15 status=1    # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
17
18 _cleanup()
19 {
20     cd /
21     rm -rf $tmp.* $testdir
22 }
23
24 # get standard environment, filters and checks
25 . ./common/rc
26 . ./common/filter
27 . ./common/reflink
28
29 # real QA test starts here
30 _supported_os Linux
31 _require_test_reflink
32 _require_cp_reflink
33 _require_xfs_io_command "fpunch"
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 nr=512
44 filesize=$((blksz * nr))
45 _pwrite_byte 0x61 0 $filesize $testdir/file1 >> $seqres.full
46
47 _cp_reflink $testdir/file1 $testdir/file2
48 _test_cycle_mount
49
50 md5sum $testdir/file1 | _filter_test_dir
51 md5sum $testdir/file2 | _filter_test_dir
52
53 echo "Write and punch"
54 _pwrite_byte 0x62 0 $((blksz * 256)) $testdir/file2 >> $seqres.full
55 $XFS_IO_PROG -f -c "fpunch $blksz $((blksz * 254))" $testdir/file2
56 _test_cycle_mount
57
58 echo "Compare results"
59 md5sum $testdir/file1 | _filter_test_dir
60 md5sum $testdir/file2 | _filter_test_dir
61
62 # success, all done
63 status=0
64 exit