generic: add test for boundary in xfs_attr_shortform_verify
[xfstests-dev.git] / tests / generic / 253
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
4 #
5 # FS QA Test No. 253
6 #
7 # Truncate a file at midway through a CoW region.
8 #
9 # This test is dependent on the system page size, so we cannot use md5 in
10 # the golden output; we can only compare to a check file.
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.*
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_scratch_reflink
35 _require_cp_reflink
36 _require_xfs_io_command "truncate"
37
38 rm -f $seqres.full
39
40
41 echo "Format and mount"
42 _scratch_mkfs > $seqres.full 2>&1
43 _scratch_mount >> $seqres.full 2>&1
44
45 testdir=$SCRATCH_MNT/test-$seq
46 mkdir $testdir
47
48 blksz=65536
49 nr=4
50 filesize=$((blksz * nr))
51
52 echo "Create the original files"
53 _pwrite_byte 0x61 0 $filesize $testdir/file1 >> $seqres.full
54 _cp_reflink $testdir/file1 $testdir/file2 >> $seqres.full
55 _pwrite_byte 0x61 0 $filesize $testdir/file2.chk >> $seqres.full
56 _scratch_cycle_mount
57
58 echo "Compare files"
59 md5sum $testdir/file1 | _filter_scratch
60 md5sum $testdir/file2 | _filter_scratch
61 md5sum $testdir/file2.chk | _filter_scratch
62
63 echo "CoW and unmount"
64 $XFS_IO_PROG -f -c "pwrite -S 0x62 -b $((blksz * 2)) $blksz $((blksz * 2))" -c "truncate $((blksz * 2))" $testdir/file2 >> $seqres.full
65 _scratch_cycle_mount
66 $XFS_IO_PROG -f -c "pwrite -S 0x62 -b $((blksz * 2)) $blksz $((blksz * 2))" -c "truncate $((blksz * 2))" $testdir/file2.chk >> $seqres.full
67 _scratch_cycle_mount
68
69 echo "Compare files"
70 md5sum $testdir/file1 | _filter_scratch
71 md5sum $testdir/file2 | _filter_scratch
72 md5sum $testdir/file2.chk | _filter_scratch
73
74 # success, all done
75 status=0
76 exit