X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=tests%2Ftest-fdutimensat.c;h=39d677831936a6caf9615ee72506369119776557;hb=2f681c52f62c1bb9c9dd3fe5cd7a32ec384c34c7;hp=80eb373d0076b024b15b27d0675e8876d5998ed8;hpb=18aae5b74420237d8c827e7c68312c5b71d659dc;p=gnulib.git diff --git a/tests/test-fdutimensat.c b/tests/test-fdutimensat.c index 80eb373d0..39d677831 100644 --- a/tests/test-fdutimensat.c +++ b/tests/test-fdutimensat.c @@ -1,5 +1,5 @@ /* Tests of fdutimensat. - Copyright (C) 2009, 2010 Free Software Foundation, Inc. + Copyright (C) 2009-2011 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 @@ -40,7 +40,7 @@ static int dfd = AT_FDCWD; static int do_futimens (int fd, struct timespec const times[2]) { - return fdutimensat (dfd, NULL, fd, times, 0); + return fdutimensat (fd, dfd, NULL, times, 0); } /* Test the use of file descriptors alongside a name. */ @@ -48,12 +48,17 @@ static int do_fdutimens (char const *name, struct timespec const times[2]) { int result; + int nofollow_result; + int nofollow_errno; int fd = openat (dfd, name, O_WRONLY); if (fd < 0) fd = openat (dfd, name, O_RDONLY); errno = 0; - result = fdutimensat (dfd, name, fd, times, 0); - ASSERT (fdutimensat (dfd, name, fd, times, AT_SYMLINK_NOFOLLOW) == result); + nofollow_result = fdutimensat (fd, dfd, name, times, AT_SYMLINK_NOFOLLOW); + nofollow_errno = errno; + result = fdutimensat (fd, dfd, name, times, 0); + ASSERT (result == nofollow_result + || (nofollow_result == -1 && nofollow_errno == ENOSYS)); if (0 <= fd) { int saved_errno = errno; @@ -74,14 +79,14 @@ do_lutimens (const char *name, struct timespec const times[2]) static int do_lutimens1 (const char *name, struct timespec const times[2]) { - return fdutimensat (dfd, name, -1, times, AT_SYMLINK_NOFOLLOW); + return fdutimensat (-1, dfd, name, times, AT_SYMLINK_NOFOLLOW); } /* Wrap fdutimensat to behave like utimens. */ static int do_utimens (const char *name, struct timespec const times[2]) { - return fdutimensat (dfd, name, -1, times, 0); + return fdutimensat (-1, dfd, name, times, 0); } int @@ -117,12 +122,12 @@ main (void) fd = creat ("file", 0600); ASSERT (0 <= fd); errno = 0; - ASSERT (fdutimensat (fd, ".", AT_FDCWD, NULL, 0) == -1); + ASSERT (fdutimensat (AT_FDCWD, fd, ".", NULL, 0) == -1); ASSERT (errno == ENOTDIR); { struct timespec ts[2] = { { Y2K, 0 }, { Y2K, 0 } }; struct stat st; - ASSERT (fdutimensat (dfd, BASE "dir/file", fd, ts, 0) == 0); + ASSERT (fdutimensat (fd, dfd, BASE "dir/file", ts, 0) == 0); ASSERT (stat ("file", &st) == 0); ASSERT (st.st_atime == Y2K); ASSERT (get_stat_atime_ns (&st) == 0); @@ -132,7 +137,7 @@ main (void) ASSERT (close (fd) == 0); ASSERT (close (dfd) == 0); errno = 0; - ASSERT (fdutimensat (dfd, ".", -1, NULL, 0) == -1); + ASSERT (fdutimensat (-1, dfd, ".", NULL, 0) == -1); ASSERT (errno == EBADF); /* Cleanup. */