common: kill _supported_os
[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
47 _require_scratch
48 _require_dm_target flakey
49
50 _scratch_mkfs >/dev/null 2>&1
51 _require_metadata_journaling $SCRATCH_DEV
52 _init_flakey
53
54 testfile=$SCRATCH_MNT/testfile
55 testdir=$SCRATCH_MNT/testdir
56
57 do_check()
58 {
59         local target=$1
60         local is_dir=$2
61
62         _mount_flakey
63
64         if [ $is_dir = 1 ]; then
65                 mkdir $target
66         else
67                 touch $target
68         fi
69
70         echo "Test chmod $target" >> $seqres.full
71
72         chmod 777 $target
73         sync
74
75         chmod 755 $target
76         $XFS_IO_PROG $target -c "fsync"
77
78         local before=`stat -c %a $target`
79
80         _flakey_drop_and_remount
81
82         local after=`stat -c %a $target`
83
84         # check inode's i_mode
85         if [ "$before" != "$after" ]; then
86                 echo "Before: $before"
87                 echo "After : $after"
88         fi
89
90         if [ $is_dir = 1 ]; then
91                 rmdir $target
92         else
93                 rm -f $target
94         fi
95         _unmount_flakey
96 }
97
98 echo "Silence is golden"
99
100 do_check $testfile 0
101 do_check $testdir 1
102
103 status=0
104 exit