From fd33cbeb2af00d79957ed51beeeadec715b0290a Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Tue, 7 Jun 2011 15:41:20 -0600 Subject: [PATCH] test-perror: relax test to ignore cygwin bug glibc was not the only platform where fprintf(fopen(,"r")) fails to detect errors; cygwin 1.7.9 is another culprit (although it will be fixed for 1.7.10), and I suspect that several other platforms were failing perror2 for the same reason. At this point, there are so many functions affected, and the way to avoid the bug is easy enough (don't pass bogus streams to output-producing functions), that I'm not worried about fixing things other than to document them. * tests/test-perror2.c (main): Relax test on requiring detection of stream errors, and use unbuffered stream. * doc/posix-functions/dprintf.texi (dprintf): Document bug. * doc/posix-functions/fprintf.texi (fprintf): Likewise. * doc/posix-functions/fputc.texi (fputc): Likewise. * doc/posix-functions/fputs.texi (fputs): Likewise. * doc/posix-functions/fputws.texi (fputws): Likewise. * doc/posix-functions/fwprintf.texi (fwprintf): Likewise. * doc/posix-functions/fwrite.texi (fwrite): Likewise. * doc/posix-functions/getopt.texi (getopt): Likewise. * doc/posix-functions/perror.texi (perror): Likewise. * doc/posix-functions/printf.texi (printf): Likewise. * doc/posix-functions/psiginfo.texi (psiginfo): Likewise. * doc/posix-functions/psignal.texi (psignal): Likewise. * doc/posix-functions/putc.texi (putc): Likewise. * doc/posix-functions/putc_unlocked.texi (putc_unlocked): Likewise. * doc/posix-functions/putchar.texi (putchar): Likewise. * doc/posix-functions/putchar_unlocked.texi (putchar_unlocked): Likewise. * doc/posix-functions/puts.texi (puts): Likewise. * doc/posix-functions/putwc.texi (putwc): Likewise. * doc/posix-functions/putwchar.texi (putwchar): Likewise. * doc/posix-functions/vdprintf.texi (vdprintf): Likewise. * doc/posix-functions/vfprintf.texi (vfprintf): Likewise. * doc/posix-functions/vfwprintf.texi (vfwprintf): Likewise. * doc/posix-functions/vprintf.texi (vprintf): Likewise. * doc/posix-functions/vwprintf.texi (vwprintf): Likewise. * doc/posix-functions/wordexp.texi (wordexp): Likewise. * doc/posix-functions/wprintf.texi (wprintf): Likewise. Signed-off-by: Eric Blake --- ChangeLog | 34 +++++++++++++++++++++++ doc/posix-functions/dprintf.texi | 4 +++ doc/posix-functions/fprintf.texi | 2 +- doc/posix-functions/fputc.texi | 4 +++ doc/posix-functions/fputs.texi | 4 +++ doc/posix-functions/fputws.texi | 4 +++ doc/posix-functions/fwprintf.texi | 4 +++ doc/posix-functions/fwrite.texi | 4 +++ doc/posix-functions/getopt.texi | 4 +++ doc/posix-functions/perror.texi | 2 +- doc/posix-functions/printf.texi | 2 +- doc/posix-functions/psiginfo.texi | 3 +- doc/posix-functions/psignal.texi | 2 +- doc/posix-functions/putc.texi | 4 +++ doc/posix-functions/putc_unlocked.texi | 4 +++ doc/posix-functions/putchar.texi | 4 +++ doc/posix-functions/putchar_unlocked.texi | 4 +++ doc/posix-functions/puts.texi | 4 +++ doc/posix-functions/putwc.texi | 4 +++ doc/posix-functions/putwchar.texi | 4 +++ doc/posix-functions/vdprintf.texi | 4 +++ doc/posix-functions/vfprintf.texi | 2 +- doc/posix-functions/vfwprintf.texi | 4 +++ doc/posix-functions/vprintf.texi | 2 +- doc/posix-functions/vwprintf.texi | 4 +++ doc/posix-functions/wordexp.texi | 4 +++ doc/posix-functions/wprintf.texi | 4 +++ tests/test-perror2.c | 6 ++-- 28 files changed, 122 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 59c64ae10d..870ec7333e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,37 @@ +2011-06-07 Eric Blake + + test-perror: relax test to ignore cygwin bug + * tests/test-perror2.c (main): Relax test on requiring detection + of stream errors, and use unbuffered stream. + * doc/posix-functions/dprintf.texi (dprintf): Document bug. + * doc/posix-functions/fprintf.texi (fprintf): Likewise. + * doc/posix-functions/fputc.texi (fputc): Likewise. + * doc/posix-functions/fputs.texi (fputs): Likewise. + * doc/posix-functions/fputws.texi (fputws): Likewise. + * doc/posix-functions/fwprintf.texi (fwprintf): Likewise. + * doc/posix-functions/fwrite.texi (fwrite): Likewise. + * doc/posix-functions/getopt.texi (getopt): Likewise. + * doc/posix-functions/perror.texi (perror): Likewise. + * doc/posix-functions/printf.texi (printf): Likewise. + * doc/posix-functions/psiginfo.texi (psiginfo): Likewise. + * doc/posix-functions/psignal.texi (psignal): Likewise. + * doc/posix-functions/putc.texi (putc): Likewise. + * doc/posix-functions/putc_unlocked.texi (putc_unlocked): + Likewise. + * doc/posix-functions/putchar.texi (putchar): Likewise. + * doc/posix-functions/putchar_unlocked.texi (putchar_unlocked): + Likewise. + * doc/posix-functions/puts.texi (puts): Likewise. + * doc/posix-functions/putwc.texi (putwc): Likewise. + * doc/posix-functions/putwchar.texi (putwchar): Likewise. + * doc/posix-functions/vdprintf.texi (vdprintf): Likewise. + * doc/posix-functions/vfprintf.texi (vfprintf): Likewise. + * doc/posix-functions/vfwprintf.texi (vfwprintf): Likewise. + * doc/posix-functions/vprintf.texi (vprintf): Likewise. + * doc/posix-functions/vwprintf.texi (vwprintf): Likewise. + * doc/posix-functions/wordexp.texi (wordexp): Likewise. + * doc/posix-functions/wprintf.texi (wprintf): Likewise. + 2011-05-22 Bruno Haible strerror: Move AC_LIBOBJ invocations to module description. diff --git a/doc/posix-functions/dprintf.texi b/doc/posix-functions/dprintf.texi index dc39022926..e267cda461 100644 --- a/doc/posix-functions/dprintf.texi +++ b/doc/posix-functions/dprintf.texi @@ -24,4 +24,8 @@ glibc-2.3.6. Portability problems not fixed by Gnulib: @itemize +@item +On some platforms, this function does not set @code{errno} or the +stream error indicator on attempts to write to a read-only stream: +Cygwin 1.7.9. @end itemize diff --git a/doc/posix-functions/fprintf.texi b/doc/posix-functions/fprintf.texi index 44bcca3768..3948018b6c 100644 --- a/doc/posix-functions/fprintf.texi +++ b/doc/posix-functions/fprintf.texi @@ -86,5 +86,5 @@ Portability problems not fixed by Gnulib: @item Attempting to write to a read-only stream fails with @code{EOF} but does not set the error flag for @code{ferror} on some platforms: -glibc 2.13. +glibc 2.13, cygwin 1.7.9. @end itemize diff --git a/doc/posix-functions/fputc.texi b/doc/posix-functions/fputc.texi index 9d6c9fd29c..1b5ba7c2b5 100644 --- a/doc/posix-functions/fputc.texi +++ b/doc/posix-functions/fputc.texi @@ -28,4 +28,8 @@ Portability problems not fixed by Gnulib: @item On Windows platforms (excluding Cygwin), this function does not set @code{errno} upon failure. +@item +On some platforms, this function does not set @code{errno} or the +stream error indicator on attempts to write to a read-only stream: +Cygwin 1.7.9. @end itemize diff --git a/doc/posix-functions/fputs.texi b/doc/posix-functions/fputs.texi index 7fc4bf5311..a7e79d4862 100644 --- a/doc/posix-functions/fputs.texi +++ b/doc/posix-functions/fputs.texi @@ -28,4 +28,8 @@ Portability problems not fixed by Gnulib: @item On Windows platforms (excluding Cygwin), this function does not set @code{errno} upon failure. +@item +On some platforms, this function does not set @code{errno} or the +stream error indicator on attempts to write to a read-only stream: +Cygwin 1.7.9. @end itemize diff --git a/doc/posix-functions/fputws.texi b/doc/posix-functions/fputws.texi index f3b2b4e4b1..c842488d0a 100644 --- a/doc/posix-functions/fputws.texi +++ b/doc/posix-functions/fputws.texi @@ -18,4 +18,8 @@ IRIX 5.3, Solaris 2.5.1, Cygwin 1.5.x, BeOS. @item On AIX and Windows platforms, @code{wchar_t} is a 16-bit type and therefore cannot accommodate all Unicode characters. +@item +On some platforms, this function does not set @code{errno} or the +stream error indicator on attempts to write to a read-only stream: +Cygwin 1.7.9. @end itemize diff --git a/doc/posix-functions/fwprintf.texi b/doc/posix-functions/fwprintf.texi index 79ffc25ad5..d245890ead 100644 --- a/doc/posix-functions/fwprintf.texi +++ b/doc/posix-functions/fwprintf.texi @@ -18,4 +18,8 @@ NetBSD 3.0, OpenBSD 3.8, HP-UX 11.00, IRIX 6.5, Solaris 2.6, Cygwin 1.5.x, Inter @item On AIX and Windows platforms, @code{wchar_t} is a 16-bit type and therefore cannot accommodate all Unicode characters. +@item +On some platforms, this function does not set @code{errno} or the +stream error indicator on attempts to write to a read-only stream: +Cygwin 1.7.9. @end itemize diff --git a/doc/posix-functions/fwrite.texi b/doc/posix-functions/fwrite.texi index 20f7fb8100..c03a70ccab 100644 --- a/doc/posix-functions/fwrite.texi +++ b/doc/posix-functions/fwrite.texi @@ -28,4 +28,8 @@ Portability problems not fixed by Gnulib: @item On Windows platforms (excluding Cygwin), this function does not set @code{errno} upon failure. +@item +On some platforms, this function does not set @code{errno} or the +stream error indicator on attempts to write to a read-only stream: +Cygwin 1.7.9. @end itemize diff --git a/doc/posix-functions/getopt.texi b/doc/posix-functions/getopt.texi index 4067295ca1..bab4922e19 100644 --- a/doc/posix-functions/getopt.texi +++ b/doc/posix-functions/getopt.texi @@ -67,4 +67,8 @@ causing a reset by setting it non-zero, although it does not necessarily re-read @env{POSIXLY_CORRECT}. Solaris @code{getopt} does not support either reset method, but does not maintain state that needs the extra level of reset. +@item +On some platforms, this function does not set the stream error +indicator on attempts to write to a read-only stream: +glibc 2.13, Cygwin 1.7.9. @end itemize diff --git a/doc/posix-functions/perror.texi b/doc/posix-functions/perror.texi index 167cf39aea..13231e95ea 100644 --- a/doc/posix-functions/perror.texi +++ b/doc/posix-functions/perror.texi @@ -23,7 +23,7 @@ Portability problems not fixed by Gnulib: @item POSIX requires that this function set the stream error bit (detected by @code{ferror}) on write failure, but not all platforms do this: -glibc 2.13. +glibc 2.13, cygwin 1.7.9. @item POSIX requires that this function not alter stream orientation, but the gnulib replacement locks in byte orientation and fails on wide diff --git a/doc/posix-functions/printf.texi b/doc/posix-functions/printf.texi index 8fc8cb0922..db7218b401 100644 --- a/doc/posix-functions/printf.texi +++ b/doc/posix-functions/printf.texi @@ -86,5 +86,5 @@ Portability problems not fixed by Gnulib: @item Attempting to write to a read-only stream fails with @code{EOF} but does not set the error flag for @code{ferror} on some platforms: -glibc 2.13. +glibc 2.13, cygwin 1.7.9. @end itemize diff --git a/doc/posix-functions/psiginfo.texi b/doc/posix-functions/psiginfo.texi index 2e940c0d8a..a0f530bcc5 100644 --- a/doc/posix-functions/psiginfo.texi +++ b/doc/posix-functions/psiginfo.texi @@ -14,5 +14,6 @@ Portability problems not fixed by Gnulib: @itemize @item This function is missing on some platforms: -glibc 2.3.6, MacOS X 10.5, FreeBSD 6.0, NetBSD 5.0, OpenBSD 3.8, AIX 5.1, HP-UX 11, OSF/1 5.1, Cygwin, mingw, Interix 3.5, BeOS. +glibc 2.3.6, MacOS X 10.5, FreeBSD 6.0, NetBSD 5.0, OpenBSD 3.8, AIX +5.1, HP-UX 11, OSF/1 5.1, Cygwin 1.7.9, mingw, Interix 3.5, BeOS. @end itemize diff --git a/doc/posix-functions/psignal.texi b/doc/posix-functions/psignal.texi index 167794946c..75e6ed882f 100644 --- a/doc/posix-functions/psignal.texi +++ b/doc/posix-functions/psignal.texi @@ -14,5 +14,5 @@ Portability problems not fixed by Gnulib: @itemize @item This function is missing on some platforms: -HP-UX 11, Cygwin, mingw, Interix 3.5, BeOS. +HP-UX 11, Cygwin 1.7.9, mingw, Interix 3.5, BeOS. @end itemize diff --git a/doc/posix-functions/putc.texi b/doc/posix-functions/putc.texi index d156461ace..c6a815e3ee 100644 --- a/doc/posix-functions/putc.texi +++ b/doc/posix-functions/putc.texi @@ -28,4 +28,8 @@ Portability problems not fixed by Gnulib: @item On Windows platforms (excluding Cygwin), this function does not set @code{errno} upon failure. +@item +On some platforms, this function does not set @code{errno} or the +stream error indicator on attempts to write to a read-only stream: +Cygwin 1.7.9. @end itemize diff --git a/doc/posix-functions/putc_unlocked.texi b/doc/posix-functions/putc_unlocked.texi index 0c3381e20a..4fbf3c4cf8 100644 --- a/doc/posix-functions/putc_unlocked.texi +++ b/doc/posix-functions/putc_unlocked.texi @@ -15,4 +15,8 @@ Portability problems not fixed by Gnulib: @item This function is missing on some platforms: mingw. +@item +On some platforms, this function does not set @code{errno} or the +stream error indicator on attempts to write to a read-only stream: +Cygwin 1.7.9. @end itemize diff --git a/doc/posix-functions/putchar.texi b/doc/posix-functions/putchar.texi index aeb6b4307c..2ded45a2ae 100644 --- a/doc/posix-functions/putchar.texi +++ b/doc/posix-functions/putchar.texi @@ -28,4 +28,8 @@ Portability problems not fixed by Gnulib: @item On Windows platforms (excluding Cygwin), this function does not set @code{errno} upon failure. +@item +On some platforms, this function does not set @code{errno} or the +stream error indicator on attempts to write to a read-only stream: +Cygwin 1.7.9. @end itemize diff --git a/doc/posix-functions/putchar_unlocked.texi b/doc/posix-functions/putchar_unlocked.texi index 5bf55b3838..bc9c3b03de 100644 --- a/doc/posix-functions/putchar_unlocked.texi +++ b/doc/posix-functions/putchar_unlocked.texi @@ -15,4 +15,8 @@ Portability problems not fixed by Gnulib: @item This function is missing on some platforms: mingw. +@item +On some platforms, this function does not set @code{errno} or the +stream error indicator on attempts to write to a read-only stream: +Cygwin 1.7.9. @end itemize diff --git a/doc/posix-functions/puts.texi b/doc/posix-functions/puts.texi index ef350ac1b1..31e3f0e410 100644 --- a/doc/posix-functions/puts.texi +++ b/doc/posix-functions/puts.texi @@ -28,4 +28,8 @@ Portability problems not fixed by Gnulib: @item On Windows platforms (excluding Cygwin), this function does not set @code{errno} upon failure. +@item +On some platforms, this function does not set @code{errno} or the +stream error indicator on attempts to write to a read-only stream: +Cygwin 1.7.9. @end itemize diff --git a/doc/posix-functions/putwc.texi b/doc/posix-functions/putwc.texi index 82a8a962d5..b624b251e5 100644 --- a/doc/posix-functions/putwc.texi +++ b/doc/posix-functions/putwc.texi @@ -18,4 +18,8 @@ IRIX 5.3, Solaris 2.5.1, Cygwin 1.5.x, BeOS. @item On AIX and Windows platforms, @code{wchar_t} is a 16-bit type and therefore cannot accommodate all Unicode characters. +@item +On some platforms, this function does not set @code{errno} or the +stream error indicator on attempts to write to a read-only stream: +Cygwin 1.7.9. @end itemize diff --git a/doc/posix-functions/putwchar.texi b/doc/posix-functions/putwchar.texi index 985759acd2..28930c47ae 100644 --- a/doc/posix-functions/putwchar.texi +++ b/doc/posix-functions/putwchar.texi @@ -18,4 +18,8 @@ IRIX 5.3, Solaris 2.5.1, Cygwin 1.5.x, BeOS. @item On AIX and Windows platforms, @code{wchar_t} is a 16-bit type and therefore cannot accommodate all Unicode characters. +@item +On some platforms, this function does not set @code{errno} or the +stream error indicator on attempts to write to a read-only stream: +Cygwin 1.7.9. @end itemize diff --git a/doc/posix-functions/vdprintf.texi b/doc/posix-functions/vdprintf.texi index 20a6ef75c5..8b06c3e3ab 100644 --- a/doc/posix-functions/vdprintf.texi +++ b/doc/posix-functions/vdprintf.texi @@ -42,4 +42,8 @@ BeOS. Portability problems not fixed by Gnulib: @itemize +@item +On some platforms, this function does not set @code{errno} or the +stream error indicator on attempts to write to a read-only stream: +Cygwin 1.7.9. @end itemize diff --git a/doc/posix-functions/vfprintf.texi b/doc/posix-functions/vfprintf.texi index c6fab25ed7..4999fb5b23 100644 --- a/doc/posix-functions/vfprintf.texi +++ b/doc/posix-functions/vfprintf.texi @@ -86,5 +86,5 @@ Portability problems not fixed by Gnulib: @item Attempting to write to a read-only stream fails with @code{EOF} but does not set the error flag for @code{ferror} on some platforms: -glibc 2.13. +glibc 2.13, cygwin 1.7.9. @end itemize diff --git a/doc/posix-functions/vfwprintf.texi b/doc/posix-functions/vfwprintf.texi index e018cf5901..143704b4b4 100644 --- a/doc/posix-functions/vfwprintf.texi +++ b/doc/posix-functions/vfwprintf.texi @@ -18,4 +18,8 @@ NetBSD 3.0, OpenBSD 3.8, HP-UX 11.00, IRIX 6.5, Solaris 2.6, Cygwin 1.5.x, Inter @item On AIX and Windows platforms, @code{wchar_t} is a 16-bit type and therefore cannot accommodate all Unicode characters. +@item +On some platforms, this function does not set @code{errno} or the +stream error indicator on attempts to write to a read-only stream: +Cygwin 1.7.9. @end itemize diff --git a/doc/posix-functions/vprintf.texi b/doc/posix-functions/vprintf.texi index 21d4bc60f1..7534e01c0e 100644 --- a/doc/posix-functions/vprintf.texi +++ b/doc/posix-functions/vprintf.texi @@ -86,5 +86,5 @@ Portability problems not fixed by Gnulib: @item Attempting to write to a read-only stream fails with @code{EOF} but does not set the error flag for @code{ferror} on some platforms: -glibc 2.13. +glibc 2.13, cygwin 1.7.9. @end itemize diff --git a/doc/posix-functions/vwprintf.texi b/doc/posix-functions/vwprintf.texi index e82834a565..9f3e3b88de 100644 --- a/doc/posix-functions/vwprintf.texi +++ b/doc/posix-functions/vwprintf.texi @@ -22,4 +22,8 @@ platforms: Cygwin 1.5.x. @item On AIX and Windows platforms, @code{wchar_t} is a 16-bit type and therefore cannot accommodate all Unicode characters. +@item +On some platforms, this function does not set @code{errno} or the +stream error indicator on attempts to write to a read-only stream: +Cygwin 1.7.9. @end itemize diff --git a/doc/posix-functions/wordexp.texi b/doc/posix-functions/wordexp.texi index f5d9eafdb9..6787200127 100644 --- a/doc/posix-functions/wordexp.texi +++ b/doc/posix-functions/wordexp.texi @@ -15,4 +15,8 @@ Portability problems not fixed by Gnulib: @item This function is missing on some platforms: MacOS X 10.3, OpenBSD 3.8, IRIX 5.3, Cygwin 1.5.x, mingw, Interix 3.5, BeOS. +@item +On some platforms, this function does not set @code{errno} or the +stream error indicator on attempts to write to a read-only stream: +Cygwin 1.7.9. @end itemize diff --git a/doc/posix-functions/wprintf.texi b/doc/posix-functions/wprintf.texi index 885dd8b015..330ca23b19 100644 --- a/doc/posix-functions/wprintf.texi +++ b/doc/posix-functions/wprintf.texi @@ -22,4 +22,8 @@ platforms: Cygwin 1.5.x. @item On AIX and Windows platforms, @code{wchar_t} is a 16-bit type and therefore cannot accommodate all Unicode characters. +@item +On some platforms, this function does not set @code{errno} or the +stream error indicator on attempts to write to a read-only stream: +Cygwin 1.7.9. @end itemize diff --git a/tests/test-perror2.c b/tests/test-perror2.c index 3aab640a48..e230f92320 100644 --- a/tests/test-perror2.c +++ b/tests/test-perror2.c @@ -116,12 +116,14 @@ main (void) /* Test that perror reports write failure. */ { ASSERT (freopen (BASE ".tmp", "r", stderr) == stderr); - ASSERT (setvbuf (stderr, NULL, _IOLBF, BUFSIZ) == 0); + ASSERT (setvbuf (stderr, NULL, _IONBF, BUFSIZ) == 0); errno = -1; ASSERT (!ferror (stderr)); perror (NULL); - ASSERT (errno > 0); #if 0 + /* Commented out until cygwin behaves: + http://sourceware.org/ml/newlib/2011/msg00228.html */ + ASSERT (errno > 0); /* Commented out until glibc behaves: http://sourceware.org/bugzilla/show_bug.cgi?id=12792 */ ASSERT (ferror (stderr)); -- 2.30.2