summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2020-02-08 20:47:58 +0100
committerBruno Haible <bruno@clisp.org>2020-02-08 20:47:58 +0100
commitc2d184186846851f173bec9e60781a05001837c6 (patch)
treea07e8dd29f11c084a5109d13c77352d47e97e4d9 /tests
parent1bbbce29dc592833e79ab6d21472528a01ab67b2 (diff)
downloadgnulib-c2d184186846851f173bec9e60781a05001837c6.tar.gz
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.
Diffstat (limited to 'tests')
-rw-r--r--tests/test-fchmodat.c14
1 files changed, 11 insertions, 3 deletions
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;