blob: e6822dff1023915648ebe804f67e61fb1574e743 [file] [log] [blame]
Rob Landleyc008c742006-05-05 21:07:41 +00001#!/bin/sh
2
3# Readlink tests.
4# Copyright 2006 by Natanael Copa <n@tanael.org>
5# Licensed under GPL v2, see file LICENSE for details.
6
Mike Frysingercaa79402009-11-04 18:41:22 -05007. ./testing.sh
Rob Landleyc008c742006-05-05 21:07:41 +00008
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" "" ""
Rob Landley42bd9872006-05-05 22:22:30 +000021
22optional FEATURE_READLINK_FOLLOW
23
Rob Landleyc008c742006-05-05 21:07:41 +000024testing "readlink -f on a file" "readlink -f ./$TESTFILE" "$PWD/$TESTFILE\n" "" ""
25testing "readlink -f on a link" "readlink -f ./$TESTLINK" "$PWD/$TESTFILE\n" "" ""
26testing "readlink -f on an invalid link" "readlink -f ./$FAILLINK" "" "" ""
27testing "readlink -f on a wierd dir" "readlink -f $TESTDIR/../$TESTFILE" "$PWD/$TESTFILE\n" "" ""
28
29
30# clean up
Denis Vlasenko9213a9e2006-09-17 16:28:10 +000031rm -r "$TESTLINK" "$TESTDIR"
Rob Landleyc008c742006-05-05 21:07:41 +000032