annotate tests/test-yesno.sh @ 17082:62741e75b7c5

poll/select: document portability problems not fixed by Gnulib. * doc/posix-functions/poll.texi: poll does not work well on pipes under Windows. It has the same limitations as select on BeOS. * doc/posix-functions/select.texi: select does not work well on pipes under Windows.
author Paolo Bonzini <pbonzini@redhat.com>
date Thu, 13 Sep 2012 08:51:16 +0200
parents a712776b11ce
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9157
18308c6e516b Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff changeset
1 #!/bin/sh
14821
c47783837720 yesno-tests: convert to init.sh
Eric Blake <eblake@redhat.com>
parents: 12078
diff changeset
2 : ${srcdir=.}
c47783837720 yesno-tests: convert to init.sh
Eric Blake <eblake@redhat.com>
parents: 12078
diff changeset
3 . "$srcdir/init.sh"; path_prepend_ .
9157
18308c6e516b Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff changeset
4
18308c6e516b Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff changeset
5 # For now, only test with C locale
18308c6e516b Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff changeset
6 LC_ALL=C
18308c6e516b Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff changeset
7 export LC_ALL
18308c6e516b Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff changeset
8
9987
8d1cd7ae4b1e Make test-yesno.sh work on mingw.
Bruno Haible <bruno@clisp.org>
parents: 9391
diff changeset
9 # Find out how to remove carriage returns from output. Solaris /usr/ucb/tr
8d1cd7ae4b1e Make test-yesno.sh work on mingw.
Bruno Haible <bruno@clisp.org>
parents: 9391
diff changeset
10 # does not understand '\r'.
8d1cd7ae4b1e Make test-yesno.sh work on mingw.
Bruno Haible <bruno@clisp.org>
parents: 9391
diff changeset
11 if echo solaris | tr -d '\r' | grep solais > /dev/null; then
8d1cd7ae4b1e Make test-yesno.sh work on mingw.
Bruno Haible <bruno@clisp.org>
parents: 9391
diff changeset
12 cr='\015'
8d1cd7ae4b1e Make test-yesno.sh work on mingw.
Bruno Haible <bruno@clisp.org>
parents: 9391
diff changeset
13 else
8d1cd7ae4b1e Make test-yesno.sh work on mingw.
Bruno Haible <bruno@clisp.org>
parents: 9391
diff changeset
14 cr='\r'
8d1cd7ae4b1e Make test-yesno.sh work on mingw.
Bruno Haible <bruno@clisp.org>
parents: 9391
diff changeset
15 fi
8d1cd7ae4b1e Make test-yesno.sh work on mingw.
Bruno Haible <bruno@clisp.org>
parents: 9391
diff changeset
16
16358
a712776b11ce maint: spelling fixes
Paul Eggert <eggert@cs.ucla.edu>
parents: 14821
diff changeset
17 # Test with seekable stdin; the follow-on process must see remaining data.
14821
c47783837720 yesno-tests: convert to init.sh
Eric Blake <eblake@redhat.com>
parents: 12078
diff changeset
18 tr @ '\177' <<EOF > in.tmp
9157
18308c6e516b Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff changeset
19 nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn - entire line consumed
12078
3710e1c3943e test-yesno: work around sparc-dash here-document infelicity
Jim Meyering <meyering@redhat.com>
parents: 9987
diff changeset
20 y@n - backspace does not change result
9157
18308c6e516b Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff changeset
21 y
18308c6e516b Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff changeset
22 does not match either yesexpr or noexpr
18308c6e516b Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff changeset
23 n
18308c6e516b Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff changeset
24 EOF
9987
8d1cd7ae4b1e Make test-yesno.sh work on mingw.
Bruno Haible <bruno@clisp.org>
parents: 9391
diff changeset
25
14821
c47783837720 yesno-tests: convert to init.sh
Eric Blake <eblake@redhat.com>
parents: 12078
diff changeset
26 cat <<EOF > xout.tmp
9157
18308c6e516b Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff changeset
27 N
18308c6e516b Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff changeset
28 Y
18308c6e516b Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff changeset
29 Y
18308c6e516b Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff changeset
30 N
18308c6e516b Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff changeset
31 n
18308c6e516b Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff changeset
32 EOF
9987
8d1cd7ae4b1e Make test-yesno.sh work on mingw.
Bruno Haible <bruno@clisp.org>
parents: 9391
diff changeset
33
14821
c47783837720 yesno-tests: convert to init.sh
Eric Blake <eblake@redhat.com>
parents: 12078
diff changeset
34 fail=0
c47783837720 yesno-tests: convert to init.sh
Eric Blake <eblake@redhat.com>
parents: 12078
diff changeset
35 (test-yesno; test-yesno 3; cat) < in.tmp > out1.tmp || fail=1
c47783837720 yesno-tests: convert to init.sh
Eric Blake <eblake@redhat.com>
parents: 12078
diff changeset
36 LC_ALL=C tr -d "$cr" < out1.tmp > out.tmp || fail=1
c47783837720 yesno-tests: convert to init.sh
Eric Blake <eblake@redhat.com>
parents: 12078
diff changeset
37 cmp xout.tmp out.tmp || fail=1
9157
18308c6e516b Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff changeset
38
14821
c47783837720 yesno-tests: convert to init.sh
Eric Blake <eblake@redhat.com>
parents: 12078
diff changeset
39 (test-yesno 3; test-yesno; cat) < in.tmp > out1.tmp || fail=1
c47783837720 yesno-tests: convert to init.sh
Eric Blake <eblake@redhat.com>
parents: 12078
diff changeset
40 LC_ALL=C tr -d "$cr" < out1.tmp > out.tmp || fail=1
c47783837720 yesno-tests: convert to init.sh
Eric Blake <eblake@redhat.com>
parents: 12078
diff changeset
41 cmp xout.tmp out.tmp || fail=1
9157
18308c6e516b Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff changeset
42
18308c6e516b Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff changeset
43 # Test for behavior on pipe
14821
c47783837720 yesno-tests: convert to init.sh
Eric Blake <eblake@redhat.com>
parents: 12078
diff changeset
44 cat <<EOF > xout.tmp
9157
18308c6e516b Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff changeset
45 Y
18308c6e516b Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff changeset
46 N
18308c6e516b Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff changeset
47 EOF
14821
c47783837720 yesno-tests: convert to init.sh
Eric Blake <eblake@redhat.com>
parents: 12078
diff changeset
48 echo yes | test-yesno 2 > out1.tmp || fail=1
c47783837720 yesno-tests: convert to init.sh
Eric Blake <eblake@redhat.com>
parents: 12078
diff changeset
49 LC_ALL=C tr -d "$cr" < out1.tmp > out.tmp || fail=1
c47783837720 yesno-tests: convert to init.sh
Eric Blake <eblake@redhat.com>
parents: 12078
diff changeset
50 cmp xout.tmp out.tmp || fail=1
9157
18308c6e516b Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff changeset
51
18308c6e516b Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff changeset
52 # Test for behavior on EOF
14821
c47783837720 yesno-tests: convert to init.sh
Eric Blake <eblake@redhat.com>
parents: 12078
diff changeset
53 cat <<EOF > xout.tmp
9157
18308c6e516b Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff changeset
54 N
18308c6e516b Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff changeset
55 EOF
14821
c47783837720 yesno-tests: convert to init.sh
Eric Blake <eblake@redhat.com>
parents: 12078
diff changeset
56 test-yesno </dev/null > out1.tmp || fail=1
c47783837720 yesno-tests: convert to init.sh
Eric Blake <eblake@redhat.com>
parents: 12078
diff changeset
57 LC_ALL=C tr -d "$cr" < out1.tmp > out.tmp || fail=1
c47783837720 yesno-tests: convert to init.sh
Eric Blake <eblake@redhat.com>
parents: 12078
diff changeset
58 cmp xout.tmp out.tmp || fail=1
9157
18308c6e516b Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff changeset
59
18308c6e516b Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff changeset
60 # Test for behavior when stdin is closed
14821
c47783837720 yesno-tests: convert to init.sh
Eric Blake <eblake@redhat.com>
parents: 12078
diff changeset
61 test-yesno 0 <&- > out1.tmp 2> err.tmp && fail=1
c47783837720 yesno-tests: convert to init.sh
Eric Blake <eblake@redhat.com>
parents: 12078
diff changeset
62 LC_ALL=C tr -d "$cr" < out1.tmp > out.tmp || fail=1
c47783837720 yesno-tests: convert to init.sh
Eric Blake <eblake@redhat.com>
parents: 12078
diff changeset
63 cmp xout.tmp out.tmp || fail=1
c47783837720 yesno-tests: convert to init.sh
Eric Blake <eblake@redhat.com>
parents: 12078
diff changeset
64 test -s err.tmp || fail=1
9157
18308c6e516b Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff changeset
65
14821
c47783837720 yesno-tests: convert to init.sh
Eric Blake <eblake@redhat.com>
parents: 12078
diff changeset
66 Exit $fail