xfs/{263,106}: erase max warnings printout
[xfstests-dev.git] / tests / generic / 535
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2019 Huawei.  All Rights Reserved.
4 #
5 # FS QA Test 535
6 #
7 # This testcase is trying to test recovery flow of generic filesystem,
8 # w/ below steps, once i_mode changes, after we fsync that file, we can
9 # expect that i_mode can be recovered after sudden power-cuts.
10 # 1. touch testfile or mkdir testdir
11 # 2. chmod 777 testfile/testdir
12 # 3. sync
13 # 4. chmod 755 testfile/testdir
14 # 5. fsync testfile/testdir
15 # 6. record last i_mode
16 # 7. flakey drop
17 # 8. remount
18 # 9. check i_mode
19 #
20 seq=`basename $0`
21 seqres=$RESULT_DIR/$seq
22 echo "QA output created by $seq"
23
24 here=`pwd`
25 tmp=/tmp/$$
26 status=1        # failure is the default!
27 trap "_cleanup; exit \$status" 0 1 2 3 15
28
29 _cleanup()
30 {
31         _cleanup_flakey
32         cd /
33         rm -f $tmp.*
34 }
35
36 # get standard environment, filters and checks
37 . ./common/rc
38 . ./common/filter
39 . ./common/dmflakey
40
41 # remove previous $seqres.full before test
42 rm -f $seqres.full
43
44 # real QA test starts here
45 _supported_fs generic
46 _supported_os Linux
47
48 _require_scratch
49 _require_dm_target flakey
50
51 _scratch_mkfs >/dev/null 2>&1
52 _require_metadata_journaling $SCRATCH_DEV
53 _init_flakey
54
55 testfile=$SCRATCH_MNT/testfile
56 testdir=$SCRATCH_MNT/testdir
57
58 do_check()
59 {
60         local target=$1
61         local is_dir=$2
62
63         _mount_flakey
64
65         if [ $is_dir = 1 ]; then
66                 mkdir $target
67         else
68                 touch $target
69         fi
70
71         echo "Test chmod $target" >> $seqres.full
72
73         chmod 777 $target
74         sync
75
76         chmod 755 $target
77         $XFS_IO_PROG $target -c "fsync"
78
79         local before=`stat -c %a $target`
80
81         _flakey_drop_and_remount
82
83         local after=`stat -c %a $target`
84
85         # check inode's i_mode
86         if [ "$before" != "$after" ]; then
87                 echo "Before: $before"
88                 echo "After : $after"
89         fi
90
91         if [ $is_dir = 1 ]; then
92                 rmdir $target
93         else
94                 rm -f $target
95         fi
96         _unmount_flakey
97 }
98
99 echo "Silence is golden"
100
101 do_check $testfile 0
102 do_check $testdir 1
103
104 status=0
105 exit