generic: add test for boundary in xfs_attr_shortform_verify
[xfstests-dev.git] / tests / generic / 466
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017, Oracle and/or its affiliates.  All Rights Reserved.
4 #
5 # FS QA Test No. 466
6 #
7 # Check that high-offset reads and writes work.
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 -f $tmp.*
22 }
23
24 # get standard environment, filters and checks
25 . ./common/rc
26 . ./common/filter
27
28 # real QA test starts here
29 _supported_os Linux
30 _supported_fs generic
31 _require_scratch_nocheck
32 _require_block_device $SCRATCH_DEV
33
34 rm -f $seqres.full
35
36 echo "Silence is golden"
37
38 # clear MKFS_OPTIONS which may contain user specified block size value, and
39 # _scratch_mkfs_sized will always use that value to create filesystem.
40 unset MKFS_OPTIONS
41
42 echo "Starting test" > $seqres.full
43 devsize=$(blockdev --getsize64 $SCRATCH_DEV)
44 for blocksize in 512 1024 2048 4096 8192 16384 32768 65536; do
45         echo "+ Format blocksize $blocksize and mount" >> $seqres.full
46         _scratch_unmount > /dev/null 2>&1
47         # Try to format and mount with the given blocksize.  If they don't
48         # succeed, move on to the next block size.
49         if ! _scratch_mkfs_sized $devsize $blocksize >> $seqres.full 2>&1 ||
50            ! _try_scratch_mount >> $seqres.full 2>&1 ||
51            test "$(stat -f -c '%S' $SCRATCH_MNT)" -ne "$blocksize"; then
52                 echo "+++ Format and mount failed" >> $seqres.full
53                 continue
54         fi
55
56         testdir=$SCRATCH_MNT/test-$seq
57         mkdir $testdir
58
59         echo "++ Create the original files" >> $seqres.full
60         bigoff=$(echo "2^63 - 2" | $BC_PROG)
61         len=$(echo "2^63 - 1" | $BC_PROG)
62         $XFS_IO_PROG -f -c "truncate $len" $testdir/file0 >> $seqres.full 2>&1
63         if [ ! -s $testdir/file0 ]; then
64                 # If we can't set a large file size then don't bother
65                 # with this blocksize because the fs doesn't support it.
66                 echo "+++ High offset ftruncate failed" >> $seqres.full
67                 continue
68         fi
69         _pwrite_byte 0x61 $bigoff 1 $testdir/file1 >> $seqres.full
70
71         echo "++ Check file creation" >> $seqres.full
72         _scratch_cycle_mount
73
74         expected="7ffffffffffffffe:  61  a"
75         actual="$($XFS_IO_PROG -c "pread -v -q $bigoff 1" $testdir/file1)"
76         if [ "$expected" = "$actual" ]; then
77                 echo "+++ Success!" >> $seqres.full
78         else
79                 echo "+++ Discrepancy @ blocksize $blocksize" >> $seqres.full
80                 echo "Discrepancy @ blocksize $blocksize"
81         fi
82
83         echo "++ Check scratchfs" >> $seqres.full
84         _check_scratch_fs
85 done
86
87 # success, all done
88 status=0
89 exit