aboutsummaryrefslogtreecommitdiff
path: root/scripts/test
diff options
context:
space:
mode:
authorElie De Brauwer <eliedebrauwer@gmail.com>2012-12-15 19:51:43 +0100
committerElie De Brauwer <eliedebrauwer@gmail.com>2012-12-15 19:51:43 +0100
commite9e10b58c2ea156e59c78642d5a88756e3649d56 (patch)
tree9610e7cda74423811f491fd201a8bb092b1fb385 /scripts/test
parentd4d51198e8d7b650850d8c6e0b02b511ff61c07f (diff)
downloadtoybox-e9e10b58c2ea156e59c78642d5a88756e3649d56.tar.gz
Adding tests for tac based on cat tests
Diffstat (limited to 'scripts/test')
-rw-r--r--scripts/test/tac.test30
1 files changed, 30 insertions, 0 deletions
diff --git a/scripts/test/tac.test b/scripts/test/tac.test
new file mode 100644
index 00000000..a70c3c1e
--- /dev/null
+++ b/scripts/test/tac.test
@@ -0,0 +1,30 @@
+#!/bin/bash
+
+[ -f testing.sh ] && . testing.sh
+
+#testing "name" "command" "result" "infile" "stdin"
+
+
+echo -e "one-A\none-B" > file1
+echo -e "two-A\ntwo-B" > file2
+testing "tac" "tac && echo yes" "one-B\none-A\nyes\n" "" "one-A\none-B\n"
+testing "tac -" "tac - && echo yes" "one-B\none-A\nyes\n" "" "one-A\none-B\n"
+testing "tac file1 file2" "tac file1 file2" "one-B\none-A\ntwo-B\ntwo-A\n" "" ""
+testing "tac - file" "tac - file1" "zero-B\nzero-A\none-B\none-A\n" "" "zero-A\nzero-B\n"
+testing "tac file -" "tac file1 -" "one-B\none-A\nzero-B\nzero-A\n" "" "zero-A\nzero-B\n"
+
+testing "tac file1 notfound file2" \
+ "tac file1 notfound file2 2>stderr && echo ok ; tac stderr; rm stderr" \
+ "one-B\none-A\ntwo-B\ntwo-A\ntac: notfound: No such file or directory\n" "" ""
+
+# echo -ne "abc\ndef" | tac actually gives "defabc\n"
+testing "tac no trailing newline" "tac -" "def\nabc\n" "" "abc\ndef"
+
+# xputs used by tac does not propagate this error condition properly.
+#testing "tac > /dev/full" \
+# "tac - > /dev/full 2>stderr && echo ok; cat stderr; rm stderr" \
+# "tac: write: No space left on device\n" "" "zero\n"
+
+#
+
+rm file1 file2 \ No newline at end of file