summaryrefslogtreecommitdiff
path: root/testsuite/readlink.tests
blob: 73163b0778da915c47a2b79b9c67765dc3a714c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/sh

# Readlink tests.
# Copyright 2006 by Natanael Copa <n@tanael.org>
# Licensed under GPLv2, see file LICENSE in this source tree.

. ./testing.sh

TESTDIR=readlink_testdir
TESTFILE="$TESTDIR/testfile"
TESTLINK="testlink"
FAILLINK="$TESTDIR/$TESTDIR/testlink"

# create the dir and test files
mkdir -p "./$TESTDIR"
touch "./$TESTFILE"
ln -s "./$TESTFILE" "./$TESTLINK"

testing "readlink on a file" "readlink ./$TESTFILE" "" "" ""
testing "readlink on a link" "readlink ./$TESTLINK" "./$TESTFILE\n" "" ""

optional FEATURE_READLINK_FOLLOW

testing "readlink -f on a file" "readlink -f ./$TESTFILE" "$PWD/$TESTFILE\n" "" ""
testing "readlink -f on a link" "readlink -f ./$TESTLINK" "$PWD/$TESTFILE\n" "" ""
testing "readlink -f on an invalid link" "readlink -f ./$FAILLINK" "" "" ""
testing "readlink -f on a wierd dir" "readlink -f $TESTDIR/../$TESTFILE" "$PWD/$TESTFILE\n" "" ""


# clean up
rm -r "$TESTLINK" "$TESTDIR"