generic/395: remove workarounds for wrong error codes
[xfstests-dev.git] / tests / generic / 414
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 Oracle, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 414
6 #
7 # Check that reflinking adjacent blocks in a file produces a single
8 # block mapping extent.
9 #
10 seq=`basename $0`
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
13
14 here=`pwd`
15 tmp=/tmp/$$
16 status=1        # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 7 15
18
19 _cleanup()
20 {
21         cd /
22         rm -rf $tmp.*
23         wait
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_fs generic
33 _require_scratch_reflink
34 _require_xfs_io_command "falloc"
35 _require_xfs_io_command "fiemap"
36
37 echo "Format and mount"
38 _scratch_mkfs > $seqres.full 2>&1
39 _scratch_mount >> $seqres.full 2>&1
40
41 testdir=$SCRATCH_MNT/test-$seq
42 mkdir $testdir
43
44 blocks=32
45 blksz=65536
46 sz=$((blocks * blksz))
47
48 echo "Create the original files"
49 $XFS_IO_PROG -f -c "falloc 0 $sz" $testdir/file1 >> $seqres.full
50 _pwrite_byte 0x61 0 $sz $testdir/file1 >> $seqres.full
51 seq 0 $blksz $((sz - blksz)) | while read offset; do
52         _reflink_range $testdir/file1 $offset $testdir/file2 $offset $blksz >> $seqres.full
53 done
54
55 echo "Compare files"
56 md5sum $testdir/file1 | _filter_scratch
57 md5sum $testdir/file2 | _filter_scratch
58
59 echo "Check extent counts"
60 f1=$(_count_extents $testdir/file1)
61 f2=$(_count_extents $testdir/file2)
62 s1=$($XFS_IO_PROG -c 'fiemap -v' $testdir/file1 | awk '{print $5}' | grep -c '0x.*[2367aAbBfF]...$')
63 s2=$($XFS_IO_PROG -c 'fiemap -v' $testdir/file2 | awk '{print $5}' | grep -c '0x.*[2367aAbBfF]...$')
64
65 # Did the fs combine the extent mappings when we made f2?
66 test $f1 -eq $f2 || echo "f1 ($f1) != f2 ($f2)"
67 test $s1 -eq $s2 || echo "s1 ($s1) != s2 ($s2)"
68 test $f1 -eq $s1 || echo "f1 ($f1) != s1 ($f1)"
69 test $f2 -eq $s2 || echo "f2 ($f2) != s2 ($f2)"
70
71 _scratch_cycle_mount
72
73 echo "Compare files after remounting"
74 md5sum $testdir/file1 | _filter_scratch
75 md5sum $testdir/file2 | _filter_scratch
76
77 echo "Check extent counts"
78 f1=$(_count_extents $testdir/file1)
79 f2=$(_count_extents $testdir/file2)
80 s1=$($XFS_IO_PROG -c 'fiemap -v' $testdir/file1 | awk '{print $5}' | grep -c '0x.*[2367aAbBfF]...$')
81 s2=$($XFS_IO_PROG -c 'fiemap -v' $testdir/file2 | awk '{print $5}' | grep -c '0x.*[2367aAbBfF]...$')
82
83 # Are the mappings still combined?
84 test $f1 -eq $f2 || echo "f1 ($f1) != f2 ($f2)"
85 test $s1 -eq $s2 || echo "s1 ($s1) != s2 ($s2)"
86 test $f1 -eq $s1 || echo "f1 ($f1) != s1 ($f1)"
87 test $f2 -eq $s2 || echo "f2 ($f2) != s2 ($f2)"
88
89 # success, all done
90 status=0
91 exit