# HG changeset patch # User Eric Blake # Date 1306278960 21600 # Node ID a29ad2af0c293764cceed799819c542216862c16 # Parent c4778383772078e4d799e453ed668092a5557746 closein-tests: convert to init.sh * modules/closein-tests (Files): Add init.sh * tests/test-closein.sh Use it. Signed-off-by: Eric Blake diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2011-05-24 Eric Blake + closein-tests: convert to init.sh + * modules/closein-tests (Files): Add init.sh + * tests/test-closein.sh Use it. + yesno-tests: convert to init.sh * modules/yesno-tests (Files): Add init.sh. * tests/test-yesno.sh: Use it. diff --git a/modules/closein-tests b/modules/closein-tests --- a/modules/closein-tests +++ b/modules/closein-tests @@ -1,4 +1,5 @@ Files: +tests/init.sh tests/test-closein.sh tests/test-closein.c diff --git a/tests/test-closein.sh b/tests/test-closein.sh --- 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 - -p=t-closein- -tmpfiles="${p}in.tmp ${p}xout.tmp ${p}out1.tmp ${p}out2.tmp" +echo Hello world > in.tmp +echo world > xout.tmp -echo Hello world > ${p}in.tmp -echo world > ${p}xout.tmp - +fail=0 # 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-closein; cat) < in.tmp > out1.tmp || fail=1 +cmp out1.tmp in.tmp || 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-closein consume; cat) < in.tmp > out2.tmp || fail=1 +cmp out2.tmp xout.tmp || fail=1 # Test for lack of error on pipe. Ignore any EPIPE failures from cat. -cat ${p}in.tmp 2>/dev/null | ./test-closein${EXEEXT} || exit 1 +cat in.tmp 2>/dev/null | test-closein || fail=1 -cat ${p}in.tmp 2>/dev/null | ./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 +test-closein consume close <&- 2>/dev/null && fail=1 -# Cleanup -rm -fr $tmpfiles - -exit 0 +Exit $fail