From b2fb3b5d42009294104f52129fd4c0d7e75202f0 Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Sat, 10 Oct 2009 07:06:22 -0600 Subject: [PATCH] test-dup2: enhance test 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 --- ChangeLog | 3 +++ tests/test-dup2.c | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/ChangeLog b/ChangeLog index 379780eeb..f2427e466 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2009-10-10 Eric Blake + 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. diff --git a/tests/test-dup2.c b/tests/test-dup2.c index 379a6135e..e1ffc2176 100644 --- a/tests/test-dup2.c +++ b/tests/test-dup2.c @@ -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); -- 2.11.0