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