summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorEric Blake <ebb9@byu.net>2009-12-08 06:13:05 -0700
committerEric Blake <ebb9@byu.net>2009-12-08 06:32:18 -0700
commit2966d0d21fdc455b705e1b477dfe7e1b37f5f8e9 (patch)
tree09ad5a3feb230e3c409ebd7ed3f2722e58a418ab /tests
parent21a0a9e3ef07b457b04d483f8dd216bbdf06e860 (diff)
downloadgnulib-2966d0d21fdc455b705e1b477dfe7e1b37f5f8e9.tar.gz
fchdir: fix logic bugs
Configuring with ac_cv_func_fchdir=no on a system that has fchdir and where open handles directories, just to test out the replacement capabilities, uncovered an m4 test bug and a link failure on rpl_fstat. * m4/fchdir.m4 (gl_FUNC_FCHDIR): Fix logic bug. * tests/test-fchdir.c (main): Enhance test. * lib/fchdir.c (rpl_fstat): Always provide if fchdir replacement is in use. Signed-off-by: Eric Blake <ebb9@byu.net>
Diffstat (limited to 'tests')
-rw-r--r--tests/test-fchdir.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/tests/test-fchdir.c b/tests/test-fchdir.c
index 53d6631ccd..0419f43fd5 100644
--- a/tests/test-fchdir.c
+++ b/tests/test-fchdir.c
@@ -26,6 +26,8 @@
#include <stdlib.h>
#include <string.h>
+#include "cloexec.h"
+
#define ASSERT(expr) \
do \
{ \
@@ -82,7 +84,11 @@ main (void)
int new_fd = dup (fd);
ASSERT (0 <= new_fd);
ASSERT (close (fd) == 0);
- fd = new_fd;
+ ASSERT (dup2 (new_fd, fd) == fd);
+ ASSERT (close (new_fd) == 0);
+ ASSERT (dup_cloexec (fd) == new_fd);
+ ASSERT (dup2 (new_fd, fd) == fd);
+ ASSERT (close (new_fd) == 0);
}
}