d78e43fbd301a989b1bcc00f74fbd7d8797cf955
[xfstests-dev.git] / tests / generic / 005
1 #! /bin/bash
2 # FS QA Test No. 005
3 #
4 # Test symlinks & ELOOP
5 #
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2000-2004 Silicon Graphics, Inc.  All Rights Reserved.
8 #
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation.
12 #
13 # This program is distributed in the hope that it would be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write the Free Software Foundation,
20 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21 #
22 #-----------------------------------------------------------------------
23 #
24
25 #
26 # Note1: On Linux, ELOOP limit used to be 32 but changed to 8, and lately
27 # its become 5.  Who knows what it might be next.
28 # Note2: On IRIX, the limit is around the 30 mark.
29
30 # What we are looking for here is: no panic due to blowing the stack;
31 # and that the ELOOP error code is returned at some point (the actual
32 # limit point is unimportant, just checking that we do hit it).
33
34
35 seq=`basename $0`
36 seqres=$RESULT_DIR/$seq
37 echo "QA output created by $seq"
38
39 here=`pwd`
40 tmp=/tmp/$$
41 status=0        # success is the default!
42 trap "_cleanup; exit \$status" 0 1 2 3 15
43
44 _cleanup()
45 {
46     cd $TEST_DIR
47     rm -f symlink_{0,1,2,3,4}{0,1,2,3,4,5,6,7,8,9} symlink_self empty_file
48     cd /
49 }
50
51 _touch()
52 {
53     # On IRIX: Too many symbolic links in path name traversal
54     # On Linux: Too many levels of symbolic links
55     touch $@ 2>&1 | grep -q 'Too many.*symbolic links'
56     if [ $? -eq 0 ]; then
57         echo "ELOOP returned.  Good."
58     else
59         echo "No ELOOP?  Unexpected!"
60     fi
61 }
62
63 # get standard environment, filters and checks
64 . ./common/rc
65 . ./common/filter
66
67 # real QA test starts here
68 _supported_fs generic
69 _require_test
70
71 # IRIX UDF does not support symlinks
72 if [ $FSTYP == 'udf' ]; then
73     _supported_os Linux
74 else
75     _supported_os Linux IRIX
76 fi
77
78 cd $TEST_DIR
79
80 o=empty_file
81 touch $o
82 for f in symlink_{0,1,2,3,4}{0,1,2,3,4,5,6,7,8,9}
83 do
84     ln -s $o $f
85     o=$f
86 done
87
88 ln -s symlink_self symlink_self
89
90 echo "*** touch deep symlinks"
91 echo ""
92 _touch symlink_{0,1,2,3,4}{0,1,2,3,4,5,6,7,8,9}
93 echo ""
94 echo "*** touch recusive symlinks"
95 echo ""
96 _touch symlink_self
97
98 exit