2 # tests for canonicalize mode (readlink -f).
4 # Copyright (C) 2004 Free Software Foundation, Inc.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 if test "$VERBOSE" = yes; then
27 t0=`echo "$0" |sed 's,.*/,,'`.tmp; tmp=$t0/$$
28 trap 'status=$?; cd $pwd; chmod -R u+rwx $t0; rm -rf $t0 && exit $status' 0
29 trap 'status=$?; (exit $status); exit $status' 1 2 13 15
33 bindir=`cd ../../src; pwd`|| break
34 my_pwd=`$bindir/pwd` || break
36 mkdir -p $tmp || break
39 mkdir subdir removed || break
40 touch regfile || break
42 ln -s regfile link1 || break
43 ln -s subdir link2 || break
44 ln -s missing link3 || break
45 ln -s subdir/missing link4 || break
51 if test $fail = 1; then
52 echo "$0: failure in testing framework" 1>&2
58 cd "$pwd/$tmp/removed" || break
60 # Skip this test if the system doesn't let you remove the working directory.
61 if rmdir ../removed 2>/dev/null; then
62 v=`readlink -f .` && break
66 cd "$pwd/$tmp" || break
72 if test $fail = 1; then
73 (exit $fail); exit $fail
76 for p in "" "$pwd/$tmp/"; do
79 v=`readlink -f ${p}regfile` || break
80 test "$v" = "$my_pwd/$tmp/regfile" || break
82 v=`readlink -f ${p}./regfile/` && break
85 v=`readlink -f ${p}regfile/more` && break
88 v=`readlink -f ${p}./regfile/more/` && break
91 v=`readlink -f ${p}subdir` || break
92 test "$v" = "$my_pwd/$tmp/subdir" || break
94 v=`readlink -f ${p}./subdir/` || break
95 test "$v" = "$my_pwd/$tmp/subdir" || break
97 v=`readlink -f ${p}subdir/more` || break
98 test "$v" = "$my_pwd/$tmp/subdir/more" || break
100 v=`readlink -f ${p}./subdir/more/` && break
101 test -z "$v" || break
103 v=`readlink -f ${p}missing` || break
104 test "$v" = "$my_pwd/$tmp/missing" || break
106 v=`readlink -f ${p}./missing/` && break
107 test -z "$v" || break
109 v=`readlink -f ${p}missing/more` && break
110 test -z "$v" || break
112 v=`readlink -f ${p}./missing/more/` && break
113 test -z "$v" || break
115 v=`readlink -f ${p}link1` || break
116 test "$v" = "$my_pwd/$tmp/regfile" || break
118 v=`readlink -f ${p}./link1/` && break
119 test -z "$v" || break
121 v=`readlink -f ${p}link1/more` && break
122 test -z "$v" || break
124 v=`readlink -f ${p}./link1/more/` && break
125 test -z "$v" || break
127 v=`readlink -f ${p}link2` || break
128 test "$v" = "$my_pwd/$tmp/subdir" || break
130 v=`readlink -f ${p}./link2/` || break
131 test "$v" = "$my_pwd/$tmp/subdir" || break
133 v=`readlink -f ${p}link2/more` || break
134 test "$v" = "$my_pwd/$tmp/subdir/more" || break
136 v=`readlink -f ${p}./link2/more/` && break
137 test -z "$v" || break
139 v=`readlink -f ${p}link2/more/more2` && break
140 test -z "$v" || break
142 v=`readlink -f ${p}./link2/more/more2/` && break
143 test -z "$v" || break
145 v=`readlink -f ${p}link3` || break
146 test "$v" = "$my_pwd/$tmp/missing" || break
148 v=`readlink -f ${p}./link3/` && break
149 test -z "$v" || break
151 v=`readlink -f ${p}link3/more` && break
152 test -z "$v" || break
154 v=`readlink -f ${p}./link3/more/` && break
155 test -z "$v" || break
157 v=`readlink -f ${p}link4` || break
158 test "$v" = "$my_pwd/$tmp/subdir/missing" || break
160 v=`readlink -f ${p}./link4/` && break
161 test -z "$v" || break
163 v=`readlink -f ${p}link4/more` && break
164 test -z "$v" || break
169 (exit $fail); exit $fail