aboutsummaryrefslogtreecommitdiff
path: root/scripts/test/ls.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/ls.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/ls.test')
-rw-r--r--scripts/test/ls.test49
1 files changed, 49 insertions, 0 deletions
diff --git a/scripts/test/ls.test b/scripts/test/ls.test
new file mode 100644
index 00000000..d052f13a
--- /dev/null
+++ b/scripts/test/ls.test
@@ -0,0 +1,49 @@
+#!/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
+
+# Creating test-file/dir for testing ls
+mkdir -p lstest/dir1 lstest/dir2 || exit 1
+echo "test file1" > lstest/file1.txt
+echo "test file2" > lstest/file2.txt
+echo "hidden file1" > lstest/.hfile1
+
+IN="cd lstest"
+OUT="cd .. "
+
+testing "ls no argument" "$IN && ls; $OUT" "dir1\ndir2\nfile1.txt\nfile2.txt\n" "" ""
+testing "ls with wild char" "$IN && ls file*; $OUT" "file1.txt\nfile2.txt\n" "" ""
+testing "ls with wild char - long listing" "$IN && ls -1 file*; $OUT" "file1.txt\nfile2.txt\n" "" ""
+testing "ls with -p" "$IN && ls -p; $OUT" "dir1/\ndir2/\nfile1.txt\nfile2.txt\n" "" ""
+testing "ls with -a" "$IN && ls -a; $OUT" \
+ ".\n..\ndir1\ndir2\nfile1.txt\nfile2.txt\n.hfile1\n" "" ""
+testing "ls with -A" "$IN && ls -A; $OUT" \
+ "dir1\ndir2\nfile1.txt\nfile2.txt\n.hfile1\n" "" ""
+testing "ls with -d" "$IN && ls -d; $OUT" ".\n" "" ""
+testing "ls with wild char and -d *" "$IN && ls -d *; $OUT" "dir1\ndir2\nfile1.txt\nfile2.txt\n" "" ""
+testing "ls with -k" "$IN && ls -k; $OUT" "dir1\ndir2\nfile1.txt\nfile2.txt\n" "" ""
+testing "ls with -m" "$IN && ls -m; $OUT" "dir1, dir2, file1.txt, file2.txt\n" "" ""
+testing "ls with -F" "$IN && ls -F; $OUT" "dir1/\ndir2/\nfile1.txt\nfile2.txt\n" "" ""
+testing "ls with -dk *" "$IN && ls -dk *; $OUT" "dir1\ndir2\nfile1.txt\nfile2.txt\n" "" ""
+
+ln -s file1.txt lstest/slink
+testing "ls softlink - long listing" "$IN && ls -l slink | awk '{ print \$NF }' ; $OUT" \
+ "file1.txt\n" "" ""
+rm -f lstest/slink
+
+rm -rf lstest/* && mkdir -p lstest/dir1 && touch lstest/file1.txt
+testing "ls nested recursively" "$IN && ls -R; $OUT" \
+ ".:\ndir1\nfile1.txt\n\n./dir1:\n" "" ""
+
+rm -rf lstest/* && touch lstest/file1.txt && INODE=`stat -c %i lstest/file1.txt`
+testing "ls with -i" "$IN && ls -i 2>/dev/null; $OUT" "$INODE file1.txt\n" "" ""
+unset INODE
+
+# Removing test dir for cleanup purpose
+rm -rf lstest