aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2007-12-16 18:02:44 -0600
committerRob Landley <rob@landley.net>2007-12-16 18:02:44 -0600
commite25e8b5fbb55e5ae549eb13b0c6dd7c560e22b0c (patch)
treeef0391bb0d375b0146c94cb436a47cb2cf41a740 /scripts
parent03a94509e47d9e194324f50f0feba81f2d4328ae (diff)
downloadtoybox-e25e8b5fbb55e5ae549eb13b0c6dd7c560e22b0c.tar.gz
A couple more readlink tests.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/test/readlink.test15
1 files changed, 15 insertions, 0 deletions
diff --git a/scripts/test/readlink.test b/scripts/test/readlink.test
index db39e423..cf10ea48 100755
--- a/scripts/test/readlink.test
+++ b/scripts/test/readlink.test
@@ -6,11 +6,14 @@
testing "readlink missing" "readlink notfound || echo yes" "yes\n" "" ""
+# simple tests on a file
+
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" "" ""
+# Test a link that points to nonexistent file
ln -s notfound link
testing "readlink link" "readlink link" "notfound\n" "" ""
testing "readlink link->missing" "readlink -f link" "$(pwd)/notfound\n" "" ""
@@ -24,8 +27,20 @@ testing "readlink -f link->link (recursive)" "readlink -f link || echo yes" \
"yes\n" "" ""
rm file link
+# Make sure circular links don't run away.
+
ln -s link1 link2
ln -s link2 link1
testing "readlink follow recursive2" "readlink -f link1 || echo yes" \
"yes\n" "" ""
rm link1 link2
+
+# Fun with relative paths
+
+ln -s /usr/include/sys/../sys newsys
+ln -s newsys newsys2
+testing "readlink maintains relative paths" "readlink newsys" \
+ "/usr/include/sys/../sys\n" "" ""
+testing "readlink -f resolves relative path" "readlink -f newsys2/../stdio.h" \
+ "/usr/include/stdio.h\n" "" ""
+rm newsys newsys2