summaryrefslogtreecommitdiff
path: root/testsuite/readlink.tests (plain)
blob: e9d8da0fc8d6f49d8f3ced9e399c4f04b7a68ff0
1#!/bin/sh
2
3# Readlink tests.
4# Copyright 2006 by Natanael Copa <n@tanael.org>
5# Licensed under GPLv2, see file LICENSE in this source tree.
6
7. ./testing.sh
8
9TESTDIR=readlink_testdir
10TESTFILE="$TESTDIR/testfile"
11TESTLINK="testlink"
12FAILLINK="$TESTDIR/$TESTDIR/testlink"
13
14# create the dir and test files
15mkdir -p "./$TESTDIR"
16touch "./$TESTFILE"
17ln -s "./$TESTFILE" "./$TESTLINK"
18
19testing "readlink on a file" "readlink ./$TESTFILE" "" "" ""
20testing "readlink on a link" "readlink ./$TESTLINK" "./$TESTFILE\n" "" ""
21
22optional FEATURE_READLINK_FOLLOW
23
24# shell's $PWD may leave symlinks unresolved.
25# "pwd" may be a built-in and have the same problem.
26# External pwd _can't_ have that problem (current dir on Unix is physical).
27pwd=`which pwd`
28pwd=`$pwd`
29testing "readlink -f on a file" "readlink -f ./$TESTFILE" "$pwd/$TESTFILE\n" "" ""
30testing "readlink -f on a link" "readlink -f ./$TESTLINK" "$pwd/$TESTFILE\n" "" ""
31testing "readlink -f on an invalid link" "readlink -f ./$FAILLINK" "" "" ""
32testing "readlink -f on a wierd dir" "readlink -f $TESTDIR/../$TESTFILE" "$pwd/$TESTFILE\n" "" ""
33
34
35# clean up
36rm -r "$TESTLINK" "$TESTDIR"
37
38exit $((FAILCOUNT <= 255 ? FAILCOUNT : 255))
39