aboutsummaryrefslogtreecommitdiff
path: root/scripts/test/ln.test
diff options
context:
space:
mode:
authorDivya Kothari <divya.s.kothari@gmail.com>2014-06-26 07:25:20 -0500
committerDivya Kothari <divya.s.kothari@gmail.com>2014-06-26 07:25:20 -0500
commita0f56beaf63052179c69fb258478f851ef1e5ca2 (patch)
treed744c3b80dff1dce2632852eb813ea24ca0508bb /scripts/test/ln.test
parent6d15f0d33fbc422689f92fbbf4dc65d3ab1fb970 (diff)
downloadtoybox-a0f56beaf63052179c69fb258478f851ef1e5ca2.tar.gz
I have developed few testsuite for toybox commands - ls, ln, rm, mv, printf, dd, renice.
Diffstat (limited to 'scripts/test/ln.test')
-rw-r--r--scripts/test/ln.test70
1 files changed, 70 insertions, 0 deletions
diff --git a/scripts/test/ln.test b/scripts/test/ln.test
new file mode 100644
index 00000000..aea3ab04
--- /dev/null
+++ b/scripts/test/ln.test
@@ -0,0 +1,70 @@
+#!/bin/bash
+
+# Copyright 2013 Robin Mittal <robinmittal.it@gmail.com>
+# Copyright 2013 Divya Kothari <divya.s.kothari@gmail.com>
+
+[ -f testing.sh ] && . testing.sh
+
+#testing "name" "command" "result" "infile" "stdin"
+#set -x
+
+echo file1 > file
+testing "ln create_hardlink" "ln file hlink && [ file -ef hlink ] &&
+ echo 'yes'" "yes\n" "" ""
+testing "ln create_softlink" "ln -s file slink && [ -L slink ] &&
+ readlink slink" "file\n" "" ""
+rm slink hlink
+
+echo hlink1 > hlink
+testing "ln force_create_hardlink" "ln -f file hlink &&
+ [ file -ef hlink ] && cat hlink 2>/dev/null" "file1\n" "" ""
+
+echo slink1 > slink
+testing "ln force_create_softlink" "ln -f -s file slink &&
+ [ -L slink ] && readlink slink" "file\n" "" ""
+rm slink hlink
+
+echo hlink1 > hlink
+set +e
+testing "ln preserves_hardlinks" "ln file hlink 2>/dev/null || echo 'yes'" \
+ "yes\n" "" ""
+
+echo slink1 > slink
+set +e
+testing "ln preserves_softlinks" "ln -s file slink 2>/dev/null || echo 'yes'" \
+ "yes\n" "" ""
+rm slink hlink
+
+mkdir dir
+testing "ln multilevel_symbolic_links" "ln -s dir slink &&
+ ln -s file slink && [ -L slink -a -L slink/file ] &&
+ readlink slink && readlink slink/file" "dir\nfile\n" "" ""
+rm slink
+
+testing "ln no_dereference" "ln -s dir slink &&
+ ln -n -s file slink 2>/dev/null || [ -L slink ] && readlink slink" \
+ "dir\n" "" ""
+rm -rf file dir slink
+
+touch file1 file2 && mkdir dir
+testing "ln create_multiple_hardlinks" "ln file* dir/ &&
+ [ file1 -ef dir/file1 -a file2 -ef dir/file2 ] && echo 'yes'" "yes\n" "" ""
+rm -rf file* dir
+
+touch file1 file2 && mkdir dir
+testing "ln create_multiple_softlinks" "ln -s file* dir/ &&
+ [ -L dir/file1 -a -L dir/file2 ] && readlink dir/file1 &&
+ readlink dir/file2" "file1\nfile2\n" "" ""
+rm -rf file* dir
+
+echo file1 > file
+testing "ln create_softlink_and_remove_sourcefile" "ln -s file slink &&
+ [ -L slink ] && rm file && cat slink 2>/dev/null || echo 'yes' " \
+ "yes\n" "" ""
+rm -f file slink
+
+echo file1 > file
+testing "ln create_hardlink_and_remove_sourcefile" "ln file hlink &&
+ [ file -ef hlink ] && rm file && [ -f hlink ] && echo 'yes'" \
+ "yes\n" "" ""
+rm -f file hlink