summaryrefslogtreecommitdiff
path: root/gnulib-tests/test-fdopendir.c
diff options
context:
space:
mode:
authorIgor Pashev <pashev.igor@gmail.com>2015-07-04 17:13:50 +0300
committerIgor Pashev <pashev.igor@gmail.com>2015-07-04 17:13:50 +0300
commit71cd8e3a743046573744123777061b64881bf372 (patch)
tree82522befe647f4fff186a5630cad0cad33f8ef53 /gnulib-tests/test-fdopendir.c
parentc18578632fd3c9e513e613a86ba2b7c4ebee6c45 (diff)
downloadcoreutils-upstream.tar.gz
Imported Upstream version 8.24upstream/8.24upstream
Diffstat (limited to 'gnulib-tests/test-fdopendir.c')
-rw-r--r--gnulib-tests/test-fdopendir.c14
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;