test-getaddrinfo: skip (don't fail) this test when there's no network
[gnulib.git] / tests / test-canonicalize.sh
1 #!/bin/sh
2
3 tmpfiles=""
4 trap 'rm -fr $tmpfiles' 1 2 3 15
5
6 tmpfiles="$tmpfiles t-can.tmp ise"
7 mkdir t-can.tmp
8 ln -s t-can.tmp/ket ise \
9   || { echo "Skipping test: symbolic links not supported on this filesystem"
10        rm -fr $tmpfiles
11        exit 77
12      }
13 (cd t-can.tmp \
14  && ln -s bef plo \
15  && ln -s tra huk \
16  && ln -s lum bef \
17  && ln -s wum ouk \
18  && ln -s ../ise ket \
19  && echo > tra \
20  && mkdir lum
21 ) || exit 1
22
23 # Trigger a bug that would make the function mistakenly report a loop.
24 # To trigger it, we have to construct a name/situation during the
25 # resolution of which the code dereferences the same symlink (S)
26 # two different times with no actual loop.  In addition, the
27 # second and fourth calls to readlink must operate on S.
28 (cd t-can.tmp \
29  && ln -s s p \
30  && ln -s d s \
31  && mkdir d \
32  && echo > d/2 \
33  && ln -s ../s/2 d/1
34 ) || exit 1
35
36 ./test-canonicalize${EXEEXT}
37 result=$?
38
39 rm -fr $tmpfiles
40
41 exit $result