fstests: filter readonly mount error messages
[xfstests-dev.git] / tests / overlay / 035
1 #! /bin/bash
2 # FS QA Test 035
3 #
4 # Test cases that force read-only mount
5 #
6 # - No upper dir
7 # - Failure to create work dir
8 #
9 #-----------------------------------------------------------------------
10 # Copyright (C) 2017 CTERA Networks. All Rights Reserved.
11 # Author: Amir Goldstein <amir73il@gmail.com>
12 #
13 # This program is free software; you can redistribute it and/or
14 # modify it under the terms of the GNU General Public License as
15 # published by the Free Software Foundation.
16 #
17 # This program is distributed in the hope that it would be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 # GNU General Public License for more details.
21 #
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write the Free Software Foundation,
24 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
25 #-----------------------------------------------------------------------
26 #
27
28 seq=`basename $0`
29 seqres=$RESULT_DIR/$seq
30 echo "QA output created by $seq"
31
32 here=`pwd`
33 tmp=/tmp/$$
34 status=1        # failure is the default!
35 trap "_cleanup; exit \$status" 0 1 2 3 15
36
37 _cleanup()
38 {
39         cd /
40         $CHATTR_PROG -i $workdir
41         rm -f $tmp.*
42 }
43
44 # get standard environment, filters and checks
45 . ./common/rc
46 . ./common/filter
47
48 # remove previous $seqres.full before test
49 rm -f $seqres.full
50
51 # real QA test starts here
52 _supported_fs overlay
53 _supported_os Linux
54 _require_scratch
55 _require_chattr i
56
57 # Remove all files from previous tests
58 _scratch_mkfs
59
60 # Create multiple lowerdirs and upperdir, workdir
61 lowerdir1=$OVL_BASE_SCRATCH_MNT/lower1
62 lowerdir2=$OVL_BASE_SCRATCH_MNT/lower2
63 upperdir=$OVL_BASE_SCRATCH_MNT/upper
64 workdir=$OVL_BASE_SCRATCH_MNT/workdir
65 mkdir -p $lowerdir1 $lowerdir2 $upperdir $workdir
66
67 # Mount overlay with lower layers only.
68 # Verify that overlay is mounted read-only and that it cannot be remounted rw.
69 $MOUNT_PROG -t overlay -o"lowerdir=$lowerdir2:$lowerdir1" \
70                         $OVL_BASE_SCRATCH_MNT $SCRATCH_MNT
71 touch $SCRATCH_MNT/foo 2>&1 | _filter_scratch
72 _scratch_remount rw 2>&1 | _filter_ro_mount
73 $UMOUNT_PROG $SCRATCH_MNT
74
75 # Make workdir immutable to prevent workdir re-create on mount
76 $CHATTR_PROG +i $workdir
77
78 # Mount overlay with upper and workdir and expect failure to re-create workdir.
79 # Verify that overlay is mounted read-only and that it cannot be remounted rw.
80 _overlay_scratch_mount_dirs $lowerdir2 $upperdir $workdir
81 touch $SCRATCH_MNT/bar 2>&1 | _filter_scratch
82 _scratch_remount rw 2>&1 | _filter_ro_mount
83
84 # success, all done
85 status=0
86 exit