generic/395: remove workarounds for wrong error codes
[xfstests-dev.git] / tests / generic / 067
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015 Red Hat Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 067
6 #
7 # Some random mount/umount corner case tests
8 #
9 # - mount at a nonexistent mount point
10 # - mount a free loop device
11 # - mount with a wrong fs type specified
12 # - umount an symlink to device which is not mounted
13 # - umount a path with too long name
14 # - lazy umount a symlink
15 #
16 seq=`basename $0`
17 seqres=$RESULT_DIR/$seq
18 echo "QA output created by $seq"
19
20 here=`pwd`
21 tmp=/tmp/$$
22 status=1        # failure is the default!
23 trap "_cleanup; exit \$status" 0 1 2 3 15
24
25 _cleanup()
26 {
27         cd /
28         rm -f $tmp.*
29 }
30
31 # get standard environment, filters and checks
32 . ./common/rc
33 . ./common/filter
34
35 # real QA test starts here
36
37 # Modify as appropriate.
38 _supported_fs generic
39 _require_symlinks
40 _require_test
41 _require_scratch
42 _require_loop
43 _require_block_device $SCRATCH_DEV
44
45 rm -f $seqres.full
46
47 _scratch_mkfs >>$seqres.full 2>&1
48
49 # kernel should not hang nor oops when mounting fs to nonexistent mount point
50 mount_nonexistent_mnt()
51 {
52         echo "# mount to nonexistent mount point" >>$seqres.full
53         rm -rf $TEST_DIR/nosuchdir
54         $MOUNT_PROG $SCRATCH_DEV $TEST_DIR/nosuchdir >>$seqres.full 2>&1
55 }
56
57 # fs driver should be able to handle mounting a free loop device gracefully
58 # xfs ever hung, "ec53d1d xfs: don't block on buffer read errors" fixed it
59 mount_free_loopdev()
60 {
61         echo "# mount a free loop device" >>$seqres.full
62         loopdev=`losetup -f`
63         $MOUNT_PROG -t $FSTYP $loopdev $SCRATCH_MNT >>$seqres.full 2>&1
64 }
65
66 # mount with wrong fs type specified.
67 # This should fail gracefully, no hang no oops are expected
68 mount_wrong_fstype()
69 {
70         local fs=ext4
71         if [ "$FSTYP" == "ext4" ]; then
72                 fs=xfs
73         fi
74         echo "# mount with wrong fs type" >>$seqres.full
75         $MOUNT_PROG -t $fs $SCRATCH_DEV $SCRATCH_MNT >>$seqres.full 2>&1
76 }
77
78 # umount a symlink to device, which is not mounted.
79 # This should fail gracefully, no hang no oops are expected
80 umount_symlink_device()
81 {
82         local symlink=$TEST_DIR/$seq.scratch_dev_symlink
83         rm -f $symlink
84         echo "# umount symlink to device, which is not mounted" >>$seqres.full
85         ln -s $SCRATCH_DEV $symlink
86         $UMOUNT_PROG $symlink >>$seqres.full 2>&1
87 }
88
89 # umount a path name that is 256 bytes long, this should fail gracefully,
90 # and the following umount should not hang nor oops
91 umount_toolong_name()
92 {
93         local longname=$SCRATCH_MNT/`$PERL_PROG -e 'print "a"x256;'`
94
95         _scratch_mount 2>&1 | tee -a $seqres.full
96
97         echo "# umount a too-long name" >>$seqres.full
98         $UMOUNT_PROG $longname >>$seqres.full 2>&1
99         _scratch_unmount 2>&1 | tee -a $seqres.full
100 }
101
102 # lazy umount a symlink should not block following umount.
103 # This is the test case described in https://lkml.org/lkml/2014/7/21/98
104 lazy_umount_symlink()
105 {
106         local symlink=$SCRATCH_MNT/$seq.testdir_symlink
107         echo "# lazy umount a symlink" >>$seqres.full
108         _scratch_mount 2>&1 | tee -a $seqres.full
109         mkdir -p $SCRATCH_MNT/testdir
110         rm -f $symlink
111         ln -s $SCRATCH_MNT/testdir $symlink
112
113         $UMOUNT_PROG -l $symlink >>$seqres.full 2>&1
114         # _scratch_unmount should not be blocked
115         _scratch_unmount 2>&1 | tee -a $seqres.full
116 }
117
118 echo "Silence is golden"
119
120 mount_nonexistent_mnt
121 mount_free_loopdev
122 mount_wrong_fstype
123
124 umount_symlink_device
125 umount_toolong_name
126 lazy_umount_symlink
127
128 status=0
129 exit