From: Bruno Haible Date: Sat, 8 Feb 2020 19:47:58 +0000 (+0100) Subject: fchmodat: Strengthen tests. X-Git-Tag: v1.0~4258 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=c2d184186846851f173bec9e60781a05001837c6;p=gnulib.git fchmodat: Strengthen tests. * tests/test-fchmodat.c (BASE): New macro. (main): Use it, to avoid conflicts with other unit tests. Verify that fchmodat changed the file permission bits. --- diff --git a/ChangeLog b/ChangeLog index a5ca210e0e..fc07914b21 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2020-02-08 Bruno Haible + + fchmodat: Strengthen tests. + * tests/test-fchmodat.c (BASE): New macro. + (main): Use it, to avoid conflicts with other unit tests. Verify that + fchmodat changed the file permission bits. + 2020-02-08 Bruno Haible fchmodat: Fix endless recursion on Cygwin (regression from 2020-02-07). diff --git a/tests/test-fchmodat.c b/tests/test-fchmodat.c index df0f604d83..f6b695bb85 100644 --- a/tests/test-fchmodat.c +++ b/tests/test-fchmodat.c @@ -28,6 +28,8 @@ SIGNATURE_CHECK (fchmodat, int, (int, const char *, mode_t, int)); #include "macros.h" +#define BASE "test-fchmodat." + int main (void) { @@ -47,9 +49,15 @@ main (void) /* Test that fchmodat works on non-symlinks, when given the AT_SYMLINK_NOFOLLOW flag. */ { - ASSERT (close (creat ("file", 0600)) == 0); - ASSERT (fchmodat (AT_FDCWD, "file", 0700, AT_SYMLINK_NOFOLLOW) == 0); - ASSERT (unlink ("file") == 0); + struct stat statbuf; + unlink (BASE "file"); + ASSERT (close (creat (BASE "file", 0600)) == 0); + ASSERT (fchmodat (AT_FDCWD, BASE "file", 0400, AT_SYMLINK_NOFOLLOW) == 0); + ASSERT (stat (BASE "file", &statbuf) >= 0); + ASSERT ((statbuf.st_mode & 0700) == 0400); + /* Clean up. */ + ASSERT (chmod (BASE "file", 0600) == 0); + ASSERT (unlink (BASE "file") == 0); } return 0;