overlay: run unionmount testsuite test cases
[xfstests-dev.git] / tests / generic / 505
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2018 Huawei.  All Rights Reserved.
4 #
5 # FS QA Test 505
6 #
7 # This testcase is trying to test recovery flow of generic filesystem, w/ below
8 # steps, once uid or gid changes, after we fsync that file, we can expect that
9 # uid/gid can be recovered after sudden power-cuts.
10 # 1. touch testfile;
11 # 1.1 sync (optional)
12 # 2. chown 100 testfile;
13 # 3. chgrp 100 testfile;
14 # 4. xfs_io -f testfile -c "fsync";
15 # 5. godown;
16 # 6. umount;
17 # 7. mount;
18 # 8. check uid/gid
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         cd /
32         rm -f $tmp.*
33 }
34
35 # get standard environment, filters and checks
36 . ./common/rc
37 . ./common/filter
38
39 # remove previous $seqres.full before test
40 rm -f $seqres.full
41
42 # real QA test starts here
43 _supported_fs generic
44 _supported_os Linux
45
46 _require_scratch
47 _require_scratch_shutdown
48
49 _scratch_mkfs >/dev/null 2>&1
50 _require_metadata_journaling $SCRATCH_DEV
51
52 testfile=$SCRATCH_MNT/testfile
53 stat_opt='-c "uid: %u, gid: %g"'
54
55 do_check()
56 {
57         _scratch_mount
58
59         touch $testfile
60
61         if [ "$1" == "sync" ]; then
62                 sync
63         fi
64
65         chown 100 $testfile
66         chgrp 100 $testfile
67
68         before=`stat "$stat_opt" $testfile`
69
70         $XFS_IO_PROG -f $testfile -c "fsync" | _filter_xfs_io
71
72         _scratch_shutdown | tee -a $seqres.full
73         _scratch_cycle_mount
74
75         after=`stat "$stat_opt" $testfile`
76
77         # check inode's uid/gid
78         if [ "$before" != "$after" ]; then
79                 echo "Before: $before"
80                 echo "After : $after"
81         fi
82         echo "Before: $before" >> $seqres.full
83         echo "After : $after" >> $seqres.full
84
85         rm $testfile
86         _scratch_unmount
87 }
88
89 echo "Silence is golden"
90 do_check
91 do_check sync
92
93 status=0
94 exit