common/fuzzy: try to clear blocking flags first in _scratch_fuzz_modify
[xfstests-dev.git] / tests / generic / 169
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2007 Silicon Graphics, Inc.  All Rights Reserved.
4 #
5 # FSQA Test No. 169
6 #
7 # Test for file size consistency with append followed by umount/mount
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 rm -f $seqres.full
16 status=1    # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
18
19 _cleanup()
20 {
21         cd /
22         rm -f $tmp.*
23 }
24
25 _show_wrote_and_stat_only()
26 {
27         # filer out xfs_io bits we are interested in
28         perl -ne '
29                 if (/^wrote/) { print } ;
30                 if (/^stat\.size/) { print } ;
31         '
32 }
33
34 # get standard environment, filters and checks
35 . ./common/rc
36 . ./common/filter
37
38 # real QA test starts here
39 _supported_fs generic
40 _supported_os Linux
41
42 _require_scratch
43
44 _scratch_mkfs >>$seqres.full 2>&1 \
45         || _fail "mkfs scratch failed"
46
47 _scratch_mount
48
49 echo "# creating new file for io"
50 touch $SCRATCH_MNT/testfile
51
52 echo "# appending 15k to new file, sync every 5k"
53 $XFS_IO_PROG -a -c "pwrite 0 5k" -c "fsync" \
54         -c "pwrite 5k 5k" -c "fsync" \
55         -c "pwrite 10k 5k" -c "fsync" -c "stat" \
56         $SCRATCH_MNT/testfile \
57         | _show_wrote_and_stat_only
58
59 echo "# remounting scratch"
60 _scratch_cycle_mount >>$seqres.full 2>&1 \
61     || _fail "remount failed: $MOUNT_OPTIONS"
62
63 echo "# stating file to confirm correct size"
64 $XFS_IO_PROG -r -c "stat" $SCRATCH_MNT/testfile \
65         | _show_wrote_and_stat_only
66
67 echo "# appending 10 bytes to new file, sync at 5 bytes"
68 $XFS_IO_PROG -f -c "pwrite 0 5" -c s -c "pwrite 5 5" \
69         -c "stat" $SCRATCH_MNT/nextfile \
70         | _show_wrote_and_stat_only
71
72 echo "# remounting scratch"
73 _scratch_cycle_mount >>$seqres.full 2>&1 \
74     || _fail "remount failed: $MOUNT_OPTIONS"
75
76 echo "# stating file to confirm correct size"
77 $XFS_IO_PROG -r -c "stat" $SCRATCH_MNT/nextfile \
78     | _show_wrote_and_stat_only
79
80 # success, all done
81 status=0
82 exit
83