diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2014-01-20 22:12:56 -0800 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2014-01-20 22:13:39 -0800 |
commit | 1e0ad6a06d8f0638d4b312204c060778d33b03d9 (patch) | |
tree | e07d49c7527fa8ac2aa189fa5120eecb0447c38a /tests/test-fdopen.c | |
parent | 6fff2c8fdb034fbeb5407bae40fa8b7e947b946f (diff) | |
download | gnulib-1e0ad6a06d8f0638d4b312204c060778d33b03d9.tar.gz |
fdopen-tests: port to Tru64
* tests/test-fdopen.c (main): Don't invoke fdopen on a file
descriptors that is not open, as POSIX doesn't specify the
resulting behavior and the test does not work on Tru64.
Problem reported by Steven M. Schweda in:
http://lists.gnu.org/archive/html/bug-gnulib/2014-01/msg00079.html
Diffstat (limited to 'tests/test-fdopen.c')
-rw-r--r-- | tests/test-fdopen.c | 37 |
1 files changed, 15 insertions, 22 deletions
diff --git a/tests/test-fdopen.c b/tests/test-fdopen.c index 96a887fe2a..743511ecc6 100644 --- a/tests/test-fdopen.c +++ b/tests/test-fdopen.c @@ -29,28 +29,21 @@ SIGNATURE_CHECK (fdopen, FILE *, (int, const char *)); int main (void) { - /* Test behaviour for invalid file descriptors. */ - { - FILE *fp; - - errno = 0; - fp = fdopen (-1, "r"); - if (fp == NULL) - ASSERT (errno == EBADF); - else - fclose (fp); - } - { - FILE *fp; - - close (99); - errno = 0; - fp = fdopen (99, "r"); - if (fp == NULL) - ASSERT (errno == EBADF); - else - fclose (fp); - } + /* Test behavior on failure. POSIX makes it hard to check for + failure, since the behavior is not well-defined on invalid file + descriptors, so try fdopen 1000 times and if that's not enough to + fail due to EMFILE, so be it. */ + + int i; + for (i = 0; i < 1000; i++) + { + errno = 0; + if (! fdopen (STDOUT_FILENO, "w")) + { + ASSERT (errno != 0); + break; + } + } return 0; } |