diff options
Diffstat (limited to 'gnulib-tests/test-fdopendir.c')
-rw-r--r-- | gnulib-tests/test-fdopendir.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/gnulib-tests/test-fdopendir.c b/gnulib-tests/test-fdopendir.c index d780b621..8fd43824 100644 --- a/gnulib-tests/test-fdopendir.c +++ b/gnulib-tests/test-fdopendir.c @@ -1,5 +1,5 @@ /* Test opening a directory stream from a file descriptor. - Copyright (C) 2009-2014 Free Software Foundation, Inc. + Copyright (C) 2009-2015 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -64,11 +64,15 @@ main (int argc _GL_UNUSED, char *argv[]) fd = open (".", O_RDONLY); ASSERT (0 <= fd); d = fdopendir (fd); - /* We know that fd is now out of our reach, but it is not specified - whether it is closed now or at the closedir. We also can't - guarantee whether dirfd returns fd, some other descriptor, or - -1. */ ASSERT (d); + /* fdopendir should not close fd. */ + ASSERT (dup2 (fd, fd) == fd); + + /* Don't test dirfd here. dirfd (d) must return fd on current POSIX + platforms, but on pre-2008 platforms or on non-POSIX platforms + dirfd (fd) might return some other descriptor, or -1, and gnulib + does not work around this porting problem. */ + ASSERT (closedir (d) == 0); /* Now we can guarantee that fd must be closed. */ errno = 0; |