view modules/getopt-posix-tests @ 12474:266f24fed73e

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>
author Eric Blake <ebb9@byu.net>
date Wed, 02 Dec 2009 15:48:08 -0700
parents 9f4c9181d1d6
children 33ab12a7cea2
line wrap: on
line source

Files:
tests/test-getopt.c
tests/test-getopt.h
tests/test-getopt_long.h

Depends-on:
dup2
setenv
stdbool
unistd
unsetenv

configure.ac:

Makefile.am:
TESTS += test-getopt
check_PROGRAMS += test-getopt
test_getopt_LDADD = $(LDADD) $(LIBINTL)