> FAIL: test-fgetc.exe > FAIL: test-fputc.exe > FAIL: test-fread.exe > FAIL: test-fwrite.exe > > All these fail on a stream whose file descriptor has been closed. Most > libraries won't do such a thing. Therefore I don't find it worth to fix > this. Just document it.
But two of the tests still fail, and the other two succeed only accidentally. This patch makes the 4 tests pass: 2011-09-26 Bruno Haible <br...@clisp.org> fputc, fwrite tests: Avoid test failure on MSVC. * tests/test-fgetc.c: Include msvc-inval.h. (main): Invoke gl_msvc_inval_ensure_handler. * tests/test-fputc.c: Include msvc-inval.h. (main): Invoke gl_msvc_inval_ensure_handler. * tests/test-fread.c: Include msvc-inval.h. (main): Invoke gl_msvc_inval_ensure_handler. * tests/test-fwrite.c: Include msvc-inval.h. (main): Invoke gl_msvc_inval_ensure_handler. * modules/fgetc-tests (Depends-on): Add msvc-inval. * modules/fputc-tests (Depends-on): Likewise. * modules/fread-tests (Depends-on): Likewise. * modules/fwrite-tests (Depends-on): Likewise. --- modules/fgetc-tests.orig Wed Sep 28 01:57:30 2011 +++ modules/fgetc-tests Wed Sep 28 01:56:31 2011 @@ -6,6 +6,7 @@ Depends-on: unistd fdopen +msvc-inval configure.ac: --- modules/fputc-tests.orig Wed Sep 28 01:57:30 2011 +++ modules/fputc-tests Wed Sep 28 01:56:42 2011 @@ -6,6 +6,7 @@ Depends-on: unistd fdopen +msvc-inval configure.ac: --- modules/fread-tests.orig Wed Sep 28 01:57:30 2011 +++ modules/fread-tests Wed Sep 28 01:56:53 2011 @@ -6,6 +6,7 @@ Depends-on: unistd fdopen +msvc-inval configure.ac: --- modules/fwrite-tests.orig Wed Sep 28 01:57:30 2011 +++ modules/fwrite-tests Wed Sep 28 01:57:05 2011 @@ -6,6 +6,7 @@ Depends-on: unistd fdopen +msvc-inval configure.ac: --- tests/test-fgetc.c.orig Wed Sep 28 01:57:30 2011 +++ tests/test-fgetc.c Wed Sep 28 01:52:33 2011 @@ -26,6 +26,8 @@ #include <fcntl.h> #include <unistd.h> +#include "msvc-inval.h" + #include "macros.h" int @@ -33,6 +35,12 @@ { const char *filename = "test-fgetc.txt"; + /* We don't have an fread() function that installs an invalid parameter + handler so far. So install that handler here, explicitly. */ +#if MSVC_INVALID_PARAMETER_HANDLING == DEFAULT_HANDLING + gl_msvc_inval_ensure_handler (); +#endif + /* Prepare a file. */ { const char text[] = "hello world"; --- tests/test-fputc.c.orig Wed Sep 28 01:57:30 2011 +++ tests/test-fputc.c Wed Sep 28 01:52:34 2011 @@ -26,6 +26,8 @@ #include <fcntl.h> #include <unistd.h> +#include "msvc-inval.h" + #include "macros.h" int @@ -33,6 +35,12 @@ { const char *filename = "test-fputc.txt"; + /* We don't have an fputc() function that installs an invalid parameter + handler so far. So install that handler here, explicitly. */ +#if MSVC_INVALID_PARAMETER_HANDLING == DEFAULT_HANDLING + gl_msvc_inval_ensure_handler (); +#endif + /* Test that fputc() on an unbuffered stream sets errno if someone else closes the stream fd behind the back of stdio. */ { --- tests/test-fread.c.orig Wed Sep 28 01:57:30 2011 +++ tests/test-fread.c Wed Sep 28 01:52:33 2011 @@ -26,6 +26,8 @@ #include <fcntl.h> #include <unistd.h> +#include "msvc-inval.h" + #include "macros.h" int @@ -33,6 +35,12 @@ { const char *filename = "test-fread.txt"; + /* We don't have an fread() function that installs an invalid parameter + handler so far. So install that handler here, explicitly. */ +#if MSVC_INVALID_PARAMETER_HANDLING == DEFAULT_HANDLING + gl_msvc_inval_ensure_handler (); +#endif + /* Prepare a file. */ { const char text[] = "hello world"; --- tests/test-fwrite.c.orig Wed Sep 28 01:57:30 2011 +++ tests/test-fwrite.c Wed Sep 28 01:52:34 2011 @@ -26,6 +26,8 @@ #include <fcntl.h> #include <unistd.h> +#include "msvc-inval.h" + #include "macros.h" int @@ -33,6 +35,12 @@ { const char *filename = "test-fwrite.txt"; + /* We don't have an fwrite() function that installs an invalid parameter + handler so far. So install that handler here, explicitly. */ +#if MSVC_INVALID_PARAMETER_HANDLING == DEFAULT_HANDLING + gl_msvc_inval_ensure_handler (); +#endif + /* Test that fwrite() on an unbuffered stream sets errno if someone else closes the stream fd behind the back of stdio. */ { -- In memoriam Paul Eppstein <http://de.wikipedia.org/wiki/Paul_Eppstein>