2006-05-05 21:07:41 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# Readlink tests.
|
|
|
|
# Copyright 2006 by Natanael Copa <n@tanael.org>
|
2010-08-16 18:14:46 +00:00
|
|
|
# Licensed under GPLv2, see file LICENSE in this source tree.
|
2006-05-05 21:07:41 +00:00
|
|
|
|
2009-11-04 23:41:22 +00:00
|
|
|
. ./testing.sh
|
2006-05-05 21:07:41 +00:00
|
|
|
|
|
|
|
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" "" ""
|
2006-05-05 22:22:30 +00:00
|
|
|
|
|
|
|
optional FEATURE_READLINK_FOLLOW
|
|
|
|
|
2015-10-11 14:27:55 +00:00
|
|
|
# shell's $PWD may leave symlinks unresolved.
|
|
|
|
# "pwd" may be a built-in and have the same problem.
|
|
|
|
# External pwd _can't_ have that problem (current dir on Unix is physical).
|
|
|
|
pwd=`which pwd`
|
|
|
|
pwd=`$pwd`
|
|
|
|
testing "readlink -f on a file" "readlink -f ./$TESTFILE" "$pwd/$TESTFILE\n" "" ""
|
|
|
|
testing "readlink -f on a link" "readlink -f ./$TESTLINK" "$pwd/$TESTFILE\n" "" ""
|
2006-05-05 21:07:41 +00:00
|
|
|
testing "readlink -f on an invalid link" "readlink -f ./$FAILLINK" "" "" ""
|
2015-10-11 14:27:55 +00:00
|
|
|
testing "readlink -f on a wierd dir" "readlink -f $TESTDIR/../$TESTFILE" "$pwd/$TESTFILE\n" "" ""
|
2006-05-05 21:07:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
# clean up
|
2006-09-17 16:28:10 +00:00
|
|
|
rm -r "$TESTLINK" "$TESTDIR"
|
2010-08-29 02:47:03 +00:00
|
|
|
|
|
|
|
exit $((FAILCOUNT <= 255 ? FAILCOUNT : 255))
|