fstests: use _require_symlinks on all necessary tests
[xfstests-dev.git] / tests / generic / 411
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016 Red Hat Inc.  All Rights Reserved.
4 #
5 # FS QA Test 411
6 #
7 # This test cover linux commit 7ae8fd0, kernel two mnt_group_id == 0
8 # (no peer)vfsmount as peers. It case kernel dereference a NULL
9 # address.
10 #
11 seq=`basename $0`
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
14
15 here=`pwd`
16 tmp=/tmp/$$
17 status=1        # failure is the default!
18 trap "_cleanup; exit \$status" 0 1 2 3 15
19
20 _cleanup()
21 {
22         cd /
23         rm -f $tmp.*
24         _clear_mount_stack
25         # make sure there's no bug cause dentry isn't be freed
26         rm -rf $MNTHEAD
27 }
28
29 # get standard environment, filters and checks
30 . ./common/rc
31 . ./common/filter
32
33 # remove previous $seqres.full before test
34 rm -f $seqres.full
35
36 # real QA test starts here
37 _supported_fs generic
38 _supported_os Linux
39 _require_test
40 _require_scratch
41 _require_local_device $SCRATCH_DEV
42
43 fs_stress()
44 {
45         local target=$1
46
47         $FSSTRESS_PROG -z -n 500 -p 5 \
48                        -f creat=5 \
49                        -f mkdir=5 \
50                        -f dwrite=1 \
51                        -f dread=1 \
52                        -f link=2 \
53                        -f rename=1 \
54                        -f rmdir=2 \
55                        -f unlink=1 \
56                        -f symlink=1 \
57                        -f write=1 \
58                        -f read=1 \
59                        -f chown=1 \
60                        -f getdents=1 \
61                        -f fiemap=1 \
62                        -d $target >/dev/null
63         sync
64 }
65
66 # prepare some mountpoint dir
67 MNTHEAD=$TEST_DIR/$seq
68 rm -rf $MNTHEAD
69 mkdir $MNTHEAD 2>>$seqres.full
70 mpA=$MNTHEAD/"$$"_mpA
71 mpB=$MNTHEAD/"$$"_mpB
72 mpC=$MNTHEAD/"$$"_mpC
73
74 find_mnt()
75 {
76         echo "------"
77         findmnt -n -o TARGET,SOURCE $SCRATCH_DEV | \
78                 sed -e "s;$mpA;mpA;g" \
79                     -e "s;$mpB;mpB;g" \
80                     -e "s;$mpC;mpC;g" | \
81                 _filter_spaces | _filter_testdir_and_scratch | sort
82         echo "======"
83 }
84
85 start_test()
86 {
87         local type=$1
88
89         _scratch_mkfs >$seqres.full 2>&1
90         _get_mount -t $FSTYP $SCRATCH_DEV $MNTHEAD
91         $MOUNT_PROG --make-"${type}" $MNTHEAD
92         mkdir $mpA $mpB $mpC
93 }
94
95 end_test()
96 {
97         _clear_mount_stack
98         rm -rf $mpA $mpB $mpC
99 }
100
101 #
102 #            shared            New FS           shared
103 #      -----------------------[A/mnt1]----------------------
104 #     |                           |                         |
105 #     |                bind       |    bind                 |       New FS
106 # [C/mnt1]--[slave C]<------[shared A]------>[slave B]--[B/mnt1]--[B/mnt1/mnt2]
107 #
108 crash_test()
109 {
110         start_test shared
111
112         _get_mount -t $FSTYP $SCRATCH_DEV $mpA
113         mkdir $mpA/mnt1
114         $MOUNT_PROG --make-shared $mpA
115         _get_mount --bind $mpA $mpB
116         _get_mount --bind $mpA $mpC
117         $MOUNT_PROG --make-slave $mpB
118         $MOUNT_PROG --make-slave $mpC
119         _get_mount -t $FSTYP $SCRATCH_DEV $mpA/mnt1
120         mkdir $mpA/mnt1/mnt2
121
122         _get_mount -t $FSTYP $SCRATCH_DEV $mpB/mnt1/mnt2
123         find_mnt
124         fs_stress $mpB/mnt1/mnt2
125
126         end_test
127         echo "crash test passed"
128 }
129
130 crash_test
131
132 # success, all done
133 status=0
134 exit