OSDN Git Service

split pgrep/pkill tests.
[android-x86/external-toybox.git] / tests / tac.test
1 #!/bin/bash
2
3 [ -f testing.sh ] && . testing.sh
4
5 #testing "name" "command" "result" "infile" "stdin"
6
7
8 echo -e "one-A\none-B" > file1 
9 echo -e "two-A\ntwo-B" > file2
10 testing "tac" "tac && echo yes" "one-B\none-A\nyes\n" "" "one-A\none-B\n"
11 testing "tac -" "tac - && echo yes" "one-B\none-A\nyes\n" "" "one-A\none-B\n"
12 testing "tac file1 file2" "tac file1 file2" "one-B\none-A\ntwo-B\ntwo-A\n"  "" ""
13 testing "tac - file"      "tac - file1"     "zero-B\nzero-A\none-B\none-A\n" "" "zero-A\nzero-B\n"
14 testing "tac file -"      "tac file1 -"     "one-B\none-A\nzero-B\nzero-A\n" "" "zero-A\nzero-B\n"
15
16 testing "tac file1 notfound file2" \
17         "tac file1 notfound file2 2>stderr && echo ok ; tac stderr; rm stderr" \
18         "one-B\none-A\ntwo-B\ntwo-A\ntac: notfound: No such file or directory\n" "" ""
19
20 testing "tac no trailing newline" "tac -" "defabc\n" "" "abc\ndef"
21
22 # xputs used by tac does not propagate this error condition properly. 
23 #testing "tac > /dev/full" \
24 #        "tac - > /dev/full 2>stderr && echo ok; cat stderr; rm stderr" \
25 #        "tac: write: No space left on device\n" "" "zero\n"
26
27
28
29 rm file1 file2