aboutsummaryrefslogtreecommitdiff
path: root/scripts/test/rm.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/rm.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/rm.test')
-rw-r--r--scripts/test/rm.test46
1 files changed, 46 insertions, 0 deletions
diff --git a/scripts/test/rm.test b/scripts/test/rm.test
new file mode 100644
index 00000000..0dca8538
--- /dev/null
+++ b/scripts/test/rm.test
@@ -0,0 +1,46 @@
+#!/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"
+
+echo "abcdefghijklmnopqrstuvwxyz" > file.txt
+testing "Remove text-file" "rm file.txt && [ ! -e file.txt ] && echo 'yes'" "yes\n" "" ""
+rm -f file*
+
+mkdir dir
+testing "Remove empty directory" "rm -r dir && [ ! -d dir ] && echo 'yes'" "yes\n" "" ""
+rm -rf dir
+
+echo "abcdefghijklmnopqrstuvwxyz" > file.txt && chmod 000 file.txt
+testing "Remove text file(mode 000)" "rm -f file.txt && [ ! -e file.txt ] && echo 'yes'" \
+ "yes\n" "" ""
+rm -f file*
+
+touch file1.txt file2.txt
+mkdir dir1 dir2
+testing "rm -r (multiple files and dirs)" \
+ "rm -r file1.txt file2.txt dir1 dir2 2>/dev/null &&
+ [ ! -e file1.txt -a ! -e file2.txt -a ! -d dir1 -a ! -d dir2 ] && echo 'yes'" \
+ "yes\n" "" ""
+rm -rf file* dir*
+
+touch file1.txt file2.txt
+mkdir dir1 dir2
+testing "rm -rf (present + missing files and dirs)" \
+ "rm -rf file1.txt file2.txt file3.txt dir1 dir2 dir3 2>/dev/null &&
+ [ ! -e file1.txt -a ! -e file2.txt -a ! -d dir1 -a ! -d dir2 ] && echo 'yes'" \
+ "yes\n" "" ""
+rm -rf file* dir*
+
+# testing with nested dirs.
+mkdir -p dir1/dir2/dir3 dir1/dir2/dir4
+touch dir1/file1.txt dir1/dir2/file2.txt dir1/dir2/dir3/file3.txt
+testing "rm -r nested_dir" "rm -r dir1/dir2/ 2>/dev/null &&
+ [ -d dir1 -a -f dir1/file1.txt -a ! -d dir1/dir2 ] && echo 'yes'" \
+ "yes\n" "" ""
+rm -rf dir*
+