>From c2d184186846851f173bec9e60781a05001837c6 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sat, 8 Feb 2020 20:47:58 +0100 Subject: [PATCH 3/3] 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. --- ChangeLog | 7 +++++++ tests/test-fchmodat.c | 14 +++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index a5ca210..fc07914 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 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). * lib/fchmodat.c (orig_fchmodat): Move definition to immediately after '#undef __need_system_sys_stat_h'. diff --git a/tests/test-fchmodat.c b/tests/test-fchmodat.c index df0f604..f6b695b 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; -- 2.7.4