aboutsummaryrefslogtreecommitdiff
path: root/scripts/test/readlink.test
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2007-12-15 22:05:42 -0600
committerRob Landley <rob@landley.net>2007-12-15 22:05:42 -0600
commitb4ed76279fb4de3e94fee55ac31e1c99b0745ad6 (patch)
tree47d6955b3fd3ee153a707e236195f63e01ffae52 /scripts/test/readlink.test
parentbc07865a504c291b9c88e41b3481ee6b44334b4d (diff)
downloadtoybox-b4ed76279fb4de3e94fee55ac31e1c99b0745ad6.tar.gz
Basic tests for readlink.
Diffstat (limited to 'scripts/test/readlink.test')
-rwxr-xr-xscripts/test/readlink.test31
1 files changed, 31 insertions, 0 deletions
diff --git a/scripts/test/readlink.test b/scripts/test/readlink.test
new file mode 100755
index 00000000..db39e423
--- /dev/null
+++ b/scripts/test/readlink.test
@@ -0,0 +1,31 @@
+#!/bin/bash
+
+[ -f testing.sh ] && . testing.sh
+
+#testing "name" "command" "result" "infile" "stdin"
+
+testing "readlink missing" "readlink notfound || echo yes" "yes\n" "" ""
+
+touch file
+testing "readlink file" "readlink file || echo yes" "yes\n" "" ""
+testing "readlink -f dir" "readlink -f ." "$(pwd)\n" "" ""
+testing "readlink -f missing" "readlink -f notfound" "$(pwd)/notfound\n" "" ""
+
+ln -s notfound link
+testing "readlink link" "readlink link" "notfound\n" "" ""
+testing "readlink link->missing" "readlink -f link" "$(pwd)/notfound\n" "" ""
+ln -sf file link
+testing "readlink -f link->file" "readlink -f link" "$(pwd)/file\n" "" ""
+ln -sf . link
+testing "readlink -f link->dir" "readlink -f link" "$(pwd)\n" "" ""
+ln -snf link link
+testing "readlink link->link (recursive)" "readlink link" "link\n" "" ""
+testing "readlink -f link->link (recursive)" "readlink -f link || echo yes" \
+ "yes\n" "" ""
+rm file link
+
+ln -s link1 link2
+ln -s link2 link1
+testing "readlink follow recursive2" "readlink -f link1 || echo yes" \
+ "yes\n" "" ""
+rm link1 link2