test-dup2: enhance test
authorEric Blake <ebb9@byu.net>
Sat, 10 Oct 2009 13:06:22 +0000 (07:06 -0600)
committerEric Blake <ebb9@byu.net>
Sat, 10 Oct 2009 14:22:00 +0000 (08:22 -0600)
AT_FDCWD is only supposed to be special in *at functions.

* tests/test-dup2.c (main): Also check AT_FDCWD.

Signed-off-by: Eric Blake <ebb9@byu.net>
ChangeLog
tests/test-dup2.c

index 379780e..f2427e4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2009-10-10  Eric Blake  <ebb9@byu.net>
 
+       test-dup2: enhance test
+       * tests/test-dup2.c (main): Also check AT_FDCWD.
+
        test-stat-time: avoid more spurious failures
        * tests/test-stat-time.c (nap): Wait for 15ms rather than 2ms, for
        xfs; and avoid race if the two timestamps cross quantization edge.
index 379a613..e1ffc21 100644 (file)
@@ -80,6 +80,15 @@ main ()
   ASSERT (dup2 (fd, fd) == fd);
   ASSERT (is_open (fd));
 
+  /* The source must be valid.  */
+  errno = 0;
+  ASSERT (dup2 (-1, fd) == -1);
+  ASSERT (errno == EBADF);
+  errno = 0;
+  ASSERT (dup2 (AT_FDCWD, fd) == -1);
+  ASSERT (errno == EBADF);
+  ASSERT (is_open (fd));
+
   /* If the source is not open, then the destination is unaffected.  */
   errno = 0;
   ASSERT (dup2 (fd + 1, fd + 1) == -1);