test-getopt: test stderr behavior
authorEric Blake <ebb9@byu.net>
Wed, 2 Dec 2009 22:48:08 +0000 (15:48 -0700)
committerEric Blake <ebb9@byu.net>
Tue, 22 Dec 2009 13:44:00 +0000 (06:44 -0700)
commit3c8bb39bef81eb88a2aa9bdfd8af00ca151b86fd
tree3a8c9ed237f53323c672f768644a265390d01a7c
parenta8ec28b6975fc065b84c511b8108dc3658d2ccd4
test-getopt: test stderr behavior

Portions of this commit are commented out because they tickle
glibc bugs.  For a real-life example of the bug:

$ env -ua -:
env: invalid option -- :
Try `env --help' for more information.
$ env -:
env: invalid option -- :
Try `env --help' for more information.
$ env -+
env: invalid option -- +
Try `env --help' for more information.
$ env -ua -+
Try `env --help' for more information.

Notice that when -+ is not given as the first argument, the
error message is mistakenly suppressed.

* modules/getopt-posix-tests (Depends-on): Add dup2.
* tests/test-getopt.c (ASSERT): Avoid stderr.
(main): Move stderr to a temporary file.
* tests/test-getopt.h (getopt_loop): No longer manipulate opterr.
Instead, add parameter to inform caller if output occurred.
(test_getopt): Adjust all tests to expect silence, and add new
tests of leading ":".
* doc/glibc-functions/getopt_long.texi (getopt_long): Document
glibc shortcomings with leading "-:" or "+:" in optstring.
* doc/glibc-functions/getopt_long_only.texi (getopt_long_only):
Likewise.
* doc/posix-functions/getopt.texi (getopt): Likewise.

Signed-off-by: Eric Blake <ebb9@byu.net>
ChangeLog
doc/glibc-functions/getopt_long.texi
doc/glibc-functions/getopt_long_only.texi
doc/posix-functions/getopt.texi
modules/getopt-posix-tests
tests/test-getopt.c
tests/test-getopt.h