xfstests: convert tests to use new results directory
[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 seqres=$RESULT_DIR/$seq
38 seqres=$RESULT_DIR/$seq
39 echo "QA output created by $seq"
40
41 here=`pwd`
42 tmp=/tmp/$$
43 status=0        # success is the default!
44 trap "_cleanup; exit \$status" 0 1 2 3 15
45
46 _cleanup()
47 {
48     cd $testdir
49     rm -f symlink_{0,1,2,3,4}{0,1,2,3,4,5,6,7,8,9} symlink_self empty_file
50     cd /
51     _cleanup_testdir
52 }
53
54 _touch()
55 {
56     # On IRIX: Too many symbolic links in path name traversal
57     # On Linux: Too many levels of symbolic links
58     touch $@ 2>&1 | grep -q 'Too many.*symbolic links'
59     if [ $? -eq 0 ]; then
60         echo "ELOOP returned.  Good."
61     else
62         echo "No ELOOP?  Unexpected!"
63     fi
64 }
65
66 # get standard environment, filters and checks
67 . ./common.rc
68 . ./common.filter
69
70 # real QA test starts here
71 _supported_fs generic
72
73 # IRIX UDF does not support symlinks
74 if [ $FSTYP == 'udf' ]; then
75     _supported_os Linux
76 else
77     _supported_os Linux IRIX
78 fi
79
80 _setup_testdir
81
82 cd $testdir
83
84 o=empty_file
85 touch $o
86 for f in symlink_{0,1,2,3,4}{0,1,2,3,4,5,6,7,8,9}
87 do
88     ln -s $o $f
89     o=$f
90 done
91
92 ln -s symlink_self symlink_self
93
94 echo "*** touch deep symlinks"
95 echo ""
96 _touch symlink_{0,1,2,3,4}{0,1,2,3,4,5,6,7,8,9}
97 echo ""
98 echo "*** touch recusive symlinks"
99 echo ""
100 _touch symlink_self
101
102 exit