X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=tests%2Ftest-closein.sh;h=9c5e851f74359642206983dbe3b64c6158ffff91;hb=43593319b31e6b0175b8eec4433bac744959822d;hp=4f5751176e0df756c519dfc72e0bd38f1aef1dcb;hpb=49adfaf5d36d94624790dc9754a2966a8102d2b3;p=gnulib.git diff --git a/tests/test-closein.sh b/tests/test-closein.sh index 4f5751176..9c5e851f7 100755 --- a/tests/test-closein.sh +++ b/tests/test-closein.sh @@ -1,38 +1,32 @@ #!/bin/sh +: ${srcdir=.} +. "$srcdir/init.sh"; path_prepend_ . -tmpfiles= -trap 'rm -fr $tmpfiles' 1 2 3 15 +echo Hello world > in.tmp +echo world > xout.tmp -p=t-closein- -tmpfiles="${p}in.tmp ${p}xout.tmp ${p}out1.tmp ${p}out2.tmp" +fail=0 +# Test with seekable stdin; follow-on process must see remaining data +(test-closein; cat) < in.tmp > out1.tmp || fail=1 +cmp out1.tmp in.tmp || fail=1 -echo Hello world > ${p}in.tmp -echo world > ${p}xout.tmp +(test-closein consume; cat) < in.tmp > out2.tmp || fail=1 +cmp out2.tmp xout.tmp || fail=1 -# Test with seekable stdin; followon process must see remaining data -(./test-closein${EXEEXT}; cat) < ${p}in.tmp > ${p}out1.tmp || exit 1 -cmp ${p}out1.tmp ${p}in.tmp || exit 1 +# Test for lack of error on pipe. Ignore any EPIPE failures from cat. +cat in.tmp 2>/dev/null | test-closein || fail=1 -(./test-closein${EXEEXT} consume; cat) < ${p}in.tmp > ${p}out2.tmp || exit 1 -cmp ${p}out2.tmp ${p}xout.tmp || exit 1 - -# Test for lack of error on pipe -cat ${p}in.tmp | ./test-closein${EXEEXT} || exit 1 - -cat ${p}in.tmp | ./test-closein${EXEEXT} consume || exit 1 +cat in.tmp 2>/dev/null | test-closein consume || fail=1 # Test for lack of error when nothing is read -./test-closein${EXEEXT} /dev/null && exit 1 - -# Cleanup -rm -fr $tmpfiles +test-closein consume close <&- 2>/dev/null && fail=1 -exit 0 +Exit $fail