pty: Activate the signature wrapper of forkpty.
[gnulib.git] / tests / test-closein.sh
1 #!/bin/sh
2 : ${srcdir=.}
3 . "$srcdir/init.sh"; path_prepend_ .
4
5 echo Hello world > in.tmp
6 echo world > xout.tmp
7
8 fail=0
9 # Test with seekable stdin; follow-on process must see remaining data
10 (test-closein; cat) < in.tmp > out1.tmp || fail=1
11 cmp out1.tmp in.tmp || fail=1
12
13 (test-closein consume; cat) < in.tmp > out2.tmp || fail=1
14 cmp out2.tmp xout.tmp || fail=1
15
16 # Test for lack of error on pipe.  Ignore any EPIPE failures from cat.
17 cat in.tmp 2>/dev/null | test-closein || fail=1
18
19 cat in.tmp 2>/dev/null | test-closein consume || fail=1
20
21 # Test for lack of error when nothing is read
22 test-closein </dev/null || fail=1
23
24 test-closein <&- || fail=1
25
26 # Test for no error when EOF is read early
27 test-closein consume </dev/null || fail=1
28
29 # Test for error when read fails because no file available
30 test-closein consume close <&- 2>/dev/null && fail=1
31
32 Exit $fail